The R Project SVN R-packages

Rev

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

Rev 4529 Rev 4530
Line 151... Line 151...
151
 
151
 
152
SEXP gCMatrix_colSums(SEXP x, SEXP NArm, SEXP spRes, SEXP trans, SEXP means)
152
SEXP gCMatrix_colSums(SEXP x, SEXP NArm, SEXP spRes, SEXP trans, SEXP means)
153
{
153
{
154
    int mn = asLogical(means), sp = asLogical(spRes), tr = asLogical(trans);
154
    int mn = asLogical(means), sp = asLogical(spRes), tr = asLogical(trans);
155
    /* cholmod_sparse: drawback of coercing lgC to double: */
155
    /* cholmod_sparse: drawback of coercing lgC to double: */
156
    cholmod_sparse *cx = as_cholmod_sparse(x);
156
    CHM_SP cx = AS_CHM_SP(x);
-
 
157
 
157
    if (tr) {
158
    if (tr) {
158
	cholmod_sparse *cxt = cholmod_transpose(cx, (int)cx->xtype, &c);
159
	cholmod_sparse *cxt = cholmod_transpose(cx, (int)cx->xtype, &c);
159
	Free(cx);
-
 
160
	cx = cxt;
160
	cx = cxt;
161
    }
161
    }
-
 
162
 
162
    /* everything else *after* the above potential transpose : */
163
    /* everything else *after* the above potential transpose : */
-
 
164
    /* Don't declarations here require the C99 standard?  Can we assume C99? */
-
 
165
 
163
    int j, nc = cx->ncol;
166
    int j, nc = cx->ncol;
164
    int *xp = (int *)(cx -> p);
167
    int *xp = (int *)(cx -> p);
165
#ifdef _has_x_slot_
168
#ifdef _has_x_slot_
166
    int na_rm = asLogical(NArm), i, dnm = 0/*Wall*/;
169
    int na_rm = asLogical(NArm), i, dnm = 0/*Wall*/;
167
    double *xx = (double *)(cx -> x);
170
    double *xx = (double *)(cx -> x);
Line 200... Line 203...
200
	for (j = 0; j < nc; j++) {
203
	for (j = 0; j < nc; j++) {
201
	    ColSUM_column(xp[j], xp[j + 1], a[j]);
204
	    ColSUM_column(xp[j], xp[j + 1], a[j]);
202
	}
205
	}
203
    }
206
    }
204
 
207
 
205
    if (tr) cholmod_free_sparse(&cx, &c); else Free(cx);
208
    if (tr) cholmod_free_sparse(&cx, &c); 
206
    UNPROTECT(1);
209
    UNPROTECT(1);
207
    return ans;
210
    return ans;
208
}
211
}
209
 
212
 
210
#undef ColSUM_column
213
#undef ColSUM_column