/usr/include/trilinos/EpetraExt_BlockCrsMatrix.h is in libtrilinos-epetraext-dev 12.4.2-2.
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 | //@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_BLOCKCRSMATRIX_H
#define EPETRAEXT_BLOCKCRSMATRIX_H
#include <vector>
#include "Epetra_ConfigDefs.h"
#include "Epetra_CrsMatrix.h"
//! EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
/*! The EpetraExt::BlockCrsMatrix allows construction of a block matrix made up of Epetra_CrsMatrix blocks as well as access to the full systems as a Epetra_CrsMatrix. It derives from and extends the Epetra_CrsMatrix class
<b>Constructing EpetraExt::BlockCrsMatrix objects</b>
*/
namespace EpetraExt {
class BlockCrsMatrix: public Epetra_CrsMatrix {
public:
//@{ \name Constructors/Destructor.
//! BlockCrsMatrix constuctor with one block row per processor.
/*! Creates a BlockCrsMatrix object and allocates storage.
\param In
BaseGraph - Graph determining individual block structure, can be distrib. over subset of proc.'s
\param In
RowStencil - Describes the stencil for block row on this processor (i.e. (-1 0 1) centered difference)
\param In
RowIndex - Defines the index used for this block row.
*/
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
BlockCrsMatrix( const Epetra_CrsGraph & BaseGraph, const std::vector<int> & RowStencil, int RowIndex, const Epetra_Comm & GlobalComm );
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
BlockCrsMatrix( const Epetra_CrsGraph & BaseGraph, const std::vector<long long> & RowStencil, long long RowIndex, const Epetra_Comm & GlobalComm );
#endif
//! BlockCrsMatrix constuctor with multiple block rows per processor.
/*! Creates a BlockCrsMatrix object and allocates storage.
\param In
BaseGraph - Graph determining individual block structure, can be distrib. over subset of proc.'s
\param In
RowStencil - Describes the stencil for block row on this processor (i.e. (-1 0 1) centered difference)
\param In
RowIndices - Defines the indices used for this block row.
*/
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
BlockCrsMatrix( const Epetra_CrsGraph & BaseGraph, const std::vector< std::vector<int> > & RowStencil, const std::vector<int> & RowIndices, const Epetra_Comm & GlobalComm );
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
BlockCrsMatrix( const Epetra_CrsGraph & BaseGraph, const std::vector< std::vector<long long> > & RowStencil, const std::vector<long long> & RowIndices, const Epetra_Comm & GlobalComm );
#endif
//! Version taking a local block graph
BlockCrsMatrix( const Epetra_CrsGraph & BaseGraph, const Epetra_CrsGraph& LocalBlockGraph, const Epetra_Comm & GlobalComm );
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
BlockCrsMatrix( const Epetra_RowMatrix & BaseMatrix, const std::vector< std::vector<int> > & RowStencil, const std::vector<int> & RowIndices, const Epetra_Comm & GlobalComm );
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
BlockCrsMatrix( const Epetra_RowMatrix & BaseMatrix, const std::vector< std::vector<long long> > & RowStencil, const std::vector<long long> & RowIndices, const Epetra_Comm & GlobalComm );
#endif
//! Copy constructor.
BlockCrsMatrix( const BlockCrsMatrix & Matrix );
//! Destructor
virtual ~BlockCrsMatrix();
//@}
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
//! Local Stencil Info
const std::vector<int> & Stencil( int i = 0 ) {
if(BaseGraph_.RowMap().GlobalIndicesInt())
return RowStencil_int_[i];
else
throw "EpetraExt::BlockCrsMatrix::Stencil: Global Indices not int";
}
//! RowIndex
int RowIndex( int i = 0 ) {
if(BaseGraph_.RowMap().GlobalIndicesInt())
return RowIndices_int_[i];
else
throw "EpetraExt::BlockCrsMatrix::RowIndex: Global Indices not int";
}
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
//! Local Stencil Info
const std::vector<long long> & Stencil64( int i = 0 ) {
if(BaseGraph_.RowMap().GlobalIndicesLongLong())
return RowStencil_LL_[i];
else
throw "EpetraExt::BlockCrsMatrix::Stencil: Global Indices not long long";
}
//! RowIndex
long long RowIndex64( int i = 0 ) {
if(BaseGraph_.RowMap().GlobalIndicesLongLong())
return RowIndices_LL_[i];
else
throw "EpetraExt::BlockCrsMatrix::RowIndex: Global Indices not long long";
}
#endif
//! Routine for loading a base matrices values into the large Block Matrix
//! The Row and Col arguments are indices into RowStencil
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
void LoadBlock(const Epetra_RowMatrix & BaseMatrix, const int Row, const int Col);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
void LoadBlock(const Epetra_RowMatrix & BaseMatrix, const long long Row, const long long Col);
#endif
//! Routine for summing base matrices values into the large Block Matrix
//! The Row and Col arguments are indices into RowStencil
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
void SumIntoBlock(double alpha, const Epetra_RowMatrix & BaseMatrix, const int Row, const int Col);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
void SumIntoBlock(double alpha, const Epetra_RowMatrix & BaseMatrix, const long long Row, const long long Col);
#endif
//! Routine for summing base matrices values into the large Block Matrix
//! The Row and Col arguments are global indices
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
void SumIntoGlobalBlock(double alpha, const Epetra_RowMatrix & BaseMatrix, const int Row, const int Col);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
void SumIntoGlobalBlock(double alpha, const Epetra_RowMatrix & BaseMatrix, const long long Row, const long long Col);
#endif
//! Sum Entries into Block matrix using base-matrix numbering plus block Row and Col
//! The Row and Col arguments are indices into RowStencil
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
void BlockSumIntoGlobalValues(const int BaseRow, int NumIndices,
double* Values, const int* Indices, const int Row, const int Col);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
void BlockSumIntoGlobalValues(const long long BaseRow, int NumIndices,
double* Values, const long long* Indices, const long long Row, const long long Col);
#endif
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
void BlockReplaceGlobalValues(const int BaseRow, int NumIndices,
double* Values, const int* Indices, const int Row, const int Col);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
void BlockReplaceGlobalValues(const long long BaseRow, int NumIndices,
double* Values, const long long* Indices, const long long Row, const long long Col);
#endif
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
void BlockExtractGlobalRowView(const int BaseRow, int& NumEntries,
double*& Values, const int Row, const int Col);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
void BlockExtractGlobalRowView(const long long BaseRow, int& NumEntries,
double*& Values, const long long Row, const long long Col);
#endif
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
void ExtractBlock(Epetra_CrsMatrix & BaseMatrix, const int Row, const int Col);
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
void ExtractBlock(Epetra_CrsMatrix & BaseMatrix, const long long Row, const long long Col);
#endif
protected:
Epetra_CrsGraph BaseGraph_;
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
std::vector< std::vector<int> > RowStencil_int_;
std::vector<int> RowIndices_int_;
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
std::vector< std::vector<long long> > RowStencil_LL_;
std::vector<long long> RowIndices_LL_;
#endif
long long ROffset_;
long long COffset_;
private:
template<typename int_type>
void TLoadBlock(const Epetra_RowMatrix & BaseMatrix, const int_type Row, const int_type Col);
template<typename int_type>
void TSumIntoBlock(double alpha, const Epetra_RowMatrix & BaseMatrix, const int_type Row, const int_type Col);
template<typename int_type>
void TSumIntoGlobalBlock(double alpha, const Epetra_RowMatrix & BaseMatrix, const int_type Row, const int_type Col);
template<typename int_type>
void TBlockSumIntoGlobalValues(const int_type BaseRow, int NumIndices,
double* Values, const int_type* Indices, const int_type Row, const int_type Col);
template<typename int_type>
void TBlockReplaceGlobalValues(const int_type BaseRow, int NumIndices,
double* Values, const int_type* Indices, const int_type Row, const int_type Col);
template<typename int_type>
void TBlockExtractGlobalRowView(const int_type BaseRow, int& NumEntries,
double*& Values, const int_type Row, const int_type Col);
template<typename int_type>
void TExtractBlock(Epetra_CrsMatrix & BaseMatrix, const int_type Row, const int_type Col);
template<typename int_type>
std::vector< std::vector<int_type> >& TRowStencil();
template<typename int_type>
std::vector<int_type>& TRowIndices();
};
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
template<> inline std::vector<int>& BlockCrsMatrix::TRowIndices() { return RowIndices_int_; }
template<> inline std::vector< std::vector<int> >& BlockCrsMatrix::TRowStencil() { return RowStencil_int_; }
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
template<> inline std::vector<long long>& BlockCrsMatrix::TRowIndices() { return RowIndices_LL_; }
template<> inline std::vector< std::vector<long long> >& BlockCrsMatrix::TRowStencil() { return RowStencil_LL_; }
#endif
} //namespace EpetraExt
#endif /* EPETRA_CRSMATRIX_H */
|