45 #include "Thyra_ScaledLinearOpBase.hpp" 46 #include "Thyra_RowStatLinearOpBase.hpp" 47 #include "Thyra_LinearOpTester.hpp" 48 #include "Thyra_DefaultBlockedLinearOp.hpp" 49 #include "Thyra_VectorBase.hpp" 50 #include "Thyra_VectorStdOps.hpp" 51 #include "Thyra_MultiVectorBase.hpp" 52 #include "Thyra_MultiVectorStdOps.hpp" 61 bool g_dumpAll =
false;
68 "dump-all",
"no-dump-all", &g_dumpAll,
69 "Dump lots of data" );
87 using Teuchos::inOutArg;
89 using Teuchos::rcp_dynamic_cast;
90 typedef ScalarTraits<double> ST;
95 const int numLocalRows = g_localDim;
96 const int numRows = numLocalRows * comm->NumProc();
97 const int numCols = numLocalRows / 2;
102 rcp_dynamic_cast<ScaledLinearOpBase<double> >(epetraOp,
true);
106 const double two = 2.0;
109 createMember<double>(epetraOp->domain());
110 assign<double>(rhs_vec.
ptr(), two);
113 createMember<double>(epetraOp->range());
115 apply<double>(*epetraOp, Thyra::NOTRANS, *rhs_vec, lhs_orig_vec.
ptr());
118 out <<
"epetraOp = " << *epetraOp;
119 out <<
"rhs_vec = " << *rhs_vec;
120 out <<
"lhs_orig_vec = " << *lhs_orig_vec;
125 const double three = 3.0;
128 createMember<double>(epetraOp->range());
129 assign<double>(row_scaling.
ptr(), three);
131 scaledOp->scaleLeft(*row_scaling);
134 out <<
"row_scaling = " << *row_scaling;
135 out <<
"epetraOp left scaled = " << *epetraOp;
141 createMember<double>(epetraOp->range());
143 apply<double>(*epetraOp,
NOTRANS, *rhs_vec, lhs_left_scaled_vec.
ptr());
146 out <<
"lhs_left_scaled_vec = " << *lhs_left_scaled_vec;
150 three * sum<double>(*lhs_orig_vec),
151 sum<double>(*lhs_left_scaled_vec),
152 as<double>(10.0 * ST::eps())
158 createMember<double>(epetraOp->range());
159 reciprocal<double>(*row_scaling, inv_row_scaling.
ptr());
161 scaledOp->scaleLeft(*inv_row_scaling);
164 out <<
"inv_row_scaling = " << *row_scaling;
165 out <<
"epetraOp left scaled back to orig = " << *epetraOp;
169 createMember<double>(epetraOp->range());
171 apply<double>(*epetraOp, NOTRANS, *rhs_vec, lhs_orig2_vec.
ptr());
174 out <<
"lhs_orig2_vec = " << *lhs_orig2_vec;
178 sum<double>(*lhs_orig_vec),
179 sum<double>(*lhs_orig2_vec),
180 as<double>(10.0 * ST::eps())
187 const double four = 4.0;
190 createMember<double>(epetraOp->domain());
191 assign<double>(col_scaling.
ptr(), four);
193 scaledOp->scaleRight(*col_scaling);
196 out <<
"col_scaling = " << *col_scaling;
197 out <<
"epetraOp right scaled = " << *epetraOp;
203 createMember<double>(epetraOp->range());
205 apply<double>(*epetraOp, NOTRANS, *rhs_vec, lhs_right_scaled_vec.
ptr());
208 out <<
"lhs_right_scaled_vec = " << *lhs_right_scaled_vec;
212 four * sum<double>(*lhs_orig_vec),
213 sum<double>(*lhs_right_scaled_vec),
214 as<double>(10.0 * ST::eps())
220 createMember<double>(epetraOp->domain());
221 reciprocal<double>(*col_scaling, inv_col_scaling.
ptr());
223 scaledOp->scaleRight(*inv_col_scaling);
226 out <<
"inv_col_scaling = " << *col_scaling;
227 out <<
"epetraOp right scaled back to orig = " << *epetraOp;
231 createMember<double>(epetraOp->range());
233 apply<double>(*epetraOp, NOTRANS, *rhs_vec, lhs_orig3_vec.
ptr());
236 out <<
"lhs_orig3_vec = " << *lhs_orig3_vec;
240 sum<double>(*lhs_orig_vec),
241 sum<double>(*lhs_orig3_vec),
242 as<double>(10.0 * ST::eps())
253 using Teuchos::inOutArg;
255 using Teuchos::rcp_dynamic_cast;
256 typedef ScalarTraits<double> ST;
261 const int numLocalRows = g_localDim;
262 const int numRows = numLocalRows * comm->NumProc();
263 const int numCols = numLocalRows / 2;
265 const double two = 2.0;
266 epetraCrsM->PutScalar(two);
270 rcp_dynamic_cast<RowStatLinearOpBase<double> >(epetraOp,
true);
273 out <<
"epetraOp = " << *epetraOp;
279 createMember<double>(epetraOp->range());
281 rowStatOp->getRowStat(RowStatLinearOpBaseUtils::ROW_STAT_INV_ROW_SUM,
285 out <<
"inv_row_sums = " << *inv_row_sums;
289 sum<double>(*inv_row_sums),
290 as<double>((1.0 / (two * numCols)) * numRows),
291 as<double>(10.0 * ST::eps())
300 using Teuchos::inOutArg;
305 const int numLocalRows = g_localDim;
306 const int numRows = numLocalRows * comm->NumProc();
307 const int numCols = numLocalRows / 2;
313 LinearOpTester<double> linearOpTester;
314 updateSuccess(linearOpTester.check(*epetraOp, inOutArg(out)), success);
322 using Teuchos::describe;
326 epetraLinearOp(getEpetraMatrix(4,4,0));
328 epetraLinearOp(getEpetraMatrix(4,3,1));
330 epetraLinearOp(getEpetraMatrix(4,2,2));
332 epetraLinearOp(getEpetraMatrix(3,4,3));
334 epetraLinearOp(getEpetraMatrix(3,3,4));
336 epetraLinearOp(getEpetraMatrix(3,2,5));
338 epetraLinearOp(getEpetraMatrix(2,4,6));
340 epetraLinearOp(getEpetraMatrix(2,3,8));
342 epetraLinearOp(getEpetraMatrix(2,2,8));
344 out <<
"Sub operators built" << std::endl;
349 block2x2<double>(A00, A01, A10, A11), block2x1<double>(A02,A12),
350 block1x2<double>(A20, A21), A22
353 out <<
"First composite operator built" << std::endl;
359 randomize(-1.0, 1.0, x.
ptr());
368 out <<
"First composite operator completed" << std::endl;
373 A11, block1x2<double>(A10, A12),
374 block2x1<double>(A01, A21), block2x2<double>(A00, A02, A20, A22)
377 out <<
"Second composite operator built" << std::endl;
383 randomize(-1.0, 1.0, x.
ptr());
392 out <<
"Second composite operator completed" << std::endl;
395 out <<
"Test complete" << std::endl;
Concrete LinearOpBase adapter subclass for Epetra_Operator object.
static CommandLineProcessor & getCLP()
TEUCHOS_UNIT_TEST(EpetraOperatorWrapper, basic)
void updateSuccess(const bool result, bool &success)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)