Skip to content

Commit

Permalink
Add Matrix(I, dims) constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored and fredrikekre committed Jan 22, 2018
1 parent a342f94 commit 980b45f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* Constructors for `Matrix{T}`, `Array{T}`, and `SparseMatrixCSC{T}` from `UniformScaling` ([#24372], [#24657])

* Constructor for `Matrix` from `UniformScaling` ([#24372], [#24657]).

* `Uninitialized` and `uninitialized` with corresponding `Array` constructors ([#24652]).

* `BitArray` constructors for `uninitialized` ([#24785]).
Expand Down
4 changes: 4 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,10 @@ end
export parentmodule
end

@static if VERSION < v"0.7.0-DEV.2541"
(::Type{Matrix}){T}(I::UniformScaling{T}, dims...) = eye(T, dims...)
end

include("deprecated.jl")

end # module Compat
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,10 @@ end
# 0.7.0-DEV.3415
@test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5]

# 0.7.0-DEV.2541
@test Matrix(I, 2, 2) == [1 0; 0 1]
@test eltype(Matrix(1.0I, 3, 3)) == Float64

if VERSION < v"0.6.0"
include("deprecated.jl")
end
Expand Down

0 comments on commit 980b45f

Please sign in to comment.