chol                 package:Matrix                 R Documentation

_C_h_o_l_e_s_k_i _D_e_c_o_m_p_o_s_i_t_i_o_n - '_M_a_t_r_i_x' _S_4 _G_e_n_e_r_i_c

_D_e_s_c_r_i_p_t_i_o_n:

     Compute the Choleski factorization of a real symmetric
     positive-definite square matrix.

_U_s_a_g_e:

     chol(x, ...)
     ## S4 method for signature 'dsCMatrix':
     chol(x, pivot = FALSE, ...)

_A_r_g_u_m_e_n_t_s:

       x: a (sparse or dense) square matrix, here inheriting from class
          'Matrix'; if 'x' is not positive definite, an error is
          signalled.

   pivot: logical indicating if pivoting is used.

     ...: potentially further arguments passed to methods.

_V_a_l_u_e:

     a matrix of class 'Cholesky', i.e., upper triangular: R such that
     R R' = x.

_M_e_t_h_o_d_s:

     Use 'showMethods(chol)' to see all; some are worth mentioning
     here:

     _c_h_o_l 'signature(x = "dgeMatrix")': works via '"dpoMatrix"', see
          class 'dpoMatrix'.

     _c_h_o_l 'signature(x = "dpoMatrix")': Returns (and stores) the
          Cholesky decomposition of 'x', via LAPACK routines 'dlacpy'
          and 'dpotrf'.

     _c_h_o_l 'signature(x = "dppMatrix")': Returns (and stores) the
          Cholesky decomposition via LAPACK routine 'dpptrf'.

     _c_h_o_l 'signature(x = "dsCMatrix", pivot = "logical")': Returns (and
          stores) the Cholesky decomposition of 'x'.  If 'pivot' is
          'TRUE' (the default) Metis is used to create a reordering of
          the rows and columns of 'x' so as to minimize fill-in.


_S_e_e _A_l_s_o:

     The default from 'base', 'chol'.

_E_x_a_m_p_l_e_s:

     showMethods(chol, inherited = FALSE) # show different methods

     sy2 <- new("dsyMatrix", Dim = as.integer(c(2,2)), x = c(14, NA,32,77))
     (c2 <- chol(sy2))#-> "Cholesky" matrix
     stopifnot(all.equal(c2, chol(as(sy2, "dpoMatrix")), tol= 1e-13))
     str(c2)

     ## An example where chol() can't work
     (sy3 <- new("dsyMatrix", Dim = as.integer(c(2,2)), x = c(14, -1, 2, -7)))
     try(chol(sy3)) # error, since it is not positive definite

