All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Xpetra_CrsMatrixFactory.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 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
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_CRSMATRIXFACTORY_HPP
47 #define XPETRA_CRSMATRIXFACTORY_HPP
48 
49 #include "Xpetra_ConfigDefs.hpp"
50 
51 #include "Xpetra_CrsMatrix.hpp"
52 
53 #ifdef HAVE_XPETRA_TPETRA
54 #include "Xpetra_TpetraCrsMatrix.hpp"
55 #endif
56 
57 #ifdef HAVE_XPETRA_EPETRA
59 #endif
60 
61 #include "Xpetra_Exceptions.hpp"
62 
63 namespace Xpetra {
64 
65  template <class Scalar /*= CrsMatrix<>::scalar_type*/,
66  class LocalOrdinal /*=
67  typename CrsMatrix<Scalar>::local_ordinal_type*/,
68  class GlobalOrdinal /*=
69  typename CrsMatrix<Scalar, LocalOrdinal>::global_ordinal_type*/,
70  class Node /*=
71  typename CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal>::node_type*/>
73  private:
76 
77  public:
81  size_t maxNumEntriesPerRow,
83  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null)
84  {
85  XPETRA_MONITOR("CrsMatrixFactory::Build");
86 
87 #ifdef HAVE_XPETRA_TPETRA
88  if (rowMap->lib() == UseTpetra)
89  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, maxNumEntriesPerRow, pftype, plist) );
90 #endif
91 
92  XPETRA_FACTORY_ERROR_IF_EPETRA(rowMap->lib());
94  }
95 
99  const ArrayRCP<const size_t>& NumEntriesPerRowToAlloc,
101  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null)
102  {
103 #ifdef HAVE_XPETRA_TPETRA
104  if (rowMap->lib() == UseTpetra)
105  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, NumEntriesPerRowToAlloc, pftype, plist) );
106 #endif
107 
108  XPETRA_FACTORY_ERROR_IF_EPETRA(rowMap->lib());
110  }
111 
116  size_t maxNumEntriesPerRow,
117  ProfileType pftype = DynamicProfile,
118  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null)
119  {
120  XPETRA_MONITOR("CrsMatrixFactory::Build");
121 
122 #ifdef HAVE_XPETRA_TPETRA
123  if (rowMap->lib() == UseTpetra)
124  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, maxNumEntriesPerRow, pftype, plist) );
125 #endif
126 
127  XPETRA_FACTORY_ERROR_IF_EPETRA(rowMap->lib());
129  }
130 
133  XPETRA_MONITOR("CrsMatrixFactory::Build");
134 
135 #ifdef HAVE_XPETRA_TPETRA
136  if (rowMap->lib() == UseTpetra)
137  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, NumEntriesPerRowToAlloc, pftype, plist) );
138 #endif
139 
140  XPETRA_FACTORY_ERROR_IF_EPETRA(rowMap->lib());
142  }
143 
146  XPETRA_MONITOR("CrsMatrixFactory::Build");
147 
148 #ifdef HAVE_XPETRA_TPETRA
149  if (graph->getRowMap()->lib() == UseTpetra)
151 #endif
152 
153  XPETRA_FACTORY_ERROR_IF_EPETRA(graph->getRowMap()->lib());
155  }
156 
157 
161  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
162  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
163  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
164  XPETRA_MONITOR("CrsMatrixFactory::Build");
165 
166 #ifdef HAVE_XPETRA_TPETRA
167  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
168  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,importer,domainMap,rangeMap,params));
169 #endif
170 
171  XPETRA_FACTORY_ERROR_IF_EPETRA(sourceMatrix->getRowMap()->lib());
173  }
174 
178  const RCP<Map<LocalOrdinal,GlobalOrdinal,Scalar> > & domainMap = Teuchos::null,
179  const RCP<Map<LocalOrdinal,GlobalOrdinal,Scalar> > & rangeMap = Teuchos::null,
180  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
181  XPETRA_MONITOR("CrsMatrixFactory::Build");
182 
183 #ifdef HAVE_XPETRA_TPETRA
184  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
185  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,exporter,domainMap,rangeMap,params));
186 #endif
187 
188  XPETRA_FACTORY_ERROR_IF_EPETRA(sourceMatrix->getRowMap()->lib());
190  }
191 
194  const Import<LocalOrdinal,GlobalOrdinal,Node> &RowImporter,
195  const RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > DomainImporter,
196  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap,
197  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
198  const Teuchos::RCP<Teuchos::ParameterList>& params) {
199  XPETRA_MONITOR("CrsMatrixFactory::Build");
200 
201 #ifdef HAVE_XPETRA_TPETRA
202  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
203  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,RowImporter,DomainImporter,domainMap,rangeMap,params));
204 #endif
205 
206  XPETRA_FACTORY_ERROR_IF_EPETRA(sourceMatrix->getRowMap()->lib());
208  }
209 
212  const Export<LocalOrdinal,GlobalOrdinal,Node> &RowExporter,
213  const RCP<const Export<LocalOrdinal,GlobalOrdinal,Node> > DomainExporter,
214  const RCP<Map<LocalOrdinal,GlobalOrdinal,Scalar> > & domainMap,
215  const RCP<Map<LocalOrdinal,GlobalOrdinal,Scalar> > & rangeMap,
216  const Teuchos::RCP<Teuchos::ParameterList>& params) {
217  XPETRA_MONITOR("CrsMatrixFactory::Build");
218 
219 #ifdef HAVE_XPETRA_TPETRA
220  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
221  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,RowExporter,DomainExporter,domainMap,rangeMap,params));
222 #endif
223 
224  XPETRA_FACTORY_ERROR_IF_EPETRA(sourceMatrix->getRowMap()->lib());
226  }
227 
228 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
233  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
234  XPETRA_MONITOR("CrsMatrixFactory::Build");
235 
236 #ifdef HAVE_XPETRA_TPETRA
237  if (rowMap->lib() == UseTpetra)
238  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, lclMatrix, params));
239 #endif
240 
241  XPETRA_FACTORY_ERROR_IF_EPETRA(rowMap->lib());
243  }
244  static RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Build (
246  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& rowMap,
247  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& colMap,
248  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& domainMap = Teuchos::null,
249  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& rangeMap = Teuchos::null,
250  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
251  XPETRA_MONITOR("CrsMatrixFactory::Build");
252 
253 #ifdef HAVE_XPETRA_TPETRA
254  if (rowMap->lib() == UseTpetra)
255  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(lclMatrix, rowMap, colMap, domainMap, rangeMap, params));
256 #endif
257 
258  XPETRA_FACTORY_ERROR_IF_EPETRA(rowMap->lib());
260  }
261 #endif
262 
263  };
264 
265 // we need the Epetra specialization only if Epetra is enabled
266 #if (defined(HAVE_XPETRA_EPETRA) && !defined(XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES))
267 
268  // Specializtion for SC=double, LO=int, GO=int and Node=EpetraNode
269  // Used both for Epetra and Tpetra
270  template <>
271  class CrsMatrixFactory<double, int, int, EpetraNode> {
272  typedef double Scalar;
273  typedef int LocalOrdinal;
274  typedef int GlobalOrdinal;
275  typedef EpetraNode Node;
276 
277  private:
280 
281  public:
282 
284  XPETRA_MONITOR("CrsMatrixFactory::Build");
285 
286 #ifdef HAVE_XPETRA_TPETRA
287  if (rowMap->lib() == UseTpetra)
288  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, maxNumEntriesPerRow, pftype, plist) );
289 #endif
290 
291  if (rowMap->lib() == UseEpetra)
292  return rcp( new EpetraCrsMatrixT<int,Node>(rowMap, maxNumEntriesPerRow, pftype, plist) );
293 
295  }
296 
298  XPETRA_MONITOR("CrsMatrixFactory::Build");
299 
300 #ifdef HAVE_XPETRA_TPETRA
301  if (rowMap->lib() == UseTpetra)
302  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, NumEntriesPerRowToAlloc, pftype, plist) );
303 #endif
304 
305  if (rowMap->lib() == UseEpetra)
306  return rcp( new EpetraCrsMatrixT<int,Node>(rowMap, NumEntriesPerRowToAlloc, pftype, plist) );
307 
309  }
310 
313  XPETRA_MONITOR("CrsMatrixFactory::Build");
314 
315 #ifdef HAVE_XPETRA_TPETRA
316  if (rowMap->lib() == UseTpetra)
317  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, maxNumEntriesPerRow, pftype, plist) );
318 #endif
319 
320  if (rowMap->lib() == UseEpetra)
321  return rcp( new EpetraCrsMatrixT<int,Node>(rowMap, colMap, maxNumEntriesPerRow, pftype, plist) );
322 
324  }
325 
328  XPETRA_MONITOR("CrsMatrixFactory::Build");
329 
330 #ifdef HAVE_XPETRA_TPETRA
331  if (rowMap->lib() == UseTpetra)
332  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, NumEntriesPerRowToAlloc, pftype, plist) );
333 #endif
334 
335  if (rowMap->lib() == UseEpetra)
336  return rcp( new EpetraCrsMatrixT<int,Node>(rowMap, colMap, NumEntriesPerRowToAlloc, pftype, plist) );
337 
339  }
340 
343  XPETRA_MONITOR("CrsMatrixFactory::Build");
344 
345 #ifdef HAVE_XPETRA_TPETRA
346  if (graph->getRowMap()->lib() == UseTpetra)
348 #endif
349 
350  if (graph->getRowMap()->lib() == UseEpetra)
351  return rcp( new EpetraCrsMatrixT<int,Node>(graph, plist) );
352 
354  }
355 
356 
361  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
362  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
363  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
364  XPETRA_MONITOR("CrsMatrixFactory::Build");
365 
366 #ifdef HAVE_XPETRA_TPETRA
367  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
368  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,importer,domainMap,rangeMap,params) );
369 #endif
370 
371  if (sourceMatrix->getRowMap()->lib() == UseEpetra)
372  return rcp( new EpetraCrsMatrixT<int,Node>(sourceMatrix,importer,domainMap,rangeMap,params) );
373 
375  }
376 
381  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
382  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
383  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
384  XPETRA_MONITOR("CrsMatrixFactory::Build");
385 
386 #ifdef HAVE_XPETRA_TPETRA
387  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
388  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,exporter,domainMap,rangeMap,params) );
389 #endif
390 
391  if (sourceMatrix->getRowMap()->lib() == UseEpetra)
392  return rcp( new EpetraCrsMatrixT<int,Node>(sourceMatrix,exporter,domainMap,rangeMap,params) );
393 
395  }
396 
400  const Import<LocalOrdinal,GlobalOrdinal,Node> & RowImporter,
401  const RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > DomainImporter,
402  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap,
403  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
404  const Teuchos::RCP<Teuchos::ParameterList>& params) {
405  XPETRA_MONITOR("CrsMatrixFactory::Build");
406 
407 #ifdef HAVE_XPETRA_TPETRA
408  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
409  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,RowImporter,DomainImporter,domainMap,rangeMap,params) );
410 #endif
411 
412  if (sourceMatrix->getRowMap()->lib() == UseEpetra)
413  return rcp( new EpetraCrsMatrixT<int,Node>(sourceMatrix,RowImporter,DomainImporter,domainMap,rangeMap,params) );
414 
416  }
417 
421  const Export<LocalOrdinal,GlobalOrdinal,Node> &RowExporter,
422  const RCP<const Export<LocalOrdinal,GlobalOrdinal,Node> > DomainExporter,
423  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap,
424  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
425  const Teuchos::RCP<Teuchos::ParameterList>& params) {
426  XPETRA_MONITOR("CrsMatrixFactory::Build");
427 
428 #ifdef HAVE_XPETRA_TPETRA
429  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
430  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,RowExporter,DomainExporter,domainMap,rangeMap,params) );
431 #endif
432 
433  if (sourceMatrix->getRowMap()->lib() == UseEpetra)
434  return rcp( new EpetraCrsMatrixT<int,Node>(sourceMatrix,RowExporter,DomainExporter,domainMap,rangeMap,params) );
435 
437  }
438 
439 
440 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
445  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
446  XPETRA_MONITOR("CrsMatrixFactory::Build");
447 
448 #ifdef HAVE_XPETRA_TPETRA
449  if (rowMap->lib() == UseTpetra)
450  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, lclMatrix, params));
451 #endif
452 
453  if (rowMap->lib() == UseEpetra)
454  return rcp( new EpetraCrsMatrixT<int,Node>(rowMap, colMap, lclMatrix, params) );
455 
457  }
458  static RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Build (
460  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& rowMap,
461  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& colMap,
462  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& domainMap = Teuchos::null,
463  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& rangeMap = Teuchos::null,
464  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
465  XPETRA_MONITOR("CrsMatrixFactory::Build");
466 
467 #ifdef HAVE_XPETRA_TPETRA
468  if (rowMap->lib() == UseTpetra)
469  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(lclMatrix, rowMap, colMap, domainMap, rangeMap, params));
470 #endif
471 
472  if (rowMap->lib() == UseEpetra)
473  return rcp( new EpetraCrsMatrixT<int,Node>(lclMatrix, rowMap, colMap, domainMap, rangeMap, params) );
474 
476  }
477 #endif
478 
479  };
480 #endif
481 
482 // we need the Epetra specialization only if Epetra is enabled
483 #if (defined(HAVE_XPETRA_EPETRA) && !defined(XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES))
484 
485  template <>
486  class CrsMatrixFactory<double, int, long long, EpetraNode> {
487  typedef double Scalar;
488  typedef int LocalOrdinal;
489  typedef long long GlobalOrdinal;
490  typedef EpetraNode Node;
491 
492  private:
495 
496  public:
497 
499  XPETRA_MONITOR("CrsMatrixFactory::Build");
500 
501 #ifdef HAVE_XPETRA_TPETRA
502  if (rowMap->lib() == UseTpetra)
503  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, maxNumEntriesPerRow, pftype, plist) );
504 #endif
505 
506  if (rowMap->lib() == UseEpetra)
507  return rcp( new EpetraCrsMatrixT<long long, Node>(rowMap, maxNumEntriesPerRow, pftype, plist) );
508 
510  }
511 
513  XPETRA_MONITOR("CrsMatrixFactory::Build");
514 
515 #ifdef HAVE_XPETRA_TPETRA
516  if (rowMap->lib() == UseTpetra)
517  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, NumEntriesPerRowToAlloc, pftype, plist) );
518 #endif
519 
520  if (rowMap->lib() == UseEpetra)
521  return rcp( new EpetraCrsMatrixT<long long, Node>(rowMap, NumEntriesPerRowToAlloc, pftype, plist) );
522 
524  }
525 
528  XPETRA_MONITOR("CrsMatrixFactory::Build");
529 
530 #ifdef HAVE_XPETRA_TPETRA
531  if (rowMap->lib() == UseTpetra)
532  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, maxNumEntriesPerRow, pftype, plist) );
533 #endif
534 
535  if (rowMap->lib() == UseEpetra)
536  return rcp( new EpetraCrsMatrixT<long long, Node>(rowMap, colMap, maxNumEntriesPerRow, pftype, plist) );
537 
539  }
540 
543  XPETRA_MONITOR("CrsMatrixFactory::Build");
544 
545 #ifdef HAVE_XPETRA_TPETRA
546  if (rowMap->lib() == UseTpetra)
547  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, NumEntriesPerRowToAlloc, pftype, plist) );
548 #endif
549 
550  if (rowMap->lib() == UseEpetra)
551  return rcp( new EpetraCrsMatrixT<long long, Node>(rowMap, colMap, NumEntriesPerRowToAlloc, pftype, plist) );
552 
554  }
555 
558  XPETRA_MONITOR("CrsMatrixFactory::Build");
559 
560 #ifdef HAVE_XPETRA_TPETRA
561  if (graph->getRowMap()->lib() == UseTpetra)
563 #endif
564 
565  if (graph->getRowMap()->lib() == UseEpetra)
566  return rcp( new EpetraCrsMatrixT<long long, Node>(graph, plist) );
567 
569  }
570 
571 
576  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
577  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
578  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
579  XPETRA_MONITOR("CrsMatrixFactory::Build");
580 
581 #ifdef HAVE_XPETRA_TPETRA
582  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
583  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,importer,domainMap,rangeMap,params) );
584 #endif
585 
586  if (sourceMatrix->getRowMap()->lib() == UseEpetra)
587  return rcp( new EpetraCrsMatrixT<long long, Node>(sourceMatrix,importer,domainMap,rangeMap,params) );
588 
590  }
591 
596  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
597  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
598  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
599  XPETRA_MONITOR("CrsMatrixFactory::Build");
600 
601 #ifdef HAVE_XPETRA_TPETRA
602  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
603  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,exporter,domainMap,rangeMap,params) );
604 #endif
605 
606  if (sourceMatrix->getRowMap()->lib() == UseEpetra)
607  return rcp( new EpetraCrsMatrixT<long long, Node>(sourceMatrix,exporter,domainMap,rangeMap,params) );
608 
610  }
611 
615  const Import<LocalOrdinal,GlobalOrdinal,Node> & RowImporter,
616  const RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > DomainImporter,
617  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap,
618  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
619  const Teuchos::RCP<Teuchos::ParameterList>& params) {
620  XPETRA_MONITOR("CrsMatrixFactory::Build");
621 
622 #ifdef HAVE_XPETRA_TPETRA
623  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
624  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,RowImporter,DomainImporter,domainMap,rangeMap,params) );
625 #endif
626 
627  if (sourceMatrix->getRowMap()->lib() == UseEpetra)
628  return rcp( new EpetraCrsMatrixT<long long,Node>(sourceMatrix,RowImporter,DomainImporter,domainMap,rangeMap,params) );
629 
631  }
632 
636  const Export<LocalOrdinal,GlobalOrdinal,Node> &RowExporter,
637  const RCP<const Export<LocalOrdinal,GlobalOrdinal,Node> > DomainExporter,
638  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap,
639  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
640  const Teuchos::RCP<Teuchos::ParameterList>& params) {
641  XPETRA_MONITOR("CrsMatrixFactory::Build");
642 
643 #ifdef HAVE_XPETRA_TPETRA
644  if (sourceMatrix->getRowMap()->lib() == UseTpetra)
645  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(sourceMatrix,RowExporter,DomainExporter,domainMap,rangeMap,params) );
646 #endif
647 
648  if (sourceMatrix->getRowMap()->lib() == UseEpetra)
649  return rcp( new EpetraCrsMatrixT<long long,Node>(sourceMatrix,RowExporter,DomainExporter,domainMap,rangeMap,params) );
650 
652  }
653 
654 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
659  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
660  XPETRA_MONITOR("CrsMatrixFactory::Build");
661 
662 #ifdef HAVE_XPETRA_TPETRA
663  if (rowMap->lib() == UseTpetra)
664  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(rowMap, colMap, lclMatrix, params));
665 #endif
666 
667  if (rowMap->lib() == UseEpetra)
668  return rcp( new EpetraCrsMatrixT<long long, Node>(rowMap, colMap, lclMatrix, params) );
669 
671  }
672  static RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Build (
674  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& rowMap,
675  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& colMap,
676  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& domainMap = Teuchos::null,
677  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& rangeMap = Teuchos::null,
678  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
679  XPETRA_MONITOR("CrsMatrixFactory::Build");
680 
681 #ifdef HAVE_XPETRA_TPETRA
682  if (rowMap->lib() == UseTpetra)
683  return rcp( new TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(lclMatrix, rowMap, colMap, domainMap, rangeMap, params));
684 #endif
685 
686  if (rowMap->lib() == UseEpetra)
687  return rcp( new EpetraCrsMatrixT<long long, Node>(lclMatrix, rowMap, colMap, domainMap, rangeMap, params) );
688 
690  }
691 #endif
692 
693  };
694 #endif
695 
696 }
697 
698 #define XPETRA_CRSMATRIXFACTORY_SHORT
699 #endif
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor using FusedExport.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor using FusedImport.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Constructor using FusedImport.
#define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying a previously constructed graph.
CrsMatrixFactory()
Private constructor. This is a static class.
CrsMatrixFactory()
Private constructor. This is a static class.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
CrsMatrixFactory()
Private constructor. This is a static class.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying a previously constructed graph.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const RCP< Map< LocalOrdinal, GlobalOrdinal, Scalar > > &domainMap=Teuchos::null, const RCP< Map< LocalOrdinal, GlobalOrdinal, Scalar > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
#define XPETRA_FACTORY_END
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Constructor using FusedExport.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor using FusedImport.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Constructor using FusedImport.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying a previously constructed graph.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Constructor using FusedExport.
#define XPETRA_MONITOR(funcName)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor using FusedExport.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const RCP< Map< LocalOrdinal, GlobalOrdinal, Scalar > > &domainMap, const RCP< Map< LocalOrdinal, GlobalOrdinal, Scalar > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.