Skip to content

Commit

Permalink
Update src/SMatrix.jl
Browse files Browse the repository at this point in the history
Co-authored-by: Yuto Horikawa <[email protected]>
  • Loading branch information
mateuszbaran and hyrodium authored Oct 28, 2023
1 parent ce161c1 commit 127dcd3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/SMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ function static_matrix_gen(::Type{SM}, @nospecialize(ex), mod::Module) where {SM
if length(ex.args) == 3
return :($f($SM{$(escall(ex.args[2:3])...), Float64})) # default to Float64 like Base
elseif length(ex.args) == 4
if f === :rand && ex.args[3] isa Int && ex.args[3] > 0 && ex.args[4] isa Int && ex.args[4] > 0
# supports calls like rand(Type, n, m) and rand(sampler, n, m)), but only if n, m > 0
return :(_rand(Random.GLOBAL_RNG, $(esc(ex.args[2])), Size($(esc(ex.args[3])), $(esc(ex.args[4]))), $SM{$(esc(ex.args[3])), $(esc(ex.args[4]))}))
if f === :rand && ex.args[3] isa Int && ex.args[3] 0 && ex.args[4] isa Int && ex.args[4] 0
# supports calls like rand(Type, n, m) and rand(sampler, n, m))
return :(_rand(Random.GLOBAL_RNG, $(esc(ex.args[2])), Size($(esc(ex.args[3])), $(esc(ex.args[4]))), $SM{$(esc(ex.args[3])), $(esc(ex.args[4])), Random.gentype($(esc(ex.args[2])))}))
else
return :($f($SM{$(escall(ex.args[[3,4,2]])...)}))
end
Expand Down

0 comments on commit 127dcd3

Please sign in to comment.