SCM

SCM Repository

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

Diff of /pkg/src/dsCMatrix.c

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

revision 69, Sun Apr 11 23:20:25 2004 UTC revision 70, Mon Apr 12 12:10:01 2004 UTC
# Line 35  Line 35 
35          SET_SLOT(val, Matrix_ipermSym, allocVector(INTSXP, tm->n));          SET_SLOT(val, Matrix_ipermSym, allocVector(INTSXP, tm->n));
36          perm = INTEGER(GET_SLOT(val, Matrix_permSym));          perm = INTEGER(GET_SLOT(val, Matrix_permSym));
37          iperm = INTEGER(GET_SLOT(val, Matrix_ipermSym));          iperm = INTEGER(GET_SLOT(val, Matrix_ipermSym));
38          ssc_metis_order(tm->n, (tm->colptr)[tm->n], tm->colptr,          ssc_metis_order(tm->n, tm->colptr, tm->rowind, perm, iperm);
                         tm->rowind, perm, iperm);  
39          tm = taucs_dccs_permute_symmetrically(tm, perm, iperm);          tm = taucs_dccs_permute_symmetrically(tm, perm, iperm);
40      }      }
41      if (!(L = taucs_ccs_factor_llt_mf(tm)))      if (!(L = taucs_ccs_factor_llt_mf(tm)))
# Line 134  Line 133 
133      UNPROTECT(1);      UNPROTECT(1);
134      return ans;      return ans;
135  }  }
136    
137    SEXP sscMatrix_to_triplet(SEXP x)
138    {
139        SEXP
140            ans = PROTECT(NEW_OBJECT(MAKE_CLASS("tripletMatrix"))),
141            islot = GET_SLOT(x, Matrix_iSym),
142            pslot = GET_SLOT(x, Matrix_pSym);
143        int *ai, *aj, *iv = INTEGER(islot),
144            j, jj, nnz = length(islot), nout,
145            n = length(pslot) - 1,
146            *p = INTEGER(pslot), pos;
147        double *ax, *xv = REAL(GET_SLOT(x, Matrix_xSym));
148    
149        /* increment output count by number of off-diagonals */
150        nout = nnz;
151        for (j = 0; j < n; j++) {
152            int p2 = p[j+1];
153            for (jj = p[j]; jj < p2; jj++) {
154                if (iv[jj] != j) nout++;
155            }
156        }
157        SET_SLOT(ans, Matrix_DimSym, duplicate(GET_SLOT(x, Matrix_DimSym)));
158        SET_SLOT(ans, Matrix_iSym, allocVector(INTSXP, nout));
159        ai = INTEGER(GET_SLOT(ans, Matrix_iSym));
160        SET_SLOT(ans, Matrix_jSym, allocVector(INTSXP, nout));
161        aj = INTEGER(GET_SLOT(ans, Matrix_jSym));
162        SET_SLOT(ans, Matrix_xSym, allocVector(REALSXP, nout));
163        ax = REAL(GET_SLOT(ans, Matrix_xSym));
164        pos = 0;
165        for (j = 0; j < n; j++) {
166            int p2 = p[j+1];
167            for (jj = p[j]; jj < p2; jj++) {
168                int ii = iv[jj];
169                double xx = xv[jj];
170    
171                ai[pos] = ii; aj[pos] = j; ax[pos] = xx; pos++;
172                if (ii != j) {
173                    aj[pos] = ii; ai[pos] = j; ax[pos] = xx; pos++;
174                }
175            }
176        }
177        UNPROTECT(1);
178        return ans;
179    }

Legend:
Removed from v.69  
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