本文整理汇总了C++中RETURN_IF_XTYPE_INVALID函数的典型用法代码示例。如果您正苦于以下问题:C++ RETURN_IF_XTYPE_INVALID函数的具体用法?C++ RETURN_IF_XTYPE_INVALID怎么用?C++ RETURN_IF_XTYPE_INVALID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RETURN_IF_XTYPE_INVALID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CHOLMOD
int CHOLMOD(copy_dense2)
(
/* ---- input ---- */
cholmod_dense *X, /* matrix to copy */
/* ---- output --- */
cholmod_dense *Y, /* copy of matrix X */
/* --------------- */
cholmod_common *Common
)
{
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (X, FALSE) ;
RETURN_IF_NULL (Y, FALSE) ;
RETURN_IF_XTYPE_INVALID (X, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, FALSE) ;
RETURN_IF_XTYPE_INVALID (Y, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, FALSE) ;
if (X->nrow != Y->nrow || X->ncol != Y->ncol || X->xtype != Y->xtype)
{
ERROR (CHOLMOD_INVALID, "X and Y must have same dimensions and xtype") ;
return (FALSE) ;
}
if (X->d < X->nrow || Y->d < Y->nrow
|| (X->d * X->ncol) > X->nzmax || (Y->d * Y->ncol) > Y->nzmax)
{
ERROR (CHOLMOD_INVALID, "X and/or Y invalid") ;
return (FALSE) ;
}
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* copy the matrix, using template routine */
/* ---------------------------------------------------------------------- */
switch (X->xtype)
{
case CHOLMOD_REAL:
r_cholmod_copy_dense2 (X, Y) ;
break ;
case CHOLMOD_COMPLEX:
c_cholmod_copy_dense2 (X, Y) ;
break ;
case CHOLMOD_ZOMPLEX:
z_cholmod_copy_dense2 (X, Y) ;
break ;
}
return (TRUE) ;
}
开发者ID:GHilmarG,项目名称:Ua,代码行数:52,代码来源:cholmod_dense.c
示例2: CHOLMOD
int CHOLMOD(reallocate_sparse)
(
/* ---- input ---- */
size_t nznew, /* new # of entries in A */
/* ---- in/out --- */
cholmod_sparse *A, /* matrix to reallocate */
/* --------------- */
cholmod_common *Common
)
{
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (A, FALSE) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
Common->status = CHOLMOD_OK ;
PRINT1 (("realloc matrix %d to %d, xtype: %d\n",
A->nzmax, nznew, A->xtype)) ;
/* ---------------------------------------------------------------------- */
/* resize the matrix */
/* ---------------------------------------------------------------------- */
CHOLMOD(realloc_multiple) (MAX (1,nznew), 1, A->xtype, &(A->i), NULL,
&(A->x), &(A->z), &(A->nzmax), Common) ;
return (Common->status == CHOLMOD_OK) ;
}
开发者ID:Ascronia,项目名称:fieldtrip,代码行数:31,代码来源:cholmod_sparse.c
示例3: CHOLMOD
int CHOLMOD(reallocate_triplet)
(
/* ---- input ---- */
size_t nznew, /* new # of entries in T */
/* ---- in/out --- */
cholmod_triplet *T, /* triplet matrix to modify */
/* --------------- */
cholmod_common *Common
)
{
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (T, FALSE) ;
RETURN_IF_XTYPE_INVALID (T, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
Common->status = CHOLMOD_OK ;
PRINT1 (("realloc triplet %d to %d, xtype: %d\n",
T->nzmax, nznew, T->xtype)) ;
/* ---------------------------------------------------------------------- */
/* resize the matrix */
/* ---------------------------------------------------------------------- */
CHOLMOD(realloc_multiple) (MAX (1,nznew), 2, T->xtype, &(T->i), &(T->j),
&(T->x), &(T->z), &(T->nzmax), Common) ;
return (Common->status == CHOLMOD_OK) ;
}
开发者ID:Ascronia,项目名称:fieldtrip,代码行数:31,代码来源:cholmod_triplet.c
示例4: CHOLMOD
int CHOLMOD(reallocate_factor)
(
/* ---- input ---- */
size_t nznew, /* new # of entries in L */
/* ---- in/out --- */
cholmod_factor *L, /* factor to modify */
/* --------------- */
cholmod_common *Common
)
{
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (L, FALSE) ;
RETURN_IF_XTYPE_INVALID (L, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, FALSE) ;
PRINT1 (("realloc factor: xtype %d\n", L->xtype)) ;
if (L->is_super)
{
/* L must be simplicial, and not symbolic */
ERROR (CHOLMOD_INVALID, "L invalid") ;
return (FALSE) ;
}
Common->status = CHOLMOD_OK ;
PRINT1 (("realloc factor %g to %g\n", (double) L->nzmax, (double) nznew)) ;
/* ---------------------------------------------------------------------- */
/* resize (or allocate) the L->i and L->x components of the factor */
/* ---------------------------------------------------------------------- */
CHOLMOD(realloc_multiple) (nznew, 1, L->xtype, &(L->i), NULL,
&(L->x), &(L->z), &(L->nzmax), Common) ;
return (Common->status == CHOLMOD_OK) ;
}
开发者ID:Al-th,项目名称:matlab,代码行数:35,代码来源:cholmod_factor.c
示例5: RETURN_IF_NULL_COMMON
cholmod_dense *CHOLMOD(sparse_to_dense)
(
/* ---- input ---- */
cholmod_sparse *A, /* matrix to copy */
/* --------------- */
cholmod_common *Common
)
{
cholmod_dense *X = NULL ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (NULL) ;
RETURN_IF_NULL (A, NULL) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, NULL) ;
if (A->stype && A->nrow != A->ncol)
{
ERROR (CHOLMOD_INVALID, "matrix invalid") ;
return (NULL) ;
}
Common->status = CHOLMOD_OK ;
ASSERT (CHOLMOD(dump_sparse) (A, "A", Common) >= 0) ;
/* ---------------------------------------------------------------------- */
/* convert the matrix, using template routine */
/* ---------------------------------------------------------------------- */
switch (A->xtype)
{
case CHOLMOD_PATTERN:
X = p_cholmod_sparse_to_dense (A, Common) ;
break ;
case CHOLMOD_REAL:
X = r_cholmod_sparse_to_dense (A, Common) ;
break ;
case CHOLMOD_COMPLEX:
X = c_cholmod_sparse_to_dense (A, Common) ;
break ;
case CHOLMOD_ZOMPLEX:
X = z_cholmod_sparse_to_dense (A, Common) ;
break ;
}
return (X) ;
}
开发者ID:GHilmarG,项目名称:Ua,代码行数:49,代码来源:cholmod_dense.c
示例6: DEBUG
cholmod_sparse *CHOLMOD(dense_to_sparse)
(
/* ---- input ---- */
cholmod_dense *X, /* matrix to copy */
int values, /* TRUE if values to be copied, FALSE otherwise */
/* --------------- */
cholmod_common *Common
)
{
cholmod_sparse *C = NULL ;
DEBUG (CHOLMOD(dump_dense) (X, "X", Common)) ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (NULL) ;
RETURN_IF_NULL (X, NULL) ;
RETURN_IF_XTYPE_INVALID (X, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, NULL) ;
if (X->d < X->nrow)
{
ERROR (CHOLMOD_INVALID, "matrix invalid") ;
return (NULL) ;
}
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* convert the matrix, using template routine */
/* ---------------------------------------------------------------------- */
switch (X->xtype)
{
case CHOLMOD_REAL:
C = r_cholmod_dense_to_sparse (X, values, Common) ;
break ;
case CHOLMOD_COMPLEX:
C = c_cholmod_dense_to_sparse (X, values, Common) ;
break ;
case CHOLMOD_ZOMPLEX:
C = z_cholmod_dense_to_sparse (X, values, Common) ;
break ;
}
return (C) ;
}
开发者ID:GHilmarG,项目名称:Ua,代码行数:47,代码来源:cholmod_dense.c
示例7: pattern
cholmod_sparse *CHOLMOD(copy)
(
/* ---- input ---- */
cholmod_sparse *A, /* matrix to copy */
int stype, /* requested stype of C */
int mode, /* >0: numerical, 0: pattern, <0: pattern (no diag) */
/* --------------- */
cholmod_common *Common
)
{
cholmod_sparse *C ;
Int nrow, ncol, up, lo, values, diag, astype ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (NULL) ;
RETURN_IF_NULL (A, NULL) ;
values = (mode > 0) && (A->xtype != CHOLMOD_PATTERN) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN,
values ? CHOLMOD_REAL : CHOLMOD_ZOMPLEX, NULL) ;
nrow = A->nrow ;
ncol = A->ncol ;
if ((stype || A->stype) && nrow != ncol)
{
/* inputs invalid */
ERROR (CHOLMOD_INVALID, "matrix invalid") ;
return (NULL) ;
}
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* allocate workspace */
/* ---------------------------------------------------------------------- */
CHOLMOD(allocate_work) (0, MAX (nrow,ncol), 0, Common) ;
if (Common->status < CHOLMOD_OK)
{
/* out of memory */
return (NULL) ;
}
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
diag = (mode >= 0) ;
astype = SIGN (A->stype) ;
stype = SIGN (stype) ;
up = (astype > 0) ;
lo = (astype < 0) ;
/* ---------------------------------------------------------------------- */
/* copy the matrix */
/* ---------------------------------------------------------------------- */
if (astype == stype)
{
/* ------------------------------------------------------------------ */
/* symmetry of A and C are the same */
/* ------------------------------------------------------------------ */
/* copy A into C, keeping the same symmetry. If A is symmetric
* entries in the ignored part of A are not copied into C */
C = CHOLMOD(band) (A, -nrow, ncol, mode, Common) ;
}
else if (!astype)
{
/* ------------------------------------------------------------------ */
/* convert unsymmetric matrix A into a symmetric matrix C */
/* ------------------------------------------------------------------ */
if (stype > 0)
{
/* C = triu (A) */
C = CHOLMOD(band) (A, 0, ncol, mode, Common) ;
}
else
{
/* C = tril (A) */
C = CHOLMOD(band) (A, -nrow, 0, mode, Common) ;
}
if (Common->status < CHOLMOD_OK)
{
/* out of memory */
return (NULL) ;
}
C->stype = stype ;
}
else if (astype == -stype)
{
/* ------------------------------------------------------------------ */
/* transpose a symmetric matrix */
/* ------------------------------------------------------------------ */
//.........这里部分代码省略.........
开发者ID:Al-th,项目名称:matlab,代码行数:101,代码来源:cholmod_copy.c
示例8: RETURN_IF_NULL_COMMON
cholmod_sparse *CHOLMOD(submatrix)
(
/* ---- input ---- */
cholmod_sparse *A, /* matrix to subreference */
Int *rset, /* set of row indices, duplicates OK */
SuiteSparse_long rsize, /* size of rset, or -1 for ":" */
Int *cset, /* set of column indices, duplicates OK */
SuiteSparse_long csize, /* size of cset, or -1 for ":" */
int values, /* if TRUE compute the numerical values of C */
int sorted, /* if TRUE then return C with sorted columns */
/* --------------- */
cholmod_common *Common
)
{
double aij = 0 ;
double *Ax, *Cx ;
Int *Ap, *Ai, *Anz, *Ci, *Cp, *Head, *Rlen, *Rnext, *Iwork ;
cholmod_sparse *C ;
Int packed, ancol, anrow, cnrow, cncol, nnz, i, j, csorted, ilast, p,
pend, pdest, ci, cj, head, nr, nc ;
size_t s ;
int ok = TRUE ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (NULL) ;
RETURN_IF_NULL (A, NULL) ;
values = (values && (A->xtype != CHOLMOD_PATTERN)) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN,
values ? CHOLMOD_REAL : CHOLMOD_ZOMPLEX, NULL) ;
if (A->stype != 0)
{
/* A must be unsymmetric */
ERROR (CHOLMOD_INVALID, "symmetric upper or lower case not supported") ;
return (NULL) ;
}
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* allocate workspace */
/* ---------------------------------------------------------------------- */
ancol = A->ncol ;
anrow = A->nrow ;
nr = rsize ;
nc = csize ;
if (rset == NULL)
{
/* nr = 0 denotes rset = [ ], nr < 0 denotes rset = 0:anrow-1 */
nr = (nr < 0) ? (-1) : 0 ;
}
if (cset == NULL)
{
/* nr = 0 denotes cset = [ ], nr < 0 denotes cset = 0:ancol-1 */
nc = (nc < 0) ? (-1) : 0 ;
}
cnrow = (nr < 0) ? anrow : nr ; /* negative rset means rset = 0:anrow-1 */
cncol = (nc < 0) ? ancol : nc ; /* negative cset means cset = 0:ancol-1 */
if (nr < 0 && nc < 0)
{
/* ------------------------------------------------------------------ */
/* C = A (:,:), use cholmod_copy instead */
/* ------------------------------------------------------------------ */
/* workspace: Iwork (max (C->nrow,C->ncol)) */
PRINT1 (("submatrix C = A (:,:)\n")) ;
C = CHOLMOD(copy) (A, 0, values, Common) ;
if (Common->status < CHOLMOD_OK)
{
/* out of memory */
return (NULL) ;
}
return (C) ;
}
PRINT1 (("submatrix nr "ID" nc "ID" Cnrow "ID" Cncol "ID""
" Anrow "ID" Ancol "ID"\n", nr, nc, cnrow, cncol, anrow, ancol)) ;
/* s = MAX3 (anrow+MAX(0,nr), cncol, cnrow) ; */
s = CHOLMOD(add_size_t) (anrow, MAX (0,nr), &ok) ;
if (!ok)
{
ERROR (CHOLMOD_TOO_LARGE, "problem too large") ;
return (NULL) ;
}
s = MAX3 (s, ((size_t) cncol), ((size_t) cnrow)) ;
CHOLMOD(allocate_work) (anrow, s, 0, Common) ;
if (Common->status < CHOLMOD_OK)
{
/* out of memory */
return (NULL) ;
}
ASSERT (CHOLMOD(dump_work) (TRUE, TRUE, 0, Common)) ;
/* ---------------------------------------------------------------------- */
//.........这里部分代码省略.........
开发者ID:MGKhKhD,项目名称:cvxopt,代码行数:101,代码来源:cholmod_submatrix.c
示例9: CHOLMOD
int CHOLMOD(row_lsubtree)
(
/* ---- input ---- */
cholmod_sparse *A, /* matrix to analyze */
Int *Fi, size_t fnz, /* nonzero pattern of kth row of A', not required
* for the symmetric case. Need not be sorted. */
size_t krow, /* row k of L */
cholmod_factor *L, /* the factor L from which parent(i) is derived */
/* ---- output --- */
cholmod_sparse *R, /* pattern of L(k,:), n-by-1 with R->nzmax >= n */
/* --------------- */
cholmod_common *Common
)
{
Int *Rp, *Stack, *Flag, *Ap, *Ai, *Anz, *Lp, *Li, *Lnz ;
Int p, pend, parent, t, stype, nrow, k, pf, packed, sorted, top, len, i,
mark, ka ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (A, FALSE) ;
RETURN_IF_NULL (R, FALSE) ;
RETURN_IF_NULL (L, FALSE) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
RETURN_IF_XTYPE_INVALID (R, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
RETURN_IF_XTYPE_INVALID (L, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, FALSE) ;
nrow = A->nrow ;
stype = A->stype ;
if (stype < 0)
{
/* symmetric lower triangular form not supported */
ERROR (CHOLMOD_INVALID, "symmetric lower not supported") ;
return (FALSE) ;
}
if (krow > nrow)
{
ERROR (CHOLMOD_INVALID, "lsubtree: krow invalid") ;
return (FALSE) ;
}
else if (krow == nrow)
{
/* find pattern of x=L\b where b=A(:,0) */
k = nrow ; /* compute all of the result; don't stop in SUBTREE */
ka = 0 ; /* use column A(:,0) */
if (stype != 0 || A->ncol != 1)
{
/* A must be unsymmetric (it's a single sparse column vector) */
ERROR (CHOLMOD_INVALID, "lsubtree: A invalid") ;
return (FALSE) ;
}
}
else
{
/* find pattern of L(k,:) using A(:,k) and Fi if A unsymmetric */
k = krow ; /* which row of L to compute */
ka = k ; /* which column of A to use */
if (stype == 0)
{
RETURN_IF_NULL (Fi, FALSE) ;
}
}
if (R->ncol != 1 || nrow != R->nrow || nrow > R->nzmax ||
((krow == nrow || stype != 0) && ka >= A->ncol))
{
ERROR (CHOLMOD_INVALID, "lsubtree: R invalid") ;
return (FALSE) ;
}
if (L->is_super)
{
ERROR (CHOLMOD_INVALID, "lsubtree: L invalid (cannot be supernodal)") ;
return (FALSE) ;
}
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* allocate workspace */
/* ---------------------------------------------------------------------- */
CHOLMOD(allocate_work) (nrow, 0, 0, Common) ;
if (Common->status < CHOLMOD_OK)
{
return (FALSE) ;
}
ASSERT (CHOLMOD(dump_work) (TRUE, TRUE, 0, Common)) ;
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
Ap = A->p ;
Ai = A->i ;
Anz = A->nz ;
packed = A->packed ;
sorted = A->sorted ;
//.........这里部分代码省略.........
开发者ID:GHilmarG,项目名称:Ua,代码行数:101,代码来源:cholmod_rowfac.c
示例10: CHOLMOD
int CHOLMOD(metis)
(
/* ---- input ---- */
cholmod_sparse *A, /* matrix to order */
Int *fset, /* subset of 0:(A->ncol)-1 */
size_t fsize, /* size of fset */
int postorder, /* if TRUE, follow with etree or coletree postorder */
/* ---- output --- */
Int *Perm, /* size A->nrow, output permutation */
/* --------------- */
cholmod_common *Common
)
{
double d ;
Int *Iperm, *Iwork, *Bp, *Bi ;
idxtype *Mp, *Mi, *Mperm, *Miperm ;
cholmod_sparse *B ;
Int i, j, n, nz, p, identity, uncol ;
int Opt [8], nn, zero = 0 ;
size_t n1, s ;
int ok = TRUE ;
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (A, FALSE) ;
RETURN_IF_NULL (Perm, FALSE) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* quick return */
/* ---------------------------------------------------------------------- */
n = A->nrow ;
if (n == 0)
{
return (TRUE) ;
}
n1 = ((size_t) n) + 1 ;
/* ---------------------------------------------------------------------- */
/* allocate workspace */
/* ---------------------------------------------------------------------- */
/* s = 4*n + uncol */
uncol = (A->stype == 0) ? A->ncol : 0 ;
s = CHOLMOD(mult_size_t) (n, 4, &ok) ;
s = CHOLMOD(add_size_t) (s, uncol, &ok) ;
if (!ok)
{
ERROR (CHOLMOD_TOO_LARGE, "problem too large") ;
return (FALSE) ;
}
CHOLMOD(allocate_work) (n, s, 0, Common) ;
if (Common->status < CHOLMOD_OK)
{
return (FALSE) ;
}
ASSERT (CHOLMOD(dump_work) (TRUE, TRUE, 0, Common)) ;
/* ---------------------------------------------------------------------- */
/* convert the matrix to adjacency list form */
/* ---------------------------------------------------------------------- */
/* The input graph for METIS must be symmetric, with both upper and lower
* parts present, and with no diagonal entries. The columns need not be
* sorted.
* B = A+A', A*A', or A(:,f)*A(:,f)', upper and lower parts present */
if (A->stype)
{
/* Add the upper/lower part to a symmetric lower/upper matrix by
* converting to unsymmetric mode */
/* workspace: Iwork (nrow) */
B = CHOLMOD(copy) (A, 0, -1, Common) ;
}
else
{
/* B = A*A' or A(:,f)*A(:,f)', no diagonal */
/* workspace: Flag (nrow), Iwork (max (nrow,ncol)) */
B = CHOLMOD(aat) (A, fset, fsize, -1, Common) ;
}
ASSERT (CHOLMOD(dump_sparse) (B, "B for NodeND", Common) >= 0) ;
if (Common->status < CHOLMOD_OK)
{
return (FALSE) ;
}
ASSERT (B->nrow == A->nrow) ;
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
Iwork = Common->Iwork ;
Iperm = Iwork ; /* size n (i/i/l) */
Bp = B->p ;
//.........这里部分代码省略.........
开发者ID:Al-th,项目名称:matlab,代码行数:101,代码来源:cholmod_metis.c
示例11: CHOLMOD
int CHOLMOD(super_numeric)
(
/* ---- input ---- */
cholmod_sparse *A, /* matrix to factorize */
cholmod_sparse *F, /* F = A' or A(:,f)' */
double beta [2], /* beta*I is added to diagonal of matrix to factorize */
/* ---- in/out --- */
cholmod_factor *L, /* factorization */
/* --------------- */
cholmod_common *Common
)
{
cholmod_dense *C ;
Int *Super, *Map, *SuperMap ;
size_t maxcsize ;
Int nsuper, n, i, k, s, stype, nrow ;
int ok = TRUE, symbolic ;
size_t t, w ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (L, FALSE) ;
RETURN_IF_NULL (A, FALSE) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, FALSE) ;
RETURN_IF_XTYPE_INVALID (L, CHOLMOD_PATTERN, CHOLMOD_COMPLEX, FALSE) ;
stype = A->stype ;
if (stype < 0)
{
if (A->nrow != A->ncol || A->nrow != L->n)
{
ERROR (CHOLMOD_INVALID, "invalid dimensions") ;
return (FALSE) ;
}
}
else if (stype == 0)
{
if (A->nrow != L->n)
{
ERROR (CHOLMOD_INVALID, "invalid dimensions") ;
return (FALSE) ;
}
RETURN_IF_NULL (F, FALSE) ;
RETURN_IF_XTYPE_INVALID (F, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, FALSE) ;
if (A->nrow != F->ncol || A->ncol != F->nrow || F->stype != 0)
{
ERROR (CHOLMOD_INVALID, "F invalid") ;
return (FALSE) ;
}
if (A->xtype != F->xtype)
{
ERROR (CHOLMOD_INVALID, "A and F must have same xtype") ;
return (FALSE) ;
}
}
else
{
/* symmetric upper case not suppored */
ERROR (CHOLMOD_INVALID, "symmetric upper case not supported") ;
return (FALSE) ;
}
if (!(L->is_super))
{
ERROR (CHOLMOD_INVALID, "L not supernodal") ;
return (FALSE) ;
}
if (L->xtype != CHOLMOD_PATTERN)
{
if (! ((A->xtype == CHOLMOD_REAL && L->xtype == CHOLMOD_REAL)
|| (A->xtype == CHOLMOD_COMPLEX && L->xtype == CHOLMOD_COMPLEX)
|| (A->xtype == CHOLMOD_ZOMPLEX && L->xtype == CHOLMOD_COMPLEX)))
{
ERROR (CHOLMOD_INVALID, "complex type mismatch") ;
return (FALSE) ;
}
}
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* allocate workspace in Common */
/* ---------------------------------------------------------------------- */
nsuper = L->nsuper ;
maxcsize = L->maxcsize ;
nrow = A->nrow ;
n = nrow ;
PRINT1 (("nsuper "ID" maxcsize %g\n", nsuper, (double) maxcsize)) ;
ASSERT (nsuper >= 0 && maxcsize > 0) ;
/* w = 2*n + 4*nsuper */
w = CHOLMOD(mult_size_t) (n, 2, &ok) ;
t = CHOLMOD(mult_size_t) (nsuper, 4, &ok) ;
w = CHOLMOD(add_size_t) (w, t, &ok) ;
if (!ok)
{
ERROR (CHOLMOD_TOO_LARGE, "problem too large") ;
return (FALSE) ;
//.........这里部分代码省略.........
开发者ID:GYingchao,项目名称:SuiteSparse,代码行数:101,代码来源:cholmod_super_numeric.c
示例12: CHOLMOD
int CHOLMOD(resymbol_noperm)
(
/* ---- input ---- */
cholmod_sparse *A, /* matrix to analyze */
Int *fset, /* subset of 0:(A->ncol)-1 */
size_t fsize, /* size of fset */
int pack, /* if TRUE, pack the columns of L */
/* ---- in/out --- */
cholmod_factor *L, /* factorization, entries pruned on output */
/* --------------- */
cholmod_common *Common
)
{
double *Lx, *Lz ;
Int i, j, k, row, parent, p, pend, pdest, ncol, apacked, sorted, nrow, nf,
use_fset, mark, jj, stype, xtype ;
Int *Ap, *Ai, *Anz, *Li, *Lp, *Lnz, *Flag, *Head, *Link, *Anext, *Iwork ;
size_t s ;
int ok = TRUE ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (A, FALSE) ;
RETURN_IF_NULL (L, FALSE) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
RETURN_IF_XTYPE_INVALID (L, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, FALSE) ;
ncol = A->ncol ;
nrow = A->nrow ;
stype = A->stype ;
ASSERT (IMPLIES (stype != 0, nrow == ncol)) ;
if (stype > 0)
{
/* symmetric, with upper triangular part, not supported */
ERROR (CHOLMOD_INVALID, "symmetric upper not supported ") ;
return (FALSE) ;
}
if (L->is_super)
{
/* cannot operate on a supernodal or symbolic factorization */
ERROR (CHOLMOD_INVALID, "cannot operate on supernodal L") ;
return (FALSE) ;
}
if (L->n != A->nrow)
{
/* dimensions must agree */
ERROR (CHOLMOD_INVALID, "A and L dimensions do not match") ;
return (FALSE) ;
}
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* allocate workspace */
/* ---------------------------------------------------------------------- */
/* s = 2*nrow + (stype ? 0 : ncol) */
s = CHOLMOD(mult_size_t) (nrow, 2, &ok) ;
if (stype != 0)
{
s = CHOLMOD(add_size_t) (s, ncol, &ok) ;
}
if (!ok)
{
ERROR (CHOLMOD_TOO_LARGE, "problem too large") ;
return (FALSE) ;
}
CHOLMOD(allocate_work) (nrow, s, 0, Common) ;
if (Common->status < CHOLMOD_OK)
{
return (FALSE) ; /* out of memory */
}
ASSERT (CHOLMOD(dump_work) (TRUE, TRUE, 0, Common)) ;
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
Ai = A->i ;
Ap = A->p ;
Anz = A->nz ;
apacked = A->packed ;
sorted = A->sorted ;
Li = L->i ;
Lx = L->x ;
Lz = L->z ;
Lp = L->p ;
Lnz = L->nz ;
xtype = L->xtype ;
/* If L is monotonic on input, then it can be packed or
* unpacked on output, depending on the pack input parameter. */
/* cannot pack a non-monotonic matrix */
if (!(L->is_monotonic))
{
pack = FALSE ;
//.........这里部分代码省略.........
开发者ID:Cookdj0128,项目名称:fieldtrip,代码行数:101,代码来源:cholmod_resymbol.c
示例13: RETURN_IF_NULL_COMMON
cholmod_sparse *CHOLMOD(vertcat)
(
/* ---- input ---- */
cholmod_sparse *A, /* left matrix to concatenate */
cholmod_sparse *B, /* right matrix to concatenate */
int values, /* if TRUE compute the numerical values of C */
/* --------------- */
cholmod_common *Common
)
{
double *Ax, *Bx, *Cx ;
Int *Ap, *Ai, *Anz, *Bp, *Bi, *Bnz, *Cp, *Ci ;
cholmod_sparse *C, *A2, *B2 ;
Int apacked, bpacked, anrow, bnrow, ncol, nrow, anz, bnz, nz, j, p, pend,
pdest ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (NULL) ;
RETURN_IF_NULL (A, NULL) ;
RETURN_IF_NULL (B, NULL) ;
values = values &&
(A->xtype != CHOLMOD_PATTERN) && (B->xtype != CHOLMOD_PATTERN) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN,
values ? CHOLMOD_REAL : CHOLMOD_ZOMPLEX, NULL) ;
RETURN_IF_XTYPE_INVALID (B, CHOLMOD_PATTERN,
values ? CHOLMOD_REAL : CHOLMOD_ZOMPLEX, NULL) ;
if (A->ncol != B->ncol)
{
/* A and B must have the same number of columns */
ERROR (CHOLMOD_INVALID, "A and B must have same # of columns") ;
return (NULL) ;
}
/* A and B must have the same numerical type if values is TRUE (both must
* be CHOLMOD_REAL, this is implicitly checked above) */
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* allocate workspace */
/* ---------------------------------------------------------------------- */
anrow = A->nrow ;
bnrow = B->nrow ;
ncol = A->ncol ;
CHOLMOD(allocate_work) (0, MAX3 (anrow, bnrow, ncol), 0, Common) ;
if (Common->status < CHOLMOD_OK)
{
/* out of memory */
return (NULL) ;
}
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
/* convert A to unsymmetric, if necessary */
A2 = NULL ;
if (A->stype != 0)
{
/* workspace: Iwork (max (A->nrow,A->ncol)) */
A2 = CHOLMOD(copy) (A, 0, values, Common) ;
if (Common->status < CHOLMOD_OK)
{
/* out of memory */
return (NULL) ;
}
A = A2 ;
}
/* convert B to unsymmetric, if necessary */
B2 = NULL ;
if (B->stype != 0)
{
/* workspace: Iwork (max (B->nrow,B->ncol)) */
B2 = CHOLMOD(copy) (B, 0, values, Common) ;
if (Common->status < CHOLMOD_OK)
{
/* out of memory */
CHOLMOD(free_sparse) (&A2, Common) ;
return (NULL) ;
}
B = B2 ;
}
Ap = A->p ;
Anz = A->nz ;
Ai = A->i ;
Ax = A->x ;
apacked = A->packed ;
Bp = B->p ;
Bnz = B->nz ;
Bi = B->i ;
Bx = B->x ;
bpacked = B->packed ;
/* ---------------------------------------------------------------------- */
/* allocate C */
//.........这里部分代码省略.........
开发者ID:freshNfunky,项目名称:SuiteSparse-4.5.3,代码行数:101,代码来源:cholmod_vertcat.c
示例14: CHOLMOD
int CHOLMOD(super_lsolve) /* TRUE if OK, FALSE if BLAS overflow occured */
(
/* ---- input ---- */
cholmod_factor *L, /* factor to use for the forward solve */
/* ---- output ---- */
cholmod_dense *X, /* b on input, solution to Lx=b on output */
/* ---- workspace ---- */
cholmod_dense *E, /* workspace of size nrhs*(L->maxesize) */
/* --------------- */
cholmod_common *Common
)
{
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (L, FALSE) ;
RETURN_IF_NULL (X, FALSE) ;
RETURN_IF_NULL (E, FALSE) ;
RETURN_IF_XTYPE_INVALID (L, CHOLMOD_REAL, CHOLMOD_COMPLEX, FALSE) ;
RETURN_IF_XTYPE_INVALID (X, CHOLMOD_REAL, CHOLMOD_COMPLEX, FALSE) ;
RETURN_IF_XTYPE_INVALID (E, CHOLMOD_REAL, CHOLMOD_COMPLEX, FALSE) ;
if (L->xtype != X->xtype)
{
ERROR (CHOLMOD_INVALID, "L and X must have the same xtype") ;
return (FALSE) ;
}
if (L->xtype != E->xtype)
{
ERROR (CHOLMOD_INVALID, "L and E must have the same xtype") ;
return (FALSE) ;
}
if (X->d < X->nrow || L->n != X->nrow)
{
ERROR (CHOLMOD_INVALID, "X and L dimensions must match") ;
return (FALSE) ;
}
if (E->nzmax < X->ncol * (L->maxesize))
{
ERROR (CHOLMOD_INVALID, "workspace E not large enough") ;
return (FALSE) ;
}
if (!(L->is_ll) || !(L->is_super))
{
ERROR (CHOLMOD_INVALID, "L not supernodal") ;
return (FALSE) ;
}
Common->status = CHOLMOD_OK ;
ASSERT (IMPLIES (L->n == 0, L->nsuper == 0)) ;
if (L->n == 0 || X->ncol == 0)
{
/* nothing to do */
return (TRUE) ;
}
/* ---------------------------------------------------------------------- */
/* solve Lx=b using template routine */
/* ---------------------------------------------------------------------- */
switch (L->xtype)
{
case CHOLMOD_REAL:
r_cholmod_super_lsolve (L, X, E, Common) ;
break ;
case CHOLMOD_COMPLEX:
c_cholmod_super_lsolve (L, X, E, Common) ;
break ;
}
if (CHECK_BLAS_INT && !Common->blas_ok)
{
ERROR (CHOLMOD_TOO_LARGE, "problem too large for the BLAS") ;
}
return (Common->blas_ok) ;
}
开发者ID:Al-th,项目名称:matlab,代码行数:78,代码来源:cholmod_super_solve.c
示例15: CHOLMOD
int CHOLMOD(etree)
(
/* ---- input ---- */
cholmod_sparse *A,
/* ---- output --- */
Int *Parent, /* size ncol. Parent [j] = p if p is the parent of j */
/* --------------- */
cholmod_common *Common
)
{
Int *Ap, *Ai, *Anz, *Ancestor, *Prev, *Iwork ;
Int i, j, jprev, p, pend, nrow, ncol, packed, stype ;
size_t s ;
int ok = TRUE ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (A, FALSE) ;
RETURN_IF_NULL (Parent, FALSE) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
Common->status = CHOLMOD_OK ;
/* ---------------------------------------------------------------------- */
/* allocate workspace */
/* ---------------------------------------------------------------------- */
stype = A->stype ;
/* s = A->nrow + (stype ? 0 : A->ncol) */
s = CHOLMOD(add_size_t) (A->nrow, (stype ? 0 : A->ncol), &ok) ;
if (!ok)
{
ERROR (CHOLMOD_TOO_LARGE, "problem too large") ;
return (FALSE) ;
}
CHOLMOD(allocate_work) (0, s, 0, Common) ;
if (Common->status < CHOLMOD_OK)
{
return (FALSE) ; /* out of memory */
}
ASSERT (CHOLMOD(dump_sparse) (A, "etree", Common) >= 0) ;
Iwork = Common->Iwork ;
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
ncol = A->ncol ; /* the number of columns of A */
nrow = A->nrow ; /* the number of rows of A */
Ap = A->p ; /* size ncol+1, column pointers for A */
Ai = A->i ; /* the row indices of A */
Anz = A->nz ; /* number of nonzeros in each column of A */
packed = A->packed ;
Ancestor = Iwork ; /* size ncol (i/i/l) */
for (j = 0 ; j < ncol ; j++)
{
Parent [j] = EMPTY ;
Ancestor [j] = EMPTY ;
}
/* ---------------------------------------------------------------------- */
/* compute the etree */
/* ---------------------------------------------------------------------- */
if (stype > 0)
{
/* ------------------------------------------------------------------ */
/* symmetric (upper) case: compute etree (A) */
/* ------------------------------------------------------------------ */
for (j = 0 ; j < ncol ; j++)
{
/* for each row i in column j of triu(A), excluding the diagonal */
p = Ap [j] ;
pend = (packed) ? (Ap [j+1]) : (p + Anz [j]) ;
for ( ; p < pend ; p++)
{
i = Ai [p] ;
if (i < j)
{
update_etree (i, j, Parent, Ancestor) ;
}
}
}
}
else if (stype == 0)
{
/* ------------------------------------------------------------------ */
/* unsymmetric case: compute etree (A'*A) */
/* ------------------------------------------------------------------ */
//.........这里部分代码省略.........
开发者ID:Ascronia,项目名称:fieldtrip,代码行数:101,代码来源:cholmod_etree.c
示例16: CHOLMOD
int CHOLMOD(camd)
(
/* ---- input ---- */
cholmod_sparse *A, /* matrix to order */
Int *fset, /* subset of 0:(A->ncol)-1 */
size_t fsize, /* size of fset */
Int *Cmember, /* size nrow. see cholmod_ccolamd.c for description.*/
/* ---- output ---- */
Int *Perm, /* size A->nrow, output permutation */
/* --------------- */
cholmod_common *Common
)
{
double Info [CAMD_INFO], Control2 [CAMD_CONTROL], *Control ;
Int *Cp, *Len, *Nv, *Head, *Elen, *Degree, *Wi, *Next, *BucketSet,
*Work3n, *p ;
cholmod_sparse *C ;
Int j, n, cnz ;
size_t s ;
int ok = TRUE ;
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (A, FALSE) ;
n = A->nrow ;
/* s = 4*n */
s = CHOLMOD(mult_size_t) (n, 4, &ok) ;
if (!ok)
{
ERROR (CHOLMOD_TOO_LARGE, "problem too large") ;
return (FALSE) ;
}
RETURN_IF_NULL (Perm, FALSE) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
Common->status = CHOLMOD_OK ;
if (n == 0)
{
/* nothing to do */
Common->fl = 0 ;
Common->lnz = 0 ;
Common->anz = 0 ;
return (TRUE) ;
}
/* ---------------------------------------------------------------------- */
/* get workspace */
/* ---------------------------------------------------------------------- */
/* cholmod_analyze has allocated Cmember at Common->Iwork + 5*n+uncol, and
* CParent at Common->Iwork + 4*n+uncol, where uncol is 0 if A is symmetric
* or A->ncol otherwise. Thus, only the first 4n integers in Common->Iwork
* can be used here. */
CHOLMOD(allocate_work) (n, s, 0, Common) ;
if (Common->status < CHOLMOD_OK)
{
return (FALSE) ;
}
p = Common->Iwork ;
Degree = p ; p += n ; /* size n */
Elen = p ; p += n ; /* size n */
Len = p ; p += n ; /* size n */
Nv = p ; p += n ; /* size n */
Work3n = CHOLMOD(malloc) (n+1, 3*sizeof (Int), Common) ;
if (Common->status < CHOLMOD_OK)
{
return (FALSE) ;
}
p = Work3n ;
Next = p ; p += n ; /* size n */
Wi = p ; p += (n+1) ; /* size n+1 */
BucketSet = p ; /* size n */
Head = Common->Head ; /* size n+1 */
/* ---------------------------------------------------------------------- */
/* construct the input matrix for CAMD */
/* ---------------------------------------------------------------------- */
if (A->stype == 0)
{
/* C = A*A' or A(:,f)*A(:,f)', add extra space of nnz(C)/2+n to C */
C = CHOLMOD(aat) (A, fset, fsize, -2, Common) ;
}
else
{
/* C = A+A', but use only the upper triangular part of A if A->stype = 1
* and only the lower part of A if A->stype = -1. Add extra space of
* nnz(C)/2+n to C. */
C = CHOLMOD(copy) (A, 0, -2, Common) ;
}
if (Common->status < CHOLMOD_OK)
//.........这里部分代码省略.........
开发者ID:Ascronia,项目名称:fieldtrip,代码行数:101,代码来源:cholmod_camd.c
示例17: CHOLMOD
int CHOLMOD(drop)
(
/* ---- input ---- */
double tol, /* keep entries with absolute value > tol */
/* ---- in/out --- */
cholmod_sparse *A, /* matrix to drop entries from */
/* --------------- */
cholmod_common *Common
)
{
double aij ;
double *Ax ;
Int *Ap, *Ai, *Anz ;
Int packed, i, j, nrow, ncol, p, pend, nz, values ;
/* ---------------------------------------------------------------------- */
/* check inputs */
/* ---------------------------------------------------------------------- */
RETURN_IF_NULL_COMMON (FALSE) ;
RETURN_IF_NULL (A, FALSE) ;
RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_REAL, FALSE) ;
Common->status = CHOLMOD_OK ;
ASSERT (CHOLMOD(dump_sparse) (A, "A predrop", Common) >= 0) ;
/* ---------------------------------------------------------------------- */
/* get inputs */
/* ---------------------------------------------------------------------- */
Ap = A->p ;
Ai = A->i ;
Ax = A->x ;
A
|
请发表评论