function vec2ltri_alt{T}(v::AbstractVector{T}, z::T=zero(T))
n = length(v)
v1 = vcat(0,v)
s = round(Int,(sqrt(8n+1)-1)/2)
s*(s+1)/2 == n || error("vec2utri: length of vector is not triangular")
s+=1
[ i>j ? v1[round(Int, j*(j-1)/2+i)] : (i == j ? z : NaN) for i=1:s, j=1:s ]
end
On Monday, August 22, 2016 at 4:58:56 PM UTC+2, Ahmed Mazari wrote:
>
> Hello,
>
> relying on these two links. l tried to make a lower triangular matrix from
> a given matrix but it doesn't work.
>
> the used function is
>
> function vec2ltri_alt{T}(v::AbstractVector{T}, z::T=zero(T)) n = length(v) v1
> = vcat(0,v) s = round(Int,(sqrt(8n+1)-1)/2) s*(s+1)/2 == n ||
> error("vec2utri: length of vector is not triangular") s+=1 [ i>j ?
> v1[round(Int, j*(j-1)/2+i)] : (i == j ? z : NaN) for i=1:s, j=1:s ] end
>
>
>
> l got this error when l did this
>
> vec2ltri_alt(rand(5000,5000)) # because l have a matrix of 5000 by 5000,
> so l gave as a paramter my matrix
>
> *ERROR: MethodError: `vec2ltri_alt` has no method matching
> vec2ltri_alt(::Array{Float64,2})*
>
>
> http://stackoverflow.com/questions/39039553/lower-triangular-matrix-in-julia
>
> https://groups.google.com/forum/#!topic/julia-users/UARlZBCNlng
>
> thank you
>