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(
32 const Ptr<MultiVectorBase<Scalar> > &V,
33 const Ptr<RCP<MultiVectorBase<Scalar> > > &R_out
34 )
35{
37 const int n = V->domain()->dim();
38 *R_out = createMembers(V->domain(), V->domain());
39 DetachedMultiVectorView<Scalar> R(*(*R_out));
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
TypeTo as(const TypeFrom &t)