Skip to content

Commit

Permalink
Merge pull request #14008 from JuliaLang/yyc/triangular-convert
Browse files Browse the repository at this point in the history
Make constructors of Triangular matrices no op if the arguments is already of the right type
  • Loading branch information
andreasnoack committed Nov 15, 2015
2 parents 2d01b1c + 8067ec4 commit aa24ee0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/linalg/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
abstract AbstractTriangular{T,S<:AbstractMatrix} <: AbstractMatrix{T} # could be renamed to Triangular when than name has been fully deprecated

# First loop through all methods that don't need special care for upper/lower and unit diagonal
for t in (:LowerTriangular, :UnitLowerTriangular, :UpperTriangular, :UnitUpperTriangular)
for t in (:LowerTriangular, :UnitLowerTriangular, :UpperTriangular,
:UnitUpperTriangular)
@eval begin
immutable $t{T,S<:AbstractMatrix} <: AbstractTriangular{T,S}
data::S
end
$t(A::$t) = A
function $t(A::AbstractMatrix)
Base.LinAlg.chksquare(A)
return $t{eltype(A), typeof(A)}(A)
Expand Down

0 comments on commit aa24ee0

Please sign in to comment.