|
Matrix $Rev: 2718 $ at $LastChangedDate: 2011-10-06 11:45:17 +0200 (Thu, 06 Oct 2011) $
|

Go to the source code of this file.
Defines | |
| #define | ddense_CLASSES |
| Duplicate a [dln]denseMatrix or a numeric matrix or vector as a [dln]geMatrix. | |
| #define | do_ii_FILL(_i_, _j_) |
| #define | DUP_MMATRIX_ddense_CASES |
| #define | DUP_MMATRIX_NON_CLASS |
| #define | DUP_MMATRIX_SET_1 |
| #define | END_packed_getDiag |
| #define | FULL_TO_PACKED(TYPE) |
| #define | ldense_CLASSES |
| #define | MAKE_SYMMETRIC_BODY(_TO_, _FROM_) |
| #define | MAKE_TRIANGULAR_BODY(_TO_, _FROM_, _ZERO_, _ONE_) |
| #define | Matrix_Error_Bufsiz 4096 |
| #define | ndense_CLASSES |
| #define | PACKED_TO_FULL(TYPE) |
| #define | SPRINTF buf = Alloca(Matrix_Error_Bufsiz, char); R_CheckStack(); sprintf |
Functions | |
| SEXP | as_det_obj (double val, int log, int sign) |
| SEXP | check_scalar_string (SEXP sP, char *vals, char *nm) |
| Check validity of 1-letter string from a set of possible values (typically used in S4 validity method) | |
| void | d_packed_getDiag (double *dest, SEXP x, int n) |
| Copy the diagonal elements of the packed denseMatrix x to dest. | |
| SEXP | dense_nonpacked_validate (SEXP obj) |
| SEXP | dup_mMatrix_as_dgeMatrix (SEXP A) |
| SEXP | dup_mMatrix_as_geMatrix (SEXP A) |
| Rboolean | equal_string_vectors (SEXP s1, SEXP s2) |
| double | get_double_by_name (SEXP obj, char *nm) |
| SEXP | get_factors (SEXP obj, char *nm) |
| static double * | install_diagonal (double *dest, SEXP A) |
| Zero a square matrix of size nc then copy a vector to the diagonal. | |
| static int * | install_diagonal_int (int *dest, SEXP A) |
| void | l_packed_getDiag (int *dest, SEXP x, int n) |
| char | La_norm_type (const char *typstr) |
| char | La_rcond_type (const char *typstr) |
| SEXP | m_encodeInd (SEXP ij, SEXP di, SEXP chk_bnds) |
| Encode Matrix index (i,j) |--> i + j * nrow {i,j : 0-origin}. | |
| SEXP | m_encodeInd2 (SEXP i, SEXP j, SEXP di, SEXP chk_bnds) |
| Encode Matrix index (i,j) |--> i + j * nrow {i,j : 0-origin}. | |
| void | make_d_matrix_symmetric (double *to, SEXP from) void make_i_matrix_symmetric(int *to |
| void | make_d_matrix_triangular (double *to, SEXP from) void make_i_matrix_triangular(int *to |
| int | Matrix_check_class_etc (SEXP x, const char **valid) |
| Return the 0-based index of an is() match in a vector of class-name strings terminated by an empty string. | |
| SEXP | Matrix_expand_pointers (SEXP pP) |
| SEXP | Matrix_getElement (SEXP list, char *nm) |
| Return the element of a given name from a named list. | |
| SEXP | new_dgeMatrix (int nrow, int ncol) |
| SEXP | set_double_by_name (SEXP obj, double val, char *nm) |
| SEXP | set_factors (SEXP obj, SEXP val, char *nm) |
| void | tr_d_packed_getDiag (double *dest, SEXP x) |
| void | tr_l_packed_getDiag (int *dest, SEXP x) |
| #define ddense_CLASSES |
"dgeMatrix", "dtrMatrix", \ "dsyMatrix", "dpoMatrix", "ddiMatrix", \ "dtpMatrix", "dspMatrix", "dppMatrix", \ /* sub classes of those above:*/ \ /* dtr */ "Cholesky", "LDL", "BunchKaufman", \ /* dtp */ "pCholesky", "pBunchKaufman", \ /* dpo */ "corMatrix"
Duplicate a [dln]denseMatrix or a numeric matrix or vector as a [dln]geMatrix.
This is for the many *_matrix_{prod,crossprod,tcrossprod,etc.} functions that work with both classed and unclassed matrices.
| A | either a denseMatrix object or a matrix object |
Definition at line 499 of file Mutils.c.
Referenced by dup_mMatrix_as_dgeMatrix(), and dup_mMatrix_as_geMatrix().
| #define do_ii_FILL | ( | _i_, | |
| _j_ | |||
| ) |
int i; \ if(check_bounds) { \ for(i=0; i < n; i++) { \ if(_i_[i] == NA_INTEGER || _j_[i] == NA_INTEGER) \ ii[i] = NA_INTEGER; \ else { \ if(_i_[i] < 0 || _i_[i] >= Di[0]) \ error(_("subscript 'i' out of bounds in M[ij]")); \ if(_j_[i] < 0 || _j_[i] >= Di[1]) \ error(_("subscript 'j' out of bounds in M[ij]")); \ ii[i] = _i_[i] + _j_[i] * nr; \ } \ } \ } else { \ for(i=0; i < n; i++) \ ii[i] = (_i_[i] == NA_INTEGER || _j_[i] == NA_INTEGER) \ ? NA_INTEGER : _i_[i] + _j_[i] * nr; \ }
Referenced by m_encodeInd(), and m_encodeInd2().
| #define DUP_MMATRIX_ddense_CASES |
Referenced by dup_mMatrix_as_dgeMatrix(), and dup_mMatrix_as_geMatrix().
| #define DUP_MMATRIX_NON_CLASS |
if (isMatrix(A)) { /* "matrix" */ \ ad = getAttrib(A, R_DimSymbol); \ an = getAttrib(A, R_DimNamesSymbol); \ } else {/* maybe "numeric" (incl integer,logical) --> (n x 1) */\ int* dd = INTEGER(ad = PROTECT(allocVector(INTSXP, 2))); \ nprot++; \ dd[0] = LENGTH(A); \ dd[1] = 1; \ an = R_NilValue; \ } \ ctype = 0
Referenced by dup_mMatrix_as_dgeMatrix(), and dup_mMatrix_as_geMatrix().
| #define DUP_MMATRIX_SET_1 |
SET_SLOT(ans, Matrix_DimSym, duplicate(ad)); \ SET_SLOT(ans, Matrix_DimNamesSym, (LENGTH(an) == 2) ? \ duplicate(an): allocVector(VECSXP, 2)); \ sz = INTEGER(ad)[0] * INTEGER(ad)[1]
Referenced by dup_mMatrix_as_dgeMatrix(), and dup_mMatrix_as_geMatrix().
| #define END_packed_getDiag |
int j, pos = 0; \ \ if (*uplo_P(x) == 'U') { \ for(pos= 0, j=0; j < n; pos += 1+(++j)) dest[j] = xx[pos]; \ } else { \ for(pos= 0, j=0; j < n; pos += (n - j), j++) dest[j] = xx[pos]; \ } \ return
Referenced by d_packed_getDiag(), and l_packed_getDiag().
| #define FULL_TO_PACKED | ( | TYPE | ) |
TYPE *full_to_packed_ ## TYPE(TYPE *dest, const TYPE *src, int n, \ enum CBLAS_UPLO uplo, enum CBLAS_DIAG diag) \ { \ int i, j, pos = 0; \ \ for (j = 0; j < n; j++) { \ switch(uplo) { \ case UPP: \ for (i = 0; i <= j; i++) \ dest[pos++] = (i == j && diag== UNT) ? 1 : src[i + j*n]; \ break; \ case LOW: \ for (i = j; i < n; i++) \ dest[pos++] = (i == j && diag== UNT) ? 1 : src[i + j*n]; \ break; \ default: \ error(_("'uplo' must be UPP or LOW")); \ } \ } \ return dest; \ }
| #define ldense_CLASSES |
"lgeMatrix", "ltrMatrix", \ "lsyMatrix", "ldiMatrix", \ "ltpMatrix", "lspMatrix"
Definition at line 508 of file Mutils.c.
Referenced by dup_mMatrix_as_geMatrix().
| #define MAKE_SYMMETRIC_BODY | ( | _TO_, | |
| _FROM_ | |||
| ) |
{ \
int i, j, n = INTEGER(GET_SLOT(_FROM_, Matrix_DimSym))[0]; \
\
if (*uplo_P(_FROM_) == 'U') { \
for (j = 0; j < n; j++) \
for (i = j+1; i < n; i++) \
_TO_[i + j*n] = _TO_[j + i*n]; \
} else { \
for (j = 1; j < n; j++) \
for (i = 0; i < j && i < n; i++) \
_TO_[i + j*n] = _TO_[j + i*n]; \
} \
}
| #define MAKE_TRIANGULAR_BODY | ( | _TO_, | |
| _FROM_, | |||
| _ZERO_, | |||
| _ONE_ | |||
| ) |
{ \
int i, j, *dims = INTEGER(GET_SLOT(_FROM_, Matrix_DimSym)); \
int n = dims[0], m = dims[1]; \
\
if (*uplo_P(_FROM_) == 'U') { \
for (j = 0; j < n; j++) \
for (i = j+1; i < m; i++) \
_TO_[i + j*m] = _ZERO_; \
} else { \
for (j = 1; j < n; j++) \
for (i = 0; i < j && i < m; i++) \
_TO_[i + j*m] = _ZERO_; \
} \
if (*diag_P(_FROM_) == 'U') { \
j = (n < m) ? n : m; \
for (i = 0; i < j; i++) \
_TO_[i * (m + 1)] = _ONE_; \
} \
}
| #define ndense_CLASSES |
"ngeMatrix", "ntrMatrix", \ "nsyMatrix", \ "ntpMatrix", "nspMatrix"
Definition at line 513 of file Mutils.c.
Referenced by dup_mMatrix_as_geMatrix().
| #define PACKED_TO_FULL | ( | TYPE | ) |
TYPE *packed_to_full_ ## TYPE(TYPE *dest, const TYPE *src, \ int n, enum CBLAS_UPLO uplo) \ { \ int i, j, pos = 0; \ \ AZERO(dest, n*n); \ for (j = 0; j < n; j++) { \ switch(uplo) { \ case UPP: \ for (i = 0; i <= j; i++) dest[i + j * n] = src[pos++]; \ break; \ case LOW: \ for (i = j; i < n; i++) dest[i + j * n] = src[pos++]; \ break; \ default: \ error(_("'uplo' must be UPP or LOW")); \ } \ } \ return dest; \ }
| #define SPRINTF buf = Alloca(Matrix_Error_Bufsiz, char); R_CheckStack(); sprintf |
Referenced by check_scalar_string().
| SEXP as_det_obj | ( | double | val, |
| int | log, | ||
| int | sign | ||
| ) |
Definition at line 92 of file Mutils.c.
Referenced by dgeMatrix_determinant().

