SCM

SCM Repository

[matrix] Diff of /pkg/src/dtCMatrix.c
ViewVC logotype

Diff of /pkg/src/dtCMatrix.c

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

revision 10, Mon Mar 22 20:20:05 2004 UTC revision 70, Mon Apr 12 12:10:01 2004 UTC
# Line 31  Line 31 
31      UNPROTECT(1);      UNPROTECT(1);
32      return ans;      return ans;
33  }  }
34    
35    SEXP tsc_to_triplet(SEXP x)
36    {
37        SEXP ans;
38        if (toupper(CHAR(STRING_ELT(GET_SLOT(x, Matrix_diagSym), 0))[0]) != 'U')
39            ans = csc_to_triplet(x);
40        else {                      /* unit triangular matrix */
41            SEXP islot = GET_SLOT(x, Matrix_iSym),
42                pslot = GET_SLOT(x, Matrix_pSym);
43            int *ai, *aj, j,
44                n = length(pslot) - 1,
45                nod = length(islot),
46                nout = n + nod,
47                *p = INTEGER(pslot);
48            double *ax;
49    
50            ans = PROTECT(NEW_OBJECT(MAKE_CLASS("tripletMatrix")));
51            SET_SLOT(ans, Matrix_DimSym, duplicate(GET_SLOT(x, Matrix_DimSym)));
52            SET_SLOT(ans, Matrix_iSym, allocVector(INTSXP, nout));
53            ai = INTEGER(GET_SLOT(ans, Matrix_iSym));
54            Memcpy(ai, INTEGER(islot), nod);
55            SET_SLOT(ans, Matrix_jSym, allocVector(INTSXP, nout));
56            aj = INTEGER(GET_SLOT(ans, Matrix_jSym));
57            SET_SLOT(ans, Matrix_xSym, allocVector(REALSXP, nout));
58            ax = REAL(GET_SLOT(ans, Matrix_xSym));
59            Memcpy(ax, REAL(GET_SLOT(x, Matrix_xSym)), nod);
60            for (j = 0; j < n; j++) {
61                int jj, npj = nod + j,  p2 = p[j+1];
62                aj[npj] = ai[npj] = j;
63                ax[npj] = 1.;
64                for (jj = p[j]; jj < p2; jj++) aj[jj] = j;
65            }
66            UNPROTECT(1);
67        }
68        return ans;
69    }

Legend:
Removed from v.10  
changed lines
  Added in v.70

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