-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add complex random normals. #17725
Add complex random normals. #17725
Conversation
ad05f46
to
34215be
Compare
@@ -1224,6 +1227,14 @@ let Floats = Union{Float16,Float32,Float64} | |||
$randfun( dims::Integer... ) = $randfun(GLOBAL_RNG, Float64, dims...) | |||
end | |||
end | |||
|
|||
for (T,SQRT_HALF) in ((Float64, 0.7071067811865476), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last digit should be a 5: 0.7071067811865475
julia> 1/sqrt(BigFloat(2))
7.071067811865475244008443621048490392848359376884740365883398689953662392310596e-01
julia> 1/sqrt(2)
0.7071067811865475
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
34215be
to
f14fb5a
Compare
f14fb5a
to
46c927d
Compare
|
(Float32, 0.70710677f0), | ||
(Float16, 0.70710677f0)) | ||
@inline function randn(rng::AbstractRNG, ::Type{Complex{T}}) | ||
Complex{T}(SQRT_HALF*randn(rng, T), SQRT_HALF*randn(rng, T)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this doesn't seem right to me.... you're defining the function in terms of the global variable T
. I think you want to use @eval
and $T
Are we going to include this in 0.5? |
This is a new feature, albeit a small one. I don't think we should. |
@fiatflux, now that |
Thanks @stevengj! I'm tied up with a proposal deadline right now but soon I'll be ready to do some comparative tests. My use case for this is performance sensitive, so I have a vested interest in ensuring it's snappy. |
superseded by #21973 |
Implement complex normal random number generation, as discussed in #9836.
It ended up cleaner, at least on the git history side, to open a new PR rather than reopening #17443. Sorry if that makes things confusing otherwise!