| SEXP check_scalar_string | ( | SEXP | sP, |
| char * | vals, | ||
| char * | nm | ||
| ) |
Check validity of 1-letter string from a set of possible values (typically used in S4 validity method)
| sP | |
| vals | a string containing the possible valid letters |
| nm | the name of the slot being checked |
Definition at line 236 of file Mutils.c.
Referenced by symmetricMatrix_validate(), and triangularMatrix_validate().

| void d_packed_getDiag | ( | double * | dest, |
| SEXP | x, | ||
| int | n | ||
| ) |
Copy the diagonal elements of the packed denseMatrix x to dest.
| dest | vector of length ncol(x) |
| x | pointer to an object representing a packed array |
| n | number of columns in the matrix represented by x |
Definition at line 363 of file Mutils.c.
References END_packed_getDiag, and Matrix_xSym.
Referenced by dtpMatrix_getDiag(), and tr_d_packed_getDiag().

| SEXP dense_nonpacked_validate | ( | SEXP | obj | ) |
Definition at line 292 of file Mutils.c.
References _, Matrix_DimSym, and Matrix_xSym.
Referenced by dgeMatrix_validate(), dsyMatrix_validate(), and dtrMatrix_validate().

| SEXP dup_mMatrix_as_dgeMatrix | ( | SEXP | A | ) |
Definition at line 679 of file Mutils.c.
References _, class_P, ddense_CLASSES, DUP_MMATRIX_ddense_CASES, DUP_MMATRIX_NON_CLASS, DUP_MMATRIX_SET_1, Matrix_check_class_etc(), Matrix_DimNamesSym, and Matrix_DimSym.
Referenced by CHMfactor_solve(), ddense_skewpart(), ddense_symmpart(), dgCMatrix_matrix_solve(), dgeMatrix_matrix_solve(), dppMatrix_matrix_solve(), dspMatrix_matrix_mm(), dspMatrix_matrix_solve(), dsyMatrix_matrix_mm(), dsyMatrix_matrix_solve(), dtpMatrix_matrix_mm(), dtpMatrix_matrix_solve(), dtrMatrix_dtrMatrix_mm(), dtrMatrix_matrix_mm(), dtrMatrix_matrix_solve(), mMatrix_as_dgeMatrix(), sparseQR_coef(), sparseQR_qty(), and sparseQR_resid_fitted().


