Stratimikos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
BelosThyraAdapter.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Stratimikos: Thyra-based strategies for linear solvers
5// Copyright (2006) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
51
52#ifndef BELOS_THYRA_ADAPTER_HPP
53#define BELOS_THYRA_ADAPTER_HPP
54
55#include "Stratimikos_Config.h"
56#include "BelosConfigDefs.hpp"
57#include "BelosMultiVecTraits.hpp"
58#include "BelosOperatorTraits.hpp"
59
60#include <Thyra_DetachedMultiVectorView.hpp>
61#include <Thyra_MultiVectorBase.hpp>
62#include <Thyra_MultiVectorStdOps.hpp>
63#ifdef HAVE_BELOS_TSQR
64# include <Thyra_TsqrAdaptor.hpp>
65#endif // HAVE_BELOS_TSQR
66
67#ifdef HAVE_STRATIMIKOS_BELOS_TIMERS
68# include <Teuchos_TimeMonitor.hpp>
69
70# define STRATIMIKOS_TIME_MONITOR(NAME) \
71 Teuchos::TimeMonitor tM(*Teuchos::TimeMonitor::getNewTimer(std::string(NAME)))
72
73#else
74
75# define STRATIMIKOS_TIME_MONITOR(NAME)
76
77#endif
78
79namespace Belos {
80
82 //
83 // Implementation of the Belos::MultiVecTraits for Thyra::MultiVectorBase
84 //
86
93 template<class ScalarType>
94 class MultiVecTraits< ScalarType, Thyra::MultiVectorBase<ScalarType> >
95 {
96 private:
97 typedef Thyra::MultiVectorBase<ScalarType> TMVB;
98 typedef Teuchos::ScalarTraits<ScalarType> ST;
99 typedef typename ST::magnitudeType magType;
100
101 public:
102
105
110 static Teuchos::RCP<TMVB> Clone( const TMVB& mv, const int numvecs )
111 {
112 Teuchos::RCP<TMVB> c = Thyra::createMembers( mv.range(), numvecs );
113 return c;
114 }
115
120 static Teuchos::RCP<TMVB> CloneCopy( const TMVB& mv )
121 {
122 int numvecs = mv.domain()->dim();
123 // create the new multivector
124 Teuchos::RCP< TMVB > cc = Thyra::createMembers( mv.range(), numvecs );
125 // copy the data from the source multivector to the new multivector
126 Thyra::assign(cc.ptr(), mv);
127 return cc;
128 }
129
135 static Teuchos::RCP<TMVB> CloneCopy( const TMVB& mv, const std::vector<int>& index )
136 {
137 int numvecs = index.size();
138 // create the new multivector
139 Teuchos::RCP<TMVB> cc = Thyra::createMembers( mv.range(), numvecs );
140 // create a view to the relevant part of the source multivector
141 Teuchos::RCP<const TMVB> view = mv.subView(index);
142 // copy the data from the relevant view to the new multivector
143 Thyra::assign(cc.ptr(), *view);
144 return cc;
145 }
146
147 static Teuchos::RCP<TMVB>
148 CloneCopy (const TMVB& mv, const Teuchos::Range1D& index)
149 {
150 const int numVecs = index.size();
151 // Create the new multivector
152 Teuchos::RCP<TMVB> cc = Thyra::createMembers (mv.range(), numVecs);
153 // Create a view to the relevant part of the source multivector
154 Teuchos::RCP<const TMVB> view = mv.subView (index);
155 // Copy the data from the view to the new multivector.
156 Thyra::assign (cc.ptr(), *view);
157 return cc;
158 }
159
165 static Teuchos::RCP<TMVB> CloneViewNonConst( TMVB& mv, const std::vector<int>& index )
166 {
167 int numvecs = index.size();
168
169 // We do not assume that the indices are sorted, nor do we check that
170 // index.size() > 0. This code is fail-safe, in the sense that a zero
171 // length index std::vector will pass the error on the Thyra.
172
173 // Thyra has two ways to create an indexed View:
174 // * contiguous (via a range of columns)
175 // * indexed (via a std::vector of column indices)
176 // The former is significantly more efficient than the latter, in terms of
177 // computations performed with/against the created view.
178 // We will therefore check to see if the given indices are contiguous, and
179 // if so, we will use the contiguous view creation method.
180
181 int lb = index[0];
182 bool contig = true;
183 for (int i=0; i<numvecs; i++) {
184 if (lb+i != index[i]) contig = false;
185 }
186
187 Teuchos::RCP< TMVB > cc;
188 if (contig) {
189 const Thyra::Range1D rng(lb,lb+numvecs-1);
190 // create a contiguous view to the relevant part of the source multivector
191 cc = mv.subView(rng);
192 }
193 else {
194 // create an indexed view to the relevant part of the source multivector
195 cc = mv.subView(index);
196 }
197 return cc;
198 }
199
200 static Teuchos::RCP<TMVB>
201 CloneViewNonConst (TMVB& mv, const Teuchos::Range1D& index)
202 {
203 // We let Thyra be responsible for checking that the index range
204 // is nonempty.
205 //
206 // Create and return a contiguous view to the relevant part of
207 // the source multivector.
208 return mv.subView (index);
209 }
210
211
217 static Teuchos::RCP<const TMVB> CloneView( const TMVB& mv, const std::vector<int>& index )
218 {
219 int numvecs = index.size();
220
221 // We do not assume that the indices are sorted, nor do we check that
222 // index.size() > 0. This code is fail-safe, in the sense that a zero
223 // length index std::vector will pass the error on the Thyra.
224
225 // Thyra has two ways to create an indexed View:
226 // * contiguous (via a range of columns)
227 // * indexed (via a std::vector of column indices)
228 // The former is significantly more efficient than the latter, in terms of
229 // computations performed with/against the created view.
230 // We will therefore check to see if the given indices are contiguous, and
231 // if so, we will use the contiguous view creation method.
232
233 int lb = index[0];
234 bool contig = true;
235 for (int i=0; i<numvecs; i++) {
236 if (lb+i != index[i]) contig = false;
237 }
238
239 Teuchos::RCP< const TMVB > cc;
240 if (contig) {
241 const Thyra::Range1D rng(lb,lb+numvecs-1);
242 // create a contiguous view to the relevant part of the source multivector
243 cc = mv.subView(rng);
244 }
245 else {
246 // create an indexed view to the relevant part of the source multivector
247 cc = mv.subView(index);
248 }
249 return cc;
250 }
251
252 static Teuchos::RCP<const TMVB>
253 CloneView (const TMVB& mv, const Teuchos::Range1D& index)
254 {
255 // We let Thyra be responsible for checking that the index range
256 // is nonempty.
257 //
258 // Create and return a contiguous view to the relevant part of
259 // the source multivector.
260 return mv.subView (index);
261 }
262
264
267
269 static ptrdiff_t GetGlobalLength( const TMVB& mv ) {
270 return Teuchos::as<ptrdiff_t>(mv.range()->dim());
271 }
272
274 static int GetNumberVecs( const TMVB& mv )
275 { return mv.domain()->dim(); }
276
278
281
284 static void MvTimesMatAddMv( const ScalarType alpha, const TMVB& A,
285 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
286 const ScalarType beta, TMVB& mv )
287 {
288 using Teuchos::arrayView; using Teuchos::arcpFromArrayView;
289 STRATIMIKOS_TIME_MONITOR("Belos::MVT::MvTimesMatAddMv");
290
291 const int m = B.numRows();
292 const int n = B.numCols();
293 auto vs = A.domain();
294 // Create a view of the B object!
295 Teuchos::RCP< const TMVB >
296 B_thyra = vs->createCachedMembersView(
298 0, m, 0, n,
299 arcpFromArrayView(arrayView(&B(0,0), B.stride()*B.numCols())), B.stride()
300 )
301 );
302 // perform the operation via A: mv <- alpha*A*B_thyra + beta*mv
303 Thyra::apply<ScalarType>(A, Thyra::NOTRANS, *B_thyra, Teuchos::outArg(mv), alpha, beta);
304 }
305
308 static void MvAddMv( const ScalarType alpha, const TMVB& A,
309 const ScalarType beta, const TMVB& B, TMVB& mv )
310 {
311 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::inoutArg;
312 STRATIMIKOS_TIME_MONITOR("Belos::MVT::MvAddMv");
313
314 Thyra::linear_combination<ScalarType>(
315 tuple(alpha, beta)(), tuple(ptrInArg(A), ptrInArg(B))(), Teuchos::ScalarTraits<ScalarType>::zero(), inoutArg(mv));
316 }
317
320 static void MvScale ( TMVB& mv, const ScalarType alpha )
321 {
322 STRATIMIKOS_TIME_MONITOR("Belos::MVT::MvScale");
323
324 Thyra::scale(alpha, Teuchos::inoutArg(mv));
325 }
326
329 static void MvScale (TMVB& mv, const std::vector<ScalarType>& alpha)
330 {
331 STRATIMIKOS_TIME_MONITOR("Belos::MVT::MvScale");
332
333 for (unsigned int i=0; i<alpha.size(); i++) {
334 Thyra::scale<ScalarType> (alpha[i], mv.col(i).ptr());
335 }
336 }
337
340 static void MvTransMv( const ScalarType alpha, const TMVB& A, const TMVB& mv,
341 Teuchos::SerialDenseMatrix<int,ScalarType>& B )
342 {
343 using Teuchos::arrayView; using Teuchos::arcpFromArrayView;
344 STRATIMIKOS_TIME_MONITOR("Belos::MVT::MvTransMv");
345
346 // Create a multivector to hold the result (m by n)
347 int m = A.domain()->dim();
348 int n = mv.domain()->dim();
349 auto vs = A.domain();
350 // Create a view of the B object!
351 Teuchos::RCP< TMVB >
352 B_thyra = vs->createCachedMembersView(
354 0, m, 0, n,
355 arcpFromArrayView(arrayView(&B(0,0), B.stride()*B.numCols())), B.stride()
356 )
357 );
358 Thyra::apply<ScalarType>(A, Thyra::CONJTRANS, mv, B_thyra.ptr(), alpha);
359 }
360
364 static void MvDot( const TMVB& mv, const TMVB& A, std::vector<ScalarType>& b )
365 {
366 STRATIMIKOS_TIME_MONITOR("Belos::MVT::MvDot");
367
368 Thyra::dots(mv, A, Teuchos::arrayViewFromVector(b));
369 }
370
372
375
379 static void MvNorm( const TMVB& mv, std::vector<magType>& normvec,
380 NormType type = TwoNorm ) {
381 STRATIMIKOS_TIME_MONITOR("Belos::MVT::MvNorm");
382
383 if(type == TwoNorm)
384 Thyra::norms_2(mv, Teuchos::arrayViewFromVector(normvec));
385 else if(type == OneNorm)
386 Thyra::norms_1(mv, Teuchos::arrayViewFromVector(normvec));
387 else if(type == InfNorm)
388 Thyra::norms_inf(mv, Teuchos::arrayViewFromVector(normvec));
389 else
390 TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
391 "Belos::MultiVecTraits::MvNorm (Thyra specialization): "
392 "invalid norm type. Must be either TwoNorm, OneNorm or InfNorm");
393 }
394
396
399
402 static void SetBlock( const TMVB& A, const std::vector<int>& index, TMVB& mv )
403 {
404 // Extract the "numvecs" columns of mv indicated by the index std::vector.
405 int numvecs = index.size();
406 std::vector<int> indexA(numvecs);
407 int numAcols = A.domain()->dim();
408 for (int i=0; i<numvecs; i++) {
409 indexA[i] = i;
410 }
411 // Thyra::assign requires that both arguments have the same number of
412 // vectors. Enforce this, by shrinking one to match the other.
413 if ( numAcols < numvecs ) {
414 // A does not have enough columns to satisfy index_plus. Shrink
415 // index_plus.
416 numvecs = numAcols;
417 }
418 else if ( numAcols > numvecs ) {
419 numAcols = numvecs;
420 indexA.resize( numAcols );
421 }
422 // create a view to the relevant part of the source multivector
423 Teuchos::RCP< const TMVB > relsource = A.subView(indexA);
424 // create a view to the relevant part of the destination multivector
425 Teuchos::RCP< TMVB > reldest = mv.subView(index);
426 // copy the data to the destination multivector subview
427 Thyra::assign(reldest.ptr(), *relsource);
428 }
429
430 static void
431 SetBlock (const TMVB& A, const Teuchos::Range1D& index, TMVB& mv)
432 {
433 const int numColsA = A.domain()->dim();
434 const int numColsMv = mv.domain()->dim();
435 // 'index' indexes into mv; it's the index set of the target.
436 const bool validIndex = index.lbound() >= 0 && index.ubound() < numColsMv;
437 // We can't take more columns out of A than A has.
438 const bool validSource = index.size() <= numColsA;
439
440 if (! validIndex || ! validSource)
441 {
442 std::ostringstream os;
443 os << "Belos::MultiVecTraits<Scalar, Thyra::MultiVectorBase<Scalar> "
444 ">::SetBlock(A, [" << index.lbound() << ", " << index.ubound()
445 << "], mv): ";
446 TEUCHOS_TEST_FOR_EXCEPTION(index.lbound() < 0, std::invalid_argument,
447 os.str() << "Range lower bound must be nonnegative.");
448 TEUCHOS_TEST_FOR_EXCEPTION(index.ubound() >= numColsMv, std::invalid_argument,
449 os.str() << "Range upper bound must be less than "
450 "the number of columns " << numColsA << " in the "
451 "'mv' output argument.");
452 TEUCHOS_TEST_FOR_EXCEPTION(index.size() > numColsA, std::invalid_argument,
453 os.str() << "Range must have no more elements than"
454 " the number of columns " << numColsA << " in the "
455 "'A' input argument.");
456 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Should never get here!");
457 }
458
459 // View of the relevant column(s) of the target multivector mv.
460 // We avoid view creation overhead by only creating a view if
461 // the index range is different than [0, (# columns in mv) - 1].
462 Teuchos::RCP<TMVB> mv_view;
463 if (index.lbound() == 0 && index.ubound()+1 == numColsMv)
464 mv_view = Teuchos::rcpFromRef (mv); // Non-const, non-owning RCP
465 else
466 mv_view = mv.subView (index);
467
468 // View of the relevant column(s) of the source multivector A.
469 // If A has fewer columns than mv_view, then create a view of
470 // the first index.size() columns of A.
471 Teuchos::RCP<const TMVB> A_view;
472 if (index.size() == numColsA)
473 A_view = Teuchos::rcpFromRef (A); // Const, non-owning RCP
474 else
475 A_view = A.subView (Teuchos::Range1D(0, index.size()-1));
476
477 // Copy the data to the destination multivector.
478 Thyra::assign(mv_view.ptr(), *A_view);
479 }
480
481 static void
482 Assign (const TMVB& A, TMVB& mv)
483 {
484 STRATIMIKOS_TIME_MONITOR("Belos::MVT::Assign");
485
486 const int numColsA = A.domain()->dim();
487 const int numColsMv = mv.domain()->dim();
488 if (numColsA > numColsMv)
489 {
490 std::ostringstream os;
491 os << "Belos::MultiVecTraits<Scalar, Thyra::MultiVectorBase<Scalar>"
492 " >::Assign(A, mv): ";
493 TEUCHOS_TEST_FOR_EXCEPTION(numColsA > numColsMv, std::invalid_argument,
494 os.str() << "Input multivector 'A' has "
495 << numColsA << " columns, but output multivector "
496 "'mv' has only " << numColsMv << " columns.");
497 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Should never get here!");
498 }
499 // Copy the data to the destination multivector.
500 if (numColsA == numColsMv) {
501 Thyra::assign (Teuchos::outArg (mv), A);
502 } else {
503 Teuchos::RCP<TMVB> mv_view =
504 CloneViewNonConst (mv, Teuchos::Range1D(0, numColsA-1));
505 Thyra::assign (mv_view.ptr(), A);
506 }
507 }
508
511 static void MvRandom( TMVB& mv )
512 {
513 // Thyra::randomize generates via a uniform distribution on [l,u]
514 // We will use this to generate on [-1,1]
515 Thyra::randomize<ScalarType>(
516 -Teuchos::ScalarTraits<ScalarType>::one(),
517 Teuchos::ScalarTraits<ScalarType>::one(),
518 Teuchos::outArg(mv));
519 }
520
522 static void
523 MvInit (TMVB& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero())
524 {
525 Thyra::assign (Teuchos::outArg (mv), alpha);
526 }
527
529
532
535 static void MvPrint( const TMVB& mv, std::ostream& os )
536 { os << describe(mv,Teuchos::VERB_EXTREME); }
537
539
540#ifdef HAVE_BELOS_TSQR
546 typedef Thyra::TsqrAdaptor< ScalarType > tsqr_adaptor_type;
547#endif // HAVE_BELOS_TSQR
548 };
549
551 //
552 // Implementation of the Belos::OperatorTraits for Thyra::LinearOpBase
553 //
555
563 template<class ScalarType>
564 class OperatorTraits <ScalarType,
565 Thyra::MultiVectorBase<ScalarType>,
566 Thyra::LinearOpBase<ScalarType> >
567 {
568 private:
569 typedef Thyra::MultiVectorBase<ScalarType> TMVB;
570 typedef Thyra::LinearOpBase<ScalarType> TLOB;
571
572 public:
588 static void
589 Apply (const TLOB& Op,
590 const TMVB& x,
591 TMVB& y,
592 ETrans trans = NOTRANS)
593 {
594 Thyra::EOpTransp whichOp;
595
596 // We don't check here whether the operator implements the
597 // requested operation. Call HasApplyTranspose() to check.
598 // Thyra::LinearOpBase implementations are not required to
599 // implement NOTRANS. However, Belos needs NOTRANS
600 // (obviously!), so we assume that Op implements NOTRANS.
601 if (trans == NOTRANS)
602 whichOp = Thyra::NOTRANS;
603 else if (trans == TRANS)
604 whichOp = Thyra::TRANS;
605 else if (trans == CONJTRANS)
606 whichOp = Thyra::CONJTRANS;
607 else
608 TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
609 "Belos::OperatorTraits::Apply (Thyra specialization): "
610 "'trans' argument must be neither NOTRANS=" << NOTRANS
611 << ", TRANS=" << TRANS << ", or CONJTRANS=" << CONJTRANS
612 << ", but instead has an invalid value of " << trans << ".");
613 Thyra::apply<ScalarType>(Op, whichOp, x, Teuchos::outArg(y));
614 }
615
617 static bool HasApplyTranspose (const TLOB& Op)
618 {
619 typedef Teuchos::ScalarTraits<ScalarType> STS;
620
621 // Thyra::LinearOpBase's interface lets you check whether the
622 // operator implements any of all four possible combinations of
623 // conjugation and transpose. Belos only needs transpose
624 // (TRANS) if the operator is real; in that case, Apply() does
625 // the same thing with trans = CONJTRANS or TRANS. If the
626 // operator is complex, Belos needs both transpose and conjugate
627 // transpose (CONJTRANS) if the operator is complex.
628 return Op.opSupported (Thyra::TRANS) &&
629 (! STS::isComplex || Op.opSupported (Thyra::CONJTRANS));
630 }
631 };
632
633} // end of Belos namespace
634
635#endif
636// end of file BELOS_THYRA_ADAPTER_HPP
#define STRATIMIKOS_TIME_MONITOR(NAME)
static void MvPrint(const TMVB &mv, std::ostream &os)
Print the mv multi-stdvector to the os output stream.
static void SetBlock(const TMVB &A, const std::vector< int > &index, TMVB &mv)
Copy the vectors in A to a set of vectors in mv indicated by the indices given in index.
static void MvAddMv(const ScalarType alpha, const TMVB &A, const ScalarType beta, const TMVB &B, TMVB &mv)
Replace mv with .
static int GetNumberVecs(const TMVB &mv)
Obtain the number of vectors in mv.
static Teuchos::RCP< TMVB > CloneCopy(const TMVB &mv)
Creates a new MultiVectorBase and copies contents of mv into the new std::vector (deep copy).
static Teuchos::RCP< const TMVB > CloneView(const TMVB &mv, const Teuchos::Range1D &index)
static void SetBlock(const TMVB &A, const Teuchos::Range1D &index, TMVB &mv)
static ptrdiff_t GetGlobalLength(const TMVB &mv)
Obtain the std::vector length of mv.
static void MvDot(const TMVB &mv, const TMVB &A, std::vector< ScalarType > &b)
Compute a std::vector b where the components are the individual dot-products of the i-th columns of A...
static Teuchos::RCP< TMVB > CloneCopy(const TMVB &mv, const std::vector< int > &index)
Creates a new MultiVectorBase and copies the selected contents of mv into the new std::vector (deep c...
static Teuchos::RCP< TMVB > CloneCopy(const TMVB &mv, const Teuchos::Range1D &index)
static Teuchos::RCP< TMVB > CloneViewNonConst(TMVB &mv, const std::vector< int > &index)
Creates a new MultiVectorBase that shares the selected contents of mv (shallow copy).
static Teuchos::RCP< TMVB > CloneViewNonConst(TMVB &mv, const Teuchos::Range1D &index)
static Teuchos::RCP< TMVB > Clone(const TMVB &mv, const int numvecs)
Creates a new empty MultiVectorBase containing numvecs columns.
static Teuchos::RCP< const TMVB > CloneView(const TMVB &mv, const std::vector< int > &index)
Creates a new const MultiVectorBase that shares the selected contents of mv (shallow copy).
static void MvScale(TMVB &mv, const ScalarType alpha)
Scale each element of the vectors in *this with alpha.
static void MvTransMv(const ScalarType alpha, const TMVB &A, const TMVB &mv, Teuchos::SerialDenseMatrix< int, ScalarType > &B)
Compute a dense matrix B through the matrix-matrix multiply .
static void MvScale(TMVB &mv, const std::vector< ScalarType > &alpha)
Scale each element of the i-th vector in *this with alpha[i].
static void MvTimesMatAddMv(const ScalarType alpha, const TMVB &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, TMVB &mv)
Update mv with .
static void MvRandom(TMVB &mv)
Replace the vectors in mv with random vectors.
static void MvNorm(const TMVB &mv, std::vector< magType > &normvec, NormType type=TwoNorm)
Compute the 2-norm of each individual std::vector of mv. Upon return, normvec[i] holds the value of ,...
static void MvInit(TMVB &mv, ScalarType alpha=Teuchos::ScalarTraits< ScalarType >::zero())
Replace each element of the vectors in mv with alpha.
static bool HasApplyTranspose(const TLOB &Op)
Whether the operator implements applying the transpose.
static void Apply(const TLOB &Op, const TMVB &x, TMVB &y, ETrans trans=NOTRANS)
Apply Op to x, storing the result in y.
Stub adaptor from Thyra::MultiVectorBase to TSQR.