Epetra Package Browser (Single Doxygen Collection)
Development
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Epetra_LinearProblem.cpp
Go to the documentation of this file.
1
2
//@HEADER
3
// ************************************************************************
4
//
5
// Epetra: Linear Algebra Services Package
6
// Copyright 2011 Sandia Corporation
7
//
8
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9
// the U.S. Government retains certain rights in this software.
10
//
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
13
// met:
14
//
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright
19
// notice, this list of conditions and the following disclaimer in the
20
// documentation and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the Corporation nor the names of the
23
// contributors may be used to endorse or promote products derived from
24
// this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39
//
40
// ************************************************************************
41
//@HEADER
42
43
#include "
Epetra_LinearProblem.h
"
44
#include "
Epetra_MultiVector.h
"
45
#include "
Epetra_Vector.h
"
46
#include "
Epetra_Map.h
"
47
48
49
//=============================================================================
50
Epetra_LinearProblem::Epetra_LinearProblem
(
void
)
51
:
Operator_
(0),
52
A_
(0),
53
X_
(0),
54
B_
(0),
55
OperatorSymmetric_
(false),
56
PDL_
(
unsure
),
57
LeftScaled_
(false),
58
RightScaled_
(false),
59
LeftScaleVector_
(0),
60
RightScaleVector_
(0)
61
{
62
}
63
//=============================================================================
64
Epetra_LinearProblem::Epetra_LinearProblem
(
Epetra_RowMatrix
* A,
65
Epetra_MultiVector
* X,
66
Epetra_MultiVector
* B)
67
:
Operator_
(0),
68
A_
(A),
69
X_
(X),
70
B_
(B),
71
OperatorSymmetric_
(false),
72
PDL_
(
unsure
),
73
LeftScaled_
(false),
74
RightScaled_
(false),
75
LeftScaleVector_
(0),
76
RightScaleVector_
(0)
77
{
78
Operator_
=
dynamic_cast<
Epetra_Operator
*
>
(
A_
);
// Try to make matrix an operator
79
}
80
//=============================================================================
81
Epetra_LinearProblem::Epetra_LinearProblem
(
Epetra_Operator
* A,
82
Epetra_MultiVector
* X,
83
Epetra_MultiVector
* B)
84
:
Operator_
(A),
85
A_
(0),
86
X_
(X),
87
B_
(B),
88
OperatorSymmetric_
(false),
89
PDL_
(
unsure
),
90
LeftScaled_
(false),
91
RightScaled_
(false),
92
LeftScaleVector_
(0),
93
RightScaleVector_
(0)
94
{
95
A_
=
dynamic_cast<
Epetra_RowMatrix
*
>
(
Operator_
);
// Try to make operator a matrix
96
}
97
//=============================================================================
98
Epetra_LinearProblem::Epetra_LinearProblem
(
const
Epetra_LinearProblem
& Problem)
99
:
Operator_
(Problem.
Operator_
),
100
A_
(Problem.
A_
),
101
X_
(Problem.
X_
),
102
B_
(Problem.
B_
),
103
OperatorSymmetric_
(Problem.
OperatorSymmetric_
),
104
PDL_
(Problem.
PDL_
),
105
LeftScaled_
(Problem.
LeftScaled_
),
106
RightScaled_
(Problem.
RightScaled_
),
107
LeftScaleVector_
(Problem.
LeftScaleVector_
),
108
RightScaleVector_
(Problem.
RightScaleVector_
)
109
{
110
}
111
//=============================================================================
112
Epetra_LinearProblem::~Epetra_LinearProblem
(
void
)
113
{
114
}
115
//=============================================================================
116
int
Epetra_LinearProblem::LeftScale
(
const
Epetra_Vector
& D)
117
{
118
if
(
A_
==0)
EPETRA_CHK_ERR
(-1);
// No matrix defined
119
if
(
B_
==0)
EPETRA_CHK_ERR
(-2);
// No RHS defined
120
if
(
A_
->UseTranspose()) {
121
EPETRA_CHK_ERR
(
A_
->RightScale(D));
122
EPETRA_CHK_ERR
(
X_
->ReciprocalMultiply(1.0, D, *
X_
, 0.0));
123
}
124
else
{
125
EPETRA_CHK_ERR
(
A_
->LeftScale(D));
126
EPETRA_CHK_ERR
(
B_
->Multiply(1.0, D, *
B_
, 0.0));
127
}
128
129
return
(0);
130
}
131
//=============================================================================
132
int
Epetra_LinearProblem::RightScale
(
const
Epetra_Vector
& D)
133
{
134
if
(
A_
==0)
EPETRA_CHK_ERR
(-1);
// No matrix defined
135
if
(
X_
==0)
EPETRA_CHK_ERR
(-2);
// No LHS defined
136
if
(
A_
->UseTranspose()) {
137
EPETRA_CHK_ERR
(
A_
->LeftScale(D));
138
EPETRA_CHK_ERR
(
B_
->Multiply(1.0, D, *
B_
, 0.0));
139
}
140
else
{
141
EPETRA_CHK_ERR
(
A_
->RightScale(D));
142
EPETRA_CHK_ERR
(
X_
->ReciprocalMultiply(1.0, D, *
X_
, 0.0));
143
}
144
return
(0);
145
}
146
//=============================================================================
147
int
Epetra_LinearProblem::CheckInput
()
const
{
148
int
ierr = 0;
149
if
(
Operator_
==0) ierr = -1;
150
if
(
X_
==0) ierr = -2;
151
if
(
B_
==0) ierr = -3;
152
153
EPETRA_CHK_ERR
(ierr);
// Return now if any essential objects missing
154
155
if
(
A_
==0)
EPETRA_CHK_ERR
(1);
// Return warning error because this problem has no matrix (just an operator)
156
157
if
(!
A_
->OperatorDomainMap().SameAs(
X_
->Map())) ierr = -4;
158
if
(!
A_
->OperatorRangeMap().SameAs(
B_
->Map())) ierr = -5;
159
160
EPETRA_CHK_ERR
(ierr);
161
return
(0);
162
163
}
EPETRA_CHK_ERR
#define EPETRA_CHK_ERR(a)
Definition
Epetra_ConfigDefs.h:307
Epetra_LinearProblem.h
Epetra_Map.h
Epetra_MultiVector.h
Epetra_Vector.h
Epetra_LinearProblem::LeftScale
int LeftScale(const Epetra_Vector &D)
Perform left scaling of a linear problem.
Definition
Epetra_LinearProblem.cpp:116
Epetra_LinearProblem::OperatorSymmetric_
bool OperatorSymmetric_
Definition
Epetra_LinearProblem.h:193
Epetra_LinearProblem::A_
Epetra_RowMatrix * A_
Definition
Epetra_LinearProblem.h:189
Epetra_LinearProblem::RightScale
int RightScale(const Epetra_Vector &D)
Perform right scaling of a linear problem.
Definition
Epetra_LinearProblem.cpp:132
Epetra_LinearProblem::Operator_
Epetra_Operator * Operator_
Definition
Epetra_LinearProblem.h:188
Epetra_LinearProblem::LeftScaled_
bool LeftScaled_
Definition
Epetra_LinearProblem.h:195
Epetra_LinearProblem::CheckInput
int CheckInput() const
Check input parameters for existence and size consistency.
Definition
Epetra_LinearProblem.cpp:147
Epetra_LinearProblem::RightScaleVector_
Epetra_Vector * RightScaleVector_
Definition
Epetra_LinearProblem.h:198
Epetra_LinearProblem::unsure
@ unsure
Definition
Epetra_LinearProblem.h:112
Epetra_LinearProblem::X_
Epetra_MultiVector * X_
Definition
Epetra_LinearProblem.h:190
Epetra_LinearProblem::PDL_
ProblemDifficultyLevel PDL_
Definition
Epetra_LinearProblem.h:194
Epetra_LinearProblem::B_
Epetra_MultiVector * B_
Definition
Epetra_LinearProblem.h:191
Epetra_LinearProblem::Epetra_LinearProblem
Epetra_LinearProblem(void)
Epetra_LinearProblem Default Constructor.
Definition
Epetra_LinearProblem.cpp:50
Epetra_LinearProblem::RightScaled_
bool RightScaled_
Definition
Epetra_LinearProblem.h:196
Epetra_LinearProblem::LeftScaleVector_
Epetra_Vector * LeftScaleVector_
Definition
Epetra_LinearProblem.h:197
Epetra_LinearProblem::~Epetra_LinearProblem
virtual ~Epetra_LinearProblem(void)
Epetra_LinearProblem Destructor.
Definition
Epetra_LinearProblem.cpp:112
Epetra_MultiVector
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
Definition
Epetra_MultiVector.h:184
Epetra_Operator
Epetra_Operator: A pure virtual class for using real-valued double-precision operators.
Definition
Epetra_Operator.h:60
Epetra_RowMatrix
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices.
Definition
Epetra_RowMatrix.h:68
Epetra_Vector
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
Definition
Epetra_Vector.h:142
Generated by
1.17.0