10 #ifndef STOKHOS_ORTHOGONALIZATION_FACTORY_HPP
11 #define STOKHOS_ORTHOGONALIZATION_FACTORY_HPP
23 template <
typename ordinal_type,
typename value_type>
41 bool verbose,
const SDM&
A,
50 if (method ==
"SVD") {
57 R(i,
j) = sigma[i]*Vt(i,
j);
59 for (
int i=0; i<n; i++)
68 std::cout <<
"rank = " << rank << std::endl;
74 if (method ==
"Householder")
77 else if (method ==
"Householder without Pivoting") {
80 for (
int i=0; i<n; i++)
84 else if (method ==
"Modified Gram-Schmidt")
87 else if (method ==
"Modified Gram-Schmidt with Reorthogonalization")
90 else if (method ==
"Modified Gram-Schmidt without Pivoting") {
93 for (
int i=0; i<n; i++)
97 else if (method ==
"Modified Gram-Schmidt without Pivoting with Reorthogonalization") {
100 for (
int i=0; i<n; i++)
106 true, std::logic_error,
107 "Invalid orthogonalization method " << method);
120 std::cout <<
"rank = " << rank << std::endl;
123 std::cout <<
"||A*P-Q*R||_infty = "
127 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.