|
Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
|
Go to the documentation of this file.
42 #ifndef _TEUCHOS_SERIALQRDENSESOLVER_MP_VECTOR_HPP_
43 #define _TEUCHOS_SERIALQRDENSESOLVER_MP_VECTOR_HPP_
59 template<
typename OrdinalType,
typename Storage>
102 base_QR_.factorWithEquilibration(flag);
107 base_QR_.solveWithTranspose(flag);
112 base_QR_.solveWithTranspose(trans);
124 int factor() {
return base_QR_.factor(); }
130 int solve() {
return base_QR_.solve(); }
137 return base_QR_.computeEquilibrateScaling();
205 bool solved() {
return base_QR_.solved(); }
243 std::vector<ScalarType>
tau()
const {
return base_QR_.tau(); }
252 void Print(std::ostream& os)
const;
300 template <
typename Ordinal,
typename Value,
typename Device>
315 Vector* v_vec = static_cast<Vector*>(
operator new(len*
sizeof(
Vector)));
317 new (v_vec+i)
Vector(vector_size, v+i*vector_size,
false);
323 template <
typename Ordinal,
typename Value,
typename Device,
int Num>
330 return reinterpret_cast<Value*>(v);
335 return reinterpret_cast<Vector*>(v);
342 using namespace details;
346 template<
typename OrdinalType,
typename Storage>
347 SerialQRDenseSolver<OrdinalType,Sacado::MP::Vector<Storage> >::
348 SerialQRDenseSolver()
350 Object(
"Teuchos::SerialQRDenseSolver"),
359 template<
typename OrdinalType,
typename Storage>
363 LHS_ = Teuchos::null;
364 RHS_ = Teuchos::null;
368 template<
typename OrdinalType,
typename Storage>
378 template<
typename OrdinalType,
typename Storage>
386 mat->values(), mat->stride()*mat->numCols());
390 mat->stride()*SacadoSize_,
391 mat->numRows()*SacadoSize_,
397 template<
typename OrdinalType,
typename Storage>
405 base_mat->values(), base_mat->stride()*base_mat->numCols(), SacadoSize_);
409 base_mat->stride()/SacadoSize_,
410 base_mat->numRows()/SacadoSize_,
411 base_mat->numCols()));
416 template<
typename OrdinalType,
typename Storage>
421 A->numRows() <
A->numCols(), std::invalid_argument,
422 "SerialQRDenseSolver<T>::setMatrix: the matrix A must have A.numRows() >= A.numCols()!");
431 if (Storage::is_static)
432 SacadoSize_ = Storage::static_size;
433 else if (M_ > 0 && N_ > 0)
434 SacadoSize_ = (*A)(0,0).size();
438 return base_QR_.setMatrix( createBaseMatrix(
A) );
442 template<
typename OrdinalType,
typename Storage>
450 B->numCols() != X->numCols(), std::invalid_argument,
451 "SerialQRDenseSolver<T>::setVectors: X and B have different numbers of columns!");
453 B->values()==0, std::invalid_argument,
454 "SerialQRDenseSolver<T>::setVectors: B is an empty SerialDenseMatrix<T>!");
456 X->values()==0, std::invalid_argument,
457 "SerialQRDenseSolver<T>::setVectors: X is an empty SerialDenseMatrix<T>!");
459 B->stride()<1, std::invalid_argument,
460 "SerialQRDenseSolver<T>::setVectors: B has an invalid stride!");
462 X->stride()<1, std::invalid_argument,
463 "SerialQRDenseSolver<T>::setVectors: X has an invalid stride!");
469 return base_QR_.setVectors( createBaseMatrix(X), createBaseMatrix(
B) );
474 template<
typename OrdinalType,
typename Storage>
477 int ret = base_QR_.
formQ();
478 FactorQ_ = createMatrix( base_QR_.getQ() );
484 template<
typename OrdinalType,
typename Storage>
487 int ret = base_QR_.
formR();
488 FactorR_ = createMatrix( base_QR_.getR() );
489 Factor_ = createMatrix( base_QR_.getFactoredMatrix() );
495 template<
typename OrdinalType,
typename Storage>
499 return base_QR_.
multiplyQ(transq, createBaseMatrix(
C));
504 template<
typename OrdinalType,
typename Storage>
508 return base_QR_.
solveR(transr, createBaseMatrix(
C));
513 template<
typename OrdinalType,
typename Storage>
515 Print(std::ostream& os)
const {
517 if (Matrix_!=Teuchos::null) os <<
"Solver Matrix" << std::endl << *Matrix_ << std::endl;
518 if (Factor_!=Teuchos::null) os <<
"Solver Factored Matrix" << std::endl << *Factor_ << std::endl;
519 if (LHS_ !=Teuchos::null) os <<
"Solver LHS" << std::endl << *LHS_ << std::endl;
520 if (RHS_ !=Teuchos::null) os <<
"Solver RHS" << std::endl << *RHS_ << std::endl;
std::vector< ScalarType > tau() const
Returns pointer to pivot vector (if factorization has been computed), zero otherwise.
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > Factor_
static Value * getValueArray(Vector *v, Ordinal len)
static Value * getValueArray(Vector *v, Ordinal len)
Templated class for solving dense linear problems.
bool shouldEquilibrate()
Returns true if the LAPACK general rules for equilibration suggest you should equilibrate the system.
SerialDenseMatrix< OrdinalType, BaseScalarType > BaseMatrixType
int factor()
Computes the in-place QR factorization of the matrix using the LAPACK routine _GETRF or the Eigen cla...
RCP< BaseMatrixType > Base_FactorQ_
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > getR() const
Returns pointer to R (assuming factorization has been performed).
OrdinalType numRows() const
Returns row dimension of system.
ScalarTraits< ScalarType >::magnitudeType MagnitudeType
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > FactorQ_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Sacado::MP::Vector< Storage > Vector
SerialDenseMatrix< OrdinalType, ScalarType > MatrixType
int multiplyQ(ETransp transq, SerialDenseMatrix< OrdinalType, ScalarType > &C)
void solveWithTranspose(bool flag)
If flag is true, causes all subsequent function calls to work with the adjoint of this matrix,...
RCP< MatrixType > Factor_
Specialization for Sacado::UQ::PCE< Storage<...> >
RCP< BaseMatrixType > Base_LHS_
Stokhos::StaticFixedStorage< Ordinal, Value, Num, Device > Storage
Stokhos::DynamicStorage< Ordinal, Value, Device > Storage
SerialQRDenseSolver & operator=(const SerialQRDenseSolver< OrdinalType, ScalarType > &Source)
int unequilibrateLHS()
Unscales the solution vectors if equilibration was used to solve the system.
bool factored()
Returns true if matrix is factored (factor available via getFactoredMatrix()).
int setMatrix(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &A)
OrdinalType numCols() const
Returns column dimension of system.
Top-level namespace for Stokhos classes and functions.
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > Matrix_
void solveWithTransposeFlag(Teuchos::ETransp trans)
All subsequent function calls will work with the transpose-type set by this method (Teuchos::NO_TRANS...
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > getFactoredMatrix() const
Returns pointer to factored matrix (assuming factorization has been performed).
virtual ~SerialQRDenseSolver()
SerialQRDenseSolver destructor.
RCP< BaseMatrixType > Base_RHS_
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > getMatrix() const
Returns pointer to current matrix.
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > getQ() const
Returns pointer to Q (assuming factorization has been performed).
bool equilibratedA()
Returns true if factor is equilibrated (factor available via getFactoredMatrix()).
RCP< MatrixType > FactorR_
static Vector * getVectorArray(Value *v, Ordinal len, Ordinal vector_size)
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > LHS_
MagnitudeType ANORM() const
Returns the absolute value of the largest element of this matrix (returns -1 if not yet computed).
bool transpose()
Returns true if adjoint of this matrix has and will be used.
Sacado::MP::Vector< Storage > ScalarType
bool solved()
Returns true if the current set of vectors has been solved.
int setVectors(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &X, const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &B)
Sacado::MP::Vector< Storage > Vector
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > getLHS() const
Returns pointer to current LHS.
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > getRHS() const
Returns pointer to current RHS.
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > FactorR_
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > RHS_
RCP< BaseMatrixType > Base_Matrix_
void factorWithEquilibration(bool flag)
Causes equilibration to be called just before the matrix factorization as part of the call to factor.
Statically allocated storage class.
int equilibrateRHS()
Equilibrates the current RHS.
int solve()
Computes the solution X to AX = B for the this matrix and the B provided to SetVectors()....
RCP< MatrixType > FactorQ_
static Vector * getVectorArray(Value *v, Ordinal len, Ordinal vector_size)
RCP< MatrixType > Matrix_
bool formedQ()
Returns true if Q has been formed explicitly.
void Print(std::ostream &os) const
int equilibrateMatrix()
Equilibrates the this matrix.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
RCP< BaseMatrixType > Base_FactorR_
ScalarType::value_type BaseScalarType
int solveR(ETransp transr, SerialDenseMatrix< OrdinalType, ScalarType > &C)
SerialQRDenseSolver< OrdinalType, BaseScalarType > BaseQRType
int computeEquilibrateScaling()
Determines if this matrix should be scaled.
bool formedR()
Returns true if R has been formed explicitly.
RCP< BaseMatrixType > Base_Factor_
bool equilibratedB()
Returns true if RHS is equilibrated (RHS available via getRHS()).