32 #ifndef __AnasaziTsqrOrthoManagerImpl_hpp 33 #define __AnasaziTsqrOrthoManagerImpl_hpp 42 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp" 114 template<
class Scalar,
class MV>
118 typedef Scalar scalar_type;
120 typedef MV multivector_type;
131 typedef typename MVT::tsqr_adaptor_type tsqr_adaptor_type;
175 const std::string& label);
191 if (label != label_) {
197 const std::string&
getLabel ()
const {
return label_; }
210 MVT::MvTransMv (SCT::one(), X, Y, Z);
231 norm (
const MV& X, std::vector<magnitude_type>& normvec)
const;
260 int normalize (MV& X, mat_ptr B);
281 normalizeOutOfPlace (MV& X, MV& Q, mat_ptr B);
304 return projectAndNormalizeImpl (X, X,
false, C, B, Q);
335 return projectAndNormalizeImpl (X_in, X_out,
true, C, B, Q);
345 const Scalar ONE = SCT::one();
346 const int ncols = MVT::GetNumberVecs(X);
347 mat_type XTX (ncols, ncols);
348 innerProd (X, X, XTX);
349 for (
int k = 0; k < ncols; ++k) {
360 const int ncols_X1 = MVT::GetNumberVecs (X1);
361 const int ncols_X2 = MVT::GetNumberVecs (X2);
362 mat_type X1_T_X2 (ncols_X1, ncols_X2);
363 innerProd (X1, X2, X1_T_X2);
387 tsqr_adaptor_type tsqrAdaptor_;
407 bool randomizeNullSpace_;
414 bool reorthogonalizeBlocks_;
419 bool throwOnReorthogFault_;
422 magnitude_type blockReorthogThreshold_;
425 magnitude_type relativeRankTolerance_;
433 bool forceNonnegativeDiagonal_;
437 raiseReorthogFault (
const std::vector<magnitude_type>& normsAfterFirstPass,
438 const std::vector<magnitude_type>& normsAfterSecondPass,
439 const std::vector<int>& faultIndices);
451 checkProjectionDims (
int& ncols_X,
471 const bool attemptToRecycle =
true)
const;
482 projectAndNormalizeImpl (MV& X_in,
484 const bool outOfPlace,
503 const mat_ptr& C)
const;
531 int rawNormalize (MV& X, MV& Q, mat_type& B);
550 int normalizeOne (MV& X, mat_ptr B)
const;
579 int normalizeImpl (MV& X, MV& Q, mat_ptr B,
const bool outOfPlace);
582 template<
class Scalar,
class MV>
588 using Teuchos::parameterList;
590 using Teuchos::sublist;
591 typedef magnitude_type M;
593 RCP<const ParameterList> defaultParams = getValidParameters ();
595 RCP<ParameterList> tsqrParams;
597 RCP<ParameterList> theParams;
599 theParams = parameterList (*defaultParams);
607 randomizeNullSpace_ =
608 theParams->
get<
bool> (
"randomizeNullSpace",
609 defaultParams->get<
bool> (
"randomizeNullSpace"));
610 reorthogonalizeBlocks_ =
611 theParams->get<
bool> (
"reorthogonalizeBlocks",
612 defaultParams->get<
bool> (
"reorthogonalizeBlocks"));
613 throwOnReorthogFault_ =
614 theParams->get<
bool> (
"throwOnReorthogFault",
615 defaultParams->get<
bool> (
"throwOnReorthogFault"));
616 blockReorthogThreshold_ =
617 theParams->get<M> (
"blockReorthogThreshold",
618 defaultParams->get<M> (
"blockReorthogThreshold"));
619 relativeRankTolerance_ =
620 theParams->get<M> (
"relativeRankTolerance",
621 defaultParams->get<M> (
"relativeRankTolerance"));
622 forceNonnegativeDiagonal_ =
623 theParams->get<
bool> (
"forceNonnegativeDiagonal",
624 defaultParams->get<
bool> (
"forceNonnegativeDiagonal"));
628 if (! theParams->isSublist (
"TSQR implementation")) {
629 theParams->set (
"TSQR implementation",
630 defaultParams->sublist (
"TSQR implementation"));
632 tsqrParams = sublist (theParams,
"TSQR implementation",
true);
636 tsqrAdaptor_.setParameterList (tsqrParams);
639 setMyParamList (theParams);
642 template<
class Scalar,
class MV>
645 const std::string& label) :
649 randomizeNullSpace_ (true),
650 reorthogonalizeBlocks_ (true),
651 throwOnReorthogFault_ (false),
652 blockReorthogThreshold_ (0),
653 relativeRankTolerance_ (0),
654 forceNonnegativeDiagonal_ (false)
659 template<
class Scalar,
class MV>
665 randomizeNullSpace_ (true),
666 reorthogonalizeBlocks_ (true),
667 throwOnReorthogFault_ (false),
668 blockReorthogThreshold_ (0),
669 relativeRankTolerance_ (0),
670 forceNonnegativeDiagonal_ (false)
675 template<
class Scalar,
class MV>
678 norm (
const MV& X, std::vector<magnitude_type>& normVec)
const 683 if (normVec.size() <
static_cast<size_t>(numCols))
684 normVec.resize (numCols);
688 template<
class Scalar,
class MV>
694 int ncols_X, num_Q_blocks, ncols_Q_total;
695 checkProjectionDims (ncols_X, num_Q_blocks, ncols_Q_total, X, Q);
699 if (ncols_X == 0 || num_Q_blocks == 0 || ncols_Q_total == 0)
703 allocateProjectionCoefficients (C, Q, X,
true);
707 std::vector<magnitude_type> columnNormsBefore (ncols_X, magnitude_type(0));
708 if (reorthogonalizeBlocks_)
713 rawProject (X, Q, C);
717 if (reorthogonalizeBlocks_)
719 std::vector<magnitude_type> columnNormsAfter (ncols_X, magnitude_type(0));
729 bool reorthogonalize =
false;
730 for (
int j = 0; j < ncols_X; ++j)
731 if (columnNormsAfter[j] < relThres * columnNormsBefore[j])
733 reorthogonalize =
true;
740 allocateProjectionCoefficients (C2, Q, X,
false);
744 rawProject (X, Q, C2);
746 for (
int k = 0; k < num_Q_blocks; ++k)
754 template<
class Scalar,
class MV>
773 return normalizeOne (X, B);
815 return normalizeImpl (X, *Q_, B,
false);
818 return normalizeImpl (X, *Q_view, B,
false);
822 template<
class Scalar,
class MV>
828 const bool attemptToRecycle)
const 830 const int num_Q_blocks = Q.size();
833 if (attemptToRecycle)
835 for (
int i = 0; i < num_Q_blocks; ++i)
846 Ci.
shape (ncols_Qi, ncols_X);
854 for (
int i = 0; i < num_Q_blocks; ++i)
862 template<
class Scalar,
class MV>
870 }
else if (numVecs == 1) {
877 const int rank = normalizeOne (X, B);
886 return normalizeImpl (X, Q, B,
true);
890 template<
class Scalar,
class MV>
895 const bool outOfPlace,
907 std::invalid_argument,
908 "Belos::TsqrOrthoManagerImpl::" 909 "projectAndNormalizeOutOfPlace(...):" 911 <<
" columns, but X_in has " 916 int ncols_X, num_Q_blocks, ncols_Q_total;
917 checkProjectionDims (ncols_X, num_Q_blocks, ncols_Q_total, X_in, Q);
924 if (num_Q_blocks == 0 || ncols_Q_total == 0) {
935 allocateProjectionCoefficients (C, Q, X_in,
true);
940 std::vector<magnitude_type> normsBeforeFirstPass (ncols_X,
SCTM::zero());
941 if (reorthogonalizeBlocks_) {
946 rawProject (X_in, Q, C);
963 std::invalid_argument,
964 "normalizeOne: Input matrix B must be at " 965 "least " << ncols_X <<
" x " << ncols_X
966 <<
", but is instead " << B->numRows()
967 <<
" x " << B->numCols() <<
".");
977 const int firstPassRank = outOfPlace ?
988 int rank = firstPassRank;
1004 if (firstPassRank < ncols_X && randomizeNullSpace_) {
1005 const int numNullSpaceCols = ncols_X - firstPassRank;
1006 const Range1D nullSpaceIndices (firstPassRank, ncols_X - 1);
1010 for (
int k = 0; k < num_Q_blocks; ++k) {
1012 C_null[k] =
rcp (
new mat_type (numColsQk, numNullSpaceCols));
1015 RCP<mat_type> B_null (
new mat_type (numNullSpaceCols, numNullSpaceCols));
1017 int randomVectorsRank;
1030 rawProject (*X_in_null, Q, C_null);
1038 rawProject (*X_null, Q, C_null);
1039 randomVectorsRank =
normalize (*X_null, B_null);
1047 "Belos::TsqrOrthoManagerImpl::projectAndNormalize" 1048 "OutOfPlace(): After projecting and normalizing the " 1049 "random vectors (used to replace the null space " 1050 "basis vectors from normalizing X), they have rank " 1051 << randomVectorsRank <<
", but should have full " 1052 "rank " << numNullSpaceCols <<
".");
1057 if (reorthogonalizeBlocks_) {
1060 std::vector<magnitude_type>
1061 normsAfterFirstPass (firstPassRank,
SCTM::zero());
1062 std::vector<magnitude_type>
1063 normsAfterSecondPass (firstPassRank,
SCTM::zero());
1078 for (
int j = 0; j < firstPassRank; ++j) {
1079 const Scalar*
const B_j = &(*B_out)(0,j);
1082 normsAfterFirstPass[j] = blas.
NRM2 (firstPassRank, B_j, 1);
1086 bool reorthogonalize =
false;
1087 for (
int j = 0; j < firstPassRank; ++j) {
1094 const magnitude_type curThreshold =
1096 if (normsAfterFirstPass[j] < curThreshold) {
1097 reorthogonalize =
true;
1112 bool reorthogFault =
false;
1114 std::vector<int> faultIndices;
1115 if (reorthogonalize) {
1129 allocateProjectionCoefficients (C2, Q, X_in,
false);
1134 rawProject (X_in, Q, C2);
1137 RCP<mat_type> B2 (
new mat_type (ncols_X, ncols_X));
1140 const int secondPassRank = outOfPlace ?
1143 rank = secondPassRank;
1148 mat_type B_copy (
Copy, *B_out, B_out->numRows(), B_out->numCols());
1153 "Teuchos::SerialDenseMatrix::multiply " 1154 "returned err = " << err <<
" != 0");
1158 for (
int k = 0; k < num_Q_blocks; ++k) {
1159 mat_type C_k_copy (
Copy, *C[k], C[k]->numRows(), C[k]->numCols());
1165 "Teuchos::SerialDenseMatrix::multiply " 1166 "returned err = " << err <<
" != 0");
1171 for (
int j = 0; j < rank; ++j) {
1172 const Scalar*
const B2_j = &(*B2)(0,j);
1173 normsAfterSecondPass[j] = blas.
NRM2 (rank, B2_j, 1);
1178 reorthogFault =
false;
1179 for (
int j = 0; j < rank; ++j) {
1180 const magnitude_type relativeLowerBound =
1182 if (normsAfterSecondPass[j] < relativeLowerBound) {
1183 reorthogFault =
true;
1184 faultIndices.push_back (j);
1189 if (reorthogFault) {
1190 if (throwOnReorthogFault_) {
1191 raiseReorthogFault (normsAfterFirstPass,
1192 normsAfterSecondPass,
1201 "TsqrOrthoManagerImpl has not yet implemented" 1202 " recovery from an orthogonalization fault.");
1210 template<
class Scalar,
class MV>
1214 const std::vector<magnitude_type>& normsAfterSecondPass,
1215 const std::vector<int>& faultIndices)
1218 typedef std::vector<int>::size_type size_type;
1219 std::ostringstream os;
1221 os <<
"Orthogonalization fault at the following column(s) of X:" << endl;
1222 os <<
"Column\tNorm decrease factor" << endl;
1223 for (size_type k = 0; k < faultIndices.size(); ++k)
1225 const int index = faultIndices[k];
1226 const magnitude_type decreaseFactor =
1227 normsAfterSecondPass[index] / normsAfterFirstPass[index];
1228 os << index <<
"\t" << decreaseFactor << endl;
1233 template<
class Scalar,
class MV>
1238 using Teuchos::parameterList;
1241 if (defaultParams_.is_null()) {
1242 RCP<ParameterList> params = parameterList (
"TsqrOrthoManagerImpl");
1246 params->set (
"TSQR implementation", *(tsqrAdaptor_.getValidParameters()),
1247 "TSQR implementation parameters.");
1251 const bool defaultRandomizeNullSpace =
true;
1252 params->set (
"randomizeNullSpace", defaultRandomizeNullSpace,
1253 "Whether to fill in null space vectors with random data.");
1255 const bool defaultReorthogonalizeBlocks =
true;
1256 params->set (
"reorthogonalizeBlocks", defaultReorthogonalizeBlocks,
1257 "Whether to do block reorthogonalization as necessary.");
1261 const magnitude_type defaultBlockReorthogThreshold =
1263 params->set (
"blockReorthogThreshold", defaultBlockReorthogThreshold,
1264 "If reorthogonalizeBlocks==true, and if the norm of " 1265 "any column within a block decreases by this much or " 1266 "more after orthogonalization, we reorthogonalize.");
1270 const magnitude_type defaultRelativeRankTolerance =
1271 Teuchos::as<magnitude_type>(10) *
SCTM::eps();
1276 params->set (
"relativeRankTolerance", defaultRelativeRankTolerance,
1277 "Relative tolerance to determine the numerical rank of a " 1278 "block when normalizing.");
1282 const bool defaultThrowOnReorthogFault =
true;
1283 params->set (
"throwOnReorthogFault", defaultThrowOnReorthogFault,
1284 "Whether to throw an exception if an orthogonalization " 1285 "fault occurs. This only matters if reorthogonalization " 1286 "is enabled (reorthogonalizeBlocks==true).");
1288 const bool defaultForceNonnegativeDiagonal =
false;
1289 params->set (
"forceNonnegativeDiagonal", defaultForceNonnegativeDiagonal,
1290 "Whether to force the R factor produced by the normalization " 1291 "step to have a nonnegative diagonal.");
1293 defaultParams_ = params;
1295 return defaultParams_;
1298 template<
class Scalar,
class MV>
1308 RCP<ParameterList> params =
rcp (
new ParameterList (*defaultParams));
1317 const bool randomizeNullSpace =
false;
1318 params->set (
"randomizeNullSpace", randomizeNullSpace);
1319 const bool reorthogonalizeBlocks =
false;
1320 params->set (
"reorthogonalizeBlocks", reorthogonalizeBlocks);
1325 template<
class Scalar,
class MV>
1337 tsqrAdaptor_.factorExplicit (X, Q, B, forceNonnegativeDiagonal_);
1340 rank = tsqrAdaptor_.revealRank (Q, B, relativeRankTolerance_);
1341 }
catch (std::exception& e) {
1347 template<
class Scalar,
class MV>
1360 const int numRows = B->
numRows();
1361 const int numCols = B->
numCols();
1363 std::invalid_argument,
1364 "normalizeOne: Input matrix B must be at " 1365 "least 1 x 1, but is instead " << numRows
1366 <<
" x " << numCols <<
".");
1372 std::vector<magnitude_type> theNorm (1,
SCTM::zero());
1374 (*B_out)(0,0) = theNorm[0];
1391 if (randomizeNullSpace_) {
1400 "vector has norm zero!");
1405 const Scalar alpha =
SCT::one() / theNorm[0];
1413 const Scalar alpha =
SCT::one() / theNorm[0];
1420 template<
class Scalar,
class MV>
1428 const int num_Q_blocks = Q.size();
1429 for (
int i = 0; i < num_Q_blocks; ++i)
1438 const MV& Qi = *Q[i];
1445 template<
class Scalar,
class MV>
1457 template<
class Scalar,
class MV>
1463 const bool outOfPlace)
1469 using Teuchos::tuple;
1474 const bool extraDebug =
false;
1484 std::invalid_argument,
1485 "TsqrOrthoManagerImpl::normalizeImpl(X,Q,B): Q has " 1487 "few, since X has " << numCols <<
" columns.");
1503 std::invalid_argument,
1504 "normalizeOne: Input matrix B must be at " 1505 "least " << numCols <<
" x " << numCols
1506 <<
", but is instead " << B->
numRows()
1507 <<
" x " << B->
numCols() <<
".");
1514 std::vector<magnitude_type> norms (numCols);
1516 cerr <<
"Column norms of X before orthogonalization: ";
1517 typedef typename std::vector<magnitude_type>::const_iterator iter_type;
1518 for (iter_type iter = norms.begin(); iter != norms.end(); ++iter) {
1520 if (iter+1 != norms.end())
1534 const int rank = rawNormalize (X, *Q_view, *B_out);
1545 std::vector<magnitude_type> norms (numCols);
1547 cerr <<
"Column norms of Q_view after orthogonalization: ";
1548 for (
typename std::vector<magnitude_type>::const_iterator iter = norms.begin();
1549 iter != norms.end(); ++iter) {
1551 if (iter+1 != norms.end())
1556 "Belos::TsqrOrthoManagerImpl::normalizeImpl: " 1557 "rawNormalize() returned rank = " << rank <<
" for a " 1558 "matrix X with " << numCols <<
" columns. Please report" 1559 " this bug to the Belos developers.");
1560 if (extraDebug && rank == 0) {
1564 std::vector<magnitude_type> norms (B_ref.
numCols());
1567 mat_scalar_type sumOfSquares = ScalarTraits<mat_scalar_type>::zero();
1569 const mat_scalar_type B_ij =
1570 ScalarTraits<mat_scalar_type>::magnitude (B_ref(i,j));
1571 sumOfSquares += B_ij*B_ij;
1573 norms[j] = ScalarTraits<mat_scalar_type>::squareroot (sumOfSquares);
1577 cerr <<
"Norms of columns of B after orthogonalization: ";
1588 if (rank == numCols || ! randomizeNullSpace_) {
1597 if (randomizeNullSpace_ && rank < numCols) {
1604 const int nullSpaceNumCols = numCols - rank;
1607 Range1D nullSpaceIndices (rank, numCols-1);
1625 bool anyZero =
false;
1626 typedef typename std::vector<magnitude_type>::const_iterator iter_type;
1627 for (iter_type it = norms.begin(); it != norms.end(); ++it) {
1633 std::ostringstream os;
1634 os <<
"TsqrOrthoManagerImpl::normalizeImpl: " 1635 "We are being asked to randomize the null space, for a matrix " 1636 "with " << numCols <<
" columns and reported column rank " 1637 << rank <<
". The inclusive range of columns to fill with " 1638 "random data is [" << nullSpaceIndices.lbound() <<
"," 1639 << nullSpaceIndices.ubound() <<
"]. After filling the null " 1640 "space vectors with random numbers, at least one of the vectors" 1641 " has norm zero. Here are the norms of all the null space " 1643 for (iter_type it = norms.begin(); it != norms.end(); ++it) {
1645 if (it+1 != norms.end())
1648 os <<
"].) There is a tiny probability that this could happen " 1649 "randomly, but it is likely a bug. Please report it to the " 1650 "Belos developers, especially if you are able to reproduce the " 1663 RCP<const MV> Q_col =
MVT::CloneView (*Q_view, Range1D(0, rank-1));
1669 rawProject (*Q_null, Q_col, C_null);
1681 mat_type B_null (nullSpaceNumCols, nullSpaceNumCols);
1683 const int nullSpaceBasisRank = rawNormalize (*Q_null, *X_null, B_null);
1697 if (nullSpaceBasisRank < nullSpaceNumCols) {
1700 std::ostringstream os;
1701 os <<
"TsqrOrthoManagerImpl::normalizeImpl: " 1702 <<
"We are being asked to randomize the null space, " 1703 <<
"for a matrix with " << numCols <<
" columns and " 1704 <<
"column rank " << rank <<
". After projecting and " 1705 <<
"normalizing the generated random vectors, they " 1706 <<
"only have rank " << nullSpaceBasisRank <<
". They" 1707 <<
" should have full rank " << nullSpaceNumCols
1708 <<
". (The inclusive range of columns to fill with " 1709 <<
"random data is [" << nullSpaceIndices.lbound()
1710 <<
"," << nullSpaceIndices.ubound() <<
"]. The " 1711 <<
"column norms of the resulting Q factor are: [";
1712 for (
typename std::vector<magnitude_type>::size_type k = 0;
1713 k < norms.size(); ++k) {
1715 if (k != norms.size()-1) {
1719 os <<
"].) There is a tiny probability that this could " 1720 <<
"happen randomly, but it is likely a bug. Please " 1721 <<
"report it to the Belos developers, especially if " 1722 <<
"you are able to reproduce the behavior.";
1736 }
else if (rank > 0) {
1738 RCP<const MV> Q_col =
MVT::CloneView (*Q_view, Range1D(0, rank-1));
1747 template<
class Scalar,
class MV>
1762 int the_ncols_X, the_num_Q_blocks, the_ncols_Q_total;
1763 the_num_Q_blocks = Q.size();
1767 the_ncols_Q_total = 0;
1772 typedef typename ArrayView<RCP<const MV> >::const_iterator iter_type;
1773 for (iter_type it = Q.begin(); it != Q.end(); ++it) {
1774 const MV& Qi = **it;
1779 ncols_X = the_ncols_X;
1780 num_Q_blocks = the_num_Q_blocks;
1781 ncols_Q_total = the_ncols_Q_total;
1786 #endif // __AnasaziTsqrOrthoManagerImpl_hpp static void MvRandom(MV &mv)
Replace the vectors in mv with random vectors.
static void MvTimesMatAddMv(const ScalarType alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, MV &mv)
Update mv with .
An extension of the MultiVecTraits class that adds a new vector length method.This traits class provi...
bool is_null(const boost::shared_ptr< T > &p)
TSQR-based OrthoManager subclass implementation.
static ptrdiff_t GetGlobalLength(const MV &mv)
static magnitudeType eps()
Declaration of basic traits for the multivector type.
T & get(const std::string &name, T def_value)
int projectAndNormalize(MV &X, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q)
Project X against Q and normalize X.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::SerialDenseMatrix< int, Scalar > mat_type
magnitude_type blockReorthogThreshold() const
static void Assign(const MV &A, MV &mv)
mv := A
magnitude_type orthonormError(const MV &X) const
Return .
void innerProd(const MV &X, const MV &Y, mat_type &Z) const
Euclidean inner product.
void norm(const MV &X, std::vector< magnitude_type > &normvec) const
ScalarTraits< ScalarType >::magnitudeType normFrobenius() const
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Set parameters from the given parameter list.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
TsqrOrthoManagerImpl(const Teuchos::RCP< Teuchos::ParameterList > ¶ms, const std::string &label)
Constructor (that sets user-specified parameters).
TsqrOrthoManager(Impl) error.
void setLabel(const std::string &label)
Set the label for timers.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
Templated virtual class for providing orthogonalization/orthonormalization methods.
Traits class which defines basic operations on multivectors.
static void MvScale(MV &mv, const ScalarType alpha)
Scale each element of the vectors in mv with alpha.
const std::string & getLabel() const
Get the label for timers (if timers are enabled).
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters()
Get "fast" parameters for TsqrOrthoManagerImpl.
void project(MV &X, Teuchos::Array< mat_ptr > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q)
Compute and .
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
void resize(size_type new_size, const value_type &x=value_type())
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
Creates a new MV that shares the selected contents of mv (shallow copy).
Exception thrown to signal error in an orthogonalization manager method.
int projectAndNormalizeOutOfPlace(MV &X_in, MV &X_out, Teuchos::Array< mat_ptr > C, mat_ptr B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q)
Project and normalize X_in into X_out; overwrite X_in.
static void MvNorm(const MV &mv, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec)
Compute the 2-norm of each individual vector of mv. Upon return, normvec[i] holds the value of ...
int normalizeOutOfPlace(MV &X, MV &Q, mat_ptr B)
Normalize X into Q*B, overwriting X.
static Teuchos::RCP< const MV > CloneView(const MV &mv, const std::vector< int > &index)
Creates a new const MV that shares the selected contents of mv (shallow copy).
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
OrdinalType numCols() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Default valid parameter list.
magnitude_type relativeRankTolerance() const
magnitude_type orthogError(const MV &X1, const MV &X2) const
Return the Frobenius norm of the inner product of X1 with itself.
int shape(OrdinalType numRows, OrdinalType numCols)
int normalize(MV &X, mat_ptr B)
Orthogonalize the columns of X in place.
static Teuchos::RCP< MV > Clone(const MV &mv, const int numvecs)
Creates a new empty MV containing numvecs columns.
OrdinalType numRows() const
ScalarTraits< ScalarType >::magnitudeType NRM2(const OrdinalType n, const ScalarType *x, const OrdinalType incx) const