SCM

SCM Repository

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

Diff of /pkg/src/cs_utils.c

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

revision 2386, Wed May 27 20:54:45 2009 UTC revision 2387, Fri May 29 12:50:34 2009 UTC
# Line 34  Line 34 
34      int *ep = eye->p, *ei = eye->i;      int *ep = eye->p, *ei = eye->i;
35      double *ex = eye->x;      double *ex = eye->x;
36    
37      if (n <= 0) error("csp_eye argument n must be positive");      if (n <= 0) error(_("csp_eye argument n must be positive"));
38      eye->nz = -1;               /* compressed column storage */      eye->nz = -1;               /* compressed column storage */
39      for (int j = 0; j < n; j++) {      for (int j = 0; j < n; j++) {
40          ep[j] = ei[j] = j;          ep[j] = ei[j] = j;
# Line 65  Line 65 
65      int *dims, ctype = Matrix_check_class_etc(x, valid);      int *dims, ctype = Matrix_check_class_etc(x, valid);
66      SEXP islot;      SEXP islot;
67    
68      if (ctype < 0) error("invalid class of 'x' in Matrix_as_cs(a, x)");      if (ctype < 0) error(_("invalid class of 'x' in Matrix_as_cs(a, x)"));
69                                  /* dimensions and nzmax */                                  /* dimensions and nzmax */
70      dims = INTEGER(GET_SLOT(x, Matrix_DimSym));      dims = INTEGER(GET_SLOT(x, Matrix_DimSym));
71      ans->m = dims[0]; ans->n = dims[1];      ans->m = dims[0]; ans->n = dims[1];
# Line 124  Line 124 
124      int *dims, ctype = Matrix_check_class(cl, valid), nz;      int *dims, ctype = Matrix_check_class(cl, valid), nz;
125    
126      if (ctype < 0)      if (ctype < 0)
127          error(_("invalid class of object to Matrix_cs_to_SEXP"));          error(_("invalid class of object to %s"), "Matrix_cs_to_SEXP");
128      ans = PROTECT(NEW_OBJECT(MAKE_CLASS(cl)));      ans = PROTECT(NEW_OBJECT(MAKE_CLASS(cl)));
129                                  /* allocate and copy common slots */                                  /* allocate and copy common slots */
130      dims = INTEGER(ALLOC_SLOT(ans, Matrix_DimSym, INTSXP, 2));      dims = INTEGER(ALLOC_SLOT(ans, Matrix_DimSym, INTSXP, 2));
# Line 167  Line 167 
167      int *nz = INTEGER(GET_SLOT(x, install("nz"))),      int *nz = INTEGER(GET_SLOT(x, install("nz"))),
168          ctype = Matrix_check_class(cl, valid);          ctype = Matrix_check_class(cl, valid);
169    
170      if (ctype < 0) error("invalid class of object to Matrix_as_css");      if (ctype < 0)
171            error(_("invalid class of object to %s"), "Matrix_as_css");
172      ans->q = INTEGER(GET_SLOT(x, install("Q")));      ans->q = INTEGER(GET_SLOT(x, install("Q")));
173      ans->m2 = nz[0]; ans->lnz = nz[1]; ans->unz = nz[2];      ans->m2 = nz[0]; ans->lnz = nz[1]; ans->unz = nz[2];
174      switch(ctype) {      switch(ctype) {
# Line 182  Line 183 
183          ans->cp = INTEGER(GET_SLOT(x, install("cp")));          ans->cp = INTEGER(GET_SLOT(x, install("cp")));
184          break;          break;
185      default:      default:
186          error("invalid class of object to Matrix_as_css");          error(_("invalid class of object to %s"), "Matrix_as_css");
187      }      }
188      return ans;      return ans;
189  }  }
# Line 201  Line 202 
202      char *valid[] = {"csn_LU", "csn_QR", ""};      char *valid[] = {"csn_LU", "csn_QR", ""};
203      int ctype = Matrix_check_class(class_P(x), valid);      int ctype = Matrix_check_class(class_P(x), valid);
204    
205      if (ctype < 0) error("invalid class of object to Matrix_as_csn");      if (ctype < 0)
206            error(_("invalid class of object to %s"), "Matrix_as_csn");
207      ans->U = Matrix_as_cs(GET_SLOT(x, install("U")));      ans->U = Matrix_as_cs(GET_SLOT(x, install("U")));
208      ans->L = Matrix_as_cs(GET_SLOT(x, install("L")));      ans->L = Matrix_as_cs(GET_SLOT(x, install("L")));
209      switch(ctype) {      switch(ctype) {
# Line 214  Line 216 
216          ans->pinv = (int*) NULL;          ans->pinv = (int*) NULL;
217          break;          break;
218      default:      default:
219          error("invalid class of object to Matrix_as_csn");          error(_("invalid class of object to %s"), "Matrix_as_csn");
220      }      }
221      return ans;      return ans;
222  }  }
# Line 238  Line 240 
240      int *nz, ctype = Matrix_check_class(cl, valid);      int *nz, ctype = Matrix_check_class(cl, valid);
241    
242      if (ctype < 0)      if (ctype < 0)
243          error("Inappropriate class '%s' for Matrix_css_to_SEXP", cl);          error(_("Inappropriate class cl='%s' in Matrix_css_to_SEXP(S, cl, ..)"),
244                  cl);
245      ans = PROTECT(NEW_OBJECT(MAKE_CLASS(cl)));      ans = PROTECT(NEW_OBJECT(MAKE_CLASS(cl)));
246                                  /* allocate and copy common slots */                                  /* allocate and copy common slots */
247      Memcpy(INTEGER(ALLOC_SLOT(ans, install("Q"), INTSXP, n)), S->q, n);      Memcpy(INTEGER(ALLOC_SLOT(ans, install("Q"), INTSXP, n)), S->q, n);
# Line 256  Line 259 
259                 S->cp, n);                 S->cp, n);
260          break;          break;
261      default:      default:
262          error("Inappropriate class '%s' for Matrix_css_to_SEXP", cl);          error(_("Inappropriate class cl='%s' in Matrix_css_to_SEXP(S, cl, ..)"),
263                  cl);
264      }      }
265      if (dofree > 0) cs_sfree(S);      if (dofree > 0) cs_sfree(S);
266      if (dofree < 0) Free(S);      if (dofree < 0) Free(S);
# Line 281  Line 285 
285      int ctype = Matrix_check_class(cl, valid), n = (N->U)->n;      int ctype = Matrix_check_class(cl, valid), n = (N->U)->n;
286    
287      if (ctype < 0)      if (ctype < 0)
288          error("Inappropriate class '%s' for Matrix_csn_to_SEXP", cl);          error(_("Inappropriate class cl='%s' in Matrix_csn_to_SEXP(S, cl, ..)"),
289                  cl);
290      ans = PROTECT(NEW_OBJECT(MAKE_CLASS(cl)));      ans = PROTECT(NEW_OBJECT(MAKE_CLASS(cl)));
291                                  /* allocate and copy common slots */                                  /* allocate and copy common slots */
292      /* FIXME: Use the triangular matrix classes for csn_LU */      /* FIXME: Use the triangular matrix classes for csn_LU */
# Line 299  Line 304 
304                 N->B, n);                 N->B, n);
305          break;          break;
306      default:      default:
307          error("Inappropriate class '%s' for Matrix_csn_to_SEXP", cl);          error(_("Inappropriate class cl='%s' in Matrix_csn_to_SEXP(S, cl, ..)"),
308                  cl);
309      }      }
310      if (dofree > 0) cs_nfree(N);      if (dofree > 0) cs_nfree(N);
311      if (dofree < 0) {      if (dofree < 0) {

Legend:
Removed from v.2386  
changed lines
  Added in v.2387

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