Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_MatrixAdapter_def.hpp
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Amesos2: Templated Direct Sparse Solver Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 //
42 // @HEADER
43 
44 
45 #ifndef AMESOS2_MATRIXADAPTER_DEF_HPP
46 #define AMESOS2_MATRIXADAPTER_DEF_HPP
47 #include <Tpetra_Util.hpp>
48 #include "Amesos2_MatrixAdapter_decl.hpp"
49 #include "Amesos2_ConcreteMatrixAdapter_def.hpp"
50 //#include "Amesos2_ConcreteMatrixAdapter.hpp"
51 
52 
53 namespace Amesos2 {
54 
55 
56  template < class Matrix >
57  MatrixAdapter<Matrix>::MatrixAdapter(const Teuchos::RCP<Matrix> m)
58  : mat_(m)
59  {
60  comm_ = static_cast<const adapter_t*>(this)->getComm_impl();
61  col_map_ = static_cast<const adapter_t*>(this)->getColMap_impl();
62  row_map_ = static_cast<const adapter_t*>(this)->getRowMap_impl();
63  }
64 
65  template < class Matrix >
66  void
67  MatrixAdapter<Matrix>::getCrs(const Teuchos::ArrayView<scalar_t> nzval,
68  const Teuchos::ArrayView<global_ordinal_t> colind,
69  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> rowptr,
70  typename MatrixAdapter<Matrix>::global_size_t& nnz,
71  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> > rowmap,
72  EStorage_Ordering ordering,
73  EDistribution distribution) const
74  {
75  help_getCrs(nzval, colind, rowptr,
76  nnz, rowmap, distribution, ordering,
77  typename adapter_t::get_crs_spec());
78  }
79 
80  template < class Matrix >
81  void
82  MatrixAdapter<Matrix>::getCrs(const Teuchos::ArrayView<scalar_t> nzval,
83  const Teuchos::ArrayView<global_ordinal_t> colind,
84  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> rowptr,
85  typename MatrixAdapter<Matrix>::global_size_t& nnz,
86  EDistribution distribution,
87  EStorage_Ordering ordering) const
88  {
89  const Teuchos::RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap
90  = Util::getDistributionMap<local_ordinal_t,global_ordinal_t,global_size_t,node_t>(distribution,
91  this->getGlobalNumRows(),
92  this->getComm());
93  this->getCrs(nzval, colind, rowptr, nnz, Teuchos::ptrInArg(*rowmap), ordering, distribution);
94  }
95 
96  template < class Matrix >
97  void
98  MatrixAdapter<Matrix>::getCcs(const Teuchos::ArrayView<scalar_t> nzval,
99  const Teuchos::ArrayView<global_ordinal_t> rowind,
100  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> colptr,
101  typename MatrixAdapter<Matrix>::global_size_t& nnz,
102  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> > colmap,
103  EStorage_Ordering ordering,
104  EDistribution distribution) const
105  {
106  help_getCcs(nzval, rowind, colptr,
107  nnz, colmap, distribution, ordering,
108  typename adapter_t::get_ccs_spec());
109  }
110 
111  template < class Matrix >
112  void
113  MatrixAdapter<Matrix>::getCcs(const Teuchos::ArrayView<scalar_t> nzval,
114  const Teuchos::ArrayView<global_ordinal_t> rowind,
115  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> colptr,
116  typename MatrixAdapter<Matrix>::global_size_t& nnz,
117  EDistribution distribution,
118  EStorage_Ordering ordering) const
119  {
120  const Teuchos::RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap
121  = Util::getDistributionMap<local_ordinal_t,global_ordinal_t,global_size_t,node_t>(distribution,
122  this->getGlobalNumCols(),
123  this->getComm());
124  this->getCcs(nzval, rowind, colptr, nnz, Teuchos::ptrInArg(*colmap), ordering, distribution);
125  }
126 
127  template < class Matrix >
128  typename MatrixAdapter<Matrix>::global_size_t
130  {
131  return static_cast<const adapter_t*>(this)->getGlobalNumRows_impl();
132  }
133 
134  template < class Matrix >
135  typename MatrixAdapter<Matrix>::global_size_t
137  {
138  return static_cast<const adapter_t*>(this)->getGlobalNumCols_impl();
139  }
140 
141  template < class Matrix >
142  typename MatrixAdapter<Matrix>::global_size_t
144  {
145  return row_map_->getIndexBase();
146  }
147 
148  template < class Matrix >
149  typename MatrixAdapter<Matrix>::global_size_t
151  {
152  return col_map_->getIndexBase();
153  }
154 
155  template < class Matrix >
156  typename MatrixAdapter<Matrix>::global_size_t
158  {
159  return static_cast<const adapter_t*>(this)->getGlobalNNZ_impl();
160  }
161 
162  template < class Matrix >
163  size_t
165  {
166  return row_map_->getNodeNumElements(); // TODO: verify
167  }
168 
169  template < class Matrix >
170  size_t
172  {
173  return col_map_->getNodeNumElements();
174  }
175 
176  template < class Matrix >
177  size_t
179  {
180  return static_cast<const adapter_t*>(this)->getLocalNNZ_impl();
181  }
182 
183  // NDE: This is broken for Epetra_CrsMatrix
184  template < class Matrix >
185  std::string
187  {
188  std::ostringstream oss;
189  oss << "Amesos2::MatrixAdapter wrapping: ";
190  oss << mat_->description(); // NDE: This is not defined in Epetra_CrsMatrix, only in Tpetra::CrsMatrix
191  return oss.str();
192  }
193 
194  template < class Matrix >
195  void
196  MatrixAdapter<Matrix>::describe(Teuchos::FancyOStream &out,
197  const Teuchos::EVerbosityLevel verbLevel) const
198  {}
199 
200  template < class Matrix >
201  typename MatrixAdapter<Matrix>::spmtx_ptr_t
203  {
204  return static_cast<const adapter_t*>(this)->getSparseRowPtr();
205  }
206 
207  template < class Matrix >
208  typename MatrixAdapter<Matrix>::spmtx_idx_t
210  {
211  return static_cast<const adapter_t*>(this)->getSparseColInd();
212  }
213 
214  template < class Matrix >
215  typename MatrixAdapter<Matrix>::spmtx_vals_t
217  {
218  return static_cast<const adapter_t*>(this)->getSparseValues();
219  }
220 
221 
222  /******************************
223  * Private method definitions *
224  ******************************/
225 
226  template < class Matrix >
227  void
228  MatrixAdapter<Matrix>::help_getCrs(const Teuchos::ArrayView<scalar_t> nzval,
229  const Teuchos::ArrayView<global_ordinal_t> colind,
230  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> rowptr,
231  typename MatrixAdapter<Matrix>::global_size_t& nnz,
232  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
233  EDistribution distribution,
234  EStorage_Ordering ordering,
235  has_special_impl) const
236  {
237  static_cast<const adapter_t*>(this)->getCrs_spec(nzval, colind, rowptr,
238  nnz, rowmap, ordering);
239  }
240 
241  template < class Matrix >
242  void
243  MatrixAdapter<Matrix>::help_getCrs(const Teuchos::ArrayView<scalar_t> nzval,
244  const Teuchos::ArrayView<global_ordinal_t> colind,
245  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> rowptr,
246  typename MatrixAdapter<Matrix>::global_size_t& nnz,
247  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
248  EDistribution distribution,
249  EStorage_Ordering ordering,
250  no_special_impl nsi) const
251  {
252 
253  //Added void to remove parameter not used warning
254  ((void)nsi);
255  do_getCrs(nzval, colind, rowptr,
256  nnz, rowmap, distribution, ordering,
257  typename adapter_t::major_access());
258  }
259 
260  template < class Matrix >
261  void
262  MatrixAdapter<Matrix>::do_getCrs(const Teuchos::ArrayView<scalar_t> nzval,
263  const Teuchos::ArrayView<global_ordinal_t> colind,
264  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> rowptr,
265  typename MatrixAdapter<Matrix>::global_size_t& nnz,
266  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
267  EDistribution distribution,
268  EStorage_Ordering ordering,
269  row_access ra) const
270  {
271  using Teuchos::rcp;
272  using Teuchos::RCP;
273  using Teuchos::ArrayView;
274  using Teuchos::OrdinalTraits;
275 
276 
277  ((void) ra);
278 
279  RCP<const type> get_mat;
280  if( *rowmap == *this->row_map_ && distribution != CONTIGUOUS_AND_ROOTED ){
281  // No need to redistribute
282  get_mat = rcp(this,false); // non-owning
283  } else {
284  get_mat = get(rowmap, distribution);
285  }
286  // RCP<const type> get_mat = get(rowmap);
287 
288  // rmap may not necessarily check same as rowmap because rmap may
289  // have been constructued with Tpetra's "expert" constructor,
290  // which assumes that the map points are non-contiguous.
291  //
292  // TODO: There may be some more checking between the row map
293  // compatibility, but things are working fine now.
294 
295  RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rmap = get_mat->getRowMap();
296  ArrayView<const global_ordinal_t> node_elements = rmap->getNodeElementList();
297  if( node_elements.size() == 0 ) return; // no more contribution
298 
299  typename ArrayView<const global_ordinal_t>::iterator row_it, row_end;
300  row_end = node_elements.end();
301 
302  size_t rowptr_ind = OrdinalTraits<size_t>::zero();
303  global_ordinal_t rowInd = OrdinalTraits<global_ordinal_t>::zero();
304  for( row_it = node_elements.begin(); row_it != row_end; ++row_it ){
305  rowptr[rowptr_ind++] = rowInd;
306  size_t rowNNZ = get_mat->getGlobalRowNNZ(*row_it);
307  size_t nnzRet = OrdinalTraits<size_t>::zero();
308  ArrayView<global_ordinal_t> colind_view = colind.view(rowInd,rowNNZ);
309  ArrayView<scalar_t> nzval_view = nzval.view(rowInd,rowNNZ);
310 
311  get_mat->getGlobalRowCopy(*row_it, colind_view, nzval_view, nnzRet);
312  for (size_t rr = 0; rr < nnzRet ; rr++)
313  {
314  colind_view[rr] = colind_view[rr] - rmap->getIndexBase();
315  }
316 
317  // It was suggested that instead of sorting each row's indices
318  // individually, that we instead do a double-transpose at the
319  // end, which would also lead to the indices being sorted.
320  if( ordering == SORTED_INDICES ){
321  Tpetra::sort2(colind_view.begin(), colind_view.end(), nzval_view.begin());
322  }
323 
324  TEUCHOS_TEST_FOR_EXCEPTION( rowNNZ != nnzRet,
325  std::runtime_error,
326  "Number of values returned different from "
327  "number of values reported");
328  rowInd += rowNNZ;
329  }
330  rowptr[rowptr_ind] = nnz = rowInd;
331  }
332 
333  // TODO: This may not work with distributed matrices.
334  template < class Matrix >
335  void
336  MatrixAdapter<Matrix>::do_getCrs(const Teuchos::ArrayView<scalar_t> nzval,
337  const Teuchos::ArrayView<global_ordinal_t> colind,
338  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> rowptr,
339  typename MatrixAdapter<Matrix>::global_size_t& nnz,
340  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
341  EDistribution distribution,
342  EStorage_Ordering ordering,
343  col_access ca) const
344  {
345  using Teuchos::Array;
346  // get the ccs and transpose
347 
348  Array<scalar_t> nzval_tmp(nzval.size(), 0);
349  Array<global_ordinal_t> rowind(colind.size(), 0);
350  Array<global_size_t> colptr(this->getGlobalNumCols() + 1);
351  this->getCcs(nzval_tmp(), rowind(), colptr(), nnz, rowmap, ordering, distribution);
352 
353  if( !nzval.is_null() && !colind.is_null() && !rowptr.is_null() )
354  Util::transpose(nzval_tmp(), rowind(), colptr(), nzval, colind, rowptr);
355  }
356 
357  template < class Matrix >
358  void
359  MatrixAdapter<Matrix>::help_getCcs(const Teuchos::ArrayView<scalar_t> nzval,
360  const Teuchos::ArrayView<global_ordinal_t> rowind,
361  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> colptr,
362  typename MatrixAdapter<Matrix>::global_size_t& nnz,
363  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
364  EDistribution distribution,
365  EStorage_Ordering ordering,
366  has_special_impl) const
367  {
368  static_cast<const adapter_t*>(this)->getCcs_spec(nzval, rowind, colptr,
369  nnz, colmap, ordering);
370  }
371 
372  template < class Matrix >
373  void
374  MatrixAdapter<Matrix>::help_getCcs(const Teuchos::ArrayView<scalar_t> nzval,
375  const Teuchos::ArrayView<global_ordinal_t> rowind,
376  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> colptr,
377  typename MatrixAdapter<Matrix>::global_size_t& nnz,
378  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
379  EDistribution distribution,
380  EStorage_Ordering ordering,
381  no_special_impl nsi) const
382  {
383  ((void)nsi);
384 
385  do_getCcs(nzval, rowind, colptr,
386  nnz, colmap, distribution, ordering,
387  typename adapter_t::major_access());
388  }
389 
390  template < class Matrix >
391  void
392  MatrixAdapter<Matrix>::do_getCcs(const Teuchos::ArrayView<scalar_t> nzval,
393  const Teuchos::ArrayView<global_ordinal_t> rowind,
394  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> colptr,
395  typename MatrixAdapter<Matrix>::global_size_t& nnz,
396  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
397  EDistribution distribution,
398  EStorage_Ordering ordering,
399  row_access ra) const
400  {
401  using Teuchos::Array;
402  // get the crs and transpose
403 
404  ((void) ra);
405 
406  Array<scalar_t> nzval_tmp(nzval.size(), 0);
407  Array<global_ordinal_t> colind(rowind.size(), 0);
408  Array<global_size_t> rowptr(this->getGlobalNumRows() + 1);
409  this->getCrs(nzval_tmp(), colind(), rowptr(), nnz, colmap, ordering, distribution);
410 
411  if( !nzval.is_null() && !rowind.is_null() && !colptr.is_null() )
412  Util::transpose(nzval_tmp(), colind(), rowptr(), nzval, rowind, colptr);
413  }
414 
415  template < class Matrix >
416  void
417  MatrixAdapter<Matrix>::do_getCcs(const Teuchos::ArrayView<scalar_t> nzval,
418  const Teuchos::ArrayView<global_ordinal_t> rowind,
419  const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> colptr,
420  typename MatrixAdapter<Matrix>::global_size_t& nnz,
421  const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
422  EDistribution distribution,
423  EStorage_Ordering ordering,
424  col_access ca) const
425  {
426  using Teuchos::RCP;
427  using Teuchos::ArrayView;
428  using Teuchos::OrdinalTraits;
429 
430  RCP<const type> get_mat;
431  if( *colmap == *this->col_map_ && distribution != CONTIGUOUS_AND_ROOTED ){
432  // No need to redistribute
433  get_mat = rcp(this,false); // non-owning
434  } else {
435  get_mat = get(colmap, distribution);
436  }
437 
438  // If all is well and good, then colmap == cmap
439  RCP<const Tpetra::Map<scalar_t,local_ordinal_t,global_ordinal_t> > cmap = get_mat->getColMap();
440  TEUCHOS_ASSERT( *colmap == *cmap );
441 
442  ArrayView<global_ordinal_t> node_elements = cmap->getNodeElementList();
443  if( node_elements.size() == 0 ) return; // no more contribution
444 
445  typename ArrayView<global_ordinal_t>::iterator col_it, col_end;
446  col_end = node_elements.end();
447 
448  size_t colptr_ind = OrdinalTraits<size_t>::zero();
449  global_ordinal_t colInd = OrdinalTraits<global_ordinal_t>::zero();
450  for( col_it = node_elements.begin(); col_it != col_end; ++col_it ){
451  colptr[colptr_ind++] = colInd;
452  size_t colNNZ = getGlobalColNNZ(*col_it);
453  size_t nnzRet = 0;
454  ArrayView<global_ordinal_t> rowind_view = rowind.view(colInd,colNNZ);
455  ArrayView<scalar_t> nzval_view = nzval.view(colInd,colNNZ);
456  getGlobalColCopy(*col_it, rowind_view, nzval_view, nnzRet);
457 
458  // It was suggested that instead of sorting each row's indices
459  // individually, that we instead do a double-transpose at the
460  // end, which would also lead to the indices being sorted.
461  if( ordering == SORTED_INDICES ){
462  Tpetra::sort2(rowind_view.begin(), rowind_view.end(), nzval_view.begin());
463  }
464 
465  TEUCHOS_TEST_FOR_EXCEPTION( colNNZ != nnzRet,
466  std::runtime_error,
467  "Number of values returned different from "
468  "number of values reported");
469  colInd += colNNZ;
470  }
471  colptr[colptr_ind] = nnz = colInd;
472  }
473 
474 
475  // These will link to concrete implementations
476  template < class Matrix >
477  void
479  const Teuchos::ArrayView<global_ordinal_t>& indices,
480  const Teuchos::ArrayView<scalar_t>& vals,
481  size_t& nnz) const
482  {
483  static_cast<const adapter_t*>(this)->getGlobalRowCopy_impl(row, indices, vals, nnz);
484  }
485 
486  template < class Matrix >
487  void
489  const Teuchos::ArrayView<global_ordinal_t>& indices,
490  const Teuchos::ArrayView<scalar_t>& vals,
491  size_t& nnz) const
492  {
493  static_cast<const adapter_t*>(this)->getGlobalColCopy_impl(col, indices, vals, nnz);
494  }
495 
496  template < class Matrix >
497  size_t
499  {
500  return static_cast<const adapter_t*>(this)->getMaxRowNNZ_impl();
501  }
502 
503  template < class Matrix >
504  size_t
505  MatrixAdapter<Matrix>::getMaxColNNZ() const
506  {
507  return static_cast<const adapter_t*>(this)->getMaxColNNZ_impl();
508  }
509 
510  template < class Matrix >
511  size_t
512  MatrixAdapter<Matrix>::getGlobalRowNNZ(global_ordinal_t row) const
513  {
514  return static_cast<const adapter_t*>(this)->getGlobalRowNNZ_impl(row);
515  }
516 
517  template < class Matrix >
518  size_t
519  MatrixAdapter<Matrix>::getLocalRowNNZ(local_ordinal_t row) const
520  {
521  return static_cast<const adapter_t*>(this)->getLocalRowNNZ_impl(row);
522  }
523 
524  template < class Matrix >
525  size_t
526  MatrixAdapter<Matrix>::getGlobalColNNZ(global_ordinal_t col) const
527  {
528  return static_cast<const adapter_t*>(this)->getGlobalColNNZ_impl(col);
529  }
530 
531  template < class Matrix >
532  size_t
533  MatrixAdapter<Matrix>::getLocalColNNZ(local_ordinal_t col) const
534  {
535  return static_cast<const adapter_t*>(this)->getLocalColNNZ_impl(col);
536  }
537 
538  template < class Matrix >
539  bool
540  MatrixAdapter<Matrix>::isLocallyIndexed() const
541  {
542  return static_cast<const adapter_t*>(this)->isLocallyIndexed_impl();
543  }
544 
545  template < class Matrix >
546  bool
547  MatrixAdapter<Matrix>::isGloballyIndexed() const
548  {
549  return static_cast<const adapter_t*>(this)->isGloballyIndexed_impl();
550  }
551 
552 
553  template < class Matrix >
554  Teuchos::RCP<const MatrixAdapter<Matrix> >
555  MatrixAdapter<Matrix>::get(const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map, EDistribution distribution) const
556  {
557  return static_cast<const adapter_t*>(this)->get_impl(map, distribution);
558  }
559 
560 
561  template <class Matrix>
562  Teuchos::RCP<MatrixAdapter<Matrix> >
563  createMatrixAdapter(Teuchos::RCP<Matrix> m){
564  using Teuchos::rcp;
565  using Teuchos::rcp_const_cast;
566 
567  if(m.is_null()) return Teuchos::null;
568  return( rcp(new ConcreteMatrixAdapter<Matrix>(m)) );
569  }
570 
571  template <class Matrix>
572  Teuchos::RCP<const MatrixAdapter<Matrix> >
573  createConstMatrixAdapter(Teuchos::RCP<const Matrix> m){
574  using Teuchos::rcp;
575  using Teuchos::rcp_const_cast;
576 
577  if(m.is_null()) return Teuchos::null;
578  return( rcp(new ConcreteMatrixAdapter<Matrix>(rcp_const_cast<Matrix,const Matrix>(m))).getConst() );
579  }
580 
581 } // end namespace Amesos2
582 
583 #endif // AMESOS2_MATRIXADAPTER_DEF_HPP
EStorage_Ordering
Definition: Amesos2_TypeDecl.hpp:141
Indicates that the concrete class has a special implementation that should be called.
Definition: Amesos2_TypeDecl.hpp:82
void transpose(ArrayView< Scalar > vals, ArrayView< GlobalOrdinal > indices, ArrayView< GlobalSizeT > ptr, ArrayView< Scalar > trans_vals, ArrayView< GlobalOrdinal > trans_indices, ArrayView< GlobalSizeT > trans_ptr)
std::string description() const
Returns a short description of this Solver.
Definition: Amesos2_MatrixAdapter_def.hpp:186
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
EDistribution
Definition: Amesos2_TypeDecl.hpp:123