Thyra Version of the Day
Loading...
Searching...
No Matches
sillyModifiedGramSchmidt.hpp
1// @HEADER
2// *****************************************************************************
3// Thyra: Interfaces and Support for Abstract Numerical Algorithms
4//
5// Copyright 2004 NTESS and the Thyra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef THYRA_SILLY_MODIFIED_GRAM_SHMIDT_HPP
11#define THYRA_SILLY_MODIFIED_GRAM_SHMIDT_HPP
12
13#include "Thyra_MultiVectorBase.hpp"
14#include "Thyra_MultiVectorStdOps.hpp"
15#include "Thyra_VectorStdOps.hpp"
16#include "Thyra_DetachedMultiVectorView.hpp"
17
18namespace Thyra {
19
30template<class Scalar>
31void sillyModifiedGramSchmidt(
33 const Ptr<RCP<MultiVectorBase<Scalar> > > &R_out
34 )
35{
36 typedef Teuchos::ScalarTraits<Scalar> ST; using Teuchos::as;
37 const int n = V->domain()->dim();
38 *R_out = createMembers(V->domain(), V->domain());
40 for (int k = 0; k < n; ++k) {
41 R(k,k) = norm(*V->col(k));
42 Vt_S(V->col(k).ptr(), ST::one()/R(k,k));
43 for (int j = k+1; j < n; ++j) {
44 R(k,j) = scalarProd(*V->col(k), *V->col(j));
45 Vp_StV(V->col(j).ptr(), -R(k,j), *V->col(k));
46 }
47 }
48} // end sillyModifiedGramSchmidt
49
50} // namespace Thyra
51
52#endif // THYRA_SILLY_MODIFIED_GRAM_SHMIDT_HPP
Create an explicit mutable (non-const) view of a MultiVectorBase object.
Interface for a collection of column vectors called a multi-vector.
void Vt_S(const Ptr< MultiVectorBase< Scalar > > &Z, const Scalar &alpha)
Z(i,j) *= alpha, i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void Vp_StV(const Ptr< VectorBase< Scalar > > &y, const Scalar &alpha, const VectorBase< Scalar > &x)
AXPY: y(i) = alpha * x(i) + y(i), i = 0...y->space()->dim()-1.
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y)
Scalar product result = <x,y>.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm(const VectorBase< Scalar > &v)
Natural norm: result = sqrt(<v,v>).
RCP< MultiVectorBase< Scalar > > createMembers(const RCP< const VectorSpaceBase< Scalar > > &vs, int numMembers, const std::string &label="")
Create a set of vector members (a MultiVectorBase) from the vector space.
TypeTo as(const TypeFrom &t)