/usr/include/trilinos/EpetraExt_MatrixMatrix.h is in libtrilinos-epetraext-dev 12.12.1-5.
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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | //@HEADER
// ***********************************************************************
//
// EpetraExt: Epetra Extended - Linear Algebra Services Package
// Copyright (2011) Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ***********************************************************************
//@HEADER
#ifndef EPETRAEXT_MATRIXMATRIX_H
#define EPETRAEXT_MATRIXMATRIX_H
#include <EpetraExt_ConfigDefs.h>
class Epetra_CrsMatrix;
class Epetra_Map;
class Epetra_Vector;
#ifdef HAVE_VECTOR
#include <vector>
#endif
namespace EpetraExt {
class CrsMatrixStruct;
/** Collection of matrix-matrix operations. This class basically
functions as a namespace, containing only static methods.
See the program epetraext/test/MatrixMatrix/cxx_main.cpp for
a usage example.
*/
class MatrixMatrix {
public:
/** destructor */
virtual ~MatrixMatrix(){}
/** Given Epetra_CrsMatrix objects A, B and C, form the product C = A*B.
In a parallel setting, A and B need not have matching distributions,
but C needs to have the same row-map as A.
@param A Input, must already have had 'FillComplete()' called.
@param transposeA Input, whether to use transpose of matrix A.
@param B Input, must already have had 'FillComplete()' called.
@param transposeB Input, whether to use transpose of matrix B.
@param C Result. On entry to this method, it doesn't matter whether
FillComplete() has already been called on C or not. If it has,
then C's graph must already contain all nonzero locations that
will be produced when forming the product A*B. On exit,
C.FillComplete() will have been called, unless the last argument
to this function is specified to be false.
@param call_FillComplete_on_result Optional argument, defaults to true.
Power users may specify this argument to be false if they *DON'T*
want this function to call C.FillComplete. (It is often useful
to allow this function to call C.FillComplete, in cases where
one or both of the input matrices are rectangular and it is not
trivial to know which maps to use for the domain- and range-maps.)
@param keep_all_hard_zeros Optional argument, defaults to false.
If true, Multiply, keeps all entries in C corresponding to hard zeros.
If false, the following happens by case:
A*B^T, A^T*B^T - Does not store entries caused by hard zeros in C.
A^T*B (unoptimized) - Hard zeros are always stored (this option has no effect)
A*B, A^T*B (optimized) - Hard zeros in corresponding to hard zeros in A are not stored,
There are certain cases involving reuse of C, where this can be useful.
@return error-code, 0 if successful. non-zero returns may result if A or
B are not already Filled, or if errors occur in putting values
into C, etc.
*/
static int Multiply(const Epetra_CrsMatrix& A,
bool transposeA,
const Epetra_CrsMatrix& B,
bool transposeB,
Epetra_CrsMatrix& C,
bool call_FillComplete_on_result=true,
bool keep_all_hard_zeros=false);
/** Given Epetra_CrsMatrix objects A and B, form the sum B = a*A + b*B
@param A Input, must already have had 'FillComplete()' called.
@param transposeA Input, whether to use transpose of matrix A.
@param scalarA Input, scalar multiplier for matrix A.
@param B Result. On entry to this method, it doesn't matter whether
FillComplete() has already been called on B or not. If it has,
then B's graph must already contain all nonzero locations that
will be produced when forming the sum.
@param scalarB Input, scalar multiplier for matrix B.
@return error-code, 0 if successful. non-zero returns may result if A is
not already Filled, or if errors occur in putting values
into B, etc.
*/
static int Add(const Epetra_CrsMatrix& A,
bool transposeA,
double scalarA,
Epetra_CrsMatrix& B,
double scalarB);
/** Given Epetra_CrsMatrix objects A and B, form the sum C = a*A + b*B
@param A Input, must already have had 'FillComplete()' called.
@param transposeA Input, whether to use transpose of matrix A.
@param scalarA Input, scalar multiplier for matrix A.
@param B Input, must already have had 'FillComplete()' called.
@param transposeB Input, whether to use transpose of matrix B.
@param scalarB Input, scalar multiplier for matrix B.
@param C Result. On entry to this method, C can be NULL or a pointer
to an unfilled or filled matrix. If C is NULL then a new
object is allocated and must be deleted by the user.
If C is not NULL and FillComplete has already
been called then the sparsity pattern is assumed to be fixed
and compatible with the sparsity of A+B. If FillComplete has
not been called then the sum is completed and the function
returns without calling FillComplete on C.
@return error-code, 0 if successful. non-zero returns may result if A or is
not already Filled, or if errors occur in putting values
into C, etc.
*/
static int Add(const Epetra_CrsMatrix& A,
bool transposeA,
double scalarA,
const Epetra_CrsMatrix & B,
bool transposeB,
double scalarB,
Epetra_CrsMatrix * & C);
/** Given Epetra_CrsMatrix objects A, B and C, and Epetra_Vector Dinv, form the product C = (I-omega * Dinv A)*B
In a parallel setting, A and B need not have matching distributions,
but C needs to have the same row-map as A.
@param omega Input, scalar multiplier for Dinverse A
@param Dinv Input, Epetra_Vector representing a diagonal matrix, must match A's RowMap
@param A Input, must already have had 'FillComplete()' called.
@param B Input, must already have had 'FillComplete()' called.
@param C Result. On entry to this method, it doesn't matter whether
FillComplete() has already been called on C or not. If it has,
then C's graph must already contain all nonzero locations that
will be produced when forming the product A*B. On exit,
C.FillComplete() will have been called, unless the last argument
to this function is specified to be false.
@param call_FillComplete_on_result Optional argument, defaults to true.
Power users may specify this argument to be false if they *DON'T*
want this function to call C.FillComplete. (It is often useful
to allow this function to call C.FillComplete, in cases where
one or both of the input matrices are rectangular and it is not
trivial to know which maps to use for the domain- and range-maps.)
@return error-code, 0 if successful. non-zero returns may result if A or
B are not already Filled, or if errors occur in putting values
into C, etc.
*/
static int Jacobi(double omega,
const Epetra_Vector & Dinv,
const Epetra_CrsMatrix& A,
const Epetra_CrsMatrix& B,
Epetra_CrsMatrix& C,
bool call_FillComplete_on_result=true);
private:
template<typename int_type>
static int Tmult_A_B(const Epetra_CrsMatrix & A,
CrsMatrixStruct & Aview,
const Epetra_CrsMatrix & B,
CrsMatrixStruct& Bview,
Epetra_CrsMatrix& C,
bool call_FillComplete_on_result,
bool keep_all_hard_zeros);
static int mult_A_B(const Epetra_CrsMatrix & A,
CrsMatrixStruct & Aview,
const Epetra_CrsMatrix & B,
CrsMatrixStruct& Bview,
Epetra_CrsMatrix& C,
bool call_FillComplete_on_result,
bool keep_all_hard_zeros);
template<typename int_type>
static int Tmult_AT_B_newmatrix(const CrsMatrixStruct & Atransview,
const CrsMatrixStruct & Bview,
Epetra_CrsMatrix & C,
bool keep_all_hard_zeros);
static int mult_AT_B_newmatrix(const CrsMatrixStruct & Atransview,
const CrsMatrixStruct & Bview,
Epetra_CrsMatrix & C,
bool keep_all_hard_zeros);
template<typename int_type>
static int TMultiply(const Epetra_CrsMatrix& A,
bool transposeA,
const Epetra_CrsMatrix& B,
bool transposeB,
Epetra_CrsMatrix& C,
bool call_FillComplete_on_result,
bool keep_all_hard_zeros);
template<typename int_type>
static int TAdd(const Epetra_CrsMatrix& A,
bool transposeA,
double scalarA,
Epetra_CrsMatrix& B,
double scalarB);
template<typename int_type>
static int TAdd(const Epetra_CrsMatrix& A,
bool transposeA,
double scalarA,
const Epetra_CrsMatrix & B,
bool transposeB,
double scalarB,
Epetra_CrsMatrix * & C);
template<typename int_type>
static int Tjacobi_A_B(double omega,
const Epetra_Vector & Dinv,
const Epetra_CrsMatrix & A,
CrsMatrixStruct & Aview,
const Epetra_CrsMatrix & B,
CrsMatrixStruct& Bview,
Epetra_CrsMatrix& C,
bool call_FillComplete_on_result);
static int jacobi_A_B(double omega,
const Epetra_Vector & Dinv,
const Epetra_CrsMatrix & A,
CrsMatrixStruct & Aview,
const Epetra_CrsMatrix & B,
CrsMatrixStruct& Bview,
Epetra_CrsMatrix& C,
bool call_FillComplete_on_result);
template<typename int_type>
static int TJacobi(double omega,
const Epetra_Vector & Dinv,
const Epetra_CrsMatrix& A,
const Epetra_CrsMatrix& B,
Epetra_CrsMatrix& C,
bool call_FillComplete_on_result);
};//class MatrixMatrix
/**
*Method for internal use... sparsedot forms a dot-product between two
*sparsely-populated 'vectors'.
*Important assumption: assumes the indices in u_ind and v_ind are sorted.
*/
template<typename int_type>
double sparsedot(double* u, int_type* u_ind, int u_len,
double* v, int_type* v_ind, int v_len);
}//namespace EpetraExt
#endif
|