The R Project SVN R-packages

Rev

Rev 3404 | Rev 3410 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3404 Rev 3406
Line 36... Line 36...
36
 
36
 
37
    Free(chxs);
37
    Free(chxs);
38
    return chm_dense_to_SEXP(chxd, 1);
38
    return chm_dense_to_SEXP(chxd, 1);
39
}
39
}
40
 
40
 
-
 
41
SEXP Csparse_to_logical(SEXP x, SEXP tri)
-
 
42
{
-
 
43
    cholmod_sparse *chxs = as_cholmod_sparse(x);
-
 
44
    cholmod_sparse
-
 
45
	*chxcp = cholmod_copy(chxs, chxs->stype, CHOLMOD_PATTERN, &c);
-
 
46
    int uploT = 0; char *diag = "";
-
 
47
 
-
 
48
    Free(chxs);
-
 
49
    if (asLogical(tri)) {	/* triangular sparse matrices */
-
 
50
	uploT = (strcmp(CHAR(asChar(GET_SLOT(x, Matrix_uploSym))), "U")) ?
-
 
51
	    -1 : 1;
-
 
52
	diag = CHAR(asChar(GET_SLOT(x, Matrix_diagSym)));
-
 
53
    }
-
 
54
    return chm_sparse_to_SEXP(chxcp, 1, uploT, diag,
-
 
55
				GET_SLOT(x, Matrix_DimNamesSym));
-
 
56
}
-
 
57
 
41
SEXP Csparse_to_matrix(SEXP x)
58
SEXP Csparse_to_matrix(SEXP x)
42
{
59
{
43
    cholmod_sparse *chxs = as_cholmod_sparse(x);
60
    cholmod_sparse *chxs = as_cholmod_sparse(x);
44
    cholmod_dense *chxd = cholmod_sparse_to_dense(chxs, &c);
61
    cholmod_dense *chxd = cholmod_sparse_to_dense(chxs, &c);
45
 
62
 
Line 59... Line 76...
59
	uploT = (strcmp(CHAR(asChar(GET_SLOT(x, Matrix_uploSym))), "U")) ?
76
	uploT = (strcmp(CHAR(asChar(GET_SLOT(x, Matrix_uploSym))), "U")) ?
60
	    -1 : 1;
77
	    -1 : 1;
61
	diag = CHAR(asChar(GET_SLOT(x, Matrix_diagSym)));
78
	diag = CHAR(asChar(GET_SLOT(x, Matrix_diagSym)));
62
    }
79
    }
63
    return chm_triplet_to_SEXP(chxt, 1, uploT, diag,
80
    return chm_triplet_to_SEXP(chxt, 1, uploT, diag,
64
			       duplicate(GET_SLOT(x, Matrix_DimNamesSym)));
81
			       GET_SLOT(x, Matrix_DimNamesSym));
-
 
82
}
-
 
83
 
-
 
84
SEXP Csparse_symmetric_to_general(SEXP x)
-
 
85
{
-
 
86
    cholmod_sparse *chx = as_cholmod_sparse(x), *chgx;
-
 
87
 
-
 
88
    if (!(chx->stype))
-
 
89
	error(_("Nonsymmetric matrix in Csparse_symmeteric_to_general"));
-
 
90
    chgx = cholmod_copy(chx, 0, chx->xtype, &c);
-
 
91
    Free(chx);
-
 
92
    return chm_sparse_to_SEXP(chgx, 1, 0, "",
-
 
93
			      GET_SLOT(x, Matrix_DimNamesSym));
65
}
94
}
66
 
95
 
67
SEXP Csparse_transpose(SEXP x, SEXP tri)
96
SEXP Csparse_transpose(SEXP x, SEXP tri)
68
{
97
{
69
    cholmod_sparse *chx = as_cholmod_sparse(x);
98
    cholmod_sparse *chx = as_cholmod_sparse(x);