Matrix  $Rev: 3071 $ at $LastChangedDate: 2015-03-26 15:35:47 +0100 (Thu, 26 Mar 2015) $
dtrMatrix.c File Reference
#include "dtrMatrix.h"
Include dependency graph for dtrMatrix.c:

Go to the source code of this file.

Macros

#define GET_trMatrix_Diag(_C_TYPE_, _SEXPTYPE_, _SEXP_, _ONE_)
 
#define SET_trMatrix_Diag(_C_TYPE_, _SEXP_)
 

Functions

SEXP dtrMatrix_addDiag (SEXP x, SEXP d)
 
SEXP dtrMatrix_as_dtpMatrix (SEXP from)
 
SEXP dtrMatrix_as_matrix (SEXP from, SEXP keep_dimnames)
 
SEXP dtrMatrix_chol2inv (SEXP a)
 
SEXP dtrMatrix_dtrMatrix_mm (SEXP a, SEXP b, SEXP right, SEXP trans)
 Matrix products of dense triangular Matrices. More...
 
SEXP dtrMatrix_getDiag (SEXP x)
 
SEXP dtrMatrix_matrix_mm (SEXP a, SEXP b, SEXP right, SEXP trans)
 Matrix products dense triangular Matrices o <matrix> More...
 
SEXP dtrMatrix_matrix_solve (SEXP a, SEXP b)
 
SEXP dtrMatrix_norm (SEXP obj, SEXP type)
 
SEXP dtrMatrix_rcond (SEXP obj, SEXP type)
 
SEXP dtrMatrix_setDiag (SEXP x, SEXP d)
 
SEXP dtrMatrix_solve (SEXP a)
 
static double get_norm (SEXP obj, const char *typstr)
 
SEXP ltrMatrix_getDiag (SEXP x)
 
SEXP ltrMatrix_setDiag (SEXP x, SEXP d)
 
SEXP triangularMatrix_validate (SEXP obj)
 

Macro Definition Documentation

#define GET_trMatrix_Diag (   _C_TYPE_,
  _SEXPTYPE_,
  _SEXP_,
  _ONE_ 
)
Value:
int i, n = INTEGER(GET_SLOT(x, Matrix_DimSym))[0]; \
SEXP x_x = GET_SLOT(x, Matrix_xSym); \
\
SEXP ret = PROTECT(allocVector(_SEXPTYPE_, n)); \
_C_TYPE_ *rv = _SEXP_(ret), \
*xv = _SEXP_(x_x); \
\
if ('U' == diag_P(x)[0]) { \
for (i = 0; i < n; i++) rv[i] = _ONE_; \
} else { \
for (i = 0; i < n; i++) rv[i] = xv[i * (n + 1)]; \
} \
UNPROTECT(1); \
return ret
SEXP Matrix_DimSym
Definition: Syms.h:2
SEXP Matrix_xSym
Definition: Syms.h:2
#define diag_P(_x_)
Definition: Mutils.h:175

Definition at line 250 of file dtrMatrix.c.

Referenced by dtrMatrix_getDiag(), and ltrMatrix_getDiag().

#define SET_trMatrix_Diag (   _C_TYPE_,
  _SEXP_ 
)
Value:
if ('U' == diag_P(x)[0]) \
error(_("cannot set diag() as long as 'diag = \"U\"'")); \
/* careful to recycle RHS value: */ \
int n = INTEGER(GET_SLOT(x, Matrix_DimSym))[0]; \
int l_d = LENGTH(d); Rboolean d_full = (l_d == n); \
if (!d_full && l_d != 1) \
error(_("replacement diagonal has wrong length")); \
SEXP ret = PROTECT(duplicate(x)), \
r_x = GET_SLOT(ret, Matrix_xSym); \
_C_TYPE_ *dv = _SEXP_(d), \
*rv = _SEXP_(r_x); \
\
if(d_full) for (int i = 0; i < n; i++) \
rv[i * (n + 1)] = dv[i]; \
else for (int i = 0; i < n; i++) \
rv[i * (n + 1)] = *dv; \
\
UNPROTECT(1); \
return ret
SEXP Matrix_DimSym
Definition: Syms.h:2
SEXP Matrix_xSym
Definition: Syms.h:2
#define _(String)
Definition: Mutils.h:32
#define diag_P(_x_)
Definition: Mutils.h:175

Definition at line 275 of file dtrMatrix.c.

Referenced by dtrMatrix_setDiag(), and ltrMatrix_setDiag().

Function Documentation

SEXP dtrMatrix_addDiag ( SEXP  x,
SEXP  d 
)

Definition at line 304 of file dtrMatrix.c.

References _, diag_P, Matrix_DimSym, and Matrix_xSym.

SEXP dtrMatrix_as_dtpMatrix ( SEXP  from)

