SCM

SCM Repository

[matrix] Annotation of /pkg/src/lsCMatrix.c
ViewVC logotype

Annotation of /pkg/src/lsCMatrix.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1448 - (view) (download) (as text)

1 : bates 737 #include "lsCMatrix.h"
2 :    
3 : maechler 896 /**
4 : bates 737 * Check the validity of the slots of an lsCMatrix object
5 : maechler 896 *
6 : bates 737 * @param x Pointer to an lsCMatrix object
7 : maechler 896 *
8 : bates 737 * @return an SEXP that is either TRUE or a character string
9 :     * describing the way in which the object failed the validity check
10 :     */
11 :     SEXP lsCMatrix_validate(SEXP x)
12 :     {
13 : maechler 896 SEXP val = symmetricMatrix_validate(x);
14 :     if(isString(val))
15 :     return(val);
16 :     else {
17 :     /* FIXME needed? ltC* inherits from lgC* which does this in validate*/
18 :     SEXP pslot = GET_SLOT(x, Matrix_pSym),
19 :     islot = GET_SLOT(x, Matrix_iSym);
20 :     int
21 :     ncol = length(pslot) - 1,
22 :     *xp = INTEGER(pslot),
23 :     *xi = INTEGER(islot);
24 : bates 737
25 : maechler 896 if (csc_unsorted_columns(ncol, xp, xi))
26 :     csc_sort_columns(ncol, xp, xi, (double *) NULL);
27 :    
28 :     return ScalarLogical(1);
29 :     }
30 : bates 737 }
31 :    
32 : bates 1448 #if 0 /* no longer used */
33 : maechler 896 /**
34 : bates 737 * Transpose an lsCMatrix
35 : maechler 896 *
36 : bates 737 * @param x Pointer to an lsCMatrix object
37 : maechler 896 *
38 : bates 737 * @return the transpose of x. It represents the same matrix but is
39 :     * stored in the opposite triangle.
40 :     */
41 :     SEXP lsCMatrix_trans(SEXP x)
42 :     {
43 :     SEXP Xi = GET_SLOT(x, Matrix_iSym),
44 :     xDim = GET_SLOT(x, Matrix_DimSym),
45 :     ans = PROTECT(NEW_OBJECT(MAKE_CLASS("lsCMatrix")));
46 :     int n = INTEGER(xDim)[0], nz = length(Xi);
47 :     int *xj = expand_cmprPt(n, INTEGER(GET_SLOT(x, Matrix_pSym)),
48 :     Calloc(nz, int)),
49 :     *xi = Memcpy(Calloc(nz, int), Xi, nz);
50 : maechler 951 int up = uplo_P(x)[0] == 'U';
51 : bates 737
52 :     SET_SLOT(ans, Matrix_DimSym, duplicate(xDim));
53 :     SET_SLOT(ans, Matrix_DimNamesSym,
54 :     duplicate(GET_SLOT(x, Matrix_DimNamesSym)));
55 :     SET_SLOT(ans, Matrix_uploSym, mkString(up ? "L" : "U"));
56 :     make_upper_triangular(up ? xj : xi, up ? xi : xj, nz);
57 :     triplet_to_col(n, n, nz, xi, xj, (double *) NULL,
58 :     INTEGER(ALLOC_SLOT(ans, Matrix_pSym, INTSXP, n + 1)),
59 :     INTEGER(ALLOC_SLOT(ans, Matrix_iSym, INTSXP, nz)),
60 :     (double *) NULL);
61 :     Free(xj); Free(xi);
62 :     UNPROTECT(1);
63 :     return ans;
64 :     }
65 : bates 1448 #endif

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