The R Project SVN R-packages

Rev

Rev 1463 | Rev 2095 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1463 Rev 1908
Line 76... Line 76...
76
  return ScalarReal(set_rcond(obj, CHAR(asChar(type))));
76
  return ScalarReal(set_rcond(obj, CHAR(asChar(type))));
77
}
77
}
78
 
78
 
79
SEXP dgeMatrix_crossprod(SEXP x, SEXP trans)
79
SEXP dgeMatrix_crossprod(SEXP x, SEXP trans)
80
{
80
{
81
    int tr = asLogical(trans);
81
    int tr = asLogical(trans);/* trans=TRUE: tcrossprod(x) */
82
    SEXP val = PROTECT(NEW_OBJECT(MAKE_CLASS("dpoMatrix")));
82
    SEXP val = PROTECT(NEW_OBJECT(MAKE_CLASS("dpoMatrix")));
83
    int *Dims = INTEGER(GET_SLOT(x, Matrix_DimSym)),
83
    int *Dims = INTEGER(GET_SLOT(x, Matrix_DimSym)),
84
	*vDims = INTEGER(ALLOC_SLOT(val, Matrix_DimSym, INTSXP, 2));
84
	*vDims = INTEGER(ALLOC_SLOT(val, Matrix_DimSym, INTSXP, 2));
85
    int k = tr ? Dims[1] : Dims[0], n = tr ? Dims[0] : Dims[1];
85
    int k = tr ? Dims[1] : Dims[0], n = tr ? Dims[0] : Dims[1];
86
    double one = 1.0, zero = 0.0;
86
    double one = 1.0, zero = 0.0;
Line 535... Line 535...
535
    int useCols = asLogical(cols);
535
    int useCols = asLogical(cols);
536
    int *dims = INTEGER(GET_SLOT(x, Matrix_DimSym));
536
    int *dims = INTEGER(GET_SLOT(x, Matrix_DimSym));
537
    int cnt = 0, i, j, n = dims[0], p = dims[1];
537
    int cnt = 0, i, j, n = dims[0], p = dims[1];
538
    SEXP ans = PROTECT(allocVector(REALSXP, (useCols) ? p : n));
538
    SEXP ans = PROTECT(allocVector(REALSXP, (useCols) ? p : n));
539
    double *xx = REAL(GET_SLOT(x, Matrix_xSym)), *rx, sum;
539
    double *xx = REAL(GET_SLOT(x, Matrix_xSym)), *rx, sum;
540
    
540
 
541
    if (useCols) {
541
    if (useCols) {
542
	cnt = n;
542
	cnt = n;
543
	for (j = 0; j < p; j++) {
543
	for (j = 0; j < p; j++) {
544
	    rx = xx + n*j;
544
	    rx = xx + n*j;
545
	    if (keepNA)
545
	    if (keepNA)