| 1 | /*BHEADER**********************************************************************
|
|---|
| 2 | * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
|
|---|
| 3 | * Produced at the Lawrence Livermore National Laboratory.
|
|---|
| 4 | * This file is part of HYPRE. See file COPYRIGHT for details.
|
|---|
| 5 | *
|
|---|
| 6 | * HYPRE is free software; you can redistribute it and/or modify it under the
|
|---|
| 7 | * terms of the GNU Lesser General Public License (as published by the Free
|
|---|
| 8 | * Software Foundation) version 2.1 dated February 1999.
|
|---|
| 9 | *
|
|---|
| 10 | * $Revision: 2.4 $
|
|---|
| 11 | ***********************************************************************EHEADER*/
|
|---|
| 12 | /*BHEADER**********************************************************************
|
|---|
| 13 | * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
|
|---|
| 14 | * Produced at the Lawrence Livermore National Laboratory.
|
|---|
| 15 | * This file is part of HYPRE. See file COPYRIGHT for details.
|
|---|
| 16 | *
|
|---|
| 17 | * HYPRE is free software; you can redistribute it and/or modify it under the
|
|---|
| 18 | * terms of the GNU Lesser General Public License (as published by the Free
|
|---|
| 19 | * Software Foundation) version 2.1 dated February 1999.
|
|---|
| 20 | *
|
|---|
| 21 | * $Revision: 2.4 $
|
|---|
| 22 | ***********************************************************************EHEADER*/
|
|---|
| 23 |
|
|---|
| 24 | #include "HYPRE_seq_mv.h"
|
|---|
| 25 |
|
|---|
| 26 | #ifndef hypre_MV_HEADER
|
|---|
| 27 | #define hypre_MV_HEADER
|
|---|
| 28 |
|
|---|
| 29 | #include "utilities.h"
|
|---|
| 30 |
|
|---|
| 31 | #ifdef __cplusplus
|
|---|
| 32 | extern "C" {
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | /******************************************************************************
|
|---|
| 40 | *
|
|---|
| 41 | * Header info for CSR Matrix data structures
|
|---|
| 42 | *
|
|---|
| 43 | * Note: this matrix currently uses 0-based indexing.
|
|---|
| 44 | *
|
|---|
| 45 | *****************************************************************************/
|
|---|
| 46 |
|
|---|
| 47 | #ifndef hypre_CSR_MATRIX_HEADER
|
|---|
| 48 | #define hypre_CSR_MATRIX_HEADER
|
|---|
| 49 |
|
|---|
| 50 | /*--------------------------------------------------------------------------
|
|---|
| 51 | * CSR Matrix
|
|---|
| 52 | *--------------------------------------------------------------------------*/
|
|---|
| 53 |
|
|---|
| 54 | typedef struct
|
|---|
| 55 | {
|
|---|
| 56 | double *data;
|
|---|
| 57 | int *i;
|
|---|
| 58 | int *j;
|
|---|
| 59 | int num_rows;
|
|---|
| 60 | int num_cols;
|
|---|
| 61 | int num_nonzeros;
|
|---|
| 62 |
|
|---|
| 63 | /* for compressing rows in matrix multiplication */
|
|---|
| 64 | int *rownnz;
|
|---|
| 65 | int num_rownnz;
|
|---|
| 66 |
|
|---|
| 67 | /* Does the CSRMatrix create/destroy `data', `i', `j'? */
|
|---|
| 68 | int owns_data;
|
|---|
| 69 |
|
|---|
| 70 | /* only used for threaded MatVecT */
|
|---|
| 71 | double *expand_data;
|
|---|
| 72 |
|
|---|
| 73 | } hypre_CSRMatrix;
|
|---|
| 74 |
|
|---|
| 75 | /*--------------------------------------------------------------------------
|
|---|
| 76 | * Accessor functions for the CSR Matrix structure
|
|---|
| 77 | *--------------------------------------------------------------------------*/
|
|---|
| 78 |
|
|---|
| 79 | #define hypre_CSRMatrixData(matrix) ((matrix) -> data)
|
|---|
| 80 | #define hypre_CSRMatrixI(matrix) ((matrix) -> i)
|
|---|
| 81 | #define hypre_CSRMatrixJ(matrix) ((matrix) -> j)
|
|---|
| 82 | #define hypre_CSRMatrixNumRows(matrix) ((matrix) -> num_rows)
|
|---|
| 83 | #define hypre_CSRMatrixNumCols(matrix) ((matrix) -> num_cols)
|
|---|
| 84 | #define hypre_CSRMatrixNumNonzeros(matrix) ((matrix) -> num_nonzeros)
|
|---|
| 85 | #define hypre_CSRMatrixRownnz(matrix) ((matrix) -> rownnz)
|
|---|
| 86 | #define hypre_CSRMatrixNumRownnz(matrix) ((matrix) -> num_rownnz)
|
|---|
| 87 | #define hypre_CSRMatrixOwnsData(matrix) ((matrix) -> owns_data)
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | /*--------------------------------------------------------------------------
|
|---|
| 91 | * BigCSR Matrix
|
|---|
| 92 | *--------------------------------------------------------------------------*/
|
|---|
| 93 |
|
|---|
| 94 | typedef struct
|
|---|
| 95 | {
|
|---|
| 96 | int *i;
|
|---|
| 97 | HYPRE_BigInt *j;
|
|---|
| 98 | double *data;
|
|---|
| 99 | int num_rows;
|
|---|
| 100 | int num_cols;
|
|---|
| 101 | int num_nonzeros;
|
|---|
| 102 | int owns_data;
|
|---|
| 103 |
|
|---|
| 104 | /* only used for threaded MatVecT */
|
|---|
| 105 | double *expand_data;
|
|---|
| 106 |
|
|---|
| 107 | } hypre_BigCSRMatrix;
|
|---|
| 108 |
|
|---|
| 109 | /*--------------------------------------------------------------------------
|
|---|
| 110 | * Accessor functions for the BigCSRMatrix structure
|
|---|
| 111 | *--------------------------------------------------------------------------*/
|
|---|
| 112 |
|
|---|
| 113 | #define hypre_BigCSRMatrixI(matrix) ((matrix)->i)
|
|---|
| 114 | #define hypre_BigCSRMatrixJ(matrix) ((matrix)->j)
|
|---|
| 115 | #define hypre_BigCSRMatrixData(matrix) ((matrix)->data)
|
|---|
| 116 | #define hypre_BigCSRMatrixNumRows(matrix) ((matrix)->num_rows)
|
|---|
| 117 | #define hypre_BigCSRMatrixNumCols(matrix) ((matrix)->num_cols)
|
|---|
| 118 | #define hypre_BigCSRMatrixNumNonzeros(matrix)((matrix)->num_nonzeros)
|
|---|
| 119 | #define hypre_BigCSRMatrixOwnsData(matrix) ((matrix)->owns_data)
|
|---|
| 120 |
|
|---|
| 121 | #endif
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 | /******************************************************************************
|
|---|
| 128 | *
|
|---|
| 129 | * Header info for Vector data structure
|
|---|
| 130 | *
|
|---|
| 131 | *****************************************************************************/
|
|---|
| 132 |
|
|---|
| 133 | #ifndef hypre_VECTOR_HEADER
|
|---|
| 134 | #define hypre_VECTOR_HEADER
|
|---|
| 135 |
|
|---|
| 136 | /*--------------------------------------------------------------------------
|
|---|
| 137 | * hypre_Vector
|
|---|
| 138 | *--------------------------------------------------------------------------*/
|
|---|
| 139 |
|
|---|
| 140 | typedef struct
|
|---|
| 141 | {
|
|---|
| 142 | double *data;
|
|---|
| 143 | int size;
|
|---|
| 144 |
|
|---|
| 145 | /* Does the Vector create/destroy `data'? */
|
|---|
| 146 | int owns_data;
|
|---|
| 147 |
|
|---|
| 148 | /* For multivectors...*/
|
|---|
| 149 | int num_vectors; /* the above "size" is size of one vector */
|
|---|
| 150 | int multivec_storage_method;
|
|---|
| 151 | /* ...if 0, store colwise v0[0], v0[1], ..., v1[0], v1[1], ... v2[0]... */
|
|---|
| 152 | /* ...if 1, store rowwise v0[0], v1[0], ..., v0[1], v1[1], ... */
|
|---|
| 153 | /* With colwise storage, vj[i] = data[ j*size + i]
|
|---|
| 154 | With rowwise storage, vj[i] = data[ j + num_vectors*i] */
|
|---|
| 155 | int vecstride, idxstride;
|
|---|
| 156 | /* ... so vj[i] = data[ j*vecstride + i*idxstride ] regardless of row_storage.*/
|
|---|
| 157 |
|
|---|
| 158 | } hypre_Vector;
|
|---|
| 159 |
|
|---|
| 160 | /*--------------------------------------------------------------------------
|
|---|
| 161 | * Accessor functions for the Vector structure
|
|---|
| 162 | *--------------------------------------------------------------------------*/
|
|---|
| 163 |
|
|---|
| 164 | #define hypre_VectorData(vector) ((vector) -> data)
|
|---|
| 165 | #define hypre_VectorSize(vector) ((vector) -> size)
|
|---|
| 166 | #define hypre_VectorOwnsData(vector) ((vector) -> owns_data)
|
|---|
| 167 | #define hypre_VectorNumVectors(vector) ((vector) -> num_vectors)
|
|---|
| 168 | #define hypre_VectorMultiVecStorageMethod(vector) ((vector) -> multivec_storage_method)
|
|---|
| 169 | #define hypre_VectorVectorStride(vector) ((vector) -> vecstride )
|
|---|
| 170 | #define hypre_VectorIndexStride(vector) ((vector) -> idxstride )
|
|---|
| 171 |
|
|---|
| 172 | #endif
|
|---|
| 173 |
|
|---|
| 174 | /* big_csr_matrix.c */
|
|---|
| 175 | hypre_BigCSRMatrix *hypre_BigCSRMatrixCreate ( int num_rows , int num_cols , int num_nonzeros );
|
|---|
| 176 | int hypre_BigCSRMatrixDestroy ( hypre_BigCSRMatrix *matrix );
|
|---|
| 177 | int hypre_BigCSRMatrixInitialize ( hypre_BigCSRMatrix *matrix );
|
|---|
| 178 | int hypre_BigCSRMatrixSetDataOwner ( hypre_BigCSRMatrix *matrix , int owns_data );
|
|---|
| 179 | int hypre_BigCSRMatrixCopy ( hypre_BigCSRMatrix *A , hypre_BigCSRMatrix *B , int copy_data );
|
|---|
| 180 |
|
|---|
| 181 | /* csr_matop.c */
|
|---|
| 182 | hypre_CSRMatrix *hypre_CSRMatrixAdd ( hypre_CSRMatrix *A , hypre_CSRMatrix *B );
|
|---|
| 183 | hypre_CSRMatrix *hypre_CSRMatrixMultiply ( hypre_CSRMatrix *A , hypre_CSRMatrix *B );
|
|---|
| 184 | hypre_CSRMatrix *hypre_CSRMatrixDeleteZeros ( hypre_CSRMatrix *A , double tol );
|
|---|
| 185 | int hypre_CSRMatrixTranspose ( hypre_CSRMatrix *A , hypre_CSRMatrix **AT , int data );
|
|---|
| 186 | int hypre_CSRMatrixReorder ( hypre_CSRMatrix *A );
|
|---|
| 187 | double hypre_CSRMatrixSumElts ( hypre_CSRMatrix *A );
|
|---|
| 188 |
|
|---|
| 189 | /* csr_matrix.c */
|
|---|
| 190 | hypre_CSRMatrix *hypre_CSRMatrixCreate ( int num_rows , int num_cols , int num_nonzeros );
|
|---|
| 191 | int hypre_CSRMatrixDestroy ( hypre_CSRMatrix *matrix );
|
|---|
| 192 | int hypre_CSRMatrixInitialize ( hypre_CSRMatrix *matrix );
|
|---|
| 193 | int hypre_CSRMatrixSetDataOwner ( hypre_CSRMatrix *matrix , int owns_data );
|
|---|
| 194 | int hypre_CSRMatrixSetRownnz ( hypre_CSRMatrix *matrix );
|
|---|
| 195 | hypre_CSRMatrix *hypre_CSRMatrixRead ( char *file_name );
|
|---|
| 196 | int hypre_CSRMatrixPrint ( hypre_CSRMatrix *matrix , char *file_name );
|
|---|
| 197 | int hypre_CSRMatrixCopy ( hypre_CSRMatrix *A , hypre_CSRMatrix *B , int copy_data );
|
|---|
| 198 | hypre_CSRMatrix *hypre_CSRMatrixClone ( hypre_CSRMatrix *A );
|
|---|
| 199 | hypre_CSRMatrix *hypre_CSRMatrixUnion ( hypre_CSRMatrix *A , hypre_CSRMatrix *B , HYPRE_BigInt *col_map_offd_A , HYPRE_BigInt *col_map_offd_B , HYPRE_BigInt **col_map_offd_C );
|
|---|
| 200 |
|
|---|
| 201 | /* csr_matvec.c */
|
|---|
| 202 | int hypre_CSRMatrixMatvec ( double alpha , hypre_CSRMatrix *A , hypre_Vector *x , double beta , hypre_Vector *y );
|
|---|
| 203 | int hypre_CSRMatrixMatvecT ( double alpha , hypre_CSRMatrix *A , hypre_Vector *x , double beta , hypre_Vector *y );
|
|---|
| 204 | int hypre_CSRMatrixMatvec_FF ( double alpha , hypre_CSRMatrix *A , hypre_Vector *x , double beta , hypre_Vector *y , int *CF_marker_x , int *CF_marker_y , int fpt );
|
|---|
| 205 |
|
|---|
| 206 | /* genpart.c */
|
|---|
| 207 | int hypre_GeneratePartitioning ( HYPRE_BigInt length , int num_procs , HYPRE_BigInt **part_ptr );
|
|---|
| 208 | int hypre_GenerateLocalPartitioning ( HYPRE_BigInt length , int num_procs , int myid , HYPRE_BigInt **part_ptr );
|
|---|
| 209 |
|
|---|
| 210 | /* HYPRE_csr_matrix.c */
|
|---|
| 211 | HYPRE_CSRMatrix HYPRE_CSRMatrixCreate ( int num_rows , int num_cols , int *row_sizes );
|
|---|
| 212 | int HYPRE_CSRMatrixDestroy ( HYPRE_CSRMatrix matrix );
|
|---|
| 213 | int HYPRE_CSRMatrixInitialize ( HYPRE_CSRMatrix matrix );
|
|---|
| 214 | HYPRE_CSRMatrix HYPRE_CSRMatrixRead ( char *file_name );
|
|---|
| 215 | void HYPRE_CSRMatrixPrint ( HYPRE_CSRMatrix matrix , char *file_name );
|
|---|
| 216 | int HYPRE_CSRMatrixGetNumRows ( HYPRE_CSRMatrix matrix , int *num_rows );
|
|---|
| 217 |
|
|---|
| 218 | /* HYPRE_vector.c */
|
|---|
| 219 | HYPRE_Vector HYPRE_VectorCreate ( int size );
|
|---|
| 220 | int HYPRE_VectorDestroy ( HYPRE_Vector vector );
|
|---|
| 221 | int HYPRE_VectorInitialize ( HYPRE_Vector vector );
|
|---|
| 222 | int HYPRE_VectorPrint ( HYPRE_Vector vector , char *file_name );
|
|---|
| 223 | HYPRE_Vector HYPRE_VectorRead ( char *file_name );
|
|---|
| 224 |
|
|---|
| 225 | /* vector.c */
|
|---|
| 226 | hypre_Vector *hypre_SeqVectorCreate ( int size );
|
|---|
| 227 | hypre_Vector *hypre_SeqMultiVectorCreate ( int size , int num_vectors );
|
|---|
| 228 | int hypre_SeqVectorDestroy ( hypre_Vector *vector );
|
|---|
| 229 | int hypre_SeqVectorInitialize ( hypre_Vector *vector );
|
|---|
| 230 | int hypre_SeqVectorSetDataOwner ( hypre_Vector *vector , int owns_data );
|
|---|
| 231 | hypre_Vector *hypre_SeqVectorRead ( char *file_name );
|
|---|
| 232 | int hypre_SeqVectorPrint ( hypre_Vector *vector , char *file_name );
|
|---|
| 233 | int hypre_SeqVectorSetConstantValues ( hypre_Vector *v , double value );
|
|---|
| 234 | int hypre_SeqVectorSetRandomValues ( hypre_Vector *v , int seed );
|
|---|
| 235 | int hypre_SeqVectorCopy ( hypre_Vector *x , hypre_Vector *y );
|
|---|
| 236 | hypre_Vector *hypre_SeqVectorCloneDeep ( hypre_Vector *x );
|
|---|
| 237 | hypre_Vector *hypre_SeqVectorCloneShallow ( hypre_Vector *x );
|
|---|
| 238 | int hypre_SeqVectorScale ( double alpha , hypre_Vector *y );
|
|---|
| 239 | int hypre_SeqVectorAxpy ( double alpha , hypre_Vector *x , hypre_Vector *y );
|
|---|
| 240 | double hypre_SeqVectorInnerProd ( hypre_Vector *x , hypre_Vector *y );
|
|---|
| 241 | double hypre_VectorSumElts ( hypre_Vector *vector );
|
|---|
| 242 |
|
|---|
| 243 | #ifdef __cplusplus
|
|---|
| 244 | }
|
|---|
| 245 | #endif
|
|---|
| 246 |
|
|---|
| 247 | #endif
|
|---|
| 248 |
|
|---|