/usr/include/sundials/sundials_sparse.h is in libsundials-dev 2.7.0+dfsg-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | /*
* -----------------------------------------------------------------
* $Revision: 4771 $
* $Date: 2016-06-03 13:21:57 -0700 (Fri, 03 Jun 2016) $
* -----------------------------------------------------------------
* Programmer: Carol Woodward, Slaven Peles @ LLNL,
* Daniel R. Reynolds @ SMU.
* -----------------------------------------------------------------
* For details, see the LICENSE file.
* -----------------------------------------------------------------
* This header file contains definitions and declarations for use by
* sparse linear solvers for Ax = b.
* -----------------------------------------------------------------
*/
#ifndef _SUNDIALS_SPARSE_H
#define _SUNDIALS_SPARSE_H
#include <stdio.h>
#include <sundials/sundials_types.h>
#include <sundials/sundials_direct.h>
#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
#endif
/*
* ==================================================================
* Type definitions
* ==================================================================
*/
#define CSC_MAT 0
#define CSR_MAT 1
/*
* -----------------------------------------------------------------
* Type : SlsMat
* -----------------------------------------------------------------
* The type SlsMat is defined to be a pointer to a structure
* with various sizes, a data field, and arrays for the row and
* column information for the sparse matrix entries.
* The M and N fields indicates the number
* of rows and columns, respectively. The data field is a one
* dimensional array used for component storage. The NNZ field indicates
* the number of nonzero entries in the matrix. The integer array, asub,
* holds the row index for each of the matrix entries. The integer
* array, xa, holds the index entry for the starting value of each column.
* -----------------------------------------------------------------
* The relevant fields in DlsMat are:
* M - number of rows
* N - number of columns
* NNZ - the number of nonzero entries in the matrix
* NP - number of index pointers
* data - pointer to a contiguous block of realtype variables
* sparsetype - type of sparse matrix: compressed sparse column or row
* indexvals - indices of each nonzero entry (columns or rows)
* indexptrs - starting index of the first entry in data for each slice
* rowvals - pointer to row indices of each nonzero entry
* colptrs - pointer to starting indices in data array for each column
* colvals - pointer to column indices of each nonzero entry
* rowptrs - pointer to starting indices in data array for each row
*
* The nonzero entries of the matrix are stored in
* compressed column format. Row indices of entries in
* column j are stored in rowvals[colptrs[j]] through rowvals[colptrs[j+i]-1]
* and corresponding numerical values of the matrix are stored
* in the same entries of data.
* -----------------------------------------------------------------
*/
typedef struct _SlsMat {
int M;
int N;
int NNZ;
int NP;
realtype *data;
int sparsetype;
int *indexvals;
int *indexptrs;
/* CSC indices */
int **rowvals;
int **colptrs;
/* CSR indices */
int **colvals;
int **rowptrs;
} *SlsMat;
/*
* ==================================================================
* Exported function prototypes (functions working on SlsMat)
* ==================================================================
*/
/*
* -----------------------------------------------------------------
* Function: SparseNewMat
* -----------------------------------------------------------------
* SparseNewMat allocates memory for a compressed column sparse
* matrix with M rows, N columns, NNZ nonzeros and of sparsetype
* type (CSC or CSR matrix). SparseNewMat returns NULL if the
* request for matrix storage cannot be satisfied. See the above
* documentation for the type SlsMat for matrix storage details.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT SlsMat SparseNewMat(int M, int N, int NNZ, int sparsetype);
/*
* -----------------------------------------------------------------
* Function: SparseFromDenseMat
* -----------------------------------------------------------------
* SlsConvertDense creates a new CSC matrix from an existing
* dense/band matrix by copying all nonzero values into the sparse
* matrix structure. SlsConvertDense returns NULL if the request
* for matrix storage cannot be satisfied.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT SlsMat SparseFromDenseMat(const DlsMat A, int sparsetype);
/*
* -----------------------------------------------------------------
* Functions: SparseDestroyMat
* -----------------------------------------------------------------
* SparseDestroyMat frees the memory allocated by SparseNewMat
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT int SparseDestroyMat(SlsMat A);
/*
* -----------------------------------------------------------------
* Function : SparseSetMatToZero
* -----------------------------------------------------------------
* SetToZero sets all the elements of the sparse matrix A to 0.0.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT int SparseSetMatToZero(SlsMat A);
/*
* -----------------------------------------------------------------
* Functions: SparseCopyMat
* -----------------------------------------------------------------
* This function copies sparse matrix A into sparse matrix B.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT int SparseCopyMat(const SlsMat A, SlsMat B);
/*
* -----------------------------------------------------------------
* Functions: SparseScaleMat
* -----------------------------------------------------------------
* This function scales all data entries of a sparse matrix A
* by the realtype number in b.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT int SparseScaleMat(realtype b, SlsMat A);
/*
* -----------------------------------------------------------------
* Functions: SparseAddIdentityMat
* -----------------------------------------------------------------
* This function adds 1 to every diagonal entry of A.
* Note that the resulting matrix may have more nonzero entries than
* the original. This is accounted for, so that the return matrix
* may be larger than the one sent in.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT int SparseAddIdentityMat(SlsMat A);
/*
* -----------------------------------------------------------------
* Functions: SparseAddMat
* -----------------------------------------------------------------
* This function adds two sparse matrices: A = A+B.
* Note that the resulting matrix may have more nonzero entries than
* either of the original matrices. This is accounted for, so that
* the return matrix may be larger than the ones sent in. Upon
* successful completion, the return value is zero; otherwise 1 is
* returned.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT int SparseAddMat(SlsMat A, const SlsMat B);
/*
* -----------------------------------------------------------------
* Functions: SparseReallocMat
* -----------------------------------------------------------------
* This function reallocs internal arrays so that the resulting matrix
* holds colptrs[N] nonzeros.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT int SparseReallocMat(SlsMat A);
/*
* -----------------------------------------------------------------
* Functions: SparseMatvec
* -----------------------------------------------------------------
* This function computes the matrix-vector product, y=A*x, where A
* is a sparse matrix of dimension MxN, x is a realtype array of
* length N, and y is a realtype array of length M. Upon successful
* completion, the return value is zero; otherwise 1 is returned.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT int SparseMatvec(const SlsMat A, const realtype *x, realtype *y);
/*
* -----------------------------------------------------------------
* Functions: SparsePrintMat
* -----------------------------------------------------------------
* This function prints the compressed column matrix information for
* matrix A to standard output.
* It is intended as a debugging tool with small values of NNZ.
* The elements are printed using the %g/%lg/%Lg option.
* A blank line is printed before and after the matrix.
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT void SparsePrintMat(const SlsMat A, FILE* outfile);
#ifdef __cplusplus
}
#endif
#endif
|