Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
support
operator_vector
client_support
Thyra_describeLinearOp_def.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_DESCRIBE_LINEAR_OP_HPP
11
#define THYRA_DESCRIBE_LINEAR_OP_HPP
12
13
#include "Thyra_LinearOpBase.hpp"
14
#include "Thyra_MultiVectorBase.hpp"
15
#include "Thyra_VectorStdOps.hpp"
16
#include "Thyra_AssertOp.hpp"
17
#include "Thyra_AssertOp.hpp"
18
19
20
template
<
class
Scalar>
21
void
Thyra::describeLinearOp(
22
const
LinearOpBase<Scalar> &A,
23
Teuchos::FancyOStream
&out_arg,
24
const
Teuchos::EVerbosityLevel
verbLevel
25
)
26
{
27
using
Teuchos::RCP
;
28
using
Teuchos::FancyOStream
;
29
using
Teuchos::OSTab
;
30
typedef
Teuchos::ScalarTraits<Scalar>
DST;
31
32
RCP<FancyOStream> out =
rcp
(&out_arg,
false
);
33
OSTab
tab(out);
34
*out << A.description() <<
"\n"
;
35
36
const
Teuchos::RCP<const VectorSpaceBase<Scalar>
>
37
range = A.range();
38
const
Teuchos::RCP<const VectorSpaceBase<Scalar>
>
39
domain = A.domain();
40
41
if
(!range.
get
()) {
42
return
;
43
}
44
45
const
Ordinal dimDomain = domain->dim(), dimRange = range->dim();
46
if
( dimDomain > 0 && dimRange > 0 && verbLevel >=
Teuchos::VERB_EXTREME
) {
47
// Copy into dense matrix by column
48
Teuchos::RCP<VectorBase<Scalar>
> e_j =
createMember
(domain);
49
Teuchos::RCP<VectorBase<Scalar>
> t =
createMember
(range);
// temp column
50
RTOpPack::ConstSubVectorView<Scalar>
sv;
51
Array<Scalar> Md(dimRange*dimDomain);
// Column major
52
const
Ordinal
53
cs = 1,
// stride for columns or rows
54
rs = dimRange;
// stride for rows or columns
55
Ordinal i, j;
56
OSTab
tab2(out);
57
for
( j = 0; j < dimDomain; ++j ) {
58
Thyra::assign
( e_j.
ptr
(), DST::zero() );
59
Thyra::set_ele
( j, DST::one(), e_j.
ptr
() );
60
Thyra::apply<Scalar>
(A, NOTRANS, *e_j, t.
ptr
());
// extract the ith column or row
61
t->acquireDetachedView(
Range1D
(),&sv);
62
for
( i = 0; i < dimRange; ++i ) Md[ i*cs + j*rs ] = sv(i);
63
t->releaseDetachedView(&sv);
64
}
65
// Print the matrix
66
for
( i = 0; i < dimRange; ++i ) {
67
for
( j = 0; j < dimDomain; ++j )
68
*out <<
" "
<< i <<
":"
<< j <<
":"
<< Md[ i + j*dimRange ];
69
*out << std::endl;
70
}
71
}
72
73
}
74
75
76
//
77
// Explicit instant macro
78
//
79
80
#define THYRA_DESCRIBE_LINEAR_INSTANT(SCALAR) \
81
\
82
template void describeLinearOp( \
83
const LinearOpBase<SCALAR > &A, \
84
Teuchos::FancyOStream &out_arg, \
85
const Teuchos::EVerbosityLevel verbLevel \
86
); \
87
88
89
90
#endif
// THYRA_DESCRIBE_LINEAR_OP_HPP
RTOpPack::ConstSubVectorView
Teuchos::RCP
Teuchos::RCP::ptr
Ptr< T > ptr() const
Teuchos::RCP::get
T * get() const
Thyra::LinearOpBase::apply
void apply(const LinearOpBase< Scalar > &M, const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha=static_cast< Scalar >(1.0), const Scalar beta=static_cast< Scalar >(0.0))
Non-member function call for M.apply(...).
Definition
Thyra_LinearOpBase_def.hpp:41
Thyra::MultiVectorBase::assign
void assign(const Ptr< MultiVectorBase< Scalar > > &V, Scalar alpha)
V = alpha.
Definition
Thyra_MultiVectorStdOps_def.hpp:122
Thyra::VectorBase::set_ele
void set_ele(Ordinal i, Scalar alpha, const Ptr< VectorBase< Scalar > > &v)
Set single element: v(i) = alpha.
Definition
Thyra_VectorStdOps_def.hpp:121
Thyra::VectorSpaceBase::createMember
RCP< VectorBase< Scalar > > createMember(const RCP< const VectorSpaceBase< Scalar > > &vs, const std::string &label="")
Create a vector member from the vector space.
Thyra::Range1D
Teuchos::Range1D Range1D
Definition
Thyra_OperatorVectorTypes.hpp:65
Teuchos::FancyOStream
basic_FancyOStream< char > FancyOStream
Teuchos::OSTab
basic_OSTab< char > OSTab
Teuchos::EVerbosityLevel
EVerbosityLevel
Teuchos::VERB_EXTREME
VERB_EXTREME
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::ScalarTraits
Generated by
1.17.0