Belos  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BelosPCPGSolMgr.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_PCPG_SOLMGR_HPP
43 #define BELOS_PCPG_SOLMGR_HPP
44 
49 #include "BelosConfigDefs.hpp"
50 #include "BelosTypes.hpp"
51 
52 #include "BelosLinearProblem.hpp"
53 #include "BelosSolverManager.hpp"
54 
55 #include "BelosPCPGIter.hpp"
56 
62 #include "BelosStatusTestCombo.hpp"
64 #include "BelosOutputManager.hpp"
65 #include "Teuchos_BLAS.hpp"
66 #include "Teuchos_LAPACK.hpp"
67 #ifdef BELOS_TEUCHOS_TIME_MONITOR
68 #include "Teuchos_TimeMonitor.hpp"
69 #endif
70 
71 //#include <vector> //getPermThatSorts
72 //#include <algorithm> //getPermThatSorts
73 
74 
91 namespace Belos {
92 
94 
95 
103  PCPGSolMgrLinearProblemFailure(const std::string& what_arg) : BelosError(what_arg)
104  {}};
105 
111  class PCPGSolMgrOrthoFailure : public BelosError {public:
112  PCPGSolMgrOrthoFailure(const std::string& what_arg) : BelosError(what_arg)
113  {}};
114 
121  class PCPGSolMgrLAPACKFailure : public BelosError {public:
122  PCPGSolMgrLAPACKFailure(const std::string& what_arg) : BelosError(what_arg)
123  {}};
124 
131  class PCPGSolMgrRecyclingFailure : public BelosError {public:
132  PCPGSolMgrRecyclingFailure(const std::string& what_arg) : BelosError(what_arg)
133  {}};
134 
136 
137 
138  template<class ScalarType, class MV, class OP>
139  class PCPGSolMgr : public SolverManager<ScalarType,MV,OP> {
140 
141  private:
145  typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
147 
148  public:
149 
151 
152 
159  PCPGSolMgr();
160 
198 
200  virtual ~PCPGSolMgr() {};
202 
204 
205 
209  return *problem_;
210  }
211 
215 
219 
226  return Teuchos::tuple(timerSolve_);
227  }
228 
234  MagnitudeType achievedTol() const {
235  return achievedTol_;
236  }
237 
239  int getNumIters() const {
240  return numIters_;
241  }
242 
245  bool isLOADetected() const { return false; }
246 
248 
250 
251 
253  void setProblem( const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem ) { problem_ = problem; }
254 
257 
259 
261 
262 
266  void reset( const ResetType type ) { if ((type & Belos::Problem) && !Teuchos::is_null(problem_)) problem_->setProblem(); }
268 
270 
271 
289  ReturnType solve();
290 
292 
295 
297  std::string description() const;
298 
300 
301  private:
302 
303  // In the A-inner product, perform an RRQR decomposition without using A unless absolutely necessary. Given
304  // the seed space U and C = A U, find U1 and C1 with span(U1)=span(U) such that C1'U1 = I maintaining C=AU.
305  int ARRQR(int numVecs, int numOrthVecs, const Teuchos::SerialDenseMatrix<int,ScalarType>& D);
306 
307  // Linear problem.
309 
310  // Output manager.
312  Teuchos::RCP<std::ostream> outputStream_;
313 
314  // Status test.
319 
320  // Orthogonalization manager.
322 
323  // Current parameter list.
325 
326  // Default solver values.
327  static const MagnitudeType convtol_default_;
328  static const MagnitudeType orthoKappa_default_;
329  static const int maxIters_default_;
330  static const int deflatedBlocks_default_;
331  static const int savedBlocks_default_;
332  static const int verbosity_default_;
333  static const int outputStyle_default_;
334  static const int outputFreq_default_;
335  static const std::string label_default_;
336  static const std::string orthoType_default_;
337  static const Teuchos::RCP<std::ostream> outputStream_default_;
338 
339  //
340  // Current solver values.
341  //
342 
344  MagnitudeType convtol_;
345 
347  MagnitudeType orthoKappa_;
348 
350  MagnitudeType achievedTol_;
351 
353  int numIters_;
354 
356  int maxIters_;
357 
358  int deflatedBlocks_, savedBlocks_, verbosity_, outputStyle_, outputFreq_;
359  std::string orthoType_;
360 
361  // Recycled subspace, its image and the residual
362  Teuchos::RCP<MV> U_, C_, R_;
363 
364  // Actual dimension of current recycling subspace (<= savedBlocks_ )
365  int dimU_;
366 
367  // Timers.
368  std::string label_;
369  Teuchos::RCP<Teuchos::Time> timerSolve_;
370 
371  // Internal state variables.
372  bool isSet_;
373  };
374 
375 
376 // Default solver values.
377 template<class ScalarType, class MV, class OP>
378 const typename PCPGSolMgr<ScalarType,MV,OP>::MagnitudeType PCPGSolMgr<ScalarType,MV,OP>::convtol_default_ = 1e-8;
379 
380 template<class ScalarType, class MV, class OP>
381 const typename PCPGSolMgr<ScalarType,MV,OP>::MagnitudeType PCPGSolMgr<ScalarType,MV,OP>::orthoKappa_default_ = -1.0;
382 
383 template<class ScalarType, class MV, class OP>
384 const int PCPGSolMgr<ScalarType,MV,OP>::maxIters_default_ = 1000;
385 
386 template<class ScalarType, class MV, class OP>
387 const int PCPGSolMgr<ScalarType,MV,OP>::deflatedBlocks_default_ = 2;
388 
389 template<class ScalarType, class MV, class OP>
390 const int PCPGSolMgr<ScalarType,MV,OP>::savedBlocks_default_ = 16;
391 
392 template<class ScalarType, class MV, class OP>
393 const int PCPGSolMgr<ScalarType,MV,OP>::verbosity_default_ = Belos::Errors;
394 
395 template<class ScalarType, class MV, class OP>
396 const int PCPGSolMgr<ScalarType,MV,OP>::outputStyle_default_ = Belos::General;
397 
398 template<class ScalarType, class MV, class OP>
399 const int PCPGSolMgr<ScalarType,MV,OP>::outputFreq_default_ = -1;
400 
401 template<class ScalarType, class MV, class OP>
402 const std::string PCPGSolMgr<ScalarType,MV,OP>::label_default_ = "Belos";
403 
404 template<class ScalarType, class MV, class OP>
405 const std::string PCPGSolMgr<ScalarType,MV,OP>::orthoType_default_ = "DGKS";
406 
407 template<class ScalarType, class MV, class OP>
408 const Teuchos::RCP<std::ostream> PCPGSolMgr<ScalarType,MV,OP>::outputStream_default_ = Teuchos::rcp(&std::cout,false);
409 
410 
411 // Empty Constructor
412 template<class ScalarType, class MV, class OP>
414  outputStream_(outputStream_default_),
415  convtol_(convtol_default_),
416  orthoKappa_(orthoKappa_default_),
417  achievedTol_(Teuchos::ScalarTraits<MagnitudeType>::zero()),
418  numIters_(0),
419  maxIters_(maxIters_default_),
420  deflatedBlocks_(deflatedBlocks_default_),
421  savedBlocks_(savedBlocks_default_),
422  verbosity_(verbosity_default_),
423  outputStyle_(outputStyle_default_),
424  outputFreq_(outputFreq_default_),
425  orthoType_(orthoType_default_),
426  label_(label_default_),
427  isSet_(false)
428 {}
429 
430 
431 // Basic Constructor
432 template<class ScalarType, class MV, class OP>
436  problem_(problem),
437  outputStream_(outputStream_default_),
438  convtol_(convtol_default_),
439  orthoKappa_(orthoKappa_default_),
440  achievedTol_(Teuchos::ScalarTraits<MagnitudeType>::zero()),
441  numIters_(0),
442  maxIters_(maxIters_default_),
443  deflatedBlocks_(deflatedBlocks_default_),
444  savedBlocks_(savedBlocks_default_),
445  verbosity_(verbosity_default_),
446  outputStyle_(outputStyle_default_),
447  outputFreq_(outputFreq_default_),
448  orthoType_(orthoType_default_),
449  label_(label_default_),
450  isSet_(false)
451 {
452  TEUCHOS_TEST_FOR_EXCEPTION(problem_ == Teuchos::null, std::invalid_argument, "Problem not given to solver manager.");
453 
454  if (!is_null(pl)) {
455  // Set the parameters using the list that was passed in.
456  setParameters( pl );
457  }
458 }
459 
460 
461 template<class ScalarType, class MV, class OP>
463 {
464  // Create the internal parameter list if ones doesn't already exist.
465  if (params_ == Teuchos::null) {
466  params_ = Teuchos::rcp( new Teuchos::ParameterList(*getValidParameters()) );
467  }
468  else {
469  params->validateParameters(*getValidParameters());
470  }
471 
472  // Check for maximum number of iterations
473  if (params->isParameter("Maximum Iterations")) {
474  maxIters_ = params->get("Maximum Iterations",maxIters_default_);
475 
476  // Update parameter in our list and in status test.
477  params_->set("Maximum Iterations", maxIters_);
478  if (maxIterTest_!=Teuchos::null)
479  maxIterTest_->setMaxIters( maxIters_ );
480  }
481 
482  // Check for the maximum numbers of saved and deflated blocks.
483  if (params->isParameter("Num Saved Blocks")) {
484  savedBlocks_ = params->get("Num Saved Blocks",savedBlocks_default_);
485  TEUCHOS_TEST_FOR_EXCEPTION(savedBlocks_ <= 0, std::invalid_argument,
486  "Belos::PCPGSolMgr: \"Num Saved Blocks\" must be strictly positive.");
487 
488  // savedBlocks > number of matrix rows and columns, not known in parameters.
489  //TEUCHOS_TEST_FOR_EXCEPTION(savedBlocks_ >= maxIters_, std::invalid_argument,
490  //"Belos::PCPGSolMgr: \"Num Saved Blocks\" must be less than \"Maximum Iterations\".");
491 
492  // Update parameter in our list.
493  params_->set("Num Saved Blocks", savedBlocks_);
494  }
495  if (params->isParameter("Num Deflated Blocks")) {
496  deflatedBlocks_ = params->get("Num Deflated Blocks",deflatedBlocks_default_);
497  TEUCHOS_TEST_FOR_EXCEPTION(deflatedBlocks_ < 0, std::invalid_argument,
498  "Belos::PCPGSolMgr: \"Num Deflated Blocks\" must be positive.");
499 
500  TEUCHOS_TEST_FOR_EXCEPTION(deflatedBlocks_ > savedBlocks_, std::invalid_argument,
501  "Belos::PCPGSolMgr: \"Num Deflated Blocks\" must be <= \"Num Saved Blocks\".");
502 
503  // Update parameter in our list.
504  params_->set("Num Deflated Blocks", deflatedBlocks_);
505  }
506 
507  // Check to see if the timer label changed.
508  if (params->isParameter("Timer Label")) {
509  std::string tempLabel = params->get("Timer Label", label_default_);
510 
511  // Update parameter in our list and solver timer
512  if (tempLabel != label_) {
513  label_ = tempLabel;
514  params_->set("Timer Label", label_);
515  std::string solveLabel = label_ + ": PCPGSolMgr total solve time";
516 #ifdef BELOS_TEUCHOS_TIME_MONITOR
517  timerSolve_ = Teuchos::TimeMonitor::getNewCounter(solveLabel);
518 #endif
519  if (ortho_ != Teuchos::null) {
520  ortho_->setLabel( label_ );
521  }
522  }
523  }
524 
525  // Check if the orthogonalization changed.
526  if (params->isParameter("Orthogonalization")) {
527  std::string tempOrthoType = params->get("Orthogonalization",orthoType_default_);
528  TEUCHOS_TEST_FOR_EXCEPTION( tempOrthoType != "DGKS" && tempOrthoType != "ICGS" && tempOrthoType != "IMGS",
529  std::invalid_argument,
530  "Belos::PCPGSolMgr: \"Orthogonalization\" must be either \"DGKS\", \"ICGS\", or \"IMGS\".");
531  if (tempOrthoType != orthoType_) {
532  orthoType_ = tempOrthoType;
533  // Create orthogonalization manager
534  if (orthoType_=="DGKS") {
535  if (orthoKappa_ <= 0) {
536  ortho_ = Teuchos::rcp( new DGKSOrthoManager<ScalarType,MV,OP>( label_ ) );
537  }
538  else {
539  ortho_ = Teuchos::rcp( new DGKSOrthoManager<ScalarType,MV,OP>( label_ ) );
540  Teuchos::rcp_dynamic_cast<DGKSOrthoManager<ScalarType,MV,OP> >(ortho_)->setDepTol( orthoKappa_ );
541  }
542  }
543  else if (orthoType_=="ICGS") {
544  ortho_ = Teuchos::rcp( new ICGSOrthoManager<ScalarType,MV,OP>( label_ ) );
545  }
546  else if (orthoType_=="IMGS") {
547  ortho_ = Teuchos::rcp( new IMGSOrthoManager<ScalarType,MV,OP>( label_ ) );
548  }
549  }
550  }
551 
552  // Check which orthogonalization constant to use.
553  if (params->isParameter("Orthogonalization Constant")) {
554  orthoKappa_ = params->get("Orthogonalization Constant",orthoKappa_default_);
555 
556  // Update parameter in our list.
557  params_->set("Orthogonalization Constant",orthoKappa_);
558  if (orthoType_=="DGKS") {
559  if (orthoKappa_ > 0 && ortho_ != Teuchos::null) {
560  Teuchos::rcp_dynamic_cast<DGKSOrthoManager<ScalarType,MV,OP> >(ortho_)->setDepTol( orthoKappa_ );
561  }
562  }
563  }
564 
565  // Check for a change in verbosity level
566  if (params->isParameter("Verbosity")) {
567  if (Teuchos::isParameterType<int>(*params,"Verbosity")) {
568  verbosity_ = params->get("Verbosity", verbosity_default_);
569  } else {
570  verbosity_ = (int)Teuchos::getParameter<Belos::MsgType>(*params,"Verbosity");
571  }
572 
573  // Update parameter in our list.
574  params_->set("Verbosity", verbosity_);
575  if (printer_ != Teuchos::null)
576  printer_->setVerbosity(verbosity_);
577  }
578 
579  // Check for a change in output style
580  if (params->isParameter("Output Style")) {
581  if (Teuchos::isParameterType<int>(*params,"Output Style")) {
582  outputStyle_ = params->get("Output Style", outputStyle_default_);
583  } else {
584  outputStyle_ = (int)Teuchos::getParameter<Belos::OutputType>(*params,"Output Style");
585  }
586 
587  // Reconstruct the convergence test if the explicit residual test is not being used.
588  params_->set("Output Style", outputStyle_);
589  outputTest_ = Teuchos::null;
590  }
591 
592  // output stream
593  if (params->isParameter("Output Stream")) {
594  outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> >(*params,"Output Stream");
595 
596  // Update parameter in our list.
597  params_->set("Output Stream", outputStream_);
598  if (printer_ != Teuchos::null)
599  printer_->setOStream( outputStream_ );
600  }
601 
602  // frequency level
603  if (verbosity_ & Belos::StatusTestDetails) {
604  if (params->isParameter("Output Frequency")) {
605  outputFreq_ = params->get("Output Frequency", outputFreq_default_);
606  }
607 
608  // Update parameter in out list and output status test.
609  params_->set("Output Frequency", outputFreq_);
610  if (outputTest_ != Teuchos::null)
611  outputTest_->setOutputFrequency( outputFreq_ );
612  }
613 
614  // Create output manager if we need to.
615  if (printer_ == Teuchos::null) {
616  printer_ = Teuchos::rcp( new OutputManager<ScalarType>(verbosity_, outputStream_) );
617  }
618 
619  // Convergence
620  typedef Belos::StatusTestCombo<ScalarType,MV,OP> StatusTestCombo_t;
621  typedef Belos::StatusTestGenResNorm<ScalarType,MV,OP> StatusTestResNorm_t;
622 
623  // Check for convergence tolerance
624  if (params->isParameter("Convergence Tolerance")) {
625  convtol_ = params->get("Convergence Tolerance",convtol_default_);
626 
627  // Update parameter in our list and residual tests.
628  params_->set("Convergence Tolerance", convtol_);
629  if (convTest_ != Teuchos::null)
630  convTest_->setTolerance( convtol_ );
631  }
632 
633  // Create status tests if we need to.
634 
635  // Basic test checks maximum iterations and native residual.
636  if (maxIterTest_ == Teuchos::null)
637  maxIterTest_ = Teuchos::rcp( new StatusTestMaxIters<ScalarType,MV,OP>( maxIters_ ) );
638 
639  if (convTest_ == Teuchos::null)
640  convTest_ = Teuchos::rcp( new StatusTestResNorm_t( convtol_, 1 ) );
641 
642  sTest_ = Teuchos::rcp( new StatusTestCombo_t( StatusTestCombo_t::OR, maxIterTest_, convTest_ ) );
643 
644  // Create the status test output class.
645  // This class manages and formats the output from the status test.
646  StatusTestOutputFactory<ScalarType,MV,OP> stoFactory( outputStyle_ );
647  outputTest_ = stoFactory.create( printer_, sTest_, outputFreq_, Passed+Failed+Undefined );
648 
649  // Set the solver string for the output test
650  std::string solverDesc = " PCPG ";
651  outputTest_->setSolverDesc( solverDesc );
652 
653 
654  // Create orthogonalization manager if we need to.
655  if (ortho_ == Teuchos::null) {
656  if (orthoType_=="DGKS") {
657  if (orthoKappa_ <= 0) {
658  ortho_ = Teuchos::rcp( new DGKSOrthoManager<ScalarType,MV,OP>( label_ ) );
659  }
660  else {
661  ortho_ = Teuchos::rcp( new DGKSOrthoManager<ScalarType,MV,OP>( label_ ) );
662  Teuchos::rcp_dynamic_cast<DGKSOrthoManager<ScalarType,MV,OP> >(ortho_)->setDepTol( orthoKappa_ );
663  }
664  }
665  else if (orthoType_=="ICGS") {
666  ortho_ = Teuchos::rcp( new ICGSOrthoManager<ScalarType,MV,OP>( label_ ) );
667  }
668  else if (orthoType_=="IMGS") {
669  ortho_ = Teuchos::rcp( new IMGSOrthoManager<ScalarType,MV,OP>( label_ ) );
670  }
671  else {
672  TEUCHOS_TEST_FOR_EXCEPTION(orthoType_!="ICGS"&&orthoType_!="DGKS"&&orthoType_!="IMGS",std::logic_error,
673  "Belos::PCPGSolMgr(): Invalid orthogonalization type.");
674  }
675  }
676 
677  // Create the timer if we need to.
678  if (timerSolve_ == Teuchos::null) {
679  std::string solveLabel = label_ + ": PCPGSolMgr total solve time";
680 #ifdef BELOS_TEUCHOS_TIME_MONITOR
681  timerSolve_ = Teuchos::TimeMonitor::getNewCounter(solveLabel);
682 #endif
683  }
684 
685  // Inform the solver manager that the current parameters were set.
686  isSet_ = true;
687 }
688 
689 
690 template<class ScalarType, class MV, class OP>
693 {
695  if (is_null(validPL)) {
696  Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
697  // Set all the valid parameters and their default values.
698  pl->set("Convergence Tolerance", convtol_default_,
699  "The relative residual tolerance that needs to be achieved by the\n"
700  "iterative solver in order for the linear system to be declared converged.");
701  pl->set("Maximum Iterations", maxIters_default_,
702  "The maximum number of iterations allowed for each\n"
703  "set of RHS solved.");
704  pl->set("Num Deflated Blocks", deflatedBlocks_default_,
705  "The maximum number of vectors in the seed subspace." );
706  pl->set("Num Saved Blocks", savedBlocks_default_,
707  "The maximum number of vectors saved from old Krylov subspaces." );
708  pl->set("Verbosity", verbosity_default_,
709  "What type(s) of solver information should be outputted\n"
710  "to the output stream.");
711  pl->set("Output Style", outputStyle_default_,
712  "What style is used for the solver information outputted\n"
713  "to the output stream.");
714  pl->set("Output Frequency", outputFreq_default_,
715  "How often convergence information should be outputted\n"
716  "to the output stream.");
717  pl->set("Output Stream", outputStream_default_,
718  "A reference-counted pointer to the output stream where all\n"
719  "solver output is sent.");
720  pl->set("Timer Label", label_default_,
721  "The string to use as a prefix for the timer labels.");
722  // pl->set("Restart Timers", restartTimers_);
723  pl->set("Orthogonalization", orthoType_default_,
724  "The type of orthogonalization to use: DGKS, ICGS, IMGS");
725  pl->set("Orthogonalization Constant",orthoKappa_default_,
726  "The constant used by DGKS orthogonalization to determine\n"
727  "whether another step of classical Gram-Schmidt is necessary.");
728  validPL = pl;
729  }
730  return validPL;
731 }
732 
733 
734 // solve()
735 template<class ScalarType, class MV, class OP>
737 
738  // Set the current parameters if are not set already.
739  if (!isSet_) { setParameters( params_ ); }
740 
743  ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
744  ScalarType zero = Teuchos::ScalarTraits<ScalarType>::zero();
745 
747  "Belos::PCPGSolMgr::solve(): Linear problem is not a valid object.");
748 
750  "Belos::PCPGSolMgr::solve(): Linear problem is not ready, setProblem() has not been called.");
751 
752  // Create indices for the linear systems to be solved.
753  int numRHS2Solve = MVT::GetNumberVecs( *(problem_->getRHS()) );
754  std::vector<int> currIdx(1);
755  currIdx[0] = 0;
756 
757  bool debug = false;
758 
759  // Inform the linear problem of the current linear system to solve.
760  problem_->setLSIndex( currIdx ); // block size == 1
761 
762  // Assume convergence is achieved, then let any failed convergence set this to false.
763  bool isConverged = true;
764 
766  // PCPG iteration parameter list
768  plist.set("Saved Blocks", savedBlocks_);
769  plist.set("Block Size", 1);
770  plist.set("Keep Diagonal", true);
771  plist.set("Initialize Diagonal", true);
772 
774  // PCPG solver
775 
777  pcpg_iter = Teuchos::rcp( new PCPGIter<ScalarType,MV,OP>(problem_,printer_,outputTest_,ortho_,plist) );
778  // Number of iterations required to generate initial recycle space (if needed)
779 
780  // Enter solve() iterations
781  {
782 #ifdef BELOS_TEUCHOS_TIME_MONITOR
783  Teuchos::TimeMonitor slvtimer(*timerSolve_);
784 #endif
785  while ( numRHS2Solve > 0 ) { // test for quick return
786 
787  // Reset the status test.
788  outputTest_->reset();
789 
790  // Create the first block in the current Krylov basis (residual).
791  if (R_ == Teuchos::null)
792  R_ = MVT::Clone( *(problem_->getRHS()), 1 );
793 
794  problem_->computeCurrResVec( &*R_ );
795 
796 
797  // Hypothesis: if U_ is not null, then neither is C_ and furthermore U'C= I.
798  // TODO: ensure hypothesis right here ... I have to think about use cases.
799 
800  if( U_ != Teuchos::null ){
801  // Hypothesis: if U_ is not null, then neither is C_ and furthermore U'C= I.
802 
803  // possibly over solved equation ... I want residual norms
804  // relative to the initial residual, not what I am about to compute.
805  Teuchos::RCP<MV> cur_soln_vec = problem_->getCurrLHSVec();
806  std::vector<MagnitudeType> rnorm0(1);
807  MVT::MvNorm( *R_, rnorm0 ); // rnorm0 = norm(R_);
808 
809  // Z := U_'*R_; xo += U_*Z ;R_ -= C_*Z
810  std::cout << "Solver Manager: dimU_ = " << dimU_ << std::endl;
812 
813  Teuchos::RCP<const MV> Uactive, Cactive;
814  std::vector<int> active_columns( dimU_ );
815  for (int i=0; i < dimU_; ++i) active_columns[i] = i;
816  Uactive = MVT::CloneView(*U_, active_columns);
817  Cactive = MVT::CloneView(*C_, active_columns);
818 
819  if( debug ){
820  std::cout << " Solver Manager : check duality of seed basis " << std::endl;
822  MVT::MvTransMv( one, *Uactive, *Cactive, H );
823  H.print( std::cout );
824  }
825 
826  MVT::MvTransMv( one, *Uactive, *R_, Z );
827  Teuchos::RCP<MV> tempU = MVT::Clone( *R_, 1 );
828  MVT::MvTimesMatAddMv( one, *Uactive, Z, zero, *tempU ); // UZ
829  MVT::MvAddMv( one, *tempU, one, *cur_soln_vec, *cur_soln_vec ); // xo += tmp;
830  MVT::MvTimesMatAddMv( one, *Cactive, Z, zero, *tempU ); // CZ
831  MVT::MvAddMv( -one, *tempU, one, *R_, *R_ ); // R_ -= tmp;
832  std::vector<MagnitudeType> rnorm(1);
833  MVT::MvNorm( *R_, rnorm );
834  if( rnorm[0] < rnorm0[0] * .001 ){ //reorthogonalize
835  MVT::MvTransMv( one, *Uactive, *R_, Z );
836  MVT::MvTimesMatAddMv( one, *Uactive, Z, zero, *tempU );
837  MVT::MvAddMv( one, *tempU, one, *cur_soln_vec, *cur_soln_vec ); // xo += UZ;
838  MVT::MvTimesMatAddMv( one, *Cactive, Z, zero, *tempU );
839  MVT::MvAddMv( -one, *tempU, one, *R_, *R_ ); // R_ -= CZ;
840  }
841  Uactive = Teuchos::null;
842  Cactive = Teuchos::null;
843  tempU = Teuchos::null;
844  }
845  else {
846  dimU_ = 0;
847  }
848 
849 
850  // Set the new state and initialize the solver.
851  PCPGIterState<ScalarType,MV> pcpgState; // fails if R == null.
852 
853  pcpgState.R = R_;
854  if( U_ != Teuchos::null ) pcpgState.U = U_;
855  if( C_ != Teuchos::null ) pcpgState.C = C_;
856  if( dimU_ > 0 ) pcpgState.curDim = dimU_;
857  pcpg_iter->initialize(pcpgState);
858 
859  // treat initialize() exceptions here? how to use try-catch-throw? DMD
860 
861  // Get the current number of deflated blocks with the PCPG iteration
862  dimU_ = pcpgState.curDim;
863  if( !dimU_ ) printer_->stream(Debug) << " No recycled subspace available for RHS index " << currIdx[0] << std::endl << std::endl;
864  pcpg_iter->resetNumIters();
865 
866  if( dimU_ > savedBlocks_ )
867  std::cout << "Error: dimU_ = " << dimU_ << " > savedBlocks_ = " << savedBlocks_ << std::endl;
868 
869  while(1) { // dummy loop for break
870 
871  // tell pcpg_iter to iterate
872  try {
873  if( debug ) printf("********** Calling iterate...\n");
874  pcpg_iter->iterate();
875 
877  //
878  // check convergence first
879  //
881  if ( convTest_->getStatus() == Passed ) {
882  // we have convergence
883  break; // break from while(1){pcpg_iter->iterate()}
884  }
886  //
887  // check for maximum iterations
888  //
890  else if ( maxIterTest_->getStatus() == Passed ) {
891  // we don't have convergence
892  isConverged = false;
893  break; // break from while(1){pcpg_iter->iterate()}
894  }
895  else {
896 
898  //
899  // we returned from iterate(), but none of our status tests Passed.
900  // Something is wrong, and it is probably the developers fault.
901  //
903 
904  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
905  "Belos::PCPGSolMgr::solve(): Invalid return from PCPGIter::iterate().");
906  } // end if
907  } // end try
908  catch (const PCPGIterOrthoFailure &e) {
909 
910  // Check to see if the most recent solution yielded convergence.
911  sTest_->checkStatus( &*pcpg_iter );
912  if (convTest_->getStatus() != Passed)
913  isConverged = false;
914  break;
915  }
916  catch (const std::exception &e) {
917  printer_->stream(Errors) << "Error! Caught exception in PCPGIter::iterate() at iteration "
918  << pcpg_iter->getNumIters() << std::endl
919  << e.what() << std::endl;
920  throw;
921  }
922  } // end of while(1)
923 
924  // Update the linear problem.
925  Teuchos::RCP<MV> update = pcpg_iter->getCurrentUpdate();
926  problem_->updateSolution( update, true );
927 
928  // Inform the linear problem that we are finished with this block linear system.
929  problem_->setCurrLS();
930 
931  // Get the state. How did pcpgState die?
932  PCPGIterState<ScalarType,MV> oldState = pcpg_iter->getState();
933 
934  dimU_ = oldState.curDim;
935  int q = oldState.prevUdim;
936 
937  std::cout << "SolverManager: dimU_ " << dimU_ << " prevUdim= " << q << std::endl;
938 
939  if( q > deflatedBlocks_ )
940  std::cout << "SolverManager: Error deflatedBlocks = " << deflatedBlocks_ << std::endl;
941 
942  int rank;
943  if( dimU_ > q ){ // Orthogonalize [U;C](:,prevUdim:dimU_)
944  //Given the seed space U and C = A U for some symmetric positive definite A,
945  //find U1 and C1 with span(U1)=span(U) such that C1'U1 = I maintaining C=AU
946 
947  //oldState.D->print( std::cout ); D = diag( C'*U )
948 
949  U_ = oldState.U; //MVT::MvPrint( *U_, std::cout );
950  C_ = oldState.C; //MVT::MvPrint( *C_, std::cout );
951  rank = ARRQR(dimU_,q, *oldState.D );
952  if( rank < dimU_ ) {
953  std::cout << " rank decreased in ARRQR, something to do? " << std::endl;
954  }
955  dimU_ = rank;
956 
957  } // Now U_ and C_ = AU are dual bases.
958 
959  if( dimU_ > deflatedBlocks_ ){
960 
961  if( !deflatedBlocks_ ){
962  U_ = Teuchos::null;
963  C_ = Teuchos::null;
964  dimU_ = deflatedBlocks_;
965  break;
966  }
967 
968  bool Harmonic = false; // (Harmonic) Ritz vectors
969 
970  Teuchos::RCP<MV> Uorth;
971 
972  std::vector<int> active_cols( dimU_ );
973  for (int i=0; i < dimU_; ++i) active_cols[i] = i;
974 
975  if( Harmonic ){
976  Uorth = MVT::CloneCopy(*C_, active_cols);
977  }
978  else{
979  Uorth = MVT::CloneCopy(*U_, active_cols);
980  }
981 
982  // Explicitly construct Q and R factors
984  rank = ortho_->normalize(*Uorth, Teuchos::rcp(&R,false));
985  Uorth = Teuchos::null;
986  // TODO: During the previous solve, the matrix that normalizes U(1:q) was computed and discarded.
987  // One might save it, reuse it here, and just normalize columns U(q+1:dimU_) here.
988 
989  // throw an error if U is both A-orthonormal and rank deficient
991  "Belos::PCPGSolMgr::solve(): Failed to compute orthonormal basis for initial recycled subspace.");
992 
993 
994  // R VT' = Ur S,
995  Teuchos::SerialDenseMatrix<int,ScalarType> VT; // Not referenced
996  Teuchos::SerialDenseMatrix<int,ScalarType> Ur; // Not referenced
997  int lwork = 5*dimU_; // minimal, extra computation < 67*dimU_
998  int info = 0; // Hermite
999  int lrwork = 1;
1000  if( problem_->isHermitian() ) lrwork = dimU_;
1001  std::vector<ScalarType> work(lwork); //
1002  std::vector<ScalarType> Svec(dimU_); //
1003  std::vector<ScalarType> rwork(lrwork);
1004  lapack.GESVD('N', 'O',
1005  R.numRows(),R.numCols(),R.values(), R.numRows(),
1006  &Svec[0],
1007  Ur.values(),1,
1008  VT.values(),1, // Output: VT stored in R
1009  &work[0], lwork,
1010  &rwork[0], &info);
1011 
1013  "Belos::PCPGSolMgr::solve(): LAPACK _GESVD failed to compute singular values.");
1014 
1015  if( work[0] != 67. * dimU_ )
1016  std::cout << " SVD " << dimU_ << " lwork " << work[0] << std::endl;
1017  for( int i=0; i< dimU_; i++)
1018  std::cout << i << " " << Svec[i] << std::endl;
1019 
1021 
1022  int startRow = 0, startCol = 0;
1023  if( Harmonic )
1024  startCol = dimU_ - deflatedBlocks_;
1025 
1027  wholeV,
1028  wholeV.numRows(),
1029  deflatedBlocks_,
1030  startRow,
1031  startCol);
1032  std::vector<int> active_columns( dimU_ );
1033  std::vector<int> def_cols( deflatedBlocks_ );
1034  for (int i=0; i < dimU_; ++i) active_columns[i] = i;
1035  for (int i=0; i < deflatedBlocks_; ++i) def_cols[i] = i;
1036 
1037  Teuchos::RCP<MV> Uactive = MVT::CloneViewNonConst(*U_, def_cols);
1038  Teuchos::RCP<MV> Ucopy = MVT::CloneCopy( *U_, active_columns );
1039  MVT::MvTimesMatAddMv( one, *Ucopy, V, zero, *Uactive ); // U:= U*V
1040  Ucopy = Teuchos::null;
1041  Uactive = Teuchos::null;
1042  Teuchos::RCP<MV> Cactive = MVT::CloneViewNonConst(*C_, def_cols);
1043  Teuchos::RCP<MV> Ccopy = MVT::CloneCopy( *C_, active_columns );
1044  MVT::MvTimesMatAddMv( one, *Ccopy, V, zero, *Cactive ); // C:= C*V
1045  Ccopy = Teuchos::null;
1046  Cactive = Teuchos::null;
1047  dimU_ = deflatedBlocks_;
1048  }
1049  printer_->stream(Debug) << " Generated recycled subspace using RHS index " << currIdx[0] << " of dimension " << dimU_ << std::endl << std::endl;
1050 
1051  // Inform the linear problem that we are finished with this block linear system.
1052  problem_->setCurrLS();
1053 
1054  // Update indices for the linear systems to be solved.
1055  numRHS2Solve -= 1;
1056  if ( numRHS2Solve > 0 ) {
1057  currIdx[0]++;
1058 
1059  // Set the next indices.
1060  problem_->setLSIndex( currIdx );
1061  }
1062  else {
1063  currIdx.resize( numRHS2Solve );
1064  }
1065  }// while ( numRHS2Solve > 0 )
1066  }
1067 
1068  // print final summary
1069  sTest_->print( printer_->stream(FinalSummary) );
1070 
1071  // print timing information
1072 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1073  // Calling summarize() can be expensive, so don't call unless the
1074  // user wants to print out timing details. summarize() will do all
1075  // the work even if it's passed a "black hole" output stream.
1076  if (verbosity_ & TimingDetails)
1077  Teuchos::TimeMonitor::summarize( printer_->stream(TimingDetails) );
1078 #endif
1079 
1080  // Save the convergence test value ("achieved tolerance") for this solve.
1081  {
1082  using Teuchos::rcp_dynamic_cast;
1083  typedef StatusTestGenResNorm<ScalarType,MV,OP> conv_test_type;
1084  // testValues is nonnull and not persistent.
1085  const std::vector<MagnitudeType>* pTestValues =
1086  rcp_dynamic_cast<conv_test_type>(convTest_)->getTestValue();
1087 
1088  TEUCHOS_TEST_FOR_EXCEPTION(pTestValues == NULL, std::logic_error,
1089  "Belos::PCPGSolMgr::solve(): The convergence test's getTestValue() "
1090  "method returned NULL. Please report this bug to the Belos developers.");
1091 
1092  TEUCHOS_TEST_FOR_EXCEPTION(pTestValues->size() < 1, std::logic_error,
1093  "Belos::PCPGSolMgr::solve(): The convergence test's getTestValue() "
1094  "method returned a vector of length zero. Please report this bug to the "
1095  "Belos developers.");
1096 
1097  // FIXME (mfh 12 Dec 2011) Does pTestValues really contain the
1098  // achieved tolerances for all vectors in the current solve(), or
1099  // just for the vectors from the last deflation?
1100  achievedTol_ = *std::max_element (pTestValues->begin(), pTestValues->end());
1101  }
1102 
1103  // get iteration information for this solve
1104  numIters_ = maxIterTest_->getNumIters();
1105 
1106  if (!isConverged) {
1107  return Unconverged; // return from PCPGSolMgr::solve()
1108  }
1109  return Converged; // return from PCPGSolMgr::solve()
1110 }
1111 
1112 // A-orthogonalize the Seed Space
1113 // Note that Anasazi::GenOrthoManager provides simplified versions of the algorithm,
1114 // that are not rank revealing, and are not designed for PCPG in other ways too.
1115 template<class ScalarType, class MV, class OP>
1117 {
1118  using Teuchos::RCP;
1119  ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
1120  ScalarType zero = Teuchos::ScalarTraits<ScalarType>::zero();
1121 
1122  // Allocate memory for scalars.
1126  std::vector<int> curind(1);
1127  std::vector<int> ipiv(p - q); // RRQR Pivot indices
1128  std::vector<ScalarType> Pivots(p); // RRQR Pivots
1129  int i, imax, j, k, l;
1130  ScalarType rteps = 1.5e-8;
1131 
1132  // Scale such that diag( U'C) = I
1133  for( int i = q ; i < p ; i++ ){
1134  ipiv[i-q] = i;
1135  curind[0] = i;
1136  RCP<MV> P = MVT::CloneViewNonConst(*U_,curind);
1137  RCP<MV> AP = MVT::CloneViewNonConst(*C_,curind);
1138  anorm(0,0) = one / Teuchos::ScalarTraits<ScalarType>::squareroot( D(i-q,i-q) ) ;
1139  MVT::MvAddMv( anorm(0,0), *P, zero, *AP, *P );
1140  MVT::MvAddMv( zero, *P, anorm(0,0), *AP, *AP );
1141  Pivots[i] = one;
1142  }
1143 
1144  for( i = q ; i < p ; i++ ){
1145  if( q < i && i < p-1 ){ // Find the largest pivot
1146  imax = i;
1147  l = ipiv[imax-q];
1148  for( j = i+1 ; j < p ; j++ ){
1149  k = ipiv[j-q];
1150  if( Pivots[k] > Pivots[l] ){
1151  imax = j;
1152  l = k;
1153  }
1154  } // end for
1155  if( imax > i ){
1156  l = ipiv[imax-q]; // swap ipiv( imax ) and ipiv(i+1)
1157  ipiv[imax-q] = ipiv[i-q];
1158  ipiv[i-q] = l;
1159  }
1160  } // largest pivot found
1161  int k = ipiv[i-q];
1162 
1163  if( Pivots[k] > 1.5625e-2 ){
1164  anorm(0,0) = Pivots[k]; // A-norm of u
1165  }
1166  else{ // anorm(0,0) = sqrt( U(:,k)'*C(:,k) );
1167  curind[0] = k;
1168  RCP<const MV> P = MVT::CloneView(*U_,curind);
1169  RCP<const MV> AP = MVT::CloneView(*C_,curind);
1170  MVT::MvTransMv( one, *P, *AP, anorm );
1171  anorm(0,0) = Teuchos::ScalarTraits<ScalarType>::squareroot( anorm(0,0) ) ;
1172  }
1173  if( rteps <= anorm(0,0) && anorm(0,0) < 9.765625e-4){
1174  /*
1175  C(:,k) = A*U(:,k); % Change C
1176  fixC = U(:, ipiv(1:i-1) )'*C(:,k);
1177  U(:,k) = U(:,k) - U(:, ipiv(1:i-1) )*fixC;
1178  C(:,k) = C(:,k) - C(:, ipiv(1:i-1) )*fixC;
1179  anorm = sqrt( U(:,k)'*C(:,k) );
1180  */
1181  std::cout << "ARRQR: Bad case not implemented" << std::endl;
1182  }
1183  if( anorm(0,0) < rteps ){ // rank [U;C] = i-1
1184  std::cout << "ARRQR : deficient case not implemented " << std::endl;
1185  //U = U(:, ipiv(1:i-1) );
1186  //C = C(:, ipiv(1:i-1) );
1187  p = q + i;
1188  // update curDim_ in State
1189  break;
1190  }
1191  curind[0] = k;
1192  RCP<MV> P = MVT::CloneViewNonConst(*U_,curind);
1193  RCP<MV> AP = MVT::CloneViewNonConst(*C_,curind);
1194  MVT::MvAddMv( anorm(0,0), *P, zero, *AP, *P ); // U(:,k) = U(:,k)/anorm;
1195  MVT::MvAddMv( zero, *P, anorm(0,0), *AP, *AP ); // C(:,k) = C(:,k)/anorm;
1196  P = Teuchos::null;
1197  AP = Teuchos::null;
1198  Pivots[k] = one; // delete, for diagonostic purposes
1199  P = MVT::CloneViewNonConst(*U_,curind); // U(:,k)
1200  AP = MVT::CloneViewNonConst(*C_,curind); // C(:,k)
1201  for( j = i+1 ; j < p ; j++ ){
1202  l = ipiv[j-q]; // ahhh
1203  curind[0] = l;
1204  RCP<MV> Q = MVT::CloneViewNonConst(*U_,curind); // segmentation fault, j=i+1=5
1205  MVT::MvTransMv( one, *Q, *AP, alpha); // alpha(0,0) = U(:,l)'*C(:,k);
1206  MVT::MvAddMv( -alpha(0,0), *P, one, *Q, *Q ); // U(:,l) -= U(:,k) * alpha(0,0);
1207  Q = Teuchos::null;
1208  RCP<MV> AQ = MVT::CloneViewNonConst(*C_,curind);
1209  MVT::MvAddMv( -alpha(0,0), *AP, one, *AQ, *AQ ); // C(:,l) -= C(:,l) - C(:,k) * alpha(0,0);
1210  AQ = Teuchos::null;
1211  gamma(0,0) = ( Pivots[l] - alpha(0,0))*( Pivots[l] + alpha(0,0));
1212  if( gamma(0,0) > 0){
1213  Pivots[l] = Teuchos::ScalarTraits<ScalarType>::squareroot( gamma(0,0) );
1214  }
1215  else {
1216  Pivots[l] = zero; //rank deficiency revealed
1217  }
1218  }
1219  }
1220  return p;
1221 }
1222 
1223 // The method returns a string describing the solver manager.
1224 template<class ScalarType, class MV, class OP>
1226 {
1227  std::ostringstream oss;
1228  oss << "Belos::PCPGSolMgr<...,"<<Teuchos::ScalarTraits<ScalarType>::name()<<">";
1229  oss << "{";
1230  oss << "Ortho Type='"<<orthoType_;
1231  oss << "}";
1232  return oss.str();
1233 }
1234 
1235 } // end Belos namespace
1236 
1237 #endif /* BELOS_PCPG_SOLMGR_HPP */
ScalarType * values() const
Collection of types and exceptions used within the Belos solvers.
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const
Get a parameter list containing the current parameters for this object.
int prevUdim
Number of block columns in matrices C and U before current iteration.
virtual ~PCPGSolMgr()
Destructor.
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.
ReturnType solve()
The method either solves the problem or decides to quit. On each call, a (possibly null) seed space i...
bool is_null(const boost::shared_ptr< T > &p)
virtual void print(std::ostream &os) const
Belos concrete class to iterate Preconditioned Conjugate Projected Gradients.
PCPGSolMgrOrthoFailure is thrown when the orthogonalization manager is unable to generate orthonormal...
Teuchos::RCP< MV > R
The current residual.
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static RCP< Time > getNewCounter(const std::string &name)
static T squareroot(T x)
Teuchos::RCP< MV > C
C = AU, U spans recycled subspace.
PCPGSolMgrRecyclingFailure is thrown when any problem occurs in using/creating the recycling subspace...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
A factory class for generating StatusTestOutput objects.
int curDim
The current dimension of the reduction.
An implementation of StatusTestResNorm using a family of residual norms.
PCPGSolMgrOrthoFailure(const std::string &what_arg)
Structure to contain pointers to PCPGIter state variables.
PCPGSolMgrLinearProblemFailure is thrown when the linear problem is not setup (i.e.
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Get current linear problem being solved for in this object.
Belos::StatusTest class for specifying a maximum number of iterations.
static std::string name()
A factory class for generating StatusTestOutput objects.
Iterated Modified Gram-Schmidt (IMGS) implementation of the Belos::OrthoManager class.
std::string description() const
Method to return description of the PCPG solver manager.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get a parameter list containing the valid parameters for this object.
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="")
Traits class which defines basic operations on multivectors.
Belos::StatusTest for logically combining several status tests.
Teuchos::RCP< const Teuchos::SerialDenseMatrix< int, ScalarType > > D
The current Hessenberg matrix.
bool isParameter(const std::string &name) const
void reset(const ResetType type)
Performs a reset of the solver manager specified by the ResetType. This informs the solver manager th...
Classical Gram-Schmidt (with DGKS correction) implementation of the Belos::OrthoManager class...
int getNumIters() const
Get the iteration count for the most recent call to solve().
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &params)
Set the parameters the solver manager should use to solve the linear problem.
A Belos::StatusTest class for specifying a maximum number of iterations.
ResetType
How to reset the solver.
Definition: BelosTypes.hpp:200
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Pure virtual base class which describes the basic interface for a solver manager. ...
MagnitudeType achievedTol() const
Tolerance achieved by the last solve() invocation.
A linear system to solve, and its associated information.
Class which describes the linear problem to be solved by the iterative solver.
PCPGSolMgrLAPACKFailure is thrown when a nonzero value is retuned from an LAPACK call.
void GESVD(const char JOBU, const char JOBVT, const OrdinalType m, const OrdinalType n, ScalarType *A, const OrdinalType lda, MagnitudeType *S, ScalarType *U, const OrdinalType ldu, ScalarType *V, const OrdinalType ldv, ScalarType *WORK, const OrdinalType lwork, MagnitudeType *RWORK, OrdinalType *info) const
PCPGSolMgrLAPACKFailure(const std::string &what_arg)
PCPGSolMgr()
Empty constructor for PCPGSolMgr. This constructor takes no arguments and sets the default values for...
ReturnType
Whether the Belos solve converged for all linear systems.
Definition: BelosTypes.hpp:149
The Belos::SolverManager is a templated virtual base class that defines the basic interface that any ...
Iterated Classical Gram-Schmidt (ICGS) implementation of the Belos::OrthoManager class.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
An implementation of the Belos::MatOrthoManager that performs orthogonalization using multiple steps ...
Teuchos::RCP< MV > U
The recycled subspace.
An implementation of the Belos::MatOrthoManager that performs orthogonalization using multiple steps ...
OrdinalType numCols() const
Teuchos::RCP< StatusTestOutput< ScalarType, MV, OP > > create(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, int mod, int printStates)
Create the StatusTestOutput object specified by the outputStyle.
PCPGIterOrthoFailure is thrown when the PCPGIter object is unable to compute independent direction ve...
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem)
Set the linear problem that needs to be solved.
The Belos::PCPGSolMgr manages the PCPG linear solver. Three Hypotheses: First users must ensure that ...
An implementation of the Belos::MatOrthoManager that performs orthogonalization using (potentially) m...
A class for extending the status testing capabilities of Belos via logical combinations.
Class which defines basic traits for the operator type.
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return the timers for this object.
Parent class to all Belos exceptions.
Definition: BelosTypes.hpp:60
bool isLOADetected() const
Return whether a loss of accuracy was detected by this solver during the most current solve...
PCPGSolMgrRecyclingFailure(const std::string &what_arg)
This class implements the PCPG iteration, where a single-std::vector Krylov subspace is constructed...
Belos header file which uses auto-configuration information to include necessary C++ headers...
PCPGSolMgrLinearProblemFailure(const std::string &what_arg)
OrdinalType numRows() const