| SEXP dup_mMatrix_as_geMatrix | ( | SEXP | A | ) |
Definition at line 519 of file Mutils.c.
References _, ALLOC_SLOT(), class_P, ddense_CLASSES, DUP_MMATRIX_ddense_CASES, DUP_MMATRIX_NON_CLASS, DUP_MMATRIX_SET_1, install_diagonal_int(), ldense_CLASSES, LOW, make_i_matrix_symmetric(), make_i_matrix_triangular(), Matrix_check_class_etc(), Matrix_DimNamesSym, Matrix_DimSym, Matrix_xSym, ndense_CLASSES, uplo_P, and UPP.
Referenced by dense_band(), dense_to_symmetric(), and mMatrix_as_geMatrix().


| Rboolean equal_string_vectors | ( | SEXP | s1, |
| SEXP | s2 | ||
| ) |
Definition at line 268 of file Mutils.c.
References _.
Referenced by ddense_skewpart(), ddense_symmpart(), and dense_to_symmetric().

| double get_double_by_name | ( | SEXP | obj, |
| char * | nm | ||
| ) |
| SEXP get_factors | ( | SEXP | obj, |
| char * | nm | ||
| ) |
Definition at line 109 of file Mutils.c.
References _, and Matrix_factorSym.
Referenced by dgCMatrix_LU(), dgCMatrix_matrix_solve(), dgeMatrix_LU_(), dpoMatrix_chol(), dppMatrix_chol(), dspMatrix_trf(), and dsyMatrix_trf().

