Thyra Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraLinearOpTestHelpers.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
11 
12 
13 namespace {
14 
15 
16 RCP<Epetra_CrsMatrix> getEpetraMatrix(int numRows, int numCols, double shift=0.0)
17 {
18 
19  const RCP<const Epetra_Comm> comm = getEpetraComm();
20 
21  const Epetra_Map rowMap(numRows, 0, *comm);
22  const Epetra_Map domainMap(numCols, numCols, 0, *comm);
23 
24  const RCP<Epetra_CrsMatrix> epetraCrsM =
25  rcp(new Epetra_CrsMatrix(Copy, rowMap, numCols));
26 
27  Array<double> rowEntries(numCols);
28  Array<int> columnIndices(numCols);
29  for (int j = 0; j < numCols; ++j) {
30  columnIndices[j] = j;
31  }
32 
33  const int numLocalRows = rowMap.NumMyElements();
34 
35  for (int i = 0; i < numLocalRows; ++i) {
36 
37  for (int j = 0; j < numCols; ++j) {
38  rowEntries[j] = as<double>(i+1) + as<double>(j+1) / 10 + shift;
39  }
40 
41  epetraCrsM->InsertMyValues( i, numCols, &rowEntries[0], &columnIndices[0] );
42 
43  }
44 
45  epetraCrsM->FillComplete(domainMap, rowMap);
46 
47  return epetraCrsM;
48 }
49 
50 
51 } // namespace
52 
53 #if defined(Thyra_SHOW_DEPRECATED_WARNINGS)
54 #ifdef __GNUC__
55 #warning "The ThyraEpetraAdapters package is deprecated"
56 #endif
57 #endif
58 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)