Definition at line 319 of file dtrMatrix.c.

References ALLOC_SLOT(), LOW, Matrix_diagSym, Matrix_DimNamesSym, Matrix_DimSym, Matrix_uploSym, Matrix_xSym, NUN, UNT, and UPP.

Here is the call graph for this function:

SEXP dtrMatrix_as_matrix ( SEXP  from,
SEXP  keep_dimnames 
)

Definition at line 236 of file dtrMatrix.c.

References make_d_matrix_triangular(), Matrix_DimNamesSym, Matrix_DimSym, and Matrix_xSym.

Here is the call graph for this function:

SEXP dtrMatrix_chol2inv ( SEXP  a)
SEXP dtrMatrix_dtrMatrix_mm ( SEXP  a,
SEXP  b,
SEXP  right,
SEXP  trans 
)

Matrix products of dense triangular Matrices.

Parameters
atriangular matrix of class "dtrMatrix"
b( ditto )
rightlogical, if true, compute b %*% a, else a %*% b
translogical, if true, "transpose a", i.e., use t(a), otherwise a
Returns
the matrix product, one of a %*% b, t(a) %*% b, b %*% a, or b %*% t(a) depending on (right, trans) = (F, F) (F, T) (T, F) (T, T)

Definition at line 160 of file dtrMatrix.c.

References _, ALLOC_SLOT(), dup_mMatrix_as_dgeMatrix(), make_d_matrix_triangular(), Matrix_diagSym, Matrix_DimNamesSym, Matrix_DimSym, Matrix_uploSym, Matrix_xSym, and SET_DimNames().

Here is the call graph for this function:

SEXP dtrMatrix_getDiag ( SEXP  x)

Definition at line 267 of file dtrMatrix.c.

References GET_trMatrix_Diag.

SEXP dtrMatrix_matrix_mm ( SEXP  a,
SEXP  b,
SEXP  right,
SEXP  trans 
)

Matrix products dense triangular Matrices o <matrix>

Parameters
atriangular matrix of class "dtrMatrix"
ba <matrix> or <any-denseMatrix>
rightlogical, if true, compute b %*% a, else a %*% b
translogical, if true, "transpose a", i.e., use t(a), otherwise a
Returns
the matrix product, one of a %*% b, t(a) %*% b, b %*% a, or b %*% t(a) depending on (right, trans) = (F, F) (F, T) (T, F) (T, T)

Definition at line 110 of file dtrMatrix.c.

References _, diag_P, dup_mMatrix_as_dgeMatrix(), Matrix_DimNamesSym, Matrix_DimSym, Matrix_xSym, and uplo_P.

Here is the call graph for this function:

SEXP dtrMatrix_matrix_solve ( SEXP  a,
SEXP  b 
)

Definition at line 82 of file dtrMatrix.c.

References _, diag_P, dup_mMatrix_as_dgeMatrix(), Matrix_DimSym, Matrix_xSym, and uplo_P.

Here is the call graph for this function:

SEXP dtrMatrix_norm ( SEXP  obj,
SEXP  type 
)

Definition at line 36 of file dtrMatrix.c.

References get_norm().

Here is the call graph for this function:

SEXP dtrMatrix_rcond ( SEXP  obj,
SEXP  type 
)

Definition at line 41 of file dtrMatrix.c.

References diag_P, La_rcond_type(), Matrix_DimSym, Matrix_xSym, and uplo_P.

Here is the call graph for this function:

SEXP dtrMatrix_setDiag ( SEXP  x,
SEXP  d 
)

Definition at line 296 of file dtrMatrix.c.

References SET_trMatrix_Diag.

SEXP dtrMatrix_solve ( SEXP  a)

Definition at line 55 of file dtrMatrix.c.

References diag_P, Matrix_DimSym, Matrix_xSym, and uplo_P.

static double get_norm ( SEXP  obj,
const char *  typstr 
)
static

Definition at line 21 of file dtrMatrix.c.

References diag_P, La_norm_type(), Matrix_DimSym, Matrix_xSym, and uplo_P.

Referenced by dtrMatrix_norm().

Here is the call graph for this function:

Here is the caller graph for this function:

SEXP ltrMatrix_getDiag ( SEXP  x)

Definition at line 271 of file dtrMatrix.c.

References GET_trMatrix_Diag.

SEXP ltrMatrix_setDiag ( SEXP  x,
SEXP  d 
)

Definition at line 300 of file dtrMatrix.c.

References SET_trMatrix_Diag.

SEXP triangularMatrix_validate ( SEXP  obj)

Definition at line 5 of file dtrMatrix.c.

References _, check_scalar_string(), Matrix_diagSym, Matrix_DimSym, and Matrix_uploSym.

Referenced by dtpMatrix_validate().

Here is the call graph for this function:

Here is the caller graph for this function: