Anasazi Version of the Day
Loading...
Searching...
No Matches
AnasaziSaddleContainer.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Anasazi: Block Eigensolvers Package
4//
5// Copyright 2004 NTESS and the Anasazi contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
17#ifndef ANASAZI_SADDLE_CONTAINER_HPP
18#define ANASAZI_SADDLE_CONTAINER_HPP
19
20#include "AnasaziConfigDefs.hpp"
21#include "Teuchos_VerboseObject.hpp"
22
23#ifdef HAVE_ANASAZI_BELOS
24#include "BelosConfigDefs.hpp"
25#include "BelosMultiVecTraits.hpp"
26#endif
27
28using Teuchos::RCP;
29using Teuchos::rcp;
30
31namespace Anasazi {
32namespace Experimental {
33
34template <class ScalarType, class MV>
35class SaddleContainer //: public Anasazi::SaddleContainer<ScalarType, MV>
36{
37 template <class Scalar_, class MV_, class OP_> friend class SaddleOperator;
38
39private:
41 typedef Teuchos::SerialDenseMatrix<int,ScalarType> SerialDenseMatrix;
42 const ScalarType ONE, ZERO;
43 RCP<MV> upper_;
44 RCP<SerialDenseMatrix> lowerRaw_;
45 std::vector<int> indices_;
46
47 RCP<SerialDenseMatrix> getLower() const;
48 void setLower(const RCP<SerialDenseMatrix> lower);
49
50public:
51 // Constructors
52 SaddleContainer( ) : ONE(Teuchos::ScalarTraits<ScalarType>::one()), ZERO(Teuchos::ScalarTraits<ScalarType>::zero()) { };
53 SaddleContainer( const RCP<MV> X, bool eye=false );
54
55 // Things that are necessary for compilation
56 // Returns a clone of the current vector
57 SaddleContainer<ScalarType, MV> * Clone(const int nvecs) const;
58 // Returns a duplicate of the current vector
59 SaddleContainer<ScalarType, MV> * CloneCopy() const;
60 // Returns a duplicate of the specified vectors
61 SaddleContainer<ScalarType, MV> * CloneCopy(const std::vector<int> &index) const;
62 SaddleContainer<ScalarType, MV> * CloneViewNonConst(const std::vector<int> &index) const;
63 SaddleContainer<ScalarType, MV> * CloneViewNonConst(const Teuchos::Range1D& index) const;
64 const SaddleContainer<ScalarType, MV> * CloneView(const std::vector<int> &index) const;
65 const SaddleContainer<ScalarType, MV> * CloneView(const Teuchos::Range1D& index) const;
66 ptrdiff_t GetGlobalLength() const { return MVT::GetGlobalLength(*upper_) + lowerRaw_->numRows(); };
67 int GetNumberVecs() const { return MVT::GetNumberVecs(*upper_); };
68 // Update *this with alpha * A * B + beta * (*this)
69 void MvTimesMatAddMv(ScalarType alpha, const SaddleContainer<ScalarType,MV> &A,
70 const Teuchos::SerialDenseMatrix<int, ScalarType> &B,
71 ScalarType beta);
72 // Replace *this with alpha * A + beta * B
73 void MvAddMv(ScalarType alpha, const SaddleContainer<ScalarType,MV>& A,
74 ScalarType beta, const SaddleContainer<ScalarType,MV>& B);
75 // Scale the vectors by alpha
76 void MvScale( ScalarType alpha );
77 // Scale the i-th vector by alpha[i]
78 void MvScale( const std::vector<ScalarType>& alpha );
79 // Compute a dense matrix B through the matrix-matrix multiply alpha * A^H * (*this)
80 void MvTransMv (ScalarType alpha, const SaddleContainer<ScalarType, MV>& A,
81 Teuchos::SerialDenseMatrix< int, ScalarType >& B) const;
82 // Compute a vector b where the components are the individual dot-products, i.e.b[i] = A[i]^H*this[i] where A[i] is the i-th column of A.
83 void MvDot (const SaddleContainer<ScalarType, MV>& A, std::vector<ScalarType> &b) const;
84 // Compute the 2-norm of each individual vector
85 void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec) const;
86 // Copy the vectors in A to a set of vectors in *this. The numvecs vectors in
87 // A are copied to a subset of vectors in *this indicated by the indices given
88 // in index.
89 void SetBlock (const SaddleContainer<ScalarType, MV>& A, const std::vector<int> &index);
90 // Deep copy.
91 void Assign (const SaddleContainer<ScalarType, MV>&A);
92 // Fill the vectors in *this with random numbers.
93 void MvRandom ();
94 // Replace each element of the vectors in *this with alpha.
95 void MvInit (ScalarType alpha);
96 // Prints the multivector to an output stream
97 void MvPrint (std::ostream &os) const;
98};
99
100
101
102// THIS IS NEW!
103template <class ScalarType, class MV>
104RCP< Teuchos::SerialDenseMatrix<int,ScalarType> > SaddleContainer<ScalarType, MV>::getLower() const
105{
106 if(indices_.empty())
107 {
108 return lowerRaw_;
109 }
110
111 int nrows = lowerRaw_->numRows();
112 int ncols = indices_.size();
113
114 RCP<SerialDenseMatrix> lower = rcp(new SerialDenseMatrix(nrows,ncols,false));
115
116 for(int r=0; r<nrows; r++)
117 {
118 for(int c=0; c<ncols; c++)
119 {
120 (*lower)(r,c) = (*lowerRaw_)(r,indices_[c]);
121 }
122 }
123
124 return lower;
125}
126
127
128
129// THIS IS NEW!
130template <class ScalarType, class MV>
131void SaddleContainer<ScalarType, MV>::setLower(const RCP<SerialDenseMatrix> lower)
132{
133 // If the indices are empty, lower points to lowerRaw
134 if(indices_.empty())
135 {
136 return;
137 }
138
139 int nrows = lowerRaw_->numRows();
140 int ncols = indices_.size();
141
142 for(int r=0; r<nrows; r++)
143 {
144 for(int c=0; c<ncols; c++)
145 {
146 (*lowerRaw_)(r,indices_[c]) = (*lower)(r,c);
147 }
148 }
149}
150
151
152
153// Constructor
154template <class ScalarType, class MV>
155SaddleContainer<ScalarType, MV>::SaddleContainer( const RCP<MV> X, bool eye )
156: ONE(Teuchos::ScalarTraits<ScalarType>::one()), ZERO(Teuchos::ScalarTraits<ScalarType>::zero())
157{
158 int nvecs = MVT::GetNumberVecs(*X);
159
160 if(eye)
161 {
162 // Initialize upper_ as all 0s
163 upper_ = MVT::Clone(*X, nvecs);
164 MVT::MvInit(*upper_);
165
166 // Initialize Y to be I
167 lowerRaw_ = rcp(new SerialDenseMatrix(nvecs,nvecs));
168 for(int i=0; i < nvecs; i++)
169 (*lowerRaw_)(i,i) = ONE;
170 }
171 else
172 {
173 // Point upper_ to X
174 upper_ = X;
175
176 // Initialize Y to be 0
177 lowerRaw_ = rcp(new SerialDenseMatrix(nvecs,nvecs));
178 }
179}
180
181
182
183// Returns a clone of the current vector
184template <class ScalarType, class MV>
185SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::Clone(const int nvecs) const
186{
187 SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();
188
189 newSC->upper_ = MVT::Clone(*upper_,nvecs);
190 newSC->lowerRaw_ = rcp(new SerialDenseMatrix(lowerRaw_->numRows(),nvecs));
191
192 return newSC;
193}
194
195
196
197// Returns a duplicate of the current vector
198template <class ScalarType, class MV>
199SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneCopy() const
200{
201 SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();
202
203 newSC->upper_ = MVT::CloneCopy(*upper_);
204 newSC->lowerRaw_ = getLower();
205
206 return newSC;
207}
208
209
210
211// Returns a duplicate of the specified vectors
212template <class ScalarType, class MV>
213SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneCopy(const std::vector< int > &index) const
214{
215 SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();
216
217 newSC->upper_ = MVT::CloneCopy(*upper_,index);
218
219 int ncols = index.size();
220 int nrows = lowerRaw_->numRows();
221 RCP<SerialDenseMatrix> lower = getLower();
222 newSC->lowerRaw_ = rcp(new SerialDenseMatrix(nrows,ncols));
223 for(int c=0; c < ncols; c++)
224 {
225 for(int r=0; r < nrows; r++)
226 (*newSC->lowerRaw_)(r,c) = (*lower)(r,index[c]);
227 }
228
229 return newSC;
230}
231
232
233
234// THIS IS NEW!
235template <class ScalarType, class MV>
236SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneViewNonConst(const std::vector<int> &index) const
237{
238 SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();
239
240 newSC->upper_ = MVT::CloneViewNonConst(*upper_,index);
241
242 newSC->lowerRaw_ = lowerRaw_;
243
244 if(!indices_.empty())
245 {
246 newSC->indices_.resize(index.size());
247 for(unsigned int i=0; i<index.size(); i++)
248 {
249 newSC->indices_[i] = indices_[index[i]];
250 }
251 }
252 else
253 {
254 newSC->indices_ = index;
255 }
256
257 return newSC;
258}
259
260
261template <class ScalarType, class MV>
262SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneViewNonConst(const Teuchos::Range1D& index) const
263{
264 SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();
265
266 newSC->upper_ = MVT::CloneViewNonConst(*upper_,index);
267
268 newSC->lowerRaw_ = lowerRaw_;
269
270 newSC->indices_.resize(index.size());
271 for(unsigned int i=0; i<index.size(); i++)
272 {
273 newSC->indices_[i] = indices_[index.lbound()+i];
274 }
275
276 return newSC;
277}
278
279
280
281// THIS IS NEW!
282template <class ScalarType, class MV>
283const SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneView(const std::vector<int> &index) const
284{
285 SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();
286
287 newSC->upper_ = MVT::CloneViewNonConst(*upper_,index);
288
289 newSC->lowerRaw_ = lowerRaw_;
290
291 if(!indices_.empty())
292 {
293 newSC->indices_.resize(index.size());
294 for(unsigned int i=0; i<index.size(); i++)
295 {
296 newSC->indices_[i] = indices_[index[i]];
297 }
298 }
299 else
300 {
301 newSC->indices_ = index;
302 }
303
304 return newSC;
305}
306
307
308template <class ScalarType, class MV>
309const SaddleContainer<ScalarType, MV> * SaddleContainer<ScalarType, MV>::CloneView(const Teuchos::Range1D& index) const
310{
311 SaddleContainer<ScalarType, MV> * newSC = new SaddleContainer<ScalarType, MV>();
312
313 newSC->upper_ = MVT::CloneViewNonConst(*upper_,index);
314
315 newSC->lowerRaw_ = lowerRaw_;
316
317 newSC->indices_.resize(index.size());
318 for(unsigned int i=0; i<index.size(); i++)
319 {
320 newSC->indices_[i] = indices_[index.lbound()+i];
321 }
322
323 return newSC;
324}
325
326
327
328// Update *this with alpha * A * B + beta * (*this)
329// THIS IS NEW!
330template <class ScalarType, class MV>
331void SaddleContainer<ScalarType, MV>::MvTimesMatAddMv(ScalarType alpha, const SaddleContainer<ScalarType,MV> &A,
332 const Teuchos::SerialDenseMatrix<int, ScalarType> &B,
333 ScalarType beta)
334{
335 MVT::MvTimesMatAddMv(alpha,*(A.upper_),B,beta,*upper_);
336 RCP<SerialDenseMatrix> lower = getLower();
337 RCP<SerialDenseMatrix> Alower = A.getLower();
338 lower->multiply(Teuchos::NO_TRANS,Teuchos::NO_TRANS,alpha,*Alower,B,beta);
339 setLower(lower);
340}
341
342
343
344// Replace *this with alpha * A + beta * B
345template <class ScalarType, class MV>
346void SaddleContainer<ScalarType, MV>::MvAddMv(ScalarType alpha, const SaddleContainer<ScalarType,MV>& A,
347 ScalarType beta, const SaddleContainer<ScalarType,MV>& B)
348{
349 MVT::MvAddMv(alpha, *(A.upper_), beta, *(B.upper_), *upper_);
350
351 RCP<SerialDenseMatrix> lower = getLower();
352 RCP<SerialDenseMatrix> Alower = A.getLower();
353 RCP<SerialDenseMatrix> Blower = B.getLower();
354
355 //int ncolsA = Alower->numCols(); // unused
356 //int ncolsThis = lower->numCols(); // unused
357 //int nrows = lower->numRows(); // unused
358
359 // Y = alpha A
360 lower->assign(*Alower);
361 if(alpha != ONE)
362 lower->scale(alpha);
363 // Y += beta B
364 if(beta == ONE)
365 *lower += *Blower;
366 else if(beta == -ONE)
367 *lower -= *Blower;
368 else if(beta != ZERO)
369 {
370 SerialDenseMatrix scaledB(*Blower);
371 scaledB.scale(beta);
372 *lower += *Blower;
373 }
374
375 setLower(lower);
376}
377
378
379
380// Scale the vectors by alpha
381template <class ScalarType, class MV>
382void SaddleContainer<ScalarType, MV>::MvScale( ScalarType alpha )
383{
384 MVT::MvScale(*upper_, alpha);
385
386
387 RCP<SerialDenseMatrix> lower = getLower();
388 lower->scale(alpha);
389 setLower(lower);
390}
391
392
393
394// Scale the i-th vector by alpha[i]
395template <class ScalarType, class MV>
396void SaddleContainer<ScalarType, MV>::MvScale( const std::vector<ScalarType>& alpha )
397{
398 MVT::MvScale(*upper_, alpha);
399
400 RCP<SerialDenseMatrix> lower = getLower();
401
402 int nrows = lower->numRows();
403 int ncols = lower->numCols();
404
405 for(int c=0; c<ncols; c++)
406 {
407 for(int r=0; r<nrows; r++)
408 (*lower)(r,c) *= alpha[c];
409 }
410
411 setLower(lower);
412}
413
414
415
416// Compute a dense matrix B through the matrix-matrix multiply alpha * A^H * (*this)
417// THIS IS NEW!
418template <class ScalarType, class MV>
419void SaddleContainer<ScalarType, MV>::MvTransMv (ScalarType alpha, const SaddleContainer<ScalarType, MV>& A,
420 Teuchos::SerialDenseMatrix< int, ScalarType >& B) const
421{
422 MVT::MvTransMv(alpha,*(A.upper_),*upper_,B);
423 RCP<SerialDenseMatrix> lower = getLower();
424 RCP<SerialDenseMatrix> Alower = A.getLower();
425 B.multiply(Teuchos::TRANS,Teuchos::NO_TRANS,alpha,*(Alower),*lower,ONE);
426}
427
428
429
430// Compute a vector b where the components are the individual dot-products, i.e.b[i] = A[i]^H*this[i] where A[i] is the i-th column of A.
431template <class ScalarType, class MV>
432void SaddleContainer<ScalarType, MV>::MvDot (const SaddleContainer<ScalarType, MV>& A, std::vector<ScalarType> &b) const
433{
434 MVT::MvDot(*upper_, *(A.upper_), b);
435
436 RCP<SerialDenseMatrix> lower = getLower();
437 RCP<SerialDenseMatrix> Alower = A.getLower();
438
439 int nrows = lower->numRows();
440 int ncols = lower->numCols();
441
442 for(int c=0; c < ncols; c++)
443 {
444 for(int r=0; r < nrows; r++)
445 {
446 b[c] += ((*Alower)(r,c) * (*lower)(r,c));
447 }
448 }
449}
450
451
452
453// Compute the 2-norm of each individual vector
454// THIS IS NEW!
455template <class ScalarType, class MV>
456void SaddleContainer<ScalarType, MV>::MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec) const
457{
458 // TODO: Make this better
459 MvDot(*this,normvec);
460 for(unsigned int i=0; i<normvec.size(); i++)
461 normvec[i] = sqrt(normvec[i]);
462}
463
464
465
466// Copy the vectors in A to a set of vectors in *this. The numvecs vectors in
467// A are copied to a subset of vectors in *this indicated by the indices given
468// in index.
469template <class ScalarType, class MV>
470void SaddleContainer<ScalarType, MV>::SetBlock (const SaddleContainer<ScalarType, MV>& A, const std::vector<int> &index)
471{
472 MVT::SetBlock(*(A.upper_), index, *upper_);
473
474 RCP<SerialDenseMatrix> lower = getLower();
475 RCP<SerialDenseMatrix> Alower = A.getLower();
476
477 int nrows = lower->numRows();
478
479 int nvecs = index.size();
480 for(int c=0; c<nvecs; c++)
481 {
482 for(int r=0; r<nrows; r++)
483 (*lower)(r,index[c]) = (*Alower)(r,c);
484 }
485
486 setLower(lower);
487}
488
489
490
491// Deep copy.
492template <class ScalarType, class MV>
493void SaddleContainer<ScalarType, MV>::Assign (const SaddleContainer<ScalarType, MV>&A)
494{
495 MVT::Assign(*(A.upper_),*(upper_));
496
497 RCP<SerialDenseMatrix> lower = getLower();
498 RCP<SerialDenseMatrix> Alower = A.getLower();
499
500 *lower = *Alower; // This is a well-defined operator for SerialDenseMatrix
501
502 setLower(lower);
503}
504
505
506
507// Fill the vectors in *this with random numbers.
508// THIS IS NEW!
509template <class ScalarType, class MV>
510void SaddleContainer<ScalarType, MV>::MvRandom ()
511{
512 MVT::MvRandom(*upper_);
513
514 RCP<SerialDenseMatrix> lower = getLower();
515 lower->random();
516 setLower(lower);
517}
518
519
520
521// Replace each element of the vectors in *this with alpha.
522template <class ScalarType, class MV>
523void SaddleContainer<ScalarType, MV>::MvInit (ScalarType alpha)
524{
525 MVT::MvInit(*upper_,alpha);
526
527 RCP<SerialDenseMatrix> lower = getLower();
528 lower->putScalar(alpha);
529 setLower(lower);
530}
531
532
533
534// Prints the multivector to an output stream
535template <class ScalarType, class MV>
536void SaddleContainer<ScalarType, MV>::MvPrint (std::ostream &os) const
537{
538 RCP<SerialDenseMatrix> lower = getLower();
539 //int nrows = lower->numRows(); // unused
540 //int ncols = lower->numCols(); // unused
541
542 os << "Object SaddleContainer" << std::endl;
543 os << "X\n";
544 upper_->describe(*(Teuchos::VerboseObjectBase::getDefaultOStream()),Teuchos::VERB_EXTREME);
545// os << "X\n" << *upper_ << std::endl;
546
547 os << "Y\n" << *lower << std::endl;
548}
549
550} // End namespace Experimental
551
552template<class ScalarType, class MV >
553class MultiVecTraits<ScalarType,Experimental::SaddleContainer<ScalarType, MV> >
554{
555typedef Experimental::SaddleContainer<ScalarType,MV> SC;
556
557public:
558 static RCP<SC > Clone( const SC& mv, const int numvecs )
559 { return rcp( const_cast<SC&>(mv).Clone(numvecs) ); }
560
561 static RCP<SC > CloneCopy( const SC& mv )
562 { return rcp( const_cast<SC&>(mv).CloneCopy() ); }
563
564 static RCP<SC > CloneCopy( const SC& mv, const std::vector<int>& index )
565 { return rcp( const_cast<SC&>(mv).CloneCopy(index) ); }
566
567 static ptrdiff_t GetGlobalLength( const SC& mv )
568 { return mv.GetGlobalLength(); }
569
570 static int GetNumberVecs( const SC& mv )
571 { return mv.GetNumberVecs(); }
572
573 static void MvTimesMatAddMv( ScalarType alpha, const SC& A,
574 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
575 ScalarType beta, SC& mv )
576 { mv.MvTimesMatAddMv(alpha, A, B, beta); }
577
578 static void MvAddMv( ScalarType alpha, const SC& A, ScalarType beta, const SC& B, SC& mv )
579 { mv.MvAddMv(alpha, A, beta, B); }
580
581 static void MvTransMv( ScalarType alpha, const SC& A, const SC& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B)
582 { mv.MvTransMv(alpha, A, B); }
583
584 static void MvDot( const SC& mv, const SC& A, std::vector<ScalarType> & b)
585 { mv.MvDot( A, b); }
586
587 static void MvScale ( SC& mv, ScalarType alpha )
588 { mv.MvScale( alpha ); }
589
590 static void MvScale ( SC& mv, const std::vector<ScalarType>& alpha )
591 { mv.MvScale( alpha ); }
592
593 static void MvNorm( const SC& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> & normvec)
594 { mv.MvNorm(normvec); }
595
596 static void SetBlock( const SC& A, const std::vector<int>& index, SC& mv )
597 { mv.SetBlock(A, index); }
598
599 static void Assign( const SC& A, SC& mv )
600 { mv.Assign(A); }
601
602 static void MvRandom( SC& mv )
603 { mv.MvRandom(); }
604
605 static void MvInit( SC& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
606 { mv.MvInit(alpha); }
607
608 static void MvPrint( const SC& mv, std::ostream& os )
609 { mv.MvPrint(os); }
610};
611
612} // end namespace Anasazi
613
614#ifdef HAVE_ANASAZI_BELOS
615namespace Belos
616{
617
618template<class ScalarType, class MV >
619class MultiVecTraits< ScalarType, Anasazi::Experimental::SaddleContainer<ScalarType,MV> >
620{
621typedef Anasazi::Experimental::SaddleContainer<ScalarType,MV> SC;
622public:
623 static RCP<SC > Clone( const SC& mv, const int numvecs )
624 { return rcp( const_cast<SC&>(mv).Clone(numvecs) ); }
625
626 static RCP<SC > CloneCopy( const SC& mv )
627 { return rcp( const_cast<SC&>(mv).CloneCopy() ); }
628
629 static RCP<SC > CloneCopy( const SC& mv, const std::vector<int>& index )
630 { return rcp( const_cast<SC&>(mv).CloneCopy(index) ); }
631
632 static RCP<SC> CloneViewNonConst( SC& mv, const std::vector<int>& index )
633 { return rcp( mv.CloneViewNonConst(index) ); }
634
635 static RCP<SC> CloneViewNonConst( SC& mv, const Teuchos::Range1D& index )
636 { return rcp( mv.CloneViewNonConst(index) ); }
637
638 static RCP<const SC> CloneView( const SC& mv, const std::vector<int> & index )
639 { return rcp( mv.CloneView(index) ); }
640
641 static RCP<const SC> CloneView( const SC& mv, const Teuchos::Range1D& index )
642 { return rcp( mv.CloneView(index) ); }
643
644 static ptrdiff_t GetGlobalLength( const SC& mv )
645 { return mv.GetGlobalLength(); }
646
647 static int GetNumberVecs( const SC& mv )
648 { return mv.GetNumberVecs(); }
649
650 static void MvTimesMatAddMv( ScalarType alpha, const SC& A,
651 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
652 ScalarType beta, SC& mv )
653 { mv.MvTimesMatAddMv(alpha, A, B, beta); }
654
655 static void MvAddMv( ScalarType alpha, const SC& A, ScalarType beta, const SC& B, SC& mv )
656 { mv.MvAddMv(alpha, A, beta, B); }
657
658 static void MvTransMv( ScalarType alpha, const SC& A, const SC& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B)
659 { mv.MvTransMv(alpha, A, B); }
660
661 static void MvDot( const SC& mv, const SC& A, std::vector<ScalarType> & b)
662 { mv.MvDot( A, b); }
663
664 static void MvScale ( SC& mv, ScalarType alpha )
665 { mv.MvScale( alpha ); }
666
667 static void MvScale ( SC& mv, const std::vector<ScalarType>& alpha )
668 { mv.MvScale( alpha ); }
669
670 // TODO: MAKE SURE TYPE == TWONORM
671 static void MvNorm( const SC& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> & normvec, NormType type=TwoNorm)
672 { mv.MvNorm(normvec); }
673
674 static void SetBlock( const SC& A, const std::vector<int>& index, SC& mv )
675 { mv.SetBlock(A, index); }
676
677 static void Assign( const SC& A, SC& mv )
678 { mv.Assign(A); }
679
680 static void MvRandom( SC& mv )
681 { mv.MvRandom(); }
682
683 static void MvInit( SC& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
684 { mv.MvInit(alpha); }
685
686 static void MvPrint( const SC& mv, std::ostream& os )
687 { mv.MvPrint(os); }
688
689#ifdef HAVE_BELOS_TSQR
702 typedef Belos::details::StubTsqrAdapter<SC> tsqr_adaptor_type;
703#endif // HAVE_BELOS_TSQR
704};
705
706} // end namespace Belos
707#endif
708
709#endif
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
Traits class which defines basic operations on multivectors.
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
static ptrdiff_t GetGlobalLength(const MV &mv)
Return the number of rows in the given multivector mv.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.