| static double* install_diagonal | ( | double * | dest, |
| SEXP | A | ||
| ) | [static] |
Zero a square matrix of size nc then copy a vector to the diagonal.
| dest | destination array of length nc * nc |
| A | pointer to a square Matrix object |
Definition at line 461 of file Mutils.c.
References AZERO, diag_P, Matrix_DimSym, and Matrix_xSym.
| static int* install_diagonal_int | ( | int * | dest, |
| SEXP | A | ||
| ) | [static] |
Definition at line 474 of file Mutils.c.
References AZERO, diag_P, Matrix_DimSym, and Matrix_xSym.
Referenced by dup_mMatrix_as_geMatrix().

| void l_packed_getDiag | ( | int * | dest, |
| SEXP | x, | ||
| int | n | ||
| ) |
Definition at line 380 of file Mutils.c.
References END_packed_getDiag, and Matrix_xSym.
Referenced by ltpMatrix_getDiag(), and tr_l_packed_getDiag().

| char La_norm_type | ( | const char * | typstr | ) |
Definition at line 10 of file Mutils.c.
References _.
Referenced by get_norm(), get_norm_sp(), and get_norm_sy().

| char La_rcond_type | ( | const char * | typstr | ) |
Definition at line 29 of file Mutils.c.
References _.
Referenced by dgeMatrix_rcond(), dtpMatrix_rcond(), and dtrMatrix_rcond().

