-
-
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 randn #21973
Add complex randn #21973
Changes from 2 commits
d891aef
2da70cc
e21065f
f3c46e2
672c01b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1181,7 +1181,9 @@ const ziggurat_exp_r = 7.6971174701310497140446280481 | |
Generate a normally-distributed random number of type `T` with mean 0 and standard deviation 1. | ||
Optionally generate an array of normally-distributed random numbers. | ||
The `Base` module currently provides an implementation for the types | ||
`Float16`, `Float32`, and `Float64` (the default). | ||
`Float16`, `Float32`, and `Float64` (the default), and their `Complex` counterparts. | ||
When the type argument is complex, the values are drawn from the circularly symmetric | ||
complex normal distribution. | ||
""" | ||
@inline function randn(rng::AbstractRNG=GLOBAL_RNG) | ||
@inbounds begin | ||
|
@@ -1282,6 +1284,10 @@ let Floats = Union{Float16,Float32,Float64} | |
$randfun( dims::Integer... ) = $randfun(GLOBAL_RNG, Float64, dims...) | ||
end | ||
end | ||
|
||
# complex randn | ||
Base.@irrational SQRT_HALF 0.7071067811865475244008 sqrt(big(0.5)) | ||
randn(rng::AbstractRNG, ::Type{Complex{T}}) where {T <: Floats} = 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 commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, also added a statement to the NEWS |
||
end | ||
|
||
## random UUID generation | ||
|
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.
blank line inserted?
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.
oops, not sure how that got there..