Matrix r5059
Loading...
Searching...
No Matches
solve.c File Reference
#include "Lapack-etc.h"
#include "cs-etc.h"
#include "cholmod-etc.h"
#include "Mdefines.h"
#include "M5.h"
#include "idz.h"

Go to the source code of this file.

Macros

#define SOLVE_START
 
#define SOLVE_FINISH
 
#define PROMOTE(A)
 
#define SOLVE_DENSE(c)
 
#define SOLVE_DENSE(c)
 
#define SOLVE_SPARSE_TRIANGULAR(c, _A_, _ALO_, _BFR_)
 
#define SOLVE_SPARSE(c)
 
#define SOLVE_DENSE(c)
 
#define SOLVE_DENSE(c)
 
#define SOLVE_SPARSE(c)
 
#define TEMPLATE(c)
 
#define TEMPLATE(c)
 

Functions

static void solveDN (SEXP rdn, SEXP adn, SEXP bdn)
 
SEXP denseLU_solve (SEXP s_a, SEXP s_b)
 
SEXP denseBunchKaufman_solve (SEXP s_a, SEXP s_b)
 
SEXP denseCholesky_solve (SEXP s_a, SEXP s_b)
 
SEXP trMatrix_solve (SEXP s_a, SEXP s_b)
 
SEXP sparseLU_solve (SEXP s_a, SEXP s_b, SEXP s_sparse)
 
static int strmatch (const char *s, const char **nms)
 
SEXP sparseCholesky_solve (SEXP s_a, SEXP s_b, SEXP s_sparse, SEXP s_system)
 
SEXP tCMatrix_solve (SEXP s_a, SEXP s_b, SEXP s_sparse)
 
SEXP sparseQR_matmult (SEXP s_qr, SEXP s_y, SEXP s_op, SEXP s_complete, SEXP s_yxjj)
 

Macro Definition Documentation

◆ PROMOTE

#define PROMOTE ( A)
Value:
do { \
size_t n = (size_t) (A)->nzmax; \
double *x = (double *) (A)->x; \
Rcomplex *y = (Rcomplex *) R_alloc(n, sizeof(Rcomplex)); \
while (n-- > 0) { (*(y)).r = *(x++); (*(y++)).i = 0.0; } \
(A)->x = y; \
(A)->xtype = CXSPARSE_COMPLEX; \
} while (0)
#define CXSPARSE_COMPLEX
Definition cs-etc.h:9

Referenced by sparseLU_solve(), sparseQR_matmult(), and tCMatrix_solve().

◆ SOLVE_DENSE [1/4]

