00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THYRA_VECTOR_STD_OPS_HPP
00030 #define THYRA_VECTOR_STD_OPS_HPP
00031
00032 #include "Thyra_VectorStdOpsDecl.hpp"
00033 #include "Thyra_VectorSpaceBase.hpp"
00034 #include "Thyra_VectorBase.hpp"
00035 #include "RTOpPack_ROpDotProd.hpp"
00036 #include "RTOpPack_ROpMin.hpp"
00037 #include "RTOpPack_ROpMinIndex.hpp"
00038 #include "RTOpPack_ROpMinIndexGreaterThanBound.hpp"
00039 #include "RTOpPack_ROpMax.hpp"
00040 #include "RTOpPack_ROpMaxIndex.hpp"
00041 #include "RTOpPack_ROpMaxIndexLessThanBound.hpp"
00042 #include "RTOpPack_ROpNorm1.hpp"
00043 #include "RTOpPack_ROpNorm2.hpp"
00044 #include "RTOpPack_ROpNormInf.hpp"
00045 #include "RTOpPack_ROpSum.hpp"
00046 #include "RTOpPack_ROpWeightedNorm2.hpp"
00047 #include "RTOpPack_TOpAbs.hpp"
00048 #include "RTOpPack_TOpAddScalar.hpp"
00049 #include "RTOpPack_TOpAssignScalar.hpp"
00050 #include "RTOpPack_TOpAssignVectors.hpp"
00051 #include "RTOpPack_TOpAXPY.hpp"
00052 #include "RTOpPack_TOpEleWiseDivide.hpp"
00053 #include "RTOpPack_TOpEleWiseProd.hpp"
00054 #include "RTOpPack_TOpEleWiseConjProd.hpp"
00055 #include "RTOpPack_TOpEleWiseProdUpdate.hpp"
00056 #include "RTOpPack_TOpLinearCombination.hpp"
00057 #include "RTOpPack_TOpScaleVector.hpp"
00058 #include "RTOpPack_TOpReciprocal.hpp"
00059 #include "RTOpPack_TOpRandomize.hpp"
00060 #include "Teuchos_TestForException.hpp"
00061 #include "Teuchos_arrayArg.hpp"
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 template<class Scalar>
00076 Scalar Thyra::sum( const VectorBase<Scalar>& v_rhs )
00077 {
00078 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00079 RTOpPack::ROpSum<Scalar> sum_op;
00080 Teuchos::RCP<RTOpPack::ReductTarget> sum_targ = sum_op.reduct_obj_create();
00081 applyOp<Scalar>(sum_op,
00082 tuple(ptrInArg(v_rhs)),
00083 ArrayView<Ptr<VectorBase<Scalar> > >(null),
00084 sum_targ.ptr() );
00085 return sum_op(*sum_targ);
00086 }
00087
00088
00089 template<class Scalar>
00090 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00091 Thyra::norm_1( const VectorBase<Scalar>& v_rhs )
00092 {
00093 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00094 RTOpPack::ROpNorm1<Scalar> norm_1_op;
00095 Teuchos::RCP<RTOpPack::ReductTarget> norm_1_targ = norm_1_op.reduct_obj_create();
00096 applyOp<Scalar>(norm_1_op, tuple(ptrInArg(v_rhs)),
00097 ArrayView<Ptr<VectorBase<Scalar> > >(null),
00098 norm_1_targ.ptr() );
00099 return norm_1_op(*norm_1_targ);
00100 }
00101
00102
00103 template<class Scalar>
00104 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00105 Thyra::norm_2( const VectorBase<Scalar>& v_rhs )
00106 {
00107 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00108 RTOpPack::ROpNorm2<Scalar> norm_2_op;
00109 Teuchos::RCP<RTOpPack::ReductTarget> norm_2_targ = norm_2_op.reduct_obj_create();
00110 applyOp<Scalar>(norm_2_op, tuple(ptrInArg(v_rhs)),
00111 ArrayView<Ptr<VectorBase<Scalar> > >(null),
00112 norm_2_targ.ptr() );
00113 return norm_2_op(*norm_2_targ);
00114 }
00115
00116
00117 template<class Scalar>
00118 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00119 Thyra::norm_2( const VectorBase<Scalar>& w, const VectorBase<Scalar>& v )
00120 {
00121 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00122 RTOpPack::ROpWeightedNorm2<Scalar> wght_norm_2_op;
00123 Teuchos::RCP<RTOpPack::ReductTarget> wght_norm_2_targ = wght_norm_2_op.reduct_obj_create();
00124 applyOp<Scalar>(wght_norm_2_op,tuple(ptrInArg(w),ptrInArg(v)),null,wght_norm_2_targ.ptr());
00125 return wght_norm_2_op(*wght_norm_2_targ);
00126 }
00127
00128
00129 template<class Scalar>
00130 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00131 Thyra::norm_inf( const VectorBase<Scalar>& v_rhs )
00132 {
00133 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00134 RTOpPack::ROpNormInf<Scalar> norm_inf_op;
00135 Teuchos::RCP<RTOpPack::ReductTarget> norm_inf_targ = norm_inf_op.reduct_obj_create();
00136 applyOp<Scalar>(norm_inf_op, tuple(ptrInArg(v_rhs)),
00137 ArrayView<Ptr<VectorBase<Scalar> > >(null),
00138 norm_inf_targ.ptr() );
00139 return norm_inf_op(*norm_inf_targ);
00140 }
00141
00142
00143 template<class Scalar>
00144 Scalar Thyra::dot( const VectorBase<Scalar>& v_rhs1, const VectorBase<Scalar>& v_rhs2 )
00145 {
00146 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00147 RTOpPack::ROpDotProd<Scalar> dot_prod_op;
00148 Teuchos::RCP<RTOpPack::ReductTarget>
00149 dot_prod_targ = dot_prod_op.reduct_obj_create();
00150 applyOp<Scalar>(dot_prod_op,
00151 tuple(ptrInArg(v_rhs1), ptrInArg(v_rhs2))(),
00152 ArrayView<Ptr<VectorBase<Scalar> > >(null),
00153 dot_prod_targ.ptr()
00154 );
00155 return dot_prod_op(*dot_prod_targ);
00156 }
00157
00158
00159 template<class Scalar>
00160 Scalar Thyra::get_ele( const VectorBase<Scalar>& v, Ordinal i )
00161 {
00162 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00163 RTOpPack::ROpSum<Scalar> sum_op;
00164 Teuchos::RCP<RTOpPack::ReductTarget> sum_targ = sum_op.reduct_obj_create();
00165 applyOp<Scalar>(sum_op, tuple(ptrInArg(v)),
00166 ArrayView<Ptr<VectorBase<Scalar> > >(null),
00167 sum_targ.ptr(), i, 1, 0 );
00168 return sum_op(*sum_targ);
00169 }
00170
00171
00172
00173
00174
00175 template<class Scalar>
00176 void Thyra::set_ele( Ordinal i, Scalar alpha, const Ptr<VectorBase<Scalar> > &v )
00177 {
00178 using Teuchos::tuple; using Teuchos::null;
00179 RTOpPack::TOpAssignScalar<Scalar> assign_scalar_op(alpha);
00180 applyOp<Scalar>(assign_scalar_op,
00181 ArrayView<Ptr<const VectorBase<Scalar> > >(null),
00182 tuple(v),
00183 null, i, 1, 0 );
00184 }
00185
00186
00187 template<class Scalar>
00188 void Thyra::put_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
00189 {
00190 using Teuchos::tuple; using Teuchos::null;
00191 RTOpPack::TOpAssignScalar<Scalar> assign_scalar_op(alpha);
00192 applyOp<Scalar>(assign_scalar_op,
00193 ArrayView<Ptr<const VectorBase<Scalar> > >(null),
00194 tuple(v_lhs), null );
00195 }
00196
00197
00198 template<class Scalar>
00199 void Thyra::copy( const VectorBase<Scalar>& v_rhs,
00200 const Ptr<VectorBase<Scalar> > &v_lhs )
00201 {
00202 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00203 RTOpPack::TOpAssignVectors<Scalar> assign_vectors_op;
00204 applyOp<Scalar>( assign_vectors_op, tuple(ptrInArg(v_rhs)), tuple(v_lhs), null );
00205 }
00206
00207
00208 template<class Scalar>
00209 void Thyra::add_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
00210 {
00211 using Teuchos::tuple; using Teuchos::null;
00212 RTOpPack::TOpAddScalar<Scalar> add_scalar_op(alpha);
00213 applyOp<Scalar>(add_scalar_op,
00214 ArrayView<Ptr<const VectorBase<Scalar> > >(null),
00215 tuple(v_lhs), null );
00216 }
00217
00218
00219 template<class Scalar>
00220 void Thyra::scale( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
00221 {
00222 using Teuchos::tuple; using Teuchos::null;
00223 if( alpha == ScalarTraits<Scalar>::zero() ) {
00224 assign(v_lhs, ScalarTraits<Scalar>::zero());
00225 }
00226 else if( alpha != ScalarTraits<Scalar>::one() ) {
00227 RTOpPack::TOpScaleVector<Scalar> scale_vector_op(alpha);
00228 applyOp<Scalar>(scale_vector_op,
00229 ArrayView<Ptr<const VectorBase<Scalar> > >(null),
00230 tuple(v_lhs), null );
00231 }
00232 }
00233
00234
00235 template<class Scalar>
00236 void Thyra::abs( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x )
00237 {
00238 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00239 RTOpPack::TOpAbs<Scalar> abs_op;
00240 applyOp<Scalar>( abs_op, tuple(ptrInArg(x)), tuple(y), null );
00241 }
00242
00243
00244 template<class Scalar>
00245 void Thyra::reciprocal( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x )
00246 {
00247 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00248 RTOpPack::TOpReciprocal<Scalar> recip_op;
00249 applyOp<Scalar>( recip_op, tuple(ptrInArg(x)), tuple(y), null );
00250 }
00251
00252
00253 template<class Scalar>
00254 void Thyra::ele_wise_prod(
00255 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
00256 const VectorBase<Scalar>& v_rhs2, const Ptr<VectorBase<Scalar> > &v_lhs
00257 )
00258 {
00259 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00260 RTOpPack::TOpEleWiseProd<Scalar> ele_wise_prod_op(alpha);
00261 applyOp<Scalar>( ele_wise_prod_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
00262 tuple(v_lhs), null );
00263 }
00264
00265
00266 template<class Scalar>
00267 void Thyra::ele_wise_conj_prod(
00268 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
00269 const VectorBase<Scalar>& v_rhs2, const Ptr<VectorBase<Scalar> > &v_lhs
00270 )
00271 {
00272 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00273 RTOpPack::TOpEleWiseConjProd<Scalar> ele_wise_conj_prod_op(alpha);
00274 applyOp<Scalar>( ele_wise_conj_prod_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
00275 tuple(v_lhs), null );
00276 }
00277
00278
00279 template<class Scalar>
00280 void Thyra::Vp_StVtV(
00281 const Ptr<VectorBase<Scalar> > &v_lhs,
00282 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
00283 const VectorBase<Scalar>& v_rhs2
00284 )
00285 {
00286 ele_wise_prod(alpha,v_rhs1,v_rhs2,v_lhs);
00287 }
00288
00289
00290 template<class Scalar>
00291 void Thyra::ele_wise_prod_update(
00292 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
00293 const Ptr<VectorBase<Scalar> > &v_lhs
00294 )
00295 {
00296 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00297 RTOpPack::TOpEleWiseProdUpdate<Scalar> ele_wise_prod_update_op(alpha);
00298 applyOp<Scalar>( ele_wise_prod_update_op, tuple(ptrInArg(v_rhs1)),
00299 tuple(v_lhs), null );
00300 }
00301
00302
00303 template<class Scalar>
00304 void Thyra::Vt_StV(
00305 const Ptr<VectorBase<Scalar> > &v_lhs,
00306 const Scalar& alpha, const VectorBase<Scalar>& x )
00307 {
00308 ele_wise_prod_update(alpha,x,v_lhs);
00309 }
00310
00311
00312 template<class Scalar>
00313 void Thyra::ele_wise_divide(
00314 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
00315 const VectorBase<Scalar>& v_rhs2,
00316 const Ptr<VectorBase<Scalar> > &v_lhs
00317 )
00318 {
00319 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00320 RTOpPack::TOpEleWiseDivide<Scalar> ele_wise_divide_op(alpha);
00321 applyOp<Scalar>( ele_wise_divide_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
00322 tuple(v_lhs), null );
00323 }
00324
00325
00326 template<class Scalar>
00327 void Thyra::linear_combination(
00328 const ArrayView<const Scalar> &alpha,
00329 const ArrayView<const Ptr<const VectorBase<Scalar> > > &x,
00330 const Scalar &beta,
00331 const Ptr<VectorBase<Scalar> > &y
00332 )
00333 {
00334 using Teuchos::tuple; using Teuchos::ptr; using Teuchos::ptrInArg;
00335 using Teuchos::null;
00336 const int m = x.size();
00337 if( beta == Teuchos::ScalarTraits<Scalar>::one() && m == 1 ) {
00338 Vp_StV( y, alpha[0], *x[0] );
00339 return;
00340 }
00341 else if( m == 0 ) {
00342 Vt_S( y, beta );
00343 return;
00344 }
00345 RTOpPack::TOpLinearCombination<Scalar> lin_comb_op(alpha,beta);
00346 applyOp<Scalar>( lin_comb_op, x, tuple(y), null );
00347 }
00348
00349
00350 template<class Scalar>
00351 void Thyra::seed_randomize( unsigned int s )
00352 {
00353 RTOpPack::TOpRandomize<Scalar>::set_static_seed(s);
00354 }
00355
00356
00357 template<class Scalar>
00358 void Thyra::randomize( Scalar l, Scalar u, const Ptr<VectorBase<Scalar> > &v )
00359 {
00360 using Teuchos::tuple; using Teuchos::null;
00361 RTOpPack::TOpRandomize<Scalar> random_vector_op(l,u);
00362 applyOp<Scalar>( random_vector_op,
00363 ArrayView<Ptr<const VectorBase<Scalar> > >(null),
00364 tuple(v),
00365 null );
00366
00367
00368
00369
00370
00371 }
00372
00373
00374
00375
00376
00377 template<class Scalar>
00378 void Thyra::assign( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
00379 {
00380 put_scalar(alpha,v_lhs);
00381 }
00382
00383
00384 template<class Scalar>
00385 void Thyra::assign( const Ptr<VectorBase<Scalar> > &v_lhs, const VectorBase<Scalar>& v_rhs )
00386 {
00387 copy(v_rhs,v_lhs);
00388 }
00389
00390
00391 template<class Scalar>
00392 void Thyra::Vp_S( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
00393 {
00394 add_scalar(alpha,v_lhs);
00395 }
00396
00397
00398 template<class Scalar>
00399 void Thyra::Vt_S( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
00400 {
00401 scale(alpha,v_lhs);
00402 }
00403
00404
00405 template<class Scalar>
00406 void Thyra::V_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00407 const VectorBase<Scalar> &x
00408 )
00409 {
00410 using Teuchos::tuple; using Teuchos::ptrInArg;
00411 linear_combination<Scalar>( tuple<Scalar>(alpha), tuple(ptrInArg(x)),
00412 ScalarTraits<Scalar>::zero(), y );
00413 }
00414
00415
00416 template<class Scalar>
00417 void Thyra::Vp_StV( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha,
00418 const VectorBase<Scalar>& v_rhs
00419 )
00420 {
00421 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00422 RTOpPack::TOpAXPY<Scalar> axpy_op(alpha);
00423 applyOp<Scalar>( axpy_op, tuple(ptrInArg(v_rhs)), tuple(v_lhs), null );
00424 }
00425
00426
00427 template<class Scalar>
00428 void Thyra::Vp_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x,
00429 const Scalar& beta
00430 )
00431 {
00432 using Teuchos::tuple; using Teuchos::ptrInArg;
00433 linear_combination<Scalar>(
00434 tuple<Scalar>(Teuchos::ScalarTraits<Scalar>::one()),
00435 tuple(ptrInArg(x)),
00436 beta, y );
00437 }
00438
00439
00440 template<class Scalar>
00441 void Thyra::V_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x )
00442 {
00443 assign(y,x);
00444 }
00445
00446
00447 template<class Scalar>
00448 void Thyra::V_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha )
00449 {
00450 assign(y,alpha);
00451 }
00452
00453
00454 template<class Scalar>
00455 void Thyra::V_VpV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
00456 const VectorBase<Scalar>& y
00457 )
00458 {
00459 using Teuchos::tuple; using Teuchos::ptrInArg;
00460 typedef Teuchos::ScalarTraits<Scalar> ST;
00461 linear_combination<Scalar>(
00462 tuple(ST::one(),ST::one()),
00463 tuple(ptrInArg(x),ptrInArg(y)),
00464 ST::zero(), z
00465 );
00466 }
00467
00468
00469 template<class Scalar>
00470 void Thyra::V_VmV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
00471 const VectorBase<Scalar>& y
00472 )
00473 {
00474 using Teuchos::tuple; using Teuchos::ptrInArg;
00475 typedef Teuchos::ScalarTraits<Scalar> ST;
00476 linear_combination<Scalar>(
00477 tuple(ST::one(),Scalar(-ST::one())),
00478 tuple(ptrInArg(x),ptrInArg(y)),
00479 ST::zero(), z
00480 );
00481 }
00482
00483
00484 template<class Scalar>
00485 void Thyra::V_StVpV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
00486 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y
00487 )
00488 {
00489 using Teuchos::tuple; using Teuchos::ptrInArg;
00490 typedef Teuchos::ScalarTraits<Scalar> ST;
00491 linear_combination<Scalar>(
00492 tuple(alpha, ST::one()), tuple(ptrInArg(x),ptrInArg(y)),
00493 ST::zero(), z
00494 );
00495 }
00496
00497
00498 template<class Scalar>
00499 void Thyra::V_VpStV( const Ptr<VectorBase<Scalar> > &z,
00500 const VectorBase<Scalar>& x,
00501 const Scalar &alpha, const VectorBase<Scalar>& y )
00502 {
00503 using Teuchos::tuple; using Teuchos::ptrInArg;
00504 typedef Teuchos::ScalarTraits<Scalar> ST;
00505 linear_combination<Scalar>(
00506 tuple(ST::one(), alpha), tuple(ptrInArg(x),ptrInArg(y)),
00507 ST::zero(), z
00508 );
00509 }
00510
00511
00512 template<class Scalar>
00513 void Thyra::V_StVpStV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
00514 const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y
00515 )
00516 {
00517 using Teuchos::tuple; using Teuchos::ptrInArg;
00518 typedef Teuchos::ScalarTraits<Scalar> ST;
00519 linear_combination<Scalar>(
00520 tuple(alpha, beta), tuple(ptrInArg(x),ptrInArg(y)),
00521 ST::zero(), z
00522 );
00523 }
00524
00525
00526
00527
00528
00529
00530
00531 template<class Scalar>
00532 Scalar Thyra::min( const VectorBase<Scalar>& x ) {
00533 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00534 RTOpPack::ROpMin<Scalar> min_op;
00535 Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
00536 applyOp<Scalar>( min_op, tuple(ptrInArg(x)), null, min_targ.ptr() );
00537 return min_op(*min_targ);
00538 }
00539
00540
00541 template<class Scalar>
00542 void Thyra::min( const VectorBase<Scalar>& x,
00543 const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex
00544 )
00545 {
00546 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00547 RTOpPack::ROpMinIndex<Scalar> min_op;
00548 Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
00549 applyOp<Scalar>( min_op, tuple(ptrInArg(x)), null, min_targ.ptr() );
00550 RTOpPack::ScalarIndex<Scalar> scalarIndex = min_op(*min_targ);
00551 *minEle = scalarIndex.scalar;
00552 *minIndex = scalarIndex.index;
00553 }
00554
00555
00556 template<class Scalar>
00557 void Thyra::minGreaterThanBound( const VectorBase<Scalar>& x,
00558 const Scalar &bound, const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex
00559 )
00560 {
00561 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00562 RTOpPack::ROpMinIndexGreaterThanBound<Scalar> min_op(bound);
00563 Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
00564 applyOp<Scalar>( min_op, tuple(ptrInArg(x)), null, min_targ.ptr() );
00565 RTOpPack::ScalarIndex<Scalar> scalarIndex = min_op(*min_targ);
00566 *minEle = scalarIndex.scalar;
00567 *minIndex = scalarIndex.index;
00568 }
00569
00570
00571 template<class Scalar>
00572 Scalar Thyra::max( const VectorBase<Scalar>& x )
00573 {
00574 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00575 RTOpPack::ROpMax<Scalar> max_op;
00576 Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
00577 applyOp<Scalar>( max_op, tuple(ptrInArg(x)), null, max_targ.ptr() );
00578 return max_op(*max_targ);
00579 }
00580
00581
00582 template<class Scalar>
00583 void Thyra::max( const VectorBase<Scalar>& x,
00584 const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex
00585 )
00586 {
00587 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00588 RTOpPack::ROpMaxIndex<Scalar> max_op;
00589 Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
00590 applyOp<Scalar>( max_op, tuple(ptrInArg(x)), null, max_targ.ptr() );
00591 RTOpPack::ScalarIndex<Scalar> scalarIndex = max_op(*max_targ);
00592 *maxEle = scalarIndex.scalar;
00593 *maxIndex = scalarIndex.index;
00594 }
00595
00596
00597 template<class Scalar>
00598 void Thyra::maxLessThanBound( const VectorBase<Scalar>& x,
00599 const Scalar &bound, const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex
00600 )
00601 {
00602 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00603 RTOpPack::ROpMaxIndexLessThanBound<Scalar> max_op(bound);
00604 Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
00605 applyOp<Scalar>( max_op, tuple(ptrInArg(x)), null, max_targ.ptr() );
00606 RTOpPack::ScalarIndex<Scalar> scalarIndex = max_op(*max_targ);
00607 *maxEle = scalarIndex.scalar;
00608 *maxIndex = scalarIndex.index;
00609 }
00610
00611
00612 #endif // THYRA_VECTOR_STD_OPS_HPP