nsparseMatrix-classes         package:Matrix         R Documentation

_S_p_a_r_s_e _l_o_g_i_c_a_l _m_a_t_r_i_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     The 'nsparseMatrix' class is a virtual class of sparse matrices
     with 'TRUE'/'FALSE' entries.  Only the positions of the elements
     that are 'TRUE' are stored.  These can be stored in the
     ``triplet'' form (classes 'ngTMatrix', 'nsTMatrix', and
     'ntTMatrix' which really contain pairs, not triplets) or in
     compressed column-oriented form (classes 'ngCMatrix', 'nsCMatrix',
     and 'ntCMatrix') or in compressed row-oriented form (classes
     'ngRMatrix', 'nsRMatrix', and 'ntRMatrix').  The second letter in
     the name of these non-virtual classes indicates 'g'eneral,
     's'ymmetric, or 't'riangular.

_O_b_j_e_c_t_s _f_r_o_m _t_h_e _C_l_a_s_s:

     Objects can be created by calls of the form 'new("ngCMatrix",
     ...)' and so on.  More frequently objects are created by coercion
     of a numeric sparse matrix to the logical form for use in the
     symbolic analysis phase of an algorithm involving sparse matrices.
      Such algorithms often involve two phases: a symbolic phase
     wherein the positions of the non-zeros in the result are
     determined and a numeric phase wherein the actual results are
     calculated.  During the symbolic phase only the positions of the
     non-zero elements in any operands are of interest, hence any
     numeric sparse matrices can be treated as logical sparse matrices.

_S_l_o_t_s:

     '_u_p_l_o': Object of class '"character"'. Must be either "U", for
          upper triangular, and "L", for lower triangular. Present in
          the triangular and symmetric classes but not in the general
          class.

     '_d_i_a_g': Object of class '"character"'. Must be either '"U"', for
          unit triangular (diagonal is all ones), or '"N"' for
          non-unit.  The implicit diagonal elements are not explicitly
          stored when 'diag' is '"U"'.  Present in the triangular
          classes only.

     '_p': Object of class '"integer"' of pointers, one for each column
          (row), to the initial (zero-based) index of elements in the
          column.  Present in compressed column-oriented and compressed
          row-oriented forms only.

     '_i': Object of class '"integer"' of length nnzero (number of
          non-zero elements).  These are the row numbers for each TRUE
          element in the matrix.  All other elements are FALSE. Present
          in triplet and compressed column-oriented forms only.

     '_j': Object of class '"integer"' of length nnzero (number of
          non-zero elements).  These are the column numbers for each
          TRUE element in the matrix.  All other elements are FALSE.
          Present in triplet and compressed column-oriented forms only.

     '_D_i_m': Object of class '"integer"' - the dimensions of the matrix.

_M_e_t_h_o_d_s:

     _c_o_e_r_c_e 'signature(from = "dgCMatrix", to = "ngCMatrix")'

     _t 'signature(x = "ngCMatrix")': returns the transpose of 'x'

_S_e_e _A_l_s_o:

     the class 'dgCMatrix'

_E_x_a_m_p_l_e_s:

     (m <- Matrix(c(0,0,2:0), 3,5, dimnames=list(LETTERS[1:3],NULL)))
     ## ``extract the nonzero-pattern of (m) into an nMatrix'':
     nm <- as(m, "ngCMatrix")
     str(nm) # no 'x' slot
     !nm     # no longer sparse
     ## consistency check:
     stopifnot(xor(as( nm, "matrix"),
                   as(!nm, "matrix")))

     data(KNex)
     nmm <- as(KNex $ mm, "ngCMatrix")
     str(xlx <- crossprod(nmm))# "nsCMatrix"
     stopifnot(isSymmetric(xlx))
     image(xlx, main=paste("crossprod(nmm) : Sparse", class(xlx)))

