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

Go to the source code of this file.

Macros

#define CHECK_SYMMETRIC
 
#define MK_SYMMETRIC_DIMNAMES_AND_RETURN
 
#define SET_ZERO_OUTSIDE
 

Functions

SEXP checkGivens (SEXP X, SEXP jmin, SEXP rank)
 
SEXP ddense_skewpart (SEXP x)
 
SEXP ddense_symmpart (SEXP x)
 
SEXP dense_band (SEXP x, SEXP k1P, SEXP k2P)
 
SEXP dense_to_Csparse (SEXP x)
 
SEXP dense_to_symmetric (SEXP x, SEXP uplo, SEXP symm_test)
 
static SEXP getGivens (double x[], int ldx, int jmin, int rank)
 
SEXP lapack_qr (SEXP Xin, SEXP tl)
 
static int left_cyclic (double x[], int ldx, int j, int k, double cosines[], double sines[])
 Perform a left cyclic shift of columns j to k in the upper triangular matrix x, then restore it to upper triangular form with Givens rotations. More...
 
SEXP lsq_dense_Chol (SEXP X, SEXP y)
 
SEXP lsq_dense_QR (SEXP X, SEXP y)
 

Macro Definition Documentation

#define CHECK_SYMMETRIC
Value:
for (j = 0; j < n; j++) \
for (i = 0; i < j; i++) \
if(xx[j * n + i] != xx[i * n + j]) { \
UNPROTECT(1); \
error(_("matrix is not symmetric [%d,%d]"), i+1, j+1); \
return R_NilValue; /* -Wall */ \
}
#define _(String)
Definition: Mutils.h:32

Referenced by dense_to_symmetric().

#define MK_SYMMETRIC_DIMNAMES_AND_RETURN
Value:
\
dns = GET_SLOT(dx, Matrix_DimNamesSym); \
int J = 1; \
if(!equal_string_vectors(VECTOR_ELT(dns,0), \
VECTOR_ELT(dns,1))) { \
/* _symmetric_ dimnames: behave as symmDN(*, col=TRUE) */ \
if(isNull(VECTOR_ELT(dns, J))) \
J = !J; \
SET_VECTOR_ELT(dns, !J, VECTOR_ELT(dns, J)); \
} \
/* names(dimnames(.)): */ \
if(!isNull(nms_dns = getAttrib(dns, R_NamesSymbol)) && \
!R_compute_identical(STRING_ELT(nms_dns, 0), \
STRING_ELT(nms_dns, 1), 16)) { \
SET_STRING_ELT(nms_dns, !J, STRING_ELT(nms_dns, J)); \
setAttrib(dns, R_NamesSymbol, nms_dns); \
} \
\
/* Copy dx to ans; \
* Because slots of dx are freshly allocated and dx will not be \
* used, we use the slots themselves and don't duplicate */ \
\
SET_SLOT(ans, Matrix_xSym, GET_SLOT(dx, Matrix_xSym)); \
SET_SLOT(ans, Matrix_DimSym, GET_SLOT(dx, Matrix_DimSym)); \
SET_SLOT(ans, Matrix_DimNamesSym, dns); \
SET_SLOT(ans, Matrix_uploSym, mkString("U")); \
\
UNPROTECT(2); \
return ans
SEXP Matrix_DimSym
Definition: Syms.h:2
SEXP Matrix_xSym
Definition: Syms.h:2
SEXP Matrix_DimNamesSym
Definition: Syms.h:2
SEXP Matrix_uploSym
Definition: Syms.h:2
Rboolean equal_string_vectors(SEXP s1, SEXP s2)
Definition: Mutils.c:286

Referenced by ddense_skewpart(), and ddense_symmpart().

#define SET_ZERO_OUTSIDE
Value:
for (j = 0; j < n; j++) { \
int i, i1 = j - k2, i2 = j + 1 - k1; \
if(i1 > m) i1 = m; \
if(i2 < 0) i2 = 0; \
for (i = 0; i < i1; i++) xx[i + j * m] = 0; \
for (i = i2; i < m; i++) xx[i + j * m] = 0; \
}

Referenced by dense_band().

Function Documentation

SEXP checkGivens ( SEXP  X,
SEXP  jmin,
SEXP  rank 
)

Definition at line 83 of file dense.c.

References _, and getGivens().

Here is the call graph for this function:

SEXP ddense_skewpart ( SEXP  x)

Definition at line 481 of file dense.c.

References _, dup_mMatrix_as_dgeMatrix(), Matrix_DimSym, Matrix_xSym, and MK_SYMMETRIC_DIMNAMES_AND_RETURN.

Here is the call graph for this function:

SEXP ddense_symmpart ( SEXP  x)

Definition at line 423 of file dense.c.

References _, dup_mMatrix_as_dgeMatrix(), Matrix_DimSym, Matrix_xSym, and MK_SYMMETRIC_DIMNAMES_AND_RETURN.

Here is the call graph for this function:

SEXP dense_band ( SEXP  x,
SEXP  k1P,
SEXP  k2P 
)

Definition at line 279 of file dense.c.

References _, cl, class_P, ddense, dup_mMatrix_as_geMatrix(), ldense, Matrix_diagSym, Matrix_DimNamesSym, Matrix_DimSym, Matrix_uploSym, Matrix_xSym, ndense, and SET_ZERO_OUTSIDE.

Here is the call graph for this function:

SEXP dense_to_Csparse ( SEXP  x)

Definition at line 248 of file dense.c.

References AS_CHM_xDN, c, chm_sparse_to_SEXP(), Matrix_DimNamesSym, mMatrix_as_geMatrix(), and Real_KIND2.

Here is the call graph for this function:

SEXP dense_to_symmetric ( SEXP  x,
SEXP  uplo,
SEXP  symm_test 
)

Definition at line 341 of file dense.c.

References _, CHECK_SYMMETRIC, cl, class_P, ddense, dup_mMatrix_as_geMatrix(), equal_string_vectors(), ldense, Matrix_DimNamesSym, Matrix_DimSym, Matrix_uploSym, Matrix_xSym, and ndense.

Here is the call graph for this function:

static SEXP getGivens ( double  x[],
int  ldx,
int  jmin,
int  rank 
)
static

Definition at line 63 of file dense.c.

References _, and left_cyclic().

Referenced by checkGivens(), and lapack_qr().

Here is the call graph for this function:

Here is the caller graph for this function:

SEXP lapack_qr ( SEXP  Xin,
SEXP  tl 
)

Definition at line 171 of file dense.c.

References _, getGivens(), and xpt().

Here is the call graph for this function:

static int left_cyclic ( double  x[],
int  ldx,
int  j,
int  k,
double  cosines[],
double  sines[] 
)
static

Perform a left cyclic shift of columns j to k in the upper triangular matrix x, then restore it to upper triangular form with Givens rotations.

The algorithm is based on the Fortran routine DCHEX from Linpack.

The lower triangle of x is not modified.

Parameters
xMatrix stored in column-major order
ldxleading dimension of x
jcolumn number (0-based) that will be shifted to position k
klast column number (0-based) to be shifted
cosinescosines of the Givens rotations
sinessines of the Givens rotations
Returns
0 for success

Definition at line 22 of file dense.c.

References _.

Referenced by getGivens().

Here is the caller graph for this function:

SEXP lsq_dense_Chol ( SEXP  X,
SEXP  y 
)

Definition at line 99 of file dense.c.

References _.

SEXP lsq_dense_QR ( SEXP  X,
SEXP  y 
)

Definition at line 132 of file dense.c.

References _.