Next: , Previous: spdet, Up: Function Reference


22.6.0.26 spdiag

— Loadable Function: spdiag (v, k)

Return a diagonal matrix with the sparse vector v on diagonal k. The second argument is optional. If it is positive, the vector is placed on the k-th super-diagonal. If it is negative, it is placed on the -k-th sub-diagonal. The default value of k is 0, and the vector is placed on the main diagonal. For example,

          spdiag ([1, 2, 3], 1)
          ans =
          
          Compressed Column Sparse (rows=4, cols=4, nnz=3)
            (1 , 2) -> 1
            (2 , 3) -> 2
            (3 , 4) -> 3
     
     
     
See also: diag.