00001 /* ========================================================================== */ 00002 /* === Include/cholmod_matrixops.h ========================================== */ 00003 /* ========================================================================== */ 00004 00005 /* ----------------------------------------------------------------------------- 00006 * CHOLMOD/Include/cholmod_matrixops.h. 00007 * Copyright (C) 2005-2006, Timothy A. Davis 00008 * CHOLMOD/Include/cholmod_matrixops.h is licensed under Version 2.0 of the GNU 00009 * General Public License. See gpl.txt for a text of the license. 00010 * CHOLMOD is also available under other licenses; contact authors for details. 00011 * http://www.cise.ufl.edu/research/sparse 00012 * -------------------------------------------------------------------------- */ 00013 00014 /* CHOLMOD MatrixOps module. 00015 * 00016 * Basic operations on sparse and dense matrices. 00017 * 00018 * cholmod_drop A = entries in A with abs. value >= tol 00019 * cholmod_norm_dense s = norm (X), 1-norm, inf-norm, or 2-norm 00020 * cholmod_norm_sparse s = norm (A), 1-norm or inf-norm 00021 * cholmod_horzcat C = [A,B] 00022 * cholmod_scale A = diag(s)*A, A*diag(s), s*A or diag(s)*A*diag(s) 00023 * cholmod_sdmult Y = alpha*(A*X) + beta*Y or alpha*(A'*X) + beta*Y 00024 * cholmod_ssmult C = A*B 00025 * cholmod_submatrix C = A (i,j), where i and j are arbitrary vectors 00026 * cholmod_vertcat C = [A ; B] 00027 * 00028 * A, B, C: sparse matrices (cholmod_sparse) 00029 * X, Y: dense matrices (cholmod_dense) 00030 * s: scalar or vector 00031 * 00032 * Requires the Core module. Not required by any other CHOLMOD module. 00033 */ 00034 00035 #ifndef CHOLMOD_MATRIXOPS_H 00036 #define CHOLMOD_MATRIXOPS_H 00037 00038 #include "cholmod_core.h" 00039 00040 /* -------------------------------------------------------------------------- */ 00041 /* cholmod_drop: drop entries with small absolute value */ 00042 /* -------------------------------------------------------------------------- */ 00043 00044 int cholmod_drop 00045 ( 00046 /* ---- input ---- */ 00047 double tol, /* keep entries with absolute value > tol */ 00048 /* ---- in/out --- */ 00049 cholmod_sparse *A, /* matrix to drop entries from */ 00050 /* --------------- */ 00051 cholmod_common *Common 00052 ) ; 00053 00054 int cholmod_l_drop (double, cholmod_sparse *, cholmod_common *) ; 00055 00056 /* -------------------------------------------------------------------------- */ 00057 /* cholmod_norm_dense: s = norm (X), 1-norm, inf-norm, or 2-norm */ 00058 /* -------------------------------------------------------------------------- */ 00059 00060 double cholmod_norm_dense 00061 ( 00062 /* ---- input ---- */ 00063 cholmod_dense *X, /* matrix to compute the norm of */ 00064 int norm, /* type of norm: 0: inf. norm, 1: 1-norm, 2: 2-norm */ 00065 /* --------------- */ 00066 cholmod_common *Common 00067 ) ; 00068 00069 double cholmod_l_norm_dense (cholmod_dense *, int, cholmod_common *) ; 00070 00071 /* -------------------------------------------------------------------------- */ 00072 /* cholmod_norm_sparse: s = norm (A), 1-norm or inf-norm */ 00073 /* -------------------------------------------------------------------------- */ 00074 00075 double cholmod_norm_sparse 00076 ( 00077 /* ---- input ---- */ 00078 cholmod_sparse *A, /* matrix to compute the norm of */ 00079 int norm, /* type of norm: 0: inf. norm, 1: 1-norm */ 00080 /* --------------- */ 00081 cholmod_common *Common 00082 ) ; 00083 00084 double cholmod_l_norm_sparse (cholmod_sparse *, int, cholmod_common *) ; 00085 00086 /* -------------------------------------------------------------------------- */ 00087 /* cholmod_horzcat: C = [A,B] */ 00088 /* -------------------------------------------------------------------------- */ 00089 00090 cholmod_sparse *cholmod_horzcat 00091 ( 00092 /* ---- input ---- */ 00093 cholmod_sparse *A, /* left matrix to concatenate */ 00094 cholmod_sparse *B, /* right matrix to concatenate */ 00095 int values, /* if TRUE compute the numerical values of C */ 00096 /* --------------- */ 00097 cholmod_common *Common 00098 ) ; 00099 00100 cholmod_sparse *cholmod_l_horzcat (cholmod_sparse *, cholmod_sparse *, int, 00101 cholmod_common *) ; 00102 00103 /* -------------------------------------------------------------------------- */ 00104 /* cholmod_scale: A = diag(s)*A, A*diag(s), s*A or diag(s)*A*diag(s) */ 00105 /* -------------------------------------------------------------------------- */ 00106 00107 /* scaling modes, selected by the scale input parameter: */ 00108 #define CHOLMOD_SCALAR 0 /* A = s*A */ 00109 #define CHOLMOD_ROW 1 /* A = diag(s)*A */ 00110 #define CHOLMOD_COL 2 /* A = A*diag(s) */ 00111 #define CHOLMOD_SYM 3 /* A = diag(s)*A*diag(s) */ 00112 00113 int cholmod_scale 00114 ( 00115 /* ---- input ---- */ 00116 cholmod_dense *S, /* scale factors (scalar or vector) */ 00117 int scale, /* type of scaling to compute */ 00118 /* ---- in/out --- */ 00119 cholmod_sparse *A, /* matrix to scale */ 00120 /* --------------- */ 00121 cholmod_common *Common 00122 ) ; 00123 00124 int cholmod_l_scale (cholmod_dense *, int, cholmod_sparse *, cholmod_common *) ; 00125 00126 /* -------------------------------------------------------------------------- */ 00127 /* cholmod_sdmult: Y = alpha*(A*X) + beta*Y or alpha*(A'*X) + beta*Y */ 00128 /* -------------------------------------------------------------------------- */ 00129 00130 /* Sparse matrix times dense matrix */ 00131 00132 int cholmod_sdmult 00133 ( 00134 /* ---- input ---- */ 00135 cholmod_sparse *A, /* sparse matrix to multiply */ 00136 int transpose, /* use A if 0, or A' otherwise */ 00137 double alpha [2], /* scale factor for A */ 00138 double beta [2], /* scale factor for Y */ 00139 cholmod_dense *X, /* dense matrix to multiply */ 00140 /* ---- in/out --- */ 00141 cholmod_dense *Y, /* resulting dense matrix */ 00142 /* --------------- */ 00143 cholmod_common *Common 00144 ) ; 00145 00146 int cholmod_l_sdmult (cholmod_sparse *, int, double *, double *, 00147 cholmod_dense *, cholmod_dense *Y, cholmod_common *) ; 00148 00149 /* -------------------------------------------------------------------------- */ 00150 /* cholmod_ssmult: C = A*B */ 00151 /* -------------------------------------------------------------------------- */ 00152 00153 /* Sparse matrix times sparse matrix */ 00154 00155 cholmod_sparse *cholmod_ssmult 00156 ( 00157 /* ---- input ---- */ 00158 cholmod_sparse *A, /* left matrix to multiply */ 00159 cholmod_sparse *B, /* right matrix to multiply */ 00160 int stype, /* requested stype of C */ 00161 int values, /* TRUE: do numerical values, FALSE: pattern only */ 00162 int sorted, /* if TRUE then return C with sorted columns */ 00163 /* --------------- */ 00164 cholmod_common *Common 00165 ) ; 00166 00167 cholmod_sparse *cholmod_l_ssmult (cholmod_sparse *, cholmod_sparse *, int, int, 00168 int, cholmod_common *) ; 00169 00170 /* -------------------------------------------------------------------------- */ 00171 /* cholmod_submatrix: C = A (r,c), where i and j are arbitrary vectors */ 00172 /* -------------------------------------------------------------------------- */ 00173 00174 /* rsize < 0 denotes ":" in MATLAB notation, or more precisely 0:(A->nrow)-1. 00175 * In this case, r can be NULL. An rsize of zero, or r = NULL and rsize >= 0, 00176 * denotes "[ ]" in MATLAB notation (the empty set). 00177 * Similar rules hold for csize. 00178 */ 00179 00180 cholmod_sparse *cholmod_submatrix 00181 ( 00182 /* ---- input ---- */ 00183 cholmod_sparse *A, /* matrix to subreference */ 00184 int *rset, /* set of row indices, duplicates OK */ 00185 UF_long rsize, /* size of r; rsize < 0 denotes ":" */ 00186 int *cset, /* set of column indices, duplicates OK */ 00187 UF_long csize, /* size of c; csize < 0 denotes ":" */ 00188 int values, /* if TRUE compute the numerical values of C */ 00189 int sorted, /* if TRUE then return C with sorted columns */ 00190 /* --------------- */ 00191 cholmod_common *Common 00192 ) ; 00193 00194 cholmod_sparse *cholmod_l_submatrix (cholmod_sparse *, UF_long *, UF_long, 00195 UF_long *, UF_long, int, int, cholmod_common *) ; 00196 00197 /* -------------------------------------------------------------------------- */ 00198 /* cholmod_vertcat: C = [A ; B] */ 00199 /* -------------------------------------------------------------------------- */ 00200 00201 cholmod_sparse *cholmod_vertcat 00202 ( 00203 /* ---- input ---- */ 00204 cholmod_sparse *A, /* left matrix to concatenate */ 00205 cholmod_sparse *B, /* right matrix to concatenate */ 00206 int values, /* if TRUE compute the numerical values of C */ 00207 /* --------------- */ 00208 cholmod_common *Common 00209 ) ; 00210 00211 cholmod_sparse *cholmod_l_vertcat (cholmod_sparse *, cholmod_sparse *, int, 00212 cholmod_common *) ; 00213 00214 /* -------------------------------------------------------------------------- */ 00215 /* cholmod_symmetry: determine if a sparse matrix is symmetric */ 00216 /* -------------------------------------------------------------------------- */ 00217 00218 int cholmod_symmetry 00219 ( 00220 /* ---- input ---- */ 00221 cholmod_sparse *A, 00222 int option, 00223 /* ---- output ---- */ 00224 int *xmatched, 00225 int *pmatched, 00226 int *nzoffdiag, 00227 int *nzdiag, 00228 /* --------------- */ 00229 cholmod_common *Common 00230 ) ; 00231 00232 int cholmod_l_symmetry (cholmod_sparse *, int, UF_long *, UF_long *, UF_long *, 00233 UF_long *, cholmod_common *) ; 00234 00235 #endif