#define SOLVE_DENSE ( c)
Value:
do { \
c##TYPE *prx = c##PTR(rx), \
*work = (c##TYPE *) R_alloc((size_t) m, sizeof(c##TYPE)); \
memset(prx, 0, sizeof(c##TYPE) * (size_t) mn); \
for (j = 0; j < n; ++j) { \
prx[j] = c##UNIT; \
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)
cholmod_common c
Definition cholmod-etc.c:5

Referenced by sparseLU_solve(), and tCMatrix_solve().

◆ SOLVE_DENSE [2/4]

#define SOLVE_DENSE ( c)
Value:
do { \
c##TYPE *prx = c##PTR(rx), *pbx = c##PTR(bx), \
*work = (c##TYPE *) R_alloc((size_t) m, sizeof(c##TYPE)); \
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 [3/4]

#define SOLVE_DENSE ( c)
Value:
do { \
c##TYPE *prx = c##PTR(rx); \
memset(prx, 0, sizeof(c##TYPE) * (size_t) mn); \
for (j = 0; j < n; ++j) { \
prx[j] = c##UNIT; \
if (aul == 'U') \
Matrix_cs_usolve(A, prx); \
else \
Matrix_cs_lsolve(A, prx); \
prx += m; \
} \
} while (0)

◆ SOLVE_DENSE [4/4]

#define SOLVE_DENSE ( c)
Value:
do { \
c##TYPE *prx = c##PTR(rx), *pbx = c##PTR(bx); \
memcpy(prx, pbx, sizeof(c##TYPE) * (size_t) mn); \
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(DIMNAMES(r, 0)), \
adimnames = PROTECT(DIMNAMES(s_a, 0)); \
if (s_b == R_NilValue) \
cpyDN(rdimnames, adimnames, 1); \
else { \
SEXP bdimnames = PROTECT(DIMNAMES(s_b, 0)); \
solveDN(rdimnames, adimnames, bdimnames); \
UNPROTECT(1); /* bdimnames */ \
} \
UNPROTECT(2); /* adimnames, rdimnames */
#define DIMNAMES(x, mode)
Definition Mdefines.h:96

Referenced by denseBunchKaufman_solve(), denseCholesky_solve(), denseLU_solve(), sparseCholesky_solve(), sparseLU_solve(), tCMatrix_solve(), and trMatrix_solve().

◆ SOLVE_SPARSE [1/2]

#define SOLVE_SPARSE ( c)
Value:
do { \
c##TYPE *work = (c##TYPE *) R_alloc((size_t) m, sizeof(c##TYPE)); \
SOLVE_SPARSE_TRIANGULAR(c, L, 1, Bfr); \
SOLVE_SPARSE_TRIANGULAR(c, U, 0, 1); \
} while (0)

Referenced by sparseLU_solve(), and tCMatrix_solve().

◆ SOLVE_SPARSE [2/2]

#define SOLVE_SPARSE ( c)
Value:
do { \
c##TYPE *work = (c##TYPE *) R_alloc((size_t) m, sizeof(c##TYPE)); \
SOLVE_SPARSE_TRIANGULAR(c, A, aul != 'U', s_b == R_NilValue); \
} while (0)

◆ SOLVE_SPARSE_TRIANGULAR

#define SOLVE_SPARSE_TRIANGULAR ( c,
_A_,
_ALO_,
_BFR_ )

◆ SOLVE_START

#define SOLVE_START
Value:
int *padim = DIM(s_a), m = padim[0], n = padim[1]; \
if (m != n) \
Rf_error(_("'%s' is not square"), "a"); \
if (s_b != R_NilValue) { \
int *pbdim = DIM(s_b); \
if (pbdim[0] != m) \
Rf_error(_("dimensions of '%s' and '%s' are inconsistent"), \
"a", "b"); \
n = pbdim[1]; \
}
#define _(String)
Definition Mdefines.h:66
#define DIM(x)
Definition Mdefines.h:85

Referenced by denseBunchKaufman_solve(), denseCholesky_solve(), denseLU_solve(), sparseCholesky_solve(), sparseLU_solve(), tCMatrix_solve(), and trMatrix_solve().

◆ TEMPLATE [1/2]

#define TEMPLATE ( c)
Value:
do { \
c##TYPE *pyx = c##PTR(yx); \
memset(pyx, 0, sizeof(c##TYPE) * (size_t) mn); \
if (s_yxjj == R_NilValue) { \
c##TYPE one = c##UNIT; \
c##NAME(copy2)((size_t) n, \
pyx, (size_t) m + 1, &one, 0); \
} else { \
s_yxjj = Rf_coerceVector(s_yxjj, c##TYPESXP); \
c##TYPE *pyxjj = c##PTR(s_yxjj); \
c##NAME(copy2)((size_t) n, \
pyx, (size_t) m + 1, pyxjj, 1); \
} \
} while (0)

Referenced by sparseQR_matmult().

◆ TEMPLATE [2/2]

#define TEMPLATE ( c)

Function Documentation

◆ denseBunchKaufman_solve()

SEXP denseBunchKaufman_solve ( SEXP s_a,
SEXP s_b )

◆ denseCholesky_solve()

◆ denseLU_solve()

SEXP denseLU_solve ( SEXP s_a,
SEXP s_b )

◆ solveDN()

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

Definition at line 11 of file solve.c.

◆ sparseCholesky_solve()

SEXP sparseCholesky_solve ( SEXP s_a,
SEXP s_b,
SEXP s_sparse,
SEXP s_system )

Definition at line 697 of file solve.c.

References _, c, CHD2M(), CHS2M(), ERROR_OOM, M2CHD(), M2CHF(), M2CHS(), SET_UPLO, SOLVE_FINISH, SOLVE_START, strmatch(), and TYPEOF.

◆ sparseLU_solve()

◆ sparseQR_matmult()

SEXP sparseQR_matmult ( SEXP s_qr,
SEXP s_y,
SEXP s_op,
SEXP s_complete,
SEXP s_yxjj )

◆ strmatch()

static int strmatch ( const char * s,
const char ** nms )
static

Definition at line 686 of file solve.c.

Referenced by sparseCholesky_solve().

◆ tCMatrix_solve()

◆ trMatrix_solve()

SEXP trMatrix_solve ( SEXP s_a,
SEXP s_b )