Matrix r4655
Loading...
Searching...
No Matches
Macros | Functions
solve.c File Reference
#include "Lapack-etc.h"
#include "cs-etc.h"
#include "cholmod-etc.h"
#include "Mdefines.h"
#include "idz.h"
#include "solve.h"

Go to the source code of this file.

Macros

#define SOLVE_START
 
#define SOLVE_FINISH
 
#define IF_COMPLEX(_IF_, _ELSE_)    ((MCS_XTYPE_GET() == MCS_COMPLEX) ? (_IF_) : (_ELSE_))
 
#define ERROR_SOLVE_OOM(_ACL_, _BCL_)    error(_("%s(<%s>, <%s>) failed: out of memory"), "solve", _ACL_, _BCL_)
 
#define SOLVE_DENSE_1(_CTYPE_, _PTR_, _ONE_)
 
#define SOLVE_DENSE_2(_CTYPE_, _PTR_)
 
#define SOLVE_SPARSE_TRIANGULAR(_CTYPE_, _A_, _ALO_, _BFR_, _ACL_, _BCL_)
 
#define SOLVE_SPARSE(_CTYPE_)
 
#define EYE(_CTYPE_, _ONE_)
 
#define SOLVE_DENSE_1(_CTYPE_, _PTR_, _ONE_)
 
#define SOLVE_DENSE_2(_CTYPE_, _PTR_)
 
#define SOLVE_SPARSE(_CTYPE_)
 
#define EYE(_CTYPE_, _PTR_, _ONE_)
 
#define MATMULT(_CTYPE_, _PTR_)
 

Functions

static void solveDN (SEXP rdn, SEXP adn, SEXP bdn)
 
SEXP denseLU_solve (SEXP a, SEXP b)
 
SEXP BunchKaufman_solve (SEXP a, SEXP b)
 
SEXP Cholesky_solve (SEXP a, SEXP b)
 
SEXP dtrMatrix_solve (SEXP a, SEXP b)
 
SEXP sparseLU_solve (SEXP a, SEXP b, SEXP sparse)
 
static int strmatch (const char *x, const char **valid)
 
SEXP CHMfactor_solve (SEXP a, SEXP b, SEXP sparse, SEXP system)
 
SEXP dtCMatrix_solve (SEXP a, SEXP b, SEXP sparse)
 
SEXP sparseQR_matmult (SEXP qr, SEXP y, SEXP op, SEXP complete, SEXP yxjj)
 

Macro Definition Documentation

◆ ERROR_SOLVE_OOM

#define ERROR_SOLVE_OOM (   _ACL_,
  _BCL_ 
)     error(_("%s(<%s>, <%s>) failed: out of memory"), "solve", _ACL_, _BCL_)

◆ EYE [1/2]

#define EYE (   _CTYPE_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *B__x = (_CTYPE_ *) B->x; \
Matrix_memset(B__x, 0, (R_xlen_t) m * n, sizeof(_CTYPE_)); \
for (j = 0; j < n; ++j) { \
*B__x = _ONE_; \
B__x += m1a; \
} \
} while (0)

◆ EYE [2/2]

#define EYE (   _CTYPE_,
  _PTR_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *pyx = _PTR_(yx); \
Matrix_memset(pyx, 0, mn, sizeof(_CTYPE_)); \
if (isNull(yxjj)) { \
for (j = 0; j < n; ++j) { \
*pyx = _ONE_; \
pyx += m1a; \
} \
} else if (TYPEOF(yxjj) == TYPEOF(yx) && XLENGTH(yxjj) >= n) { \
_CTYPE_ *pyxjj = _PTR_(yxjj); \
for (j = 0; j < n; ++j) { \
*pyx = *pyxjj; \
pyx += m1a; \
pyxjj += 1; \
} \
} else \
error(_("invalid '%s' to '%s'"), "yxjj", __func__); \
} while (0)
#define _(String)
Definition Mdefines.h:44

◆ IF_COMPLEX

#define IF_COMPLEX (   _IF_,
  _ELSE_ 
)     ((MCS_XTYPE_GET() == MCS_COMPLEX) ? (_IF_) : (_ELSE_))

Definition at line 490 of file solve.c.

◆ MATMULT

#define MATMULT (   _CTYPE_,
  _PTR_ 
)

◆ SOLVE_DENSE_1 [1/2]

#define SOLVE_DENSE_1 (   _CTYPE_,
  _PTR_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *prx = _PTR_(rx), \
*work = (_CTYPE_ *) R_alloc((size_t) m, sizeof(_CTYPE_)); \
Matrix_memset(prx, 0, mn, sizeof(_CTYPE_)); \
for (j = 0; j < n; ++j) { \
prx[j] = _ONE_; \
Matrix_cs_pvec(pap, prx, work, m); \
Matrix_cs_lsolve(L, work); \
Matrix_cs_usolve(U, work); \
Matrix_cs_ipvec(paq, work, prx, m); \
prx += m; \
} \
} while (0)

◆ SOLVE_DENSE_1 [2/2]

#define SOLVE_DENSE_1 (   _CTYPE_,
  _PTR_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *prx = _PTR_(rx); \
Matrix_memset(prx, 0, mn, sizeof(_CTYPE_)); \
for (j = 0; j < n; ++j) { \
prx[j] = _ONE_; \
if (aul == 'U') \
Matrix_cs_usolve(A, prx); \
else \
Matrix_cs_lsolve(A, prx); \
prx += m; \
} \
} while (0)

