/usr/include/trilinos/fei_MatrixTraits_Epetra.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.
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 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | /*--------------------------------------------------------------------*/
/* Copyright 2005 Sandia Corporation. */
/* Under the terms of Contract DE-AC04-94AL85000, there is a */
/* non-exclusive license for use of this work by or on behalf */
/* of the U.S. Government. Export of this program may require */
/* a license from the United States Government. */
/*--------------------------------------------------------------------*/
#ifndef _fei_MatrixTraits_Epetra_h_
#define _fei_MatrixTraits_Epetra_h_
#include <fei_trilinos_macros.hpp>
#ifdef HAVE_FEI_EPETRA
//
//IMPORTANT NOTE: Make sure that wherever this file is included from, it
//appears BEFORE any include of fei_Vector_Impl.hpp or fei_Matrix_Impl.hpp !!!
//
#include <fei_MatrixTraits.hpp>
#include <snl_fei_BlockMatrixTraits.hpp>
#include <fei_VectorTraits_Epetra.hpp>
#include <fei_Include_Trilinos.hpp>
#include <fei_Vector_Impl.hpp>
namespace fei {
/** Declare an Epetra_CrsMatrix specialization of the
fei::MatrixTraits struct.
This allows Epetra_CrsMatrix to be used as the template parameter
of the fei::Matrix class.
*/
template<>
struct MatrixTraits<Epetra_CrsMatrix> {
static const char* typeName()
{ return("Epetra_CrsMatrix"); }
static int setValues(Epetra_CrsMatrix* mat, double scalar)
{
return( mat->PutScalar(scalar) );
}
static int getNumLocalRows(Epetra_CrsMatrix* mat, int& numRows)
{
numRows = mat->NumMyRows();
return(0);
}
static int getRowLength(Epetra_CrsMatrix* mat, int row, int& length)
{
length = mat->NumGlobalEntries(row);
if (length < 0) return(-1);
return( 0 );
}
static int copyOutRow(Epetra_CrsMatrix* mat,
int row, int len, double* coefs, int* indices)
{
int dummy;
return(mat->ExtractGlobalRowCopy(row, len, dummy, coefs, indices));
}
static int putValuesIn(Epetra_CrsMatrix* mat,
int numRows, const int* rows,
int numCols, const int* cols,
const double* const* values,
bool sum_into)
{
if (sum_into) {
for(int i=0; i<numRows; ++i) {
int err = mat->SumIntoGlobalValues(rows[i], numCols,
(double*)values[i],
(int*)cols);
if (err != 0) {
return(err);
}
}
}
else {
for(int i=0; i<numRows; ++i) {
int err = mat->ReplaceGlobalValues(rows[i], numCols,
(double*)values[i],
(int*)cols);
if (err != 0) {
return(err);
}
}
}
return(0);
}
static int globalAssemble(Epetra_CrsMatrix* mat)
{
if (!mat->Filled()) {
int err = mat->FillComplete();
if (err != 0) {
FEI_CERR << "MatrixTraits<Epetra_CrsMatrix>::globalAssemble"
<< " ERROR in mat->FillComplete" << FEI_ENDL;
return(-1);
}
}
if (!mat->StorageOptimized()) {
mat->OptimizeStorage();
}
return( 0 );
}
static int matvec(Epetra_CrsMatrix* mat,
fei::Vector* x,
fei::Vector* y)
{
fei::Vector_Impl<Epetra_MultiVector>* evx =
dynamic_cast<fei::Vector_Impl<Epetra_MultiVector>* >(x);
fei::Vector_Impl<Epetra_MultiVector>* evy =
dynamic_cast<fei::Vector_Impl<Epetra_MultiVector>* >(y);
if (evx == NULL || evy == NULL) {
return(-1);
}
Epetra_MultiVector* ex = evx->getUnderlyingVector();
Epetra_MultiVector* ey = evy->getUnderlyingVector();
return( mat->Multiply(false, *ex, *ey) );
}
};//struct MatrixTraits<Epetra_CrsMatrix>
}//namespace fei
namespace snl_fei {
/** Declare an Epetra_VbrMatrix specialization of the
snl_fei::BlockMatrixTraits struct.
This allows Epetra_VbrMatrix to be used as the template parameter
for the fei::Matrix class.
*/
template<>
struct BlockMatrixTraits<Epetra_VbrMatrix> {
static const char* typeName()
{ return("Epetra_VbrMatrix"); }
static int putScalar(Epetra_VbrMatrix* mat, double scalar)
{
return( mat->PutScalar(scalar) );
}
static int getRowLength(Epetra_VbrMatrix* mat, int row, int& length)
{
length = mat->NumGlobalBlockEntries(row);
return(0);
}
static int getPointRowLength(Epetra_VbrMatrix* mat, int row, int& length)
{
const Epetra_Map& map = mat->RowMatrixRowMap();
int minLocalRow = map.MinMyGID();
int localRow = row - minLocalRow;
int error = mat->NumMyRowEntries(localRow, length);
return(error);
}
static int copyOutRow(Epetra_VbrMatrix* mat,
int row, int numBlkCols,
int rowDim,
int* blkCols,
int* colDims,
double* coefs,
int coefsLen,
int& blkRowLength)
{
int checkRowDim;
int error = mat->BeginExtractGlobalBlockRowCopy(row, numBlkCols,
checkRowDim,
blkRowLength,
blkCols, colDims);
if (error != 0 || checkRowDim != rowDim || blkRowLength != numBlkCols) {
return(error);
}
int offset = 0;
for(int i=0; i<numBlkCols; ++i) {
if (offset >= coefsLen) {
cerr << "BlockMatrixTraits::copyOutRow ran off end of coefs array."
<< endl;
return(-2);
}
int numValues = rowDim*colDims[i];
error = mat->ExtractEntryCopy(numValues, &(coefs[offset]),
rowDim, false);
if (error != 0) {
return(error);
}
offset += numValues;
}
return(0);
}
static int copyOutPointRow(Epetra_VbrMatrix* mat,
int firstLocalOffset,
int row,
int len,
double* coefs,
int* indices,
int& rowLength)
{
int error = mat->ExtractMyRowCopy(row-firstLocalOffset,
len, rowLength,
coefs, indices);
const Epetra_Map& colmap = mat->RowMatrixColMap();
for(int i=0; i<len; ++i) {
indices[i] = colmap.GID(indices[i]);
}
return(error);
}
static int sumIn(Epetra_VbrMatrix* mat,
int blockRow,
int rowDim,
int numBlockCols,
const int* blockCols,
const int* colDims,
int LDA,
const double* values)
{
int err, *nc_cols = const_cast<int*>(blockCols);
double* nc_values = const_cast<double*>(values);
err = mat->BeginSumIntoGlobalValues(blockRow, numBlockCols, nc_cols);
if (err != 0) return(err);
int voffset = 0;
for(int j=0; j<numBlockCols; ++j) {
err = mat->SubmitBlockEntry(&(nc_values[voffset]), LDA,
rowDim, colDims[j]);
if (err != 0) return(err);
voffset += colDims[j]*LDA;
}
err = mat->EndSubmitEntries();
if (err != 0) return(err);
return(0);
}
static int copyIn(Epetra_VbrMatrix* mat,
int blockRow,
int rowDim,
int numBlockCols,
const int* blockCols,
const int* colDims,
int LDA,
const double* values)
{
int* nc_cols = const_cast<int*>(blockCols);
double* nc_values = const_cast<double*>(values);
int err = mat->BeginReplaceGlobalValues(blockRow, numBlockCols, nc_cols);
if (err != 0) return(err);
int voffset = 0;
for(int j=0; j<numBlockCols; ++j) {
err = mat->SubmitBlockEntry(&(nc_values[voffset]), LDA,
rowDim, colDims[j]);
if (err != 0) return(err);
voffset += colDims[j]*LDA;
}
err = mat->EndSubmitEntries();
if (err != 0) return(err);
return(0);
}
static int sumIn(Epetra_VbrMatrix* mat,
int row,
int rowDim,
int numCols,
const int* cols,
const int* LDAs,
const int* colDims,
const double* const* values)
{
int* nc_cols = const_cast<int*>(cols);
double** nc_values = const_cast<double**>(values);
int err = mat->BeginSumIntoGlobalValues(row,numCols,nc_cols);
if (err != 0) {
return(err);
}
for(int i=0; i<numCols; ++i) {
err = mat->SubmitBlockEntry(nc_values[i], LDAs[i], rowDim, colDims[i]);
if (err != 0) {
return(err);
}
}
err = mat->EndSubmitEntries();
return(err);
}
static int copyIn(Epetra_VbrMatrix* mat,
int row,
int rowDim,
int numCols,
const int* cols,
const int* LDAs,
const int* colDims,
const double* const* values)
{
int* nc_cols = const_cast<int*>(cols);
double** nc_values = const_cast<double**>(values);
int err = mat->BeginReplaceGlobalValues(row, numCols, nc_cols);
if (err != 0) return(err);
for(int i=0; i<numCols; ++i) {
err = mat->SubmitBlockEntry(nc_values[i], LDAs[i], rowDim, colDims[i]);
if (err != 0) return(err);
}
err = mat->EndSubmitEntries();
return(err);
}
static int globalAssemble(Epetra_VbrMatrix* mat)
{
return( mat->FillComplete() );
}
};//struct BlockMatrixTraits<Epetra_VbrMatrix>
}//namespace snl_fei
#endif //HAVE_FEI_EPETRA
#endif // _fei_MatrixTraits_Epetra_hpp_
|