Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when @SMatrix randn(rng,ComplexF64,(2,2)) #1019

Closed
ghost opened this issue Apr 3, 2022 · 2 comments
Closed

Error when @SMatrix randn(rng,ComplexF64,(2,2)) #1019

ghost opened this issue Apr 3, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 3, 2022

I try to construct static random matrix by using @SMatrix. And @SMatrix randn(ComplexF64,2,2) works. But when try to further seed the random number generator like

using StatsBase
using Statistics
using Random
using StaticArrays

rng = MersenneTwister(123)
@SMatrix randn(rng,ComplexF64,(2,2))

I got the error

ERROR: TypeError: in Type, in parameter, expected Type, got a value of type MersenneTwister
@hyrodium
Copy link
Collaborator

hyrodium commented Apr 3, 2022

You can just call randn function without the @SMatrix macro.

julia> rng = MersenneTwister(123)
MersenneTwister(123)

julia> randn(rng, SMatrix{2,2,ComplexF64})
2×2 SMatrix{2, 2, ComplexF64, 4} with indices SOneTo(2)×SOneTo(2):
 0.841646+1.44828im   -0.280494-0.470023im
 0.807976+0.324856im   0.693649-0.0533746im

x-ref: #391

@ghost
Copy link
Author

ghost commented Apr 3, 2022

Yes this works. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant