@@ -7,12 +7,12 @@ import LinearAlgebra: mul!, BLAS, BlasFloat, generic_matvecmul!, MulAddMul
77
88export SymmetricPacked, packedsize
99
10- struct SymmetricPacked{T,S<: AbstractMatrix {<:T} } <: AbstractMatrix{T}
10+ struct SymmetricPacked{T,S<: AbstractVecOrMat {<:T} } <: AbstractMatrix{T}
1111 tri:: Vector{T}
1212 n:: Int
1313 uplo:: Char
1414
15- function SymmetricPacked {T,S} (tri, n, uplo) where {T,S<: AbstractMatrix {<:T} }
15+ function SymmetricPacked {T,S} (tri, n, uplo) where {T,S<: AbstractVecOrMat {<:T} }
1616 require_one_based_indexing (tri)
1717 uplo== ' U' || uplo== ' L' || throw (ArgumentError (" uplo must be either 'U' (upper) or 'L' (lower)" ))
1818 new {T,S} (tri, n, uplo)
@@ -72,6 +72,12 @@ function SymmetricPacked(x::SymmetricPacked{T,S}) where{T,S}
7272 SymmetricPacked {T,S} (T .(x. tri), x. n, x. uplo)
7373end
7474
75+ function SymmetricPacked (V:: AbstractVector{T} , uplo:: Symbol = :U ) where {T}
76+ n = (sqrt (1 + 8 * length (V))- 1 )/ 2
77+ isinteger (n) || throw (DimensionMismatch (" length of vector does not corresond to the number of elements in the triangle of a square matrix" ))
78+ SymmetricPacked {T,typeof(V)} (V, round (Int, n), char_uplo (uplo))
79+ end
80+
7581checksquare (x:: SymmetricPacked ) = x. n
7682
7783convert (:: Type{SymmetricPacked{T,S}} , x:: SymmetricPacked ) where {T,S} = SymmetricPacked {T,S} (T .(x. tri), x. n, x. uplo)
0 commit comments