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

Add Matrix(I, n, m) method #468

Closed
andyferris opened this issue Jan 22, 2018 · 2 comments · Fixed by #438
Closed

Add Matrix(I, n, m) method #468

andyferris opened this issue Jan 22, 2018 · 2 comments · Fixed by #438

Comments

@andyferris
Copy link
Member

andyferris commented Jan 22, 2018

In Julia v0.7 you don't need to specify the eltype of the matrix - it is inferred from the UniformScaling{T} input. Compat has only defined the Matrix{T}(::UniformScaling, n, m) method.

# Julia v0.6.2
julia> using Compat

julia> Matrix(I, 4, 4)
ERROR: MethodError: no method matching Array{T,2} where T(::UniformScaling{Int64}, ::Int64, ::Int64)
Closest candidates are:
  Array{T,2} where T(::Compat.Uninitialized, ::Any...) at string:5
  Array{T,2} where T(::Integer, ::Integer) at sysimg.jl:105

julia> Matrix{Float64}(I, 4, 4)
4×4 Array{Float64,2}:
 1.0  0.0  0.0  0.0
 0.0  1.0  0.0  0.0
 0.0  0.0  1.0  0.0
 0.0  0.0  0.0  1.0
@fredrikekre
Copy link
Member

#438

@andyferris
Copy link
Member Author

Well we can't do much in Compat about a breaking change to the element type of I (we could define Compat.I I suppose).

The usage I was intending were things like Matrix(4.0*I, 4, 4). I changed these to Matrix{Float64}(4*I, 4, 4) which works on v0.6 (with Compat) and v0.7.

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

Successfully merging a pull request may close this issue.

2 participants