| SEXP m_encodeInd | ( | SEXP | ij, |
| SEXP | di, | ||
| SEXP | chk_bnds | ||
| ) |
Encode Matrix index (i,j) |--> i + j * nrow {i,j : 0-origin}.
| ij,: | 2-column integer matrix |
| di,: | dim(.), i.e. length 2 integer vector |
| chk_bnds,: | logical indicating 0 <= ij[,k] < di[k] need to be checked. |
Definition at line 738 of file Mutils.c.
References _, and do_ii_FILL.
| SEXP m_encodeInd2 | ( | SEXP | i, |
| SEXP | j, | ||
| SEXP | di, | ||
| SEXP | chk_bnds | ||
| ) |
Encode Matrix index (i,j) |--> i + j * nrow {i,j : 0-origin}.
| i,: | integer vector |
| j,: | integer vector of same length as 'i' |
| di,: | dim(.), i.e. length 2 integer vector |
| chk_bnds,: | logical indicating 0 <= ij[,k] < di[k] need to be checked. |
Definition at line 796 of file Mutils.c.
References _, and do_ii_FILL.
| void make_d_matrix_symmetric | ( | double * | to, |
| SEXP | from | ||
| ) |
| void make_d_matrix_triangular | ( | double * | to, |
| SEXP | from | ||
| ) |
Referenced by dtrMatrix_as_matrix(), dtrMatrix_dtrMatrix_mm(), and LU_expand().

| int Matrix_check_class_etc | ( | SEXP | x, |
| const char ** | valid | ||
| ) |
Return the 0-based index of an is() match in a vector of class-name strings terminated by an empty string.
These are the ones users should use -- is() versions, also looking at super classes:
Returns -1 for no match. Strives to find the correct environment() for is().
| x | an R object, about which we want is(x, .) information. |
| valid | vector of possible matches terminated by an empty string. |
Definition at line 889 of file Mutils.c.
References _, and Matrix_check_class_and_super.
Referenced by as_cholmod_factor(), as_cholmod_sparse(), as_cholmod_triplet(), compressed_to_TMatrix(), Csparse_subassign(), dup_mMatrix_as_dgeMatrix(), dup_mMatrix_as_geMatrix(), Matrix_as_cs(), R_init_Matrix(), R_to_CMatrix(), and Tsparse_diagU2N().

| SEXP Matrix_expand_pointers | ( | SEXP | pP | ) |
Definition at line 421 of file Mutils.c.
References expand_cmprPt().

| SEXP Matrix_getElement | ( | SEXP | list, |
| char * | nm | ||
| ) |
| SEXP new_dgeMatrix | ( | int | nrow, |
| int | ncol | ||
| ) |
Definition at line 714 of file Mutils.c.
References ALLOC_SLOT(), Matrix_DimNamesSym, Matrix_DimSym, and Matrix_xSym.

| SEXP set_double_by_name | ( | SEXP | obj, |
| double | val, | ||
| char * | nm | ||
| ) |
| SEXP set_factors | ( | SEXP | obj, |
| SEXP | val, | ||
| char * | nm | ||
| ) |
Definition at line 129 of file Mutils.c.
References _, and Matrix_factorSym.
Referenced by dgeMatrix_LU_(), dpoMatrix_chol(), dppMatrix_chol(), dspMatrix_trf(), dsyMatrix_trf(), install_lu(), and internal_chm_factor().

| void tr_d_packed_getDiag | ( | double * | dest, |
| SEXP | x | ||
| ) |
Definition at line 389 of file Mutils.c.
References d_packed_getDiag(), diag_P, and Matrix_DimSym.

| void tr_l_packed_getDiag | ( | int * | dest, |
| SEXP | x | ||
| ) |
Definition at line 405 of file Mutils.c.
References diag_P, l_packed_getDiag(), and Matrix_DimSym.
