Re: [julia-users] Re: lower triangular matrix in julia
x-ref: http://stackoverflow.com/questions/39039553/lower-triangular-matrix-in-julia-julia On Fri, Aug 19, 2016 at 10:29 AM, Michael Krabbe Borregaard < mkborrega...@gmail.com> wrote: > A symmetric matrix and a lower triangular matrix are different things. > Look for what you want here: http://julia.readthedocs.io/ > en/latest/manual/linear-algebra/ and here: http://julia.readthedocs.io/ > en/latest/stdlib/linalg/ > > On Fri, Aug 19, 2016 at 4:07 PM, Ahmed Mazari> wrote: > >> 4×4 Array{Int64,2}: >> 0 1 2 3 >> 1 0 4 5 >> 2 4 0 6 >> 3 5 6 0 >> >> a symetric matrix m[i,j] =m[j,i] and m[i,i]= 0 >> >> On Fri, Aug 19, 2016 at 3:59 PM, Jeffrey Sarnoff < >> jeffrey.sarn...@gmail.com> wrote: >> >>> Is this what you want, or are you looking for a more general way to >>> construct nxn matrices like this 4x4 matrix, or something else? >>> >>> julia> m = [ [0,1,2,3] [1,0,4,5] [2,3,0,6] [4,5,6,0] ] >>> 4×4 Array{Int64,2}: >>> 0 1 2 4 >>> 1 0 3 5 >>> 2 4 0 6 >>> 3 5 6 0 >>> >>> >>> On Friday, August 19, 2016 at 9:01:06 AM UTC-4, Ahmed Mazari wrote: Yes but it doesn't allow me to set the diagonal to 0 ?? On Fri, Aug 19, 2016 at 2:55 PM, Michael Borregaard < mkborr...@gmail.com> wrote: > You can build the matrix as normal, then specify that the upper > triangle is undefined by > mat = LowerTriangular(mat) # where mat is a Matrix of any eltype. > >> >
Re: [julia-users] Re: lower triangular matrix in julia
A symmetric matrix and a lower triangular matrix are different things. Look for what you want here: http://julia.readthedocs.io/en/latest/manual/linear-algebra/ and here: http://julia.readthedocs.io/en/latest/stdlib/linalg/ On Fri, Aug 19, 2016 at 4:07 PM, Ahmed Mazariwrote: > 4×4 Array{Int64,2}: > 0 1 2 3 > 1 0 4 5 > 2 4 0 6 > 3 5 6 0 > > a symetric matrix m[i,j] =m[j,i] and m[i,i]= 0 > > On Fri, Aug 19, 2016 at 3:59 PM, Jeffrey Sarnoff < > jeffrey.sarn...@gmail.com> wrote: > >> Is this what you want, or are you looking for a more general way to >> construct nxn matrices like this 4x4 matrix, or something else? >> >> julia> m = [ [0,1,2,3] [1,0,4,5] [2,3,0,6] [4,5,6,0] ] >> 4×4 Array{Int64,2}: >> 0 1 2 4 >> 1 0 3 5 >> 2 4 0 6 >> 3 5 6 0 >> >> >> On Friday, August 19, 2016 at 9:01:06 AM UTC-4, Ahmed Mazari wrote: >>> >>> Yes but it doesn't allow me to set the diagonal to 0 ?? >>> >>> On Fri, Aug 19, 2016 at 2:55 PM, Michael Borregaard >> > wrote: >>> You can build the matrix as normal, then specify that the upper triangle is undefined by mat = LowerTriangular(mat) # where mat is a Matrix of any eltype. >>> >>> >
Re: [julia-users] Re: lower triangular matrix in julia
4×4 Array{Int64,2}: 0 1 2 3 1 0 4 5 2 4 0 6 3 5 6 0 a symetric matrix m[i,j] =m[j,i] and m[i,i]= 0 On Fri, Aug 19, 2016 at 3:59 PM, Jeffrey Sarnoffwrote: > Is this what you want, or are you looking for a more general way to > construct nxn matrices like this 4x4 matrix, or something else? > > julia> m = [ [0,1,2,3] [1,0,4,5] [2,3,0,6] [4,5,6,0] ] > 4×4 Array{Int64,2}: > 0 1 2 4 > 1 0 3 5 > 2 4 0 6 > 3 5 6 0 > > > On Friday, August 19, 2016 at 9:01:06 AM UTC-4, Ahmed Mazari wrote: >> >> Yes but it doesn't allow me to set the diagonal to 0 ?? >> >> On Fri, Aug 19, 2016 at 2:55 PM, Michael Borregaard >> wrote: >> >>> You can build the matrix as normal, then specify that the upper triangle >>> is undefined by >>> mat = LowerTriangular(mat) # where mat is a Matrix of any eltype. >>> >> >>
Re: [julia-users] Re: lower triangular matrix in julia
Is this what you want, or are you looking for a more general way to construct nxn matrices like this 4x4 matrix, or something else? julia> m = [ [0,1,2,3] [1,0,4,5] [2,3,0,6] [4,5,6,0] ] 4×4 Array{Int64,2}: 0 1 2 4 1 0 3 5 2 4 0 6 3 5 6 0 On Friday, August 19, 2016 at 9:01:06 AM UTC-4, Ahmed Mazari wrote: > > Yes but it doesn't allow me to set the diagonal to 0 ?? > > On Fri, Aug 19, 2016 at 2:55 PM, Michael Borregaard> wrote: > >> You can build the matrix as normal, then specify that the upper triangle >> is undefined by >> mat = LowerTriangular(mat) # where mat is a Matrix of any eltype. >> > >
Re: [julia-users] Re: lower triangular matrix in julia
Yes but it doesn't allow me to set the diagonal to 0 ?? On Fri, Aug 19, 2016 at 2:55 PM, Michael Borregaardwrote: > You can build the matrix as normal, then specify that the upper triangle > is undefined by > mat = LowerTriangular(mat) # where mat is a Matrix of any eltype. >
[julia-users] Re: lower triangular matrix in julia
I'm guessing you have worked with R, because the example you give uses NA as if it were an integer. Julia does not have NA that way (there is special class of Nullable types that either are valued with e.g. an Int or else isnull .. probably you do not need that right now). Would using floating point values and using the floating point NaN (not-a-number, a special floating point value) where you have NA work, or is this NA more like 'dont care', where replacing them with 0s would work? On Friday, August 19, 2016 at 8:31:21 AM UTC-4, Ahmed Mazari wrote: > > Hello, > > l have the number of columns equals the number of rows . and the the > diagonal is esqual to zero . How can l build this matrix ? > #mat > # [,1] [,2] [,3] [,4] > #[1,] 0 NA NA NA > #[2,]1 0 NA NA > #[3,]24 0 NA > #[4,]356 0 > > > thank you >