Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
example
operator_vector
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
18
namespace
Thyra {
19
30
template
<
class
Scalar>
31
void
sillyModifiedGramSchmidt(
32
const
Ptr
<
MultiVectorBase<Scalar>
> &V,
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());
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
Teuchos::Ptr
Teuchos::RCP
Thyra::DetachedMultiVectorView
Create an explicit mutable (non-const) view of a MultiVectorBase object.
Definition
Thyra_DetachedMultiVectorView.hpp:76
Thyra::MultiVectorBase
Interface for a collection of column vectors called a multi-vector.
Definition
Thyra_MultiVectorBase_decl.hpp:464
Thyra::MultiVectorBase::Vt_S
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.
Definition
Thyra_MultiVectorStdOps_def.hpp:211
Thyra::VectorBase::Vp_StV
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.
Definition
Thyra_VectorStdOps_def.hpp:363
Thyra::VectorBase::scalarProd
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y)
Scalar product result = <x,y>.
Definition
Thyra_VectorStdOps_decl.hpp:600
Thyra::VectorBase::norm
Teuchos::ScalarTraits< Scalar >::magnitudeType norm(const VectorBase< Scalar > &v)
Natural norm: result = sqrt(<v,v>).
Definition
Thyra_VectorStdOps_decl.hpp:617
Thyra::VectorSpaceBase::createMembers
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.
Teuchos::as
TypeTo as(const TypeFrom &t)
Generated by
1.17.0