◆ SOLVE_DENSE_2 [1/2]

#define SOLVE_DENSE_2 (   _CTYPE_,
  _PTR_ 
)
Value:
do { \
_CTYPE_ *prx = _PTR_(rx), *pbx = _PTR_(bx), \
*work = (_CTYPE_ *) R_alloc((size_t) m, sizeof(_CTYPE_)); \
for (j = 0; j < n; ++j) { \
Matrix_cs_pvec(pap, pbx, work, m); \
Matrix_cs_lsolve(L, work); \
Matrix_cs_usolve(U, work); \
Matrix_cs_ipvec(paq, work, prx, m); \
prx += m; \
pbx += m; \
} \
} while (0)

◆ SOLVE_DENSE_2 [2/2]

#define SOLVE_DENSE_2 (   _CTYPE_,
  _PTR_ 
)
Value:
do { \
_CTYPE_ *prx = _PTR_(rx), *pbx = _PTR_(bx); \
Matrix_memcpy(prx, pbx, mn, sizeof(_CTYPE_)); \
for (j = 0; j < n; ++j) { \
if (aul == 'U') \
Matrix_cs_usolve(A, prx); \
else \
Matrix_cs_lsolve(A, prx); \
prx += m; \
} \
} while (0)

◆ SOLVE_FINISH

#define SOLVE_FINISH
Value:
SEXP rdimnames = PROTECT(GET_SLOT(r, Matrix_DimNamesSym)), \
adimnames = PROTECT(GET_SLOT(a, Matrix_DimNamesSym)); \
if (isNull(b)) \
revDN(rdimnames, adimnames); \
else { \
SEXP bdimnames = PROTECT(GET_SLOT(b, Matrix_DimNamesSym)); \
solveDN(rdimnames, adimnames, bdimnames); \
UNPROTECT(1); /* bdimnames */ \
} \
UNPROTECT(2); /* adimnames, rdimnames */
#define GET_SLOT(x, what)
Definition Mdefines.h:85
SEXP Matrix_DimNamesSym
Definition Msymbols.h:2

◆ SOLVE_SPARSE [1/2]

#define SOLVE_SPARSE (   _CTYPE_)
Value:
do { \
_CTYPE_ *work = (_CTYPE_ *) R_alloc((size_t) m, sizeof(_CTYPE_)); \
SOLVE_SPARSE_TRIANGULAR(_CTYPE_, L, 1, Bfr, \
"sparseLU", ".gCMatrix"); \
SOLVE_SPARSE_TRIANGULAR(_CTYPE_, U, 0, 1, \
"sparseLU", ".gCMatrix"); \
} while (0)

◆ SOLVE_SPARSE [2/2]

#define SOLVE_SPARSE (   _CTYPE_)
Value:
do { \
_CTYPE_ *work = (_CTYPE_ *) R_alloc((size_t) m, sizeof(_CTYPE_)); \
SOLVE_SPARSE_TRIANGULAR(_CTYPE_, A, aul != 'U', isNull(b), \
".tCMatrix", ".gCMatrix"); \
} while (0)

◆ SOLVE_SPARSE_TRIANGULAR

#define SOLVE_SPARSE_TRIANGULAR (   _CTYPE_,
  _A_,
  _ALO_,
  _BFR_,
  _ACL_,
  _BCL_ 
)

◆ SOLVE_START

#define SOLVE_START
Value:
SEXP adim = GET_SLOT(a, Matrix_DimSym); \
int *padim = INTEGER(adim), m = padim[0], n = padim[1]; \
if (m != n) \
error(_("'%s' is not square"), "a"); \
if (!isNull(b)) { \
SEXP bdim = GET_SLOT(b, Matrix_DimSym); \
int *pbdim = INTEGER(bdim); \
if (pbdim[0] != m) \
error(_("dimensions of '%s' and '%s' are inconsistent"), \
"a", "b"); \
n = pbdim[1]; \
}
SEXP Matrix_DimSym
Definition Msymbols.h:3

Function Documentation

◆ BunchKaufman_solve()

SEXP BunchKaufman_solve ( SEXP  a,
SEXP  b 
)

◆ CHMfactor_solve()

SEXP CHMfactor_solve ( SEXP  a,
SEXP  b,
SEXP  sparse,
SEXP  system 
)

◆ Cholesky_solve()

SEXP Cholesky_solve ( SEXP  a,
SEXP  b 
)

◆ denseLU_solve()

SEXP denseLU_solve ( SEXP  a,
SEXP  b 
)

◆ dtCMatrix_solve()

SEXP dtCMatrix_solve ( SEXP  a,
SEXP  b,
SEXP  sparse 
)

◆ dtrMatrix_solve()

SEXP dtrMatrix_solve ( SEXP  a,
SEXP  b 
)

◆ solveDN()

static void solveDN ( SEXP  rdn,
SEXP  adn,
SEXP  bdn 
)
static

Definition at line 9 of file solve.c.

◆ sparseLU_solve()

SEXP sparseLU_solve ( SEXP  a,
SEXP  b,
SEXP  sparse 
)

◆ sparseQR_matmult()

SEXP sparseQR_matmult ( SEXP  qr,
SEXP  y,
SEXP  op,
SEXP  complete,
SEXP  yxjj 
)

◆ strmatch()

static int strmatch ( const char *  x,
const char **  valid 
)
static

Definition at line 700 of file solve.c.

References valid.

Referenced by CHMfactor_solve().