Belos Package Browser (Single Doxygen Collection)  Development
BelosBlockCGIter.hpp
Go to the documentation of this file.
1 //@HEADER
2 // ************************************************************************
3 //
4 // Belos: Block Linear Solvers Package
5 // Copyright 2004 Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
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 Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 //@HEADER
41 
42 #ifndef BELOS_BLOCK_CG_ITER_HPP
43 #define BELOS_BLOCK_CG_ITER_HPP
44 
49 #include "BelosConfigDefs.hpp"
50 #include "BelosTypes.hpp"
51 #include "BelosCGIteration.hpp"
52 
53 #include "BelosLinearProblem.hpp"
54 #include "BelosMatOrthoManager.hpp"
55 #include "BelosOutputManager.hpp"
56 #include "BelosStatusTest.hpp"
57 #include "BelosOperatorTraits.hpp"
58 #include "BelosMultiVecTraits.hpp"
59 
60 #include "Teuchos_BLAS.hpp"
61 #include "Teuchos_LAPACK.hpp"
62 #include "Teuchos_SerialDenseMatrix.hpp"
63 #include "Teuchos_SerialDenseVector.hpp"
64 #include "Teuchos_SerialSymDenseMatrix.hpp"
65 #include "Teuchos_SerialSpdDenseSolver.hpp"
66 #include "Teuchos_ScalarTraits.hpp"
67 #include "Teuchos_ParameterList.hpp"
68 #include "Teuchos_TimeMonitor.hpp"
69 
70 namespace Belos {
71 
77 
80 template<class ScalarType, class MV, class OP,
81  const bool lapackSupportsScalarType =
83 class BlockCGIter : virtual public CGIteration<ScalarType, MV, OP> {
84 public:
87  typedef Teuchos::ScalarTraits<ScalarType> SCT;
88  typedef typename SCT::magnitudeType MagnitudeType;
89 
90  BlockCGIter( const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > & /* problem */,
91  const Teuchos::RCP<OutputManager<ScalarType> > & /* printer */,
92  const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > & /* tester */,
93  const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > & /* ortho */,
94  Teuchos::ParameterList & /* params */ )
95  {
96  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
97  }
98 
99  virtual ~BlockCGIter() {}
100 
101  void iterate () {
102  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
103  }
104 
106  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
107  }
108 
109  void initialize () {
110  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
111  }
112 
114  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
115  }
116 
117  int getNumIters() const {
118  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
119  }
120 
121  void resetNumIters( int iter=0 ) {
122  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
123  }
124 
125  Teuchos::RCP<const MV>
126  getNativeResiduals (std::vector<MagnitudeType>* /* norms */) const {
127  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
128  }
129 
130  Teuchos::RCP<MV> getCurrentUpdate() const {
131  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
132  }
133 
135  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
136  }
137 
138  int getBlockSize() const {
139  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
140  }
141 
142  void setBlockSize(int blockSize) {
143  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
144  }
145 
146  bool isInitialized() {
147  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
148  }
149 
150 private:
151  void setStateSize() {
152  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Stub");
153  }
154 };
155 
160 template<class ScalarType, class MV, class OP>
161 class BlockCGIter<ScalarType, MV, OP, true> :
162  virtual public CGIteration<ScalarType,MV,OP>
163 {
164 public:
165  //
166  // Convenience typedefs
167  //
170  typedef Teuchos::ScalarTraits<ScalarType> SCT;
171  typedef typename SCT::magnitudeType MagnitudeType;
172 
174 
175 
181  BlockCGIter( const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem,
182  const Teuchos::RCP<OutputManager<ScalarType> > &printer,
183  const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester,
184  const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho,
185  Teuchos::ParameterList &params );
186 
188  virtual ~BlockCGIter() {};
190 
191 
193 
194 
207  void iterate();
208 
224 
228  void initialize()
229  {
231  initializeCG(empty);
232  }
233 
242  state.R = R_;
243  state.P = P_;
244  state.AP = AP_;
245  state.Z = Z_;
246  return state;
247  }
248 
250 
251 
253 
254 
256  int getNumIters() const { return iter_; }
257 
259  void resetNumIters( int iter=0 ) { iter_ = iter; }
260 
263  Teuchos::RCP<const MV> getNativeResiduals( std::vector<MagnitudeType> *norms ) const { return R_; }
264 
266 
268  Teuchos::RCP<MV> getCurrentUpdate() const { return Teuchos::null; }
269 
271 
273 
274 
276  const LinearProblem<ScalarType,MV,OP>& getProblem() const { return *lp_; }
277 
279  int getBlockSize() const { return blockSize_; }
280 
282  void setBlockSize(int blockSize);
283 
285  bool isInitialized() { return initialized_; }
286 
288 
289  private:
290 
291  //
292  // Internal methods
293  //
295  void setStateSize();
296 
297  //
298  // Classes inputed through constructor that define the linear problem to be solved.
299  //
300  const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > lp_;
301  const Teuchos::RCP<OutputManager<ScalarType> > om_;
302  const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > stest_;
303  const Teuchos::RCP<OrthoManager<ScalarType,MV> > ortho_;
304 
305  //
306  // Algorithmic parameters
307  //
308  // blockSize_ is the solver block size.
310 
311  //
312  // Current solver state
313  //
314  // initialized_ specifies that the basis vectors have been initialized and the iterate() routine
315  // is capable of running; _initialize is controlled by the initialize() member method
316  // For the implications of the state of initialized_, please see documentation for initialize()
318 
319  // stateStorageInitialized_ specified that the state storage has be initialized.
320  // This initialization may be postponed if the linear problem was generated without
321  // the right-hand side or solution vectors.
323 
324  // Current subspace dimension, and number of iterations performed.
325  int iter_;
326 
327  //
328  // State Storage
329  //
330  // Residual
331  Teuchos::RCP<MV> R_;
332  //
333  // Preconditioned residual
334  Teuchos::RCP<MV> Z_;
335  //
336  // Direction std::vector
337  Teuchos::RCP<MV> P_;
338  //
339  // Operator applied to direction std::vector
340  Teuchos::RCP<MV> AP_;
341 
342 };
343 
344  template<class ScalarType, class MV, class OP>
346  BlockCGIter (const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> >& problem,
347  const Teuchos::RCP<OutputManager<ScalarType> >& printer,
348  const Teuchos::RCP<StatusTest<ScalarType,MV,OP> >& tester,
349  const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> >& ortho,
350  Teuchos::ParameterList& params) :
351  lp_(problem),
352  om_(printer),
353  stest_(tester),
354  ortho_(ortho),
355  blockSize_(0),
356  initialized_(false),
357  stateStorageInitialized_(false),
358  iter_(0)
359  {
360  // Set the block size and allocate data
361  int bs = params.get("Block Size", 1);
362  setBlockSize( bs );
363  }
364 
365  template <class ScalarType, class MV, class OP>
367  {
368  if (! stateStorageInitialized_) {
369  // Check if there is any multivector to clone from.
370  Teuchos::RCP<const MV> lhsMV = lp_->getLHS();
371  Teuchos::RCP<const MV> rhsMV = lp_->getRHS();
372  if (lhsMV == Teuchos::null && rhsMV == Teuchos::null) {
373  stateStorageInitialized_ = false;
374  return;
375  }
376  else {
377  // Initialize the state storage If the subspace has not be
378  // initialized before, generate it using the LHS or RHS from
379  // lp_.
380  if (R_ == Teuchos::null || MVT::GetNumberVecs(*R_)!=blockSize_) {
381  // Get the multivector that is not null.
382  Teuchos::RCP<const MV> tmp = ( (rhsMV!=Teuchos::null)? rhsMV: lhsMV );
383  TEUCHOS_TEST_FOR_EXCEPTION
384  (tmp == Teuchos::null,std:: invalid_argument,
385  "Belos::BlockCGIter::setStateSize: LinearProblem lacks "
386  "multivectors from which to clone.");
387  R_ = MVT::Clone (*tmp, blockSize_);
388  Z_ = MVT::Clone (*tmp, blockSize_);
389  P_ = MVT::Clone (*tmp, blockSize_);
390  AP_ = MVT::Clone (*tmp, blockSize_);
391  }
392 
393  // State storage has now been initialized.
394  stateStorageInitialized_ = true;
395  }
396  }
397  }
398 
399  template <class ScalarType, class MV, class OP>
401  {
402  // This routine only allocates space; it doesn't not perform any computation
403  // any change in size will invalidate the state of the solver.
404  TEUCHOS_TEST_FOR_EXCEPTION
405  (blockSize <= 0, std::invalid_argument, "Belos::BlockGmresIter::"
406  "setBlockSize: blockSize = " << blockSize << " <= 0.");
407  if (blockSize == blockSize_) {
408  return; // do nothing
409  }
410  if (blockSize!=blockSize_) {
411  stateStorageInitialized_ = false;
412  }
413  blockSize_ = blockSize;
414  initialized_ = false;
415  // Use the current blockSize_ to initialize the state storage.
416  setStateSize ();
417  }
418 
419  template <class ScalarType, class MV, class OP>
422  {
423  const char prefix[] = "Belos::BlockCGIter::initialize: ";
424 
425  // Initialize the state storage if it isn't already.
426  if (! stateStorageInitialized_) {
427  setStateSize();
428  }
429 
430  TEUCHOS_TEST_FOR_EXCEPTION
431  (! stateStorageInitialized_, std::invalid_argument,
432  prefix << "Cannot initialize state storage!");
433 
434  // NOTE: In BlockCGIter R_, the initial residual, is required!!!
435  const char errstr[] = "Specified multivectors must have a consistent "
436  "length and width.";
437 
438  // Create convenience variables for zero and one.
439  const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
440  const MagnitudeType zero = Teuchos::ScalarTraits<MagnitudeType>::zero();
441 
442  if (newstate.R != Teuchos::null) {
443 
444  TEUCHOS_TEST_FOR_EXCEPTION
445  (MVT::GetGlobalLength(*newstate.R) != MVT::GetGlobalLength(*R_),
446  std::invalid_argument, prefix << errstr );
447  TEUCHOS_TEST_FOR_EXCEPTION
448  (MVT::GetNumberVecs(*newstate.R) != blockSize_,
449  std::invalid_argument, prefix << errstr );
450 
451  // Copy basis vectors from newstate into V
452  if (newstate.R != R_) {
453  // copy over the initial residual (unpreconditioned).
454  MVT::MvAddMv( one, *newstate.R, zero, *newstate.R, *R_ );
455  }
456  // Compute initial direction vectors
457  // Initially, they are set to the preconditioned residuals
458  //
459  if ( lp_->getLeftPrec() != Teuchos::null ) {
460  lp_->applyLeftPrec( *R_, *Z_ );
461  if ( lp_->getRightPrec() != Teuchos::null ) {
462  Teuchos::RCP<MV> tmp = MVT::Clone( *Z_, blockSize_ );
463  lp_->applyRightPrec( *Z_, *tmp );
464  Z_ = tmp;
465  }
466  }
467  else if ( lp_->getRightPrec() != Teuchos::null ) {
468  lp_->applyRightPrec( *R_, *Z_ );
469  }
470  else {
471  Z_ = R_;
472  }
473  MVT::MvAddMv( one, *Z_, zero, *Z_, *P_ );
474  }
475  else {
476  TEUCHOS_TEST_FOR_EXCEPTION
477  (newstate.R == Teuchos::null, std::invalid_argument,
478  prefix << "BlockCGStateIterState does not have initial residual.");
479  }
480 
481  // The solver is initialized
482  initialized_ = true;
483  }
484 
485  template <class ScalarType, class MV, class OP>
487  {
488  const char prefix[] = "Belos::BlockCGIter::iterate: ";
489 
490  //
491  // Allocate/initialize data structures
492  //
493  if (initialized_ == false) {
494  initialize();
495  }
496  // Allocate data needed for LAPACK work.
497  int info = 0;
498  //char UPLO = 'U';
499  //(void) UPLO; // silence "unused variable" compiler warnings
500  bool uplo = true;
501  Teuchos::LAPACK<int,ScalarType> lapack;
502 
503  // Allocate memory for scalars.
504  Teuchos::SerialDenseMatrix<int,ScalarType> alpha( blockSize_, blockSize_ );
505  Teuchos::SerialDenseMatrix<int,ScalarType> beta( blockSize_, blockSize_ );
506  Teuchos::SerialDenseMatrix<int,ScalarType> rHz( blockSize_, blockSize_ ),
507  rHz_old( blockSize_, blockSize_ ), pAp( blockSize_, blockSize_ );
508  Teuchos::SerialSymDenseMatrix<int,ScalarType> pApHerm(Teuchos::View, uplo, pAp.values(), blockSize_, blockSize_);
509 
510  // Create dense spd solver.
511  Teuchos::SerialSpdDenseSolver<int,ScalarType> lltSolver;
512 
513  // Create convenience variables for zero and one.
514  const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
515 
516  // Get the current solution std::vector.
517  Teuchos::RCP<MV> cur_soln_vec = lp_->getCurrLHSVec();
518 
519  // Check that the current solution std::vector has blockSize_ columns.
520  TEUCHOS_TEST_FOR_EXCEPTION
521  (MVT::GetNumberVecs(*cur_soln_vec) != blockSize_, CGIterateFailure,
522  prefix << "Current linear system does not have the right number of vectors!" );
523  int rank = ortho_->normalize( *P_, Teuchos::null );
524  TEUCHOS_TEST_FOR_EXCEPTION
525  (rank != blockSize_, CGIterationOrthoFailure,
526  prefix << "Failed to compute initial block of orthonormal direction vectors.");
527 
528  //
529  // Iterate until the status test tells us to stop.
530  //
531  while (stest_->checkStatus(this) != Passed) {
532  // Increment the iteration
533  iter_++;
534 
535  // Multiply the current direction std::vector by A and store in Ap_
536  lp_->applyOp( *P_, *AP_ );
537 
538  // Compute alpha := <P_,R_> / <P_,AP_>
539  // 1) Compute P^T * A * P = pAp and P^T * R
540  // 2) Compute the Cholesky Factorization of pAp
541  // 3) Back and forward solves to compute alpha
542  //
543  MVT::MvTransMv( one, *P_, *R_, alpha );
544  MVT::MvTransMv( one, *P_, *AP_, pAp );
545 
546  // Compute Cholesky factorization of pAp
547  lltSolver.setMatrix( Teuchos::rcp(&pApHerm, false) );
548  lltSolver.factorWithEquilibration( true );
549  info = lltSolver.factor();
550  TEUCHOS_TEST_FOR_EXCEPTION
551  (info != 0, CGIterationLAPACKFailure,
552  prefix << "Failed to compute Cholesky factorization using LAPACK routine POTRF.");
553 
554  // Compute alpha by performing a back and forward solve with the
555  // Cholesky factorization in pAp.
556  lltSolver.setVectors (Teuchos::rcpFromRef (alpha), Teuchos::rcpFromRef (alpha));
557  info = lltSolver.solve();
558  TEUCHOS_TEST_FOR_EXCEPTION
559  (info != 0, CGIterationLAPACKFailure,
560  prefix << "Failed to compute alpha using Cholesky factorization (POTRS).");
561 
562  // Update the solution std::vector X := X + alpha * P_
563  MVT::MvTimesMatAddMv( one, *P_, alpha, one, *cur_soln_vec );
564  lp_->updateSolution();
565 
566  // Compute the new residual R_ := R_ - alpha * AP_
567  MVT::MvTimesMatAddMv( -one, *AP_, alpha, one, *R_ );
568 
569  // Compute the new preconditioned residual, Z_.
570  if ( lp_->getLeftPrec() != Teuchos::null ) {
571  lp_->applyLeftPrec( *R_, *Z_ );
572  if ( lp_->getRightPrec() != Teuchos::null ) {
573  Teuchos::RCP<MV> tmp = MVT::Clone( *Z_, blockSize_ );
574  lp_->applyRightPrec( *Z_, *tmp );
575  Z_ = tmp;
576  }
577  }
578  else if ( lp_->getRightPrec() != Teuchos::null ) {
579  lp_->applyRightPrec( *R_, *Z_ );
580  }
581  else {
582  Z_ = R_;
583  }
584 
585  // Compute beta := <AP_,Z_> / <P_,AP_>
586  // 1) Compute AP_^T * Z_
587  // 2) Compute the Cholesky Factorization of pAp (already have)
588  // 3) Back and forward solves to compute beta
589 
590  // Compute <AP_,Z>
591  MVT::MvTransMv( -one, *AP_, *Z_, beta );
592 
593  lltSolver.setVectors( Teuchos::rcp( &beta, false ), Teuchos::rcp( &beta, false ) );
594  info = lltSolver.solve();
595  TEUCHOS_TEST_FOR_EXCEPTION
596  (info != 0, CGIterationLAPACKFailure,
597  prefix << "Failed to compute beta using Cholesky factorization (POTRS).");
598 
599  // Compute the new direction vectors P_ = Z_ + P_ * beta
600  Teuchos::RCP<MV> Pnew = MVT::CloneCopy( *Z_ );
601  MVT::MvTimesMatAddMv(one, *P_, beta, one, *Pnew);
602  P_ = Pnew;
603 
604  // Compute orthonormal block of new direction vectors.
605  rank = ortho_->normalize( *P_, Teuchos::null );
606  TEUCHOS_TEST_FOR_EXCEPTION
607  (rank != blockSize_, CGIterationOrthoFailure,
608  prefix << "Failed to compute block of orthonormal direction vectors.");
609 
610  } // end while (sTest_->checkStatus(this) != Passed)
611  }
612 
613 } // namespace Belos
614 
615 #endif /* BELOS_BLOCK_CG_ITER_HPP */
Teuchos::RCP< const MV > R
The current residual.
Collection of types and exceptions used within the Belos solvers.
Belos&#39;s basic output manager for sending information of select verbosity levels to the appropriate ou...
Class which manages the output and verbosity of the Belos solvers.
Teuchos::ScalarTraits< ScalarType > SCT
int getNumIters() const
Get the current iteration count.
void initialize()
Initialize the solver with the initial vectors from the linear problem or random data.
int getBlockSize() const
Get the blocksize to be used by the iterative solver in solving this linear problem.
const Teuchos::RCP< OutputManager< ScalarType > > om_
BlockCGIter(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &, const Teuchos::RCP< OutputManager< ScalarType > > &, const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &, const Teuchos::RCP< MatOrthoManager< ScalarType, MV, OP > > &, Teuchos::ParameterList &)
Teuchos::RCP< MV > getCurrentUpdate() const
Get the current update to the linear system.
Structure to contain pointers to CGIteration state variables.
Pure virtual base class which augments the basic interface for a conjugate gradient linear solver ite...
void resetNumIters(int iter=0)
Reset the iteration count.
Pure virtual base class for defining the status testing capabilities of Belos.
MultiVecTraits< ScalarType, MV > MVT
Teuchos::RCP< MV > getCurrentUpdate() const
Get the current update to the linear system.
Declaration of basic traits for the multivector type.
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Get a constant reference to the linear problem.
Teuchos::ScalarTraits< ScalarType > SCT
int getBlockSize() const
Get the block size to be used by the iterative solver in solving this linear problem.
static void MvTransMv(const ScalarType alpha, const MV &A, const MV &mv, Teuchos::SerialDenseMatrix< int, ScalarType > &B)
Compute a dense matrix B through the matrix-matrix multiply .
A pure virtual class for defining the status tests for the Belos iterative solvers.
Class which defines basic traits for the operator type.
CGIterateFailure is thrown when the CGIteration object is unable to compute the next iterate in the C...
Teuchos::RCP< const MV > AP
The matrix A applied to current decent direction vector.
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
static void MvAddMv(const ScalarType alpha, const MV &A, const ScalarType beta, const MV &B, MV &mv)
Replace mv with .
Traits class which defines basic operations on multivectors.
OperatorTraits< ScalarType, MV, OP > OPT
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Get a constant reference to the linear problem.
void initializeCG(CGIterationState< ScalarType, MV > &)
Initialize the solver to an iterate, providing a complete state.
CGIterationLAPACKFailure is thrown when a nonzero return value is passed back from an LAPACK routine...
static Teuchos::RCP< MV > Clone(const MV &mv, const int numvecs)
Creates a new empty MV containing numvecs columns.
void iterate()
This method performs linear solver iterations until the status test indicates the need to stop or an ...
A linear system to solve, and its associated information.
Class which describes the linear problem to be solved by the iterative solver.
CGIterationState< ScalarType, MV > getState() const
Get the current state of the linear solver.
Teuchos::RCP< const MV > getNativeResiduals(std::vector< MagnitudeType > *norms) const
Get the norms of the residuals native to the solver.
SCT::magnitudeType MagnitudeType
Type traits class that says whether Teuchos::LAPACK has a valid implementation for the given ScalarTy...
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
Creates a new MV and copies contents of mv into the new vector (deep copy).
static void MvTimesMatAddMv(const ScalarType alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, MV &mv)
Update mv with .
const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > lp_
bool isInitialized()
States whether the solver has been initialized or not.
bool isInitialized()
States whether the solver has been initialized or not.
void resetNumIters(int iter=0)
Reset the iteration count to iter.
const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > stest_
const Teuchos::RCP< OrthoManager< ScalarType, MV > > ortho_
Teuchos::RCP< const MV > getNativeResiduals(std::vector< MagnitudeType > *) const
Teuchos::RCP< const MV > Z
The current preconditioned residual.
CGIterationState< ScalarType, MV > getState() const
Get the current state of the linear solver.
OperatorTraits< ScalarType, MV, OP > OPT
static ptrdiff_t GetGlobalLength(const MV &mv)
Return the number of rows in the given multivector mv.
CGIterationOrthoFailure is thrown when the CGIteration object is unable to compute independent direct...
void setBlockSize(int blockSize)
Set the blocksize to be used by the iterative solver in solving this linear problem.
void initialize()
Initialize the solver with the initial vectors from the linear problem or random data.
Class which defines basic traits for the operator type.
int getNumIters() const
Get the current iteration count.
Belos&#39;s templated virtual class for providing routines for orthogonalization and orthonormzalition of...
Belos header file which uses auto-configuration information to include necessary C++ headers...
Teuchos::RCP< const MV > P
The current decent direction vector.
Templated virtual class for providing orthogonalization/orthonormalization methods with matrix-based ...
Stub implementation of BlockCGIter, for ScalarType types for which Teuchos::LAPACK does NOT have a va...