SCM

SCM Repository

[matrix] Diff of /branches/Matrix-mer2/src/dgCMatrix.c
ViewVC logotype

Diff of /branches/Matrix-mer2/src/dgCMatrix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 309, Wed Oct 27 21:40:02 2004 UTC revision 310, Wed Oct 27 21:40:08 2004 UTC
# Line 200  Line 200 
200      return ans;      return ans;
201  }  }
202    
203    /* FIXME: This function does not appear to be used. */
204    static                          /* added to check if it was used */
205  SEXP csc_to_imagemat(SEXP x)  SEXP csc_to_imagemat(SEXP x)
206  {  {
207      SEXP ans, pslot = GET_SLOT(x, Matrix_pSym);      SEXP ans, pslot = GET_SLOT(x, Matrix_pSym);
# Line 329  Line 331 
331      UNPROTECT(1);      UNPROTECT(1);
332      return ans;      return ans;
333  }  }
334    
335    SEXP csc_matrix_mm(SEXP a, SEXP b)
336    {
337        int *adim = INTEGER(GET_SLOT(a, Matrix_DimSym)),
338            *ai = INTEGER(GET_SLOT(a, Matrix_iSym)),
339            *ap = INTEGER(GET_SLOT(a, Matrix_pSym)),
340            *bdim = INTEGER(getAttrib(b, R_DimSymbol));
341        int j, k, m = adim[0], n = bdim[1], r = adim[1];
342        double *ax = REAL(GET_SLOT(a, Matrix_xSym));
343        SEXP val;
344    
345        if (bdim[0] != r)
346            error("Matrices of sizes (%d,%d) and (%d,%d) cannot be multiplied",
347                  m, r, bdim[0], n);
348        val = PROTECT(allocMatrix(REALSXP, m, n));
349        for (j = 0; j < n; j++) {   /* across columns of b */
350            double *ccol = REAL(val) + j * m,
351                *bcol = REAL(b) + j * r;
352    
353            for (k = 0; k < m; k++) ccol[k] = 0.; /* zero the accumulators */
354            for (k = 0; k < r; k++) { /* across columns of a */
355                int kk, k2 = ap[k + 1];
356                for (kk = ap[k]; kk < k2; kk++) {
357                    ccol[ai[kk]] += ax[kk] * bcol[k];
358                }
359            }
360        }
361        UNPROTECT(1);
362        return val;
363    }
364    
365    
366    

Legend:
Removed from v.309  
changed lines
  Added in v.310

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge