42 #ifndef STOKHOS_ORTHOGONALIZATION_FACTORY_HPP
43 #define STOKHOS_ORTHOGONALIZATION_FACTORY_HPP
55 template <
typename ordinal_type,
typename value_type>
73 bool verbose,
const SDM&
A,
82 if (method ==
"SVD") {
89 R(i,
j) = sigma[i]*Vt(i,
j);
91 for (
int i=0; i<n; i++)
100 std::cout <<
"rank = " << rank << std::endl;
106 if (method ==
"Householder")
109 else if (method ==
"Householder without Pivoting") {
112 for (
int i=0; i<n; i++)
116 else if (method ==
"Modified Gram-Schmidt")
119 else if (method ==
"Modified Gram-Schmidt with Reorthogonalization")
122 else if (method ==
"Modified Gram-Schmidt without Pivoting") {
125 for (
int i=0; i<n; i++)
129 else if (method ==
"Modified Gram-Schmidt without Pivoting with Reorthogonalization") {
132 for (
int i=0; i<n; i++)
138 true, std::logic_error,
139 "Invalid orthogonalization method " << method);
152 std::cout <<
"rank = " << rank << std::endl;
155 std::cout <<
"||A*P-Q*R||_infty = "
159 std::cout <<
"||I - Q^T*diag(w)**Q||_infty = "
ordinal_type CPQR_MGS_threshold(const scalar_type &rank_threshold, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &A, const Teuchos::Array< scalar_type > &w, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Q, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &R, Teuchos::Array< ordinal_type > &piv)
Compute column-pivoted QR using modified Gram-Schmidt.
ordinal_type CPQR_Householder_threshold(const scalar_type &rank_threshold, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &A, const Teuchos::Array< scalar_type > &w, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Q, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &R, Teuchos::Array< ordinal_type > &piv)
Compute column-pivoted QR using Householder reflections.
void QR_MGS(ordinal_type k, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &A, const Teuchos::Array< scalar_type > &w, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Q, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &R)
Compute thin QR using modified Gram-Schmidt.
Teuchos::SerialDenseMatrix< ordinal_type, value_type > SDM
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
OrthogonalizationFactory()
Constructor.
ordinal_type svd_threshold(const scalar_type &rank_threshold, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &A, Teuchos::Array< scalar_type > &s, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &U, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Vt)
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
virtual ~OrthogonalizationFactory()
Destructor.
scalar_type residualCPQRError(const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &A, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Q, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &R, const Teuchos::Array< ordinal_type > &piv)
Compute column-pivoted QR residual error.
scalar_type weightedQROrthogonalizationError(const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Q, const Teuchos::Array< scalar_type > &w)
Compute weighted QR orthogonalization error.
OrthogonalizationFactory & operator=(const OrthogonalizationFactory &)
void resize(size_type new_size, const value_type &x=value_type())
OrdinalType numCols() const
void QR_MGS2(ordinal_type k, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &A, const Teuchos::Array< scalar_type > &w, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Q, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &R)
Compute thin QR using modified Gram-Schmidt with reorthogonalization.
int reshape(OrdinalType numRows, OrdinalType numCols)
static ordinal_type createOrthogonalBasis(const std::string &method, value_type threshold, bool verbose, const SDM &A, const Teuchos::Array< value_type > &w, SDM &Q, SDM &R, Teuchos::Array< ordinal_type > &piv)
Create orthogonal basis via the method indicated by method.
void QR_Householder(ordinal_type k, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &A, const Teuchos::Array< scalar_type > &w, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Q, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &R)
Compute thin QR using Householder reflections.
ordinal_type CPQR_MGS_reorthog_threshold(const scalar_type &rank_threshold, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &A, const Teuchos::Array< scalar_type > &w, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &Q, Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &R, Teuchos::Array< ordinal_type > &piv)
Compute column-pivoted QR using modified Gram-Schmidt and reorthogonalization.
OrdinalType numRows() const
Encapsulate various orthogonalization (ie QR) methods.