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