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 2298, Fri Oct 17 13:45:12 2008 UTC revision 2299, Fri Oct 17 16:07:38 2008 UTC
# Line 45  Line 45 
45              if (chk_nm(CHAR(STRING_ELT(nms, i)), perm, LDL, super)) {              if (chk_nm(CHAR(STRING_ELT(nms, i)), perm, LDL, super)) {
46                  L = AS_CHM_FR(VECTOR_ELT(facs, i));                  L = AS_CHM_FR(VECTOR_ELT(facs, i));
47                  R_CheckStack();                  R_CheckStack();
48                  /* copy the factor so later it can safely be cholmod_free'd */                  /* copy the factor so later it can safely be cholmod_l_free'd */
49                  L = cholmod_copy_factor(L, &c);                  L = cholmod_l_copy_factor(L, &c);
50                  if (Imult) cholmod_factorize_p(A, &Imult, (int*)NULL, 0, L, &c);                  if (Imult) cholmod_l_factorize_p(A, &Imult, (int*)NULL, 0, L, &c);
51                  return L;                  return L;
52              }              }
53          }          }
# Line 60  Line 60 
60      c.supernodal = (super > 0) ? CHOLMOD_SUPERNODAL : CHOLMOD_SIMPLICIAL;      c.supernodal = (super > 0) ? CHOLMOD_SUPERNODAL : CHOLMOD_SIMPLICIAL;
61    
62      if (perm) {                 /* obtain fill-reducing permutation */      if (perm) {                 /* obtain fill-reducing permutation */
63          L = cholmod_analyze(A, &c);          L = cholmod_l_analyze(A, &c);
64      } else {                    /* require identity permutation */      } else {                    /* require identity permutation */
65          /* save current settings */          /* save current settings */
66          int nmethods = c.nmethods, ord0 = c.method[0].ordering,          int nmethods = c.nmethods, ord0 = c.method[0].ordering,
67              postorder = c.postorder;              postorder = c.postorder;
68          c.nmethods = 1; c.method[0].ordering = CHOLMOD_NATURAL; c.postorder = FALSE;          c.nmethods = 1; c.method[0].ordering = CHOLMOD_NATURAL; c.postorder = FALSE;
69          L = cholmod_analyze(A, &c);          L = cholmod_l_analyze(A, &c);
70          /* and now restore */          /* and now restore */
71          c.nmethods = nmethods; c.method[0].ordering = ord0; c.postorder = postorder;          c.nmethods = nmethods; c.method[0].ordering = ord0; c.postorder = postorder;
72      }      }
73      if (!cholmod_factorize_p(A, &Imult, (int*)NULL, 0 /*fsize*/, L, &c))      if (!cholmod_l_factorize_p(A, &Imult, (int*)NULL, 0 /*fsize*/, L, &c))
74          error(_("Cholesky factorization failed"));          error(_("Cholesky factorization failed"));
75      c.supernodal = sup;         /* restore previous settings */      c.supernodal = sup;         /* restore previous settings */
76      c.final_ll = ll;      c.final_ll = ll;
# Line 92  Line 92 
92      CHM_SP R, Rt;      CHM_SP R, Rt;
93      SEXP ans;      SEXP ans;
94    
95      Rt = cholmod_factor_to_sparse(L, &c);      Rt = cholmod_l_factor_to_sparse(L, &c);
96      R = cholmod_transpose(Rt, /*values*/ 1, &c);      R = cholmod_l_transpose(Rt, /*values*/ 1, &c);
97      cholmod_free_sparse(&Rt, &c);      cholmod_l_free_sparse(&Rt, &c);
98      ans = PROTECT(chm_sparse_to_SEXP(R, 1/*do_free*/, 1/*uploT*/, 0/*Rkind*/,      ans = PROTECT(chm_sparse_to_SEXP(R, 1/*do_free*/, 1/*uploT*/, 0/*Rkind*/,
99                                       "N"/*diag*/, GET_SLOT(x, Matrix_DimNamesSym)));                                       "N"/*diag*/, GET_SLOT(x, Matrix_DimNamesSym)));
100    
# Line 107  Line 107 
107          setAttrib(ans, install("rank"), ScalarInteger((size_t) L->minor));          setAttrib(ans, install("rank"), ScalarInteger((size_t) L->minor));
108          UNPROTECT(1);          UNPROTECT(1);
109      }      }
110      cholmod_free_factor(&L, &c);      cholmod_l_free_factor(&L, &c);
111      UNPROTECT(1);      UNPROTECT(1);
112      return ans;      return ans;
113  }  }
# Line 154  Line 154 
154                                L->x,                                L->x,
155                                L->Perm,                                L->Perm,
156                                resultKind));                                resultKind));
157      cholmod_free_factor(&L, &c);      cholmod_l_free_factor(&L, &c);
158      UNPROTECT(1);      UNPROTECT(1);
159      return(ans);      return(ans);
160  }  }
# Line 165  Line 165 
165      CHM_SP cx, cb = AS_CHM_SP(b);      CHM_SP cx, cb = AS_CHM_SP(b);
166      R_CheckStack();      R_CheckStack();
167    
168      cx = cholmod_spsolve(CHOLMOD_A, L, cb, &c);      cx = cholmod_l_spsolve(CHOLMOD_A, L, cb, &c);
169      cholmod_free_factor(&L, &c);      cholmod_l_free_factor(&L, &c);
170      return chm_sparse_to_SEXP(cx, /*do_free*/ 1, /*uploT*/ 0,      return chm_sparse_to_SEXP(cx, /*do_free*/ 1, /*uploT*/ 0,
171                                /*Rkind*/ 0, /*diag*/ "N",                                /*Rkind*/ 0, /*diag*/ "N",
172                                /*dimnames = */ R_NilValue);                                /*dimnames = */ R_NilValue);
# Line 178  Line 178 
178      CHM_DN cx, cb = AS_CHM_DN(PROTECT(mMatrix_as_dgeMatrix(b)));      CHM_DN cx, cb = AS_CHM_DN(PROTECT(mMatrix_as_dgeMatrix(b)));
179      R_CheckStack();      R_CheckStack();
180    
181      cx = cholmod_solve(CHOLMOD_A, L, cb, &c);      cx = cholmod_l_solve(CHOLMOD_A, L, cb, &c);
182      cholmod_free_factor(&L, &c);      cholmod_l_free_factor(&L, &c);
183      UNPROTECT(1);      UNPROTECT(1);
184      return chm_dense_to_SEXP(cx, 1, 0, /*dimnames = */ R_NilValue);      return chm_dense_to_SEXP(cx, 1, 0, /*dimnames = */ R_NilValue);
185  }  }
# Line 190  Line 190 
190  SEXP dsCMatrix_to_dgTMatrix(SEXP x)  SEXP dsCMatrix_to_dgTMatrix(SEXP x)
191  {  {
192      CHM_SP A = AS_CHM_SP__(x);      CHM_SP A = AS_CHM_SP__(x);
193      CHM_SP Afull = cholmod_copy(A, /*stype*/ 0, /*mode*/ 1, &c);      CHM_SP Afull = cholmod_l_copy(A, /*stype*/ 0, /*mode*/ 1, &c);
194      CHM_TR At = cholmod_sparse_to_triplet(Afull, &c);      CHM_TR At = cholmod_l_sparse_to_triplet(Afull, &c);
195      R_CheckStack();      R_CheckStack();
196    
197      if (!A->stype)      if (!A->stype)
198          error("Non-symmetric matrix passed to dsCMatrix_to_dgTMatrix");          error("Non-symmetric matrix passed to dsCMatrix_to_dgTMatrix");
199      cholmod_free_sparse(&Afull, &c);      cholmod_l_free_sparse(&Afull, &c);
200      return chm_triplet_to_SEXP(At, 1, /*uploT*/ 0, /*Rkind*/ 0, "",      return chm_triplet_to_SEXP(At, 1, /*uploT*/ 0, /*Rkind*/ 0, "",
201                                 GET_SLOT(x, Matrix_DimNamesSym));                                 GET_SLOT(x, Matrix_DimNamesSym));
202  }  }

Legend:
Removed from v.2298  
changed lines
  Added in v.2299

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