Matrix  $Rev: 3071 $ at $LastChangedDate: 2015-03-26 15:35:47 +0100 (Thu, 26 Mar 2015) $
dtTMatrix.c
Go to the documentation of this file.
1  /* Sparse triangular matrices in triplet format */
2 #include "dtTMatrix.h"
3 #include "dgTMatrix.h" /* xTMatrix_validate */
4 
5 /* This should be use for *BOTH* triangular and symmetric Tsparse: */
6 SEXP tTMatrix_validate(SEXP x)
7 {
8  SEXP val = xTMatrix_validate(x);/* checks x slot */
9  if(isString(val))
10  return(val);
11  else {
12  SEXP
13  islot = GET_SLOT(x, Matrix_iSym),
14  jslot = GET_SLOT(x, Matrix_jSym);
15  int uploT = (*uplo_P(x) == 'U'),
16  k, nnz = length(islot),
17  *xj = INTEGER(jslot),
18  *xi = INTEGER(islot);
19 
20  /* Maybe FIXME: ">" should be ">=" for diag = 'U' (uplo = 'U') */
21  if(uploT) {
22  for (k = 0; k < nnz; k++)
23  if(xi[k] > xj[k])
24  return mkString(_("uplo='U' must not have sparse entries below the diagonal"));
25  }
26  else {
27  for (k = 0; k < nnz; k++)
28  if(xi[k] < xj[k])
29  return mkString(_("uplo='L' must not have sparse entries above the diagonal"));
30  }
31 
32  return ScalarLogical(1);
33  }
34 }
35 
36 /* SEXP dtTMatrix_as_dtrMatrix(SEXP x) ---> now in ./TMatrix_as.c */
SEXP tTMatrix_validate(SEXP x)
Definition: dtTMatrix.c:6
SEXP Matrix_jSym
Definition: Syms.h:2
#define uplo_P(_x_)
Definition: Mutils.h:174
#define _(String)
Definition: Mutils.h:32
SEXP Matrix_iSym
Definition: Syms.h:2
SEXP xTMatrix_validate(SEXP x)
Definition: dgTMatrix.c:9