42 #ifndef BELOS_TPETRA_ADAPTER_MP_VECTOR_HPP 43 #define BELOS_TPETRA_ADAPTER_MP_VECTOR_HPP 45 #include "BelosTpetraAdapter.hpp" 48 #include "KokkosBlas.hpp" 50 #ifdef HAVE_BELOS_TSQR 52 #endif // HAVE_BELOS_TSQR 72 template<
class Storage,
class LO,
class GO,
class Node>
74 Tpetra::MultiVector< Sacado::MP::Vector<Storage>,
80 typedef Tpetra::MultiVector<Scalar, LO, GO, Node>
MV;
82 typedef typename Tpetra::MultiVector<Scalar,LO,GO,Node>::dot_type
dot_type;
83 typedef typename Tpetra::MultiVector<Scalar,LO,GO,Node>::mag_type
mag_type;
90 static Teuchos::RCP<MV>
Clone (
const MV& X,
const int numVecs) {
91 Teuchos::RCP<MV> Y (
new MV (X.getMap (), numVecs,
false));
92 Y->setCopyOrView (Teuchos::View);
102 Teuchos::RCP<MV> X_copy (
new MV (X, Teuchos::Copy));
109 X_copy->setCopyOrView (Teuchos::View);
124 static Teuchos::RCP<MV>
127 #ifdef HAVE_TPETRA_DEBUG 128 const char fnName[] =
"Belos::MultiVecTraits::CloneCopy(mv,index)";
129 const size_t inNumVecs = mv.getNumVectors ();
130 TEUCHOS_TEST_FOR_EXCEPTION(
131 index.size () > 0 && *std::min_element (index.begin (), index.end ()) < 0,
132 std::runtime_error, fnName <<
": All indices must be nonnegative.");
133 TEUCHOS_TEST_FOR_EXCEPTION(
135 static_cast<size_t> (*std::max_element (index.begin (), index.end ())) >= inNumVecs,
137 fnName <<
": All indices must be strictly less than the number of " 138 "columns " << inNumVecs <<
" of the input multivector mv.");
139 #endif // HAVE_TPETRA_DEBUG 142 Teuchos::Array<size_t> columns (index.size ());
143 for (std::vector<int>::size_type
j = 0;
j < index.size (); ++
j) {
144 columns[
j] = index[
j];
149 Teuchos::RCP<MV> X_copy = mv.subCopy (columns ());
150 X_copy->setCopyOrView (Teuchos::View);
160 static Teuchos::RCP<MV>
163 const bool validRange = index.size() > 0 &&
164 index.lbound() >= 0 &&
165 index.ubound() < GetNumberVecs(mv);
167 std::ostringstream os;
168 os <<
"Belos::MultiVecTraits::CloneCopy(mv,index=[" 169 << index.lbound() <<
"," << index.ubound() <<
"]): ";
170 TEUCHOS_TEST_FOR_EXCEPTION(
171 index.size() == 0, std::invalid_argument,
172 os.str() <<
"Empty index range is not allowed.");
173 TEUCHOS_TEST_FOR_EXCEPTION(
174 index.lbound() < 0, std::invalid_argument,
175 os.str() <<
"Index range includes negative index/ices, which is not " 177 TEUCHOS_TEST_FOR_EXCEPTION(
178 index.ubound() >= GetNumberVecs(mv), std::invalid_argument,
179 os.str() <<
"Index range exceeds number of vectors " 180 << mv.getNumVectors() <<
" in the input multivector.");
181 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
182 os.str() <<
"Should never get here!");
184 Teuchos::RCP<MV> X_copy = mv.subCopy (index);
185 X_copy->setCopyOrView (Teuchos::View);
190 static Teuchos::RCP<MV>
193 #ifdef HAVE_TPETRA_DEBUG 194 const char fnName[] =
"Belos::MultiVecTraits::CloneViewNonConst(mv,index)";
195 const size_t numVecs = mv.getNumVectors ();
196 TEUCHOS_TEST_FOR_EXCEPTION(
197 index.size () > 0 && *std::min_element (index.begin (), index.end ()) < 0,
198 std::invalid_argument,
199 fnName <<
": All indices must be nonnegative.");
200 TEUCHOS_TEST_FOR_EXCEPTION(
202 static_cast<size_t> (*std::max_element (index.begin (), index.end ())) >= numVecs,
203 std::invalid_argument,
204 fnName <<
": All indices must be strictly less than the number of " 205 "columns " << numVecs <<
" in the input MultiVector mv.");
206 #endif // HAVE_TPETRA_DEBUG 209 Teuchos::Array<size_t> columns (index.size ());
210 for (std::vector<int>::size_type
j = 0;
j < index.size (); ++
j) {
211 columns[
j] = index[
j];
216 Teuchos::RCP<MV> X_view = mv.subViewNonConst (columns ());
217 X_view->setCopyOrView (Teuchos::View);
221 static Teuchos::RCP<MV>
227 const int numCols =
static_cast<int> (mv.getNumVectors());
228 const bool validRange = index.size() > 0 &&
229 index.lbound() >= 0 && index.ubound() < numCols;
231 std::ostringstream os;
232 os <<
"Belos::MultiVecTraits::CloneViewNonConst(mv,index=[" 233 << index.lbound() <<
", " << index.ubound() <<
"]): ";
234 TEUCHOS_TEST_FOR_EXCEPTION(
235 index.size() == 0, std::invalid_argument,
236 os.str() <<
"Empty index range is not allowed.");
237 TEUCHOS_TEST_FOR_EXCEPTION(
238 index.lbound() < 0, std::invalid_argument,
239 os.str() <<
"Index range includes negative inde{x,ices}, which is " 241 TEUCHOS_TEST_FOR_EXCEPTION(
242 index.ubound() >= numCols, std::invalid_argument,
243 os.str() <<
"Index range exceeds number of vectors " << numCols
244 <<
" in the input multivector.");
245 TEUCHOS_TEST_FOR_EXCEPTION(
246 true, std::logic_error,
247 os.str() <<
"Should never get here!");
249 Teuchos::RCP<MV> X_view = mv.subViewNonConst (index);
250 X_view->setCopyOrView (Teuchos::View);
254 static Teuchos::RCP<const MV>
257 #ifdef HAVE_TPETRA_DEBUG 258 const char fnName[] =
"Belos::MultiVecTraits<Scalar, " 259 "Tpetra::MultiVector<...> >::CloneView(mv,index)";
260 const size_t numVecs = mv.getNumVectors ();
261 TEUCHOS_TEST_FOR_EXCEPTION(
262 *std::min_element (index.begin (), index.end ()) < 0,
263 std::invalid_argument,
264 fnName <<
": All indices must be nonnegative.");
265 TEUCHOS_TEST_FOR_EXCEPTION(
266 static_cast<size_t> (*std::max_element (index.begin (), index.end ())) >= numVecs,
267 std::invalid_argument,
268 fnName <<
": All indices must be strictly less than the number of " 269 "columns " << numVecs <<
" in the input MultiVector mv.");
270 #endif // HAVE_TPETRA_DEBUG 273 Teuchos::Array<size_t> columns (index.size ());
274 for (std::vector<int>::size_type
j = 0;
j < index.size (); ++
j) {
275 columns[
j] = index[
j];
280 Teuchos::RCP<const MV> X_view = mv.subView (columns);
281 Teuchos::rcp_const_cast<
MV> (X_view)->setCopyOrView (Teuchos::View);
285 static Teuchos::RCP<const MV>
291 const int numCols =
static_cast<int> (mv.getNumVectors());
292 const bool validRange = index.size() > 0 &&
293 index.lbound() >= 0 && index.ubound() < numCols;
295 std::ostringstream os;
296 os <<
"Belos::MultiVecTraits::CloneView(mv, index=[" 297 << index.lbound () <<
", " << index.ubound() <<
"]): ";
298 TEUCHOS_TEST_FOR_EXCEPTION(index.size() == 0, std::invalid_argument,
299 os.str() <<
"Empty index range is not allowed.");
300 TEUCHOS_TEST_FOR_EXCEPTION(index.lbound() < 0, std::invalid_argument,
301 os.str() <<
"Index range includes negative index/ices, which is not " 303 TEUCHOS_TEST_FOR_EXCEPTION(
304 index.ubound() >= numCols, std::invalid_argument,
305 os.str() <<
"Index range exceeds number of vectors " << numCols
306 <<
" in the input multivector.");
307 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
308 os.str() <<
"Should never get here!");
310 Teuchos::RCP<const MV> X_view = mv.subView (index);
311 Teuchos::rcp_const_cast<
MV> (X_view)->setCopyOrView (Teuchos::View);
316 return static_cast<ptrdiff_t
> (mv.getGlobalLength ());
320 return static_cast<int> (mv.getNumVectors ());
324 return mv.isConstantStride ();
329 const Tpetra::MultiVector<Scalar,LO,GO,Node>& A,
330 const Teuchos::SerialDenseMatrix<int,dot_type>& B,
332 Tpetra::MultiVector<Scalar,LO,GO,Node>& C)
338 const int numRowsB = B.numRows ();
339 const int numColsB = B.numCols ();
340 const int strideB = B.stride ();
341 if (numRowsB == 1 && numColsB == 1) {
342 C.update (alpha*B(0,0), A, beta);
347 RCP<const MV> Atmp, Ctmp;
348 if (A.isConstantStride() ==
false) Atmp = rcp (
new MV (A, Teuchos::Copy));
349 else Atmp = rcp(&A,
false);
351 if (C.isConstantStride() ==
false) Ctmp = rcp (
new MV (C, Teuchos::Copy));
352 else Ctmp = rcp(&C,
false);
355 typedef Tpetra::MultiVector<dot_type,LO,GO,Node> FMV;
356 typedef typename FMV::dual_view_type::t_dev flat_view_type;
358 flat_view_type flat_A_view = Atmp->template getLocalView<execution_space>();
359 flat_view_type flat_C_view = Ctmp->template getLocalView<execution_space>();
362 typedef Kokkos::View<dot_type**, Kokkos::LayoutLeft, Kokkos::HostSpace> b_host_view_type;
363 b_host_view_type B_view_host_input( B.values(), strideB, numColsB);
364 auto B_view_host = Kokkos::subview(B_view_host_input,
365 Kokkos::pair<int,int>(0,numRowsB),
366 Kokkos::pair<int,int>(0,numColsB));
370 typedef Kokkos::View<dot_type**, Kokkos::LayoutLeft, execution_space> b_view_type;
371 typedef Kokkos::View<dot_type*, Kokkos::LayoutLeft, execution_space> b_1d_view_type;
372 b_1d_view_type B_1d_view_dev(Kokkos::ViewAllocateWithoutInitializing(
"B"), numRowsB*numColsB);
373 b_view_type B_view_dev( B_1d_view_dev.data(), numRowsB, numColsB);
378 const char ctransA =
'N', ctransB =
'N';
381 alpha, flat_A_view, B_view_dev, beta, flat_C_view);
384 if (C.isConstantStride() ==
false)
397 const Tpetra::MultiVector<Scalar,LO,GO,Node>& A,
399 const Tpetra::MultiVector<Scalar,LO,GO,Node>& B,
400 Tpetra::MultiVector<Scalar,LO,GO,Node>& mv)
402 mv.update (alpha, A, beta, B, Teuchos::ScalarTraits<Scalar>::zero ());
406 MvScale (Tpetra::MultiVector<Scalar,LO,GO,Node>& mv,
413 MvScale (Tpetra::MultiVector<Scalar,LO,GO,Node>& mv,
414 const std::vector<BaseScalar>& alphas)
416 std::vector<Scalar> alphas_mp(alphas.size());
417 const size_t sz = alphas.size();
418 for (
size_t i=0; i<sz; ++i)
419 alphas_mp[i] = alphas[i];
420 mv.scale (alphas_mp);
424 MvScale (Tpetra::MultiVector<Scalar,LO,GO,Node>& mv,
425 const std::vector<Scalar>& alphas)
432 const Tpetra::MultiVector<Scalar,LO,GO,Node>& A,
433 const Tpetra::MultiVector<Scalar,LO,GO,Node>& B,
434 Teuchos::SerialDenseMatrix<int,dot_type>& C)
439 using Teuchos::REDUCE_SUM;
440 using Teuchos::reduceAll;
443 const int numRowsC = C.numRows ();
444 const int numColsC = C.numCols ();
445 const int strideC = C.stride ();
446 if (numRowsC == 1 && numColsC == 1) {
447 if (alpha == Teuchos::ScalarTraits<Scalar>::zero ()) {
452 A.dot (B, Teuchos::ArrayView<dot_type> (C.values (), 1));
453 if (alpha != Teuchos::ScalarTraits<Scalar>::one ()) {
460 RCP<const MV> Atmp, Btmp;
461 if (A.isConstantStride() ==
false) Atmp = rcp (
new MV (A, Teuchos::Copy));
462 else Atmp = rcp(&A,
false);
464 if (B.isConstantStride() ==
false) Btmp = rcp (
new MV (B, Teuchos::Copy));
465 else Btmp = rcp(&B,
false);
468 typedef Tpetra::MultiVector<dot_type,LO,GO,Node> FMV;
469 typedef typename FMV::dual_view_type::t_dev flat_view_type;
471 flat_view_type flat_A_view = Atmp->template getLocalView<execution_space>();
472 flat_view_type flat_B_view = Btmp->template getLocalView<execution_space>();
475 typedef Kokkos::View<dot_type**, Kokkos::LayoutLeft, Kokkos::HostSpace> c_host_view_type;
476 c_host_view_type C_view_host_input( C.values(), strideC, numColsC);
477 auto C_view_host = Kokkos::subview(C_view_host_input,
478 Kokkos::pair<int,int>(0,numRowsC),
479 Kokkos::pair<int,int>(0,numColsC));
483 typedef Kokkos::View<dot_type**, Kokkos::LayoutLeft, execution_space> c_view_type;
484 typedef Kokkos::View<dot_type*, Kokkos::LayoutLeft, execution_space> c_1d_view_type;
485 c_1d_view_type C_1d_view_dev(
"C", numRowsC*numColsC);
486 c_view_type C_view_dev( C_1d_view_dev.data(), numRowsC, numColsC);
490 const char ctransA =
'C', ctransB =
'N';
493 alpha, flat_A_view, flat_B_view,
494 Kokkos::Details::ArithTraits<dot_type>::zero(),
499 RCP<const Comm<int> > pcomm = A.getMap()->getComm ();
500 if (pcomm->getSize () == 1)
503 typedef Kokkos::View<dot_type*, Kokkos::LayoutLeft, Kokkos::HostSpace> c_1d_host_view_type;
504 c_1d_host_view_type C_1d_view_tmp(Kokkos::ViewAllocateWithoutInitializing(
"C_tmp"), strideC*numColsC);
505 c_host_view_type C_view_tmp( C_1d_view_tmp.data(),
508 Kokkos::pair<int,int>(0,numRowsC),
509 Kokkos::pair<int,int>(0,numColsC)) ,
511 reduceAll<int> (*pcomm, REDUCE_SUM, strideC*numColsC,
519 MvDot (
const Tpetra::MultiVector<Scalar,LO,GO,Node>& A,
520 const Tpetra::MultiVector<Scalar,LO,GO,Node>& B,
521 std::vector<dot_type>& dots)
523 const size_t numVecs = A.getNumVectors ();
525 TEUCHOS_TEST_FOR_EXCEPTION(
526 numVecs != B.getNumVectors (), std::invalid_argument,
527 "Belos::MultiVecTraits<Scalar,Tpetra::MultiVector>::MvDot(A,B,dots): " 528 "A and B must have the same number of columns. " 529 "A has " << numVecs <<
" column(s), " 530 "but B has " << B.getNumVectors () <<
" column(s).");
531 #ifdef HAVE_TPETRA_DEBUG 532 TEUCHOS_TEST_FOR_EXCEPTION(
533 dots.size() < numVecs, std::invalid_argument,
534 "Belos::MultiVecTraits<Scalar,Tpetra::MultiVector>::MvDot(A,B,dots): " 535 "The output array 'dots' must have room for all dot products. " 536 "A and B each have " << numVecs <<
" column(s), " 537 "but 'dots' only has " << dots.size() <<
" entry(/ies).");
538 #endif // HAVE_TPETRA_DEBUG 540 Teuchos::ArrayView<dot_type> av (dots);
541 A.dot (B, av (0, numVecs));
546 MvNorm (
const Tpetra::MultiVector<Scalar,LO,GO,Node>& mv,
547 std::vector<mag_type> &normvec,
548 NormType type=TwoNorm)
551 #ifdef HAVE_TPETRA_DEBUG 552 typedef std::vector<int>::size_type size_type;
553 TEUCHOS_TEST_FOR_EXCEPTION(
554 normvec.size () <
static_cast<size_type
> (mv.getNumVectors ()),
555 std::invalid_argument,
556 "Belos::MultiVecTraits::MvNorm(mv,normvec): The normvec output " 557 "argument must have at least as many entries as the number of vectors " 558 "(columns) in the MultiVector mv. normvec.size() = " << normvec.size ()
559 <<
" < mv.getNumVectors() = " << mv.getNumVectors () <<
".");
562 Teuchos::ArrayView<mag_type> av(normvec);
565 mv.norm1(av(0,mv.getNumVectors()));
568 mv.norm2(av(0,mv.getNumVectors()));
571 mv.normInf(av(0,mv.getNumVectors()));
577 TEUCHOS_TEST_FOR_EXCEPTION(
578 true, std::logic_error,
579 "Belos::MultiVecTraits::MvNorm: Invalid NormType value " << type
580 <<
". Valid values are OneNorm=" << OneNorm <<
", TwoNorm=" 581 << TwoNorm <<
", and InfNorm=" << InfNorm <<
". If you are a Belos " 582 "user and have not modified Belos in any way, and you get this " 583 "message, then this is probably a bug in the Belos solver you were " 584 "using. Please report this to the Belos developers.");
591 using Teuchos::Range1D;
593 const size_t inNumVecs = A.getNumVectors ();
594 #ifdef HAVE_TPETRA_DEBUG 595 TEUCHOS_TEST_FOR_EXCEPTION(
596 inNumVecs < static_cast<size_t> (index.size ()), std::invalid_argument,
597 "Belos::MultiVecTraits::SetBlock(A,index,mv): 'index' argument must " 598 "have no more entries as the number of columns in the input MultiVector" 599 " A. A.getNumVectors() = " << inNumVecs <<
" < index.size () = " 600 << index.size () <<
".");
601 #endif // HAVE_TPETRA_DEBUG 602 RCP<MV> mvsub = CloneViewNonConst (mv, index);
603 if (inNumVecs > static_cast<size_t> (index.size ())) {
604 RCP<const MV> Asub = A.subView (Range1D (0, index.size () - 1));
621 const size_t maxInt =
623 const bool overflow =
624 maxInt < A.getNumVectors () && maxInt < mv.getNumVectors ();
626 std::ostringstream os;
627 os <<
"Belos::MultiVecTraits::SetBlock(A, index=[" << index.lbound ()
628 <<
", " << index.ubound () <<
"], mv): ";
629 TEUCHOS_TEST_FOR_EXCEPTION(
630 maxInt < A.getNumVectors (), std::range_error, os.str () <<
"Number " 631 "of columns (size_t) in the input MultiVector 'A' overflows int.");
632 TEUCHOS_TEST_FOR_EXCEPTION(
633 maxInt < mv.getNumVectors (), std::range_error, os.str () <<
"Number " 634 "of columns (size_t) in the output MultiVector 'mv' overflows int.");
637 const int numColsA =
static_cast<int> (A.getNumVectors ());
638 const int numColsMv =
static_cast<int> (mv.getNumVectors ());
640 const bool validIndex =
641 index.lbound () >= 0 && index.ubound () < numColsMv;
643 const bool validSource = index.size () <= numColsA;
645 if (! validIndex || ! validSource) {
646 std::ostringstream os;
647 os <<
"Belos::MultiVecTraits::SetBlock(A, index=[" << index.lbound ()
648 <<
", " << index.ubound () <<
"], mv): ";
649 TEUCHOS_TEST_FOR_EXCEPTION(
650 index.lbound() < 0, std::invalid_argument,
651 os.str() <<
"Range lower bound must be nonnegative.");
652 TEUCHOS_TEST_FOR_EXCEPTION(
653 index.ubound() >= numColsMv, std::invalid_argument,
654 os.str() <<
"Range upper bound must be less than the number of " 655 "columns " << numColsA <<
" in the 'mv' output argument.");
656 TEUCHOS_TEST_FOR_EXCEPTION(
657 index.size() > numColsA, std::invalid_argument,
658 os.str() <<
"Range must have no more elements than the number of " 659 "columns " << numColsA <<
" in the 'A' input argument.");
660 TEUCHOS_TEST_FOR_EXCEPTION(
661 true, std::logic_error,
"Should never get here!");
667 Teuchos::RCP<MV> mv_view;
668 if (index.lbound () == 0 && index.ubound () + 1 == numColsMv) {
669 mv_view = Teuchos::rcpFromRef (mv);
671 mv_view = CloneViewNonConst (mv, index);
677 Teuchos::RCP<const MV> A_view;
678 if (index.size () == numColsA) {
679 A_view = Teuchos::rcpFromRef (A);
681 A_view = CloneView (A, Teuchos::Range1D (0, index.size () - 1));
689 const char errPrefix[] =
"Belos::MultiVecTraits::Assign(A, mv): ";
698 const size_t maxInt =
700 const bool overflow =
701 maxInt < A.getNumVectors () && maxInt < mv.getNumVectors ();
703 TEUCHOS_TEST_FOR_EXCEPTION(
704 maxInt < A.getNumVectors(), std::range_error,
705 errPrefix <<
"Number of columns in the input multivector 'A' " 706 "(a size_t) overflows int.");
707 TEUCHOS_TEST_FOR_EXCEPTION(
708 maxInt < mv.getNumVectors(), std::range_error,
709 errPrefix <<
"Number of columns in the output multivector 'mv' " 710 "(a size_t) overflows int.");
711 TEUCHOS_TEST_FOR_EXCEPTION(
712 true, std::logic_error,
"Should never get here!");
715 const int numColsA =
static_cast<int> (A.getNumVectors ());
716 const int numColsMv =
static_cast<int> (mv.getNumVectors ());
717 if (numColsA > numColsMv) {
718 TEUCHOS_TEST_FOR_EXCEPTION(
719 numColsA > numColsMv, std::invalid_argument,
720 errPrefix <<
"Input multivector 'A' has " << numColsA <<
" columns, " 721 "but output multivector 'mv' has only " << numColsMv <<
" columns.");
722 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Should never get here!");
724 if (numColsA == numColsMv) {
727 Teuchos::RCP<MV> mv_view =
728 CloneViewNonConst (mv, Teuchos::Range1D (0, numColsA - 1));
741 mv.putScalar (alpha);
745 Teuchos::FancyOStream fos (Teuchos::rcpFromRef (os));
746 mv.describe (fos, Teuchos::VERB_EXTREME);
749 #ifdef HAVE_BELOS_TSQR 750 typedef Tpetra::TsqrAdaptor< Tpetra::MultiVector< Scalar, LO, GO, Node > > tsqr_adaptor_type;
754 #endif // HAVE_BELOS_TSQR 764 template <
class Storage,
class LO,
class GO,
class Node>
766 Tpetra::MultiVector<Sacado::MP::Vector<Storage>,
768 Tpetra::Operator<Sacado::MP::Vector<Storage>,
774 Apply (
const Tpetra::Operator<Scalar,LO,GO,Node>& Op,
775 const Tpetra::MultiVector<Scalar,LO,GO,Node>& X,
776 Tpetra::MultiVector<Scalar,LO,GO,Node>& Y,
777 ETrans trans=NOTRANS)
781 Op.apply(X,Y,Teuchos::NO_TRANS);
784 Op.apply(X,Y,Teuchos::TRANS);
787 Op.apply(X,Y,Teuchos::CONJ_TRANS);
790 const std::string scalarName = Teuchos::TypeNameTraits<Scalar>::name();
791 const std::string loName = Teuchos::TypeNameTraits<LO>::name();
792 const std::string goName = Teuchos::TypeNameTraits<GO>::name();
793 const std::string nodeName = Teuchos::TypeNameTraits<Node>::name();
794 const std::string otName =
"Belos::OperatorTraits<" + scalarName
795 +
"," + loName +
"," + goName +
"," + nodeName +
">";
796 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error, otName <<
": Should never " 797 "get here; fell through a switch statement. " 798 "Please report this bug to the Belos developers.");
805 return Op.hasTransposeApply ();
std::enable_if< Kokkos::is_view_mp_vector< Kokkos::View< DA, PA... > >::value &&Kokkos::is_view_mp_vector< Kokkos::View< DB, PB... > >::value &&Kokkos::is_view_mp_vector< Kokkos::View< DC, PC... > >::value >::type gemm(const char transA[], const char transB[], typename Kokkos::View< DA, PA... >::const_value_type &alpha, const Kokkos::View< DA, PA... > &A, const Kokkos::View< DB, PB... > &B, typename Kokkos::View< DC, PC... >::const_value_type &beta, const Kokkos::View< DC, PC... > &C)
Tpetra::MultiVector< Scalar, LO, GO, Node >::mag_type mag_type
static int GetNumberVecs(const MV &mv)
static bool HasApplyTranspose(const Tpetra::Operator< Scalar, LO, GO, Node > &Op)
static void Assign(const MV &A, MV &mv)
static Teuchos::RCP< MV > CloneCopy(const MV &mv, const std::vector< int > &index)
Create and return a deep copy of the given columns of mv.
static void MvScale(Tpetra::MultiVector< Scalar, LO, GO, Node > &mv, const std::vector< BaseScalar > &alphas)
Kokkos::DefaultExecutionSpace execution_space
Storage::ordinal_type s_ordinal
Tpetra::MultiVector< Scalar, LO, GO, Node > MV
Sacado::MP::Vector< Storage > Scalar
static bool HasConstantStride(const MV &mv)
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const Teuchos::Range1D &index)
static void MvTimesMatAddMv(const dot_type &alpha, const Tpetra::MultiVector< Scalar, LO, GO, Node > &A, const Teuchos::SerialDenseMatrix< int, dot_type > &B, const dot_type &beta, Tpetra::MultiVector< Scalar, LO, GO, Node > &C)
static void MvScale(Tpetra::MultiVector< Scalar, LO, GO, Node > &mv, const Scalar &alpha)
static void SetBlock(const MV &A, const std::vector< int > &index, MV &mv)
static void MvPrint(const MV &mv, std::ostream &os)
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
static void MvScale(Tpetra::MultiVector< Scalar, LO, GO, Node > &mv, const std::vector< Scalar > &alphas)
static void MvTransMv(dot_type alpha, const Tpetra::MultiVector< Scalar, LO, GO, Node > &A, const Tpetra::MultiVector< Scalar, LO, GO, Node > &B, Teuchos::SerialDenseMatrix< int, dot_type > &C)
static ptrdiff_t GetGlobalLength(const MV &mv)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
static void MvNorm(const Tpetra::MultiVector< Scalar, LO, GO, Node > &mv, std::vector< mag_type > &normvec, NormType type=TwoNorm)
For all columns j of mv, set normvec[j] = norm(mv[j]).
Storage::value_type BaseScalar
Tpetra::MultiVector< Scalar, LO, GO, Node >::dot_type dot_type
static Teuchos::RCP< MV > CloneCopy(const MV &X)
Create and return a deep copy of X.
static Teuchos::RCP< MV > Clone(const MV &X, const int numVecs)
Create a new MultiVector with numVecs columns.
static void Apply(const Tpetra::Operator< Scalar, LO, GO, Node > &Op, const Tpetra::MultiVector< Scalar, LO, GO, Node > &X, Tpetra::MultiVector< Scalar, LO, GO, Node > &Y, ETrans trans=NOTRANS)
static Teuchos::RCP< MV > CloneCopy(const MV &mv, const Teuchos::Range1D &index)
Create and return a deep copy of the given columns of mv.
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
Sacado::MP::Vector< Storage > Scalar
static void MvRandom(MV &mv)
static void MvInit(MV &mv, const Scalar alpha=Teuchos::ScalarTraits< Scalar >::zero())
static Teuchos::RCP< const MV > CloneView(const MV &mv, const Teuchos::Range1D &index)
static Teuchos::RCP< const MV > CloneView(const MV &mv, const std::vector< int > &index)
static void MvDot(const Tpetra::MultiVector< Scalar, LO, GO, Node > &A, const Tpetra::MultiVector< Scalar, LO, GO, Node > &B, std::vector< dot_type > &dots)
For all columns j of A, set dots[j] := A[j]^T * B[j].
static void SetBlock(const MV &A, const Teuchos::Range1D &index, MV &mv)
static void MvAddMv(Scalar alpha, const Tpetra::MultiVector< Scalar, LO, GO, Node > &A, Scalar beta, const Tpetra::MultiVector< Scalar, LO, GO, Node > &B, Tpetra::MultiVector< Scalar, LO, GO, Node > &mv)
mv := alpha*A + beta*B