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_TOpEleWiseProdUpdate.hpp"
00055 #include "RTOpPack_TOpLinearCombination.hpp"
00056 #include "RTOpPack_TOpScaleVector.hpp"
00057 #include "RTOpPack_TOpReciprocal.hpp"
00058 #include "RTOpPack_TOpRandomize.hpp"
00059 #include "Teuchos_TestForException.hpp"
00060 #include "Teuchos_arrayArg.hpp"
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 template<class Scalar>
00071 Scalar Thyra::sum( const VectorBase<Scalar>& v_rhs )
00072 {
00073 RTOpPack::ROpSum<Scalar> sum_op;
00074 Teuchos::RCP<RTOpPack::ReductTarget> sum_targ = sum_op.reduct_obj_create();
00075 const VectorBase<Scalar>* vecs[] = { &v_rhs };
00076 applyOp<Scalar>(sum_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*sum_targ);
00077 return sum_op(*sum_targ);
00078 }
00079
00080 template<class Scalar>
00081 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00082 Thyra::norm_1( const VectorBase<Scalar>& v_rhs )
00083 {
00084 RTOpPack::ROpNorm1<Scalar> norm_1_op;
00085 Teuchos::RCP<RTOpPack::ReductTarget> norm_1_targ = norm_1_op.reduct_obj_create();
00086 const VectorBase<Scalar>* vecs[] = { &v_rhs };
00087 applyOp<Scalar>(norm_1_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*norm_1_targ);
00088 return norm_1_op(*norm_1_targ);
00089 }
00090
00091 template<class Scalar>
00092 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00093 Thyra::norm_2( const VectorBase<Scalar>& v_rhs )
00094 {
00095 RTOpPack::ROpNorm2<Scalar> norm_2_op;
00096 Teuchos::RCP<RTOpPack::ReductTarget> norm_2_targ = norm_2_op.reduct_obj_create();
00097 const VectorBase<Scalar>* vecs[] = { &v_rhs };
00098 applyOp<Scalar>(norm_2_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*norm_2_targ);
00099 return norm_2_op(*norm_2_targ);
00100 }
00101
00102 template<class Scalar>
00103 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00104 Thyra::norm_2( const VectorBase<Scalar>& w, const VectorBase<Scalar>& v )
00105 {
00106 RTOpPack::ROpWeightedNorm2<Scalar> wght_norm_2_op;
00107 Teuchos::RCP<RTOpPack::ReductTarget> wght_norm_2_targ = wght_norm_2_op.reduct_obj_create();
00108 const VectorBase<Scalar>* vecs[] = { &w, &v };
00109 applyOp<Scalar>(wght_norm_2_op,2,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*wght_norm_2_targ);
00110 return wght_norm_2_op(*wght_norm_2_targ);
00111 }
00112
00113 template<class Scalar>
00114 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00115 Thyra::norm_inf( const VectorBase<Scalar>& v_rhs )
00116 {
00117 RTOpPack::ROpNormInf<Scalar> norm_inf_op;
00118 Teuchos::RCP<RTOpPack::ReductTarget> norm_inf_targ = norm_inf_op.reduct_obj_create();
00119 const VectorBase<Scalar>* vecs[] = { &v_rhs };
00120 applyOp<Scalar>(norm_inf_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*norm_inf_targ);
00121 return norm_inf_op(*norm_inf_targ);
00122 }
00123
00124 template<class Scalar>
00125 Scalar Thyra::dot( const VectorBase<Scalar>& v_rhs1, const VectorBase<Scalar>& v_rhs2 )
00126 {
00127 RTOpPack::ROpDotProd<Scalar> dot_prod_op;
00128 Teuchos::RCP<RTOpPack::ReductTarget> dot_prod_targ = dot_prod_op.reduct_obj_create();
00129 const VectorBase<Scalar>* vecs[] = { &v_rhs1, &v_rhs2 };
00130 applyOp<Scalar>(dot_prod_op,2,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*dot_prod_targ);
00131 return dot_prod_op(*dot_prod_targ);
00132 }
00133
00134 template<class Scalar>
00135 Scalar Thyra::get_ele( const VectorBase<Scalar>& v, Index i )
00136 {
00137 RTOpPack::ROpSum<Scalar> sum_op;
00138 Teuchos::RCP<RTOpPack::ReductTarget> sum_targ = sum_op.reduct_obj_create();
00139 const VectorBase<Scalar>* vecs[] = { &v };
00140 applyOp<Scalar>(sum_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*sum_targ,i,1,0);
00141 return sum_op(*sum_targ);
00142 }
00143
00144
00145
00146 template<class Scalar>
00147 void Thyra::set_ele( Index i, Scalar alpha, VectorBase<Scalar>* v )
00148 {
00149 #ifdef TEUCHOS_DEBUG
00150 TEST_FOR_EXCEPTION(v==NULL,std::logic_error,"set_ele(...), Error!");
00151 #endif
00152 RTOpPack::TOpAssignScalar<Scalar> assign_scalar_op(alpha);
00153 VectorBase<Scalar>* targ_vecs[] = { v };
00154 applyOp<Scalar>(assign_scalar_op,0,(const VectorBase<Scalar>**)NULL,1,targ_vecs,(RTOpPack::ReductTarget*)NULL,i,1,0);
00155 }
00156
00157 template<class Scalar>
00158 void Thyra::put_scalar( const Scalar& alpha, VectorBase<Scalar>* v_lhs )
00159 {
00160 #ifdef TEUCHOS_DEBUG
00161 TEST_FOR_EXCEPTION(v_lhs==NULL,std::logic_error,"put_scalar(...), Error!");
00162 #endif
00163 RTOpPack::TOpAssignScalar<Scalar> assign_scalar_op(alpha);
00164 VectorBase<Scalar>* targ_vecs[] = { v_lhs };
00165 applyOp<Scalar>(assign_scalar_op,0,(const VectorBase<Scalar>**)NULL,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00166 }
00167
00168 template<class Scalar>
00169 void Thyra::copy( const VectorBase<Scalar>& v_rhs, VectorBase<Scalar>* v_lhs )
00170 {
00171 #ifdef TEUCHOS_DEBUG
00172 TEST_FOR_EXCEPTION(v_lhs==NULL,std::logic_error,"copy(...), Error!");
00173 #endif
00174 RTOpPack::TOpAssignVectors<Scalar> assign_vectors_op;
00175 const VectorBase<Scalar>* vecs[] = { &v_rhs };
00176 VectorBase<Scalar>* targ_vecs[] = { v_lhs };
00177 applyOp<Scalar>(assign_vectors_op,1,vecs,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00178 }
00179
00180 template<class Scalar>
00181 void Thyra::add_scalar( const Scalar& alpha, VectorBase<Scalar>* v_lhs )
00182 {
00183 #ifdef TEUCHOS_DEBUG
00184 TEST_FOR_EXCEPTION(v_lhs==NULL,std::logic_error,"add_scalar(...), Error!");
00185 #endif
00186 RTOpPack::TOpAddScalar<Scalar> add_scalar_op(alpha);
00187 VectorBase<Scalar>* targ_vecs[] = { v_lhs };
00188 applyOp<Scalar>(add_scalar_op,0,(const VectorBase<Scalar>**)NULL,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00189 }
00190
00191 template<class Scalar>
00192 void Thyra::scale( const Scalar& alpha, VectorBase<Scalar>* v_lhs )
00193 {
00194 #ifdef TEUCHOS_DEBUG
00195 TEST_FOR_EXCEPTION(v_lhs==NULL,std::logic_error,"scale(...), Error!");
00196 #endif
00197 if( alpha == Teuchos::ScalarTraits<Scalar>::zero() ) {
00198 assign(v_lhs,Teuchos::ScalarTraits<Scalar>::zero());
00199 }
00200 else if( alpha != Teuchos::ScalarTraits<Scalar>::one() ) {
00201 RTOpPack::TOpScaleVector<Scalar> scale_vector_op(alpha);
00202 VectorBase<Scalar>* targ_vecs[] = { v_lhs };
00203 applyOp<Scalar>(scale_vector_op,0,(const VectorBase<Scalar>**)NULL,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00204 }
00205 }
00206
00207 template<class Scalar>
00208 void Thyra::abs( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00209 {
00210 #ifdef TEUCHOS_DEBUG
00211 TEST_FOR_EXCEPTION(y==NULL,std::logic_error,"assign(...), Error!");
00212 #endif
00213 RTOpPack::TOpAbs<Scalar> abs_op;
00214 const VectorBase<Scalar>* vecs[] = { &x };
00215 VectorBase<Scalar>* targ_vecs[] = { y };
00216 applyOp<Scalar>(abs_op,1,vecs,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00217 }
00218
00219 template<class Scalar>
00220 void Thyra::reciprocal( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00221 {
00222 #ifdef TEUCHOS_DEBUG
00223 TEST_FOR_EXCEPTION(y==NULL,std::logic_error,"assign(...), Error!");
00224 #endif
00225 RTOpPack::TOpReciprocal<Scalar> recip_op;
00226 const VectorBase<Scalar>* vecs[] = { &x };
00227 VectorBase<Scalar>* targ_vecs[] = { y };
00228 applyOp<Scalar>(recip_op,1,vecs,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00229 }
00230
00231 template<class Scalar>
00232 void Thyra::ele_wise_prod(
00233 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1, const VectorBase<Scalar>& v_rhs2
00234 ,VectorBase<Scalar>* v_lhs
00235 )
00236 {
00237 #ifdef TEUCHOS_DEBUG
00238 TEST_FOR_EXCEPTION(v_lhs==NULL,std::logic_error,"ele_wise_prod(...), Error");
00239 #endif
00240 RTOpPack::TOpEleWiseProd<Scalar> ele_wise_prod_op(alpha);
00241 const VectorBase<Scalar>* vecs[] = { &v_rhs1, &v_rhs2 };
00242 VectorBase<Scalar>* targ_vecs[] = { v_lhs };
00243 applyOp<Scalar>(ele_wise_prod_op,2,vecs,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00244 }
00245
00246 template<class Scalar>
00247 void Thyra::Vp_StVtV(
00248 VectorBase<Scalar>* v_lhs
00249 ,const Scalar& alpha, const VectorBase<Scalar>& v_rhs1, const VectorBase<Scalar>& v_rhs2
00250 )
00251 {
00252 ele_wise_prod(alpha,v_rhs1,v_rhs2,v_lhs);
00253 }
00254
00255 template<class Scalar>
00256 void Thyra::ele_wise_prod_update(
00257 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1, VectorBase<Scalar>* v_lhs )
00258 {
00259 #ifdef TEUCHOS_DEBUG
00260 TEST_FOR_EXCEPTION(v_lhs==NULL,std::logic_error,"ele_wise_prod_update(...), Error");
00261 #endif
00262 RTOpPack::TOpEleWiseProdUpdate<Scalar> ele_wise_prod_update_op(alpha);
00263 const VectorBase<Scalar>* vecs[] = { &v_rhs1 };
00264 VectorBase<Scalar>* targ_vecs[] = { v_lhs };
00265 applyOp<Scalar>(ele_wise_prod_update_op,1,vecs,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00266 }
00267
00268 template<class Scalar>
00269 void Thyra::Vt_StV(
00270 VectorBase<Scalar>* v_lhs, const Scalar& alpha, const VectorBase<Scalar>& x )
00271 {
00272 ele_wise_prod_update(alpha,x,v_lhs);
00273 }
00274
00275 template<class Scalar>
00276 void Thyra::ele_wise_divide(
00277 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1, const VectorBase<Scalar>& v_rhs2
00278 ,VectorBase<Scalar>* v_lhs
00279 )
00280 {
00281 #ifdef TEUCHOS_DEBUG
00282 TEST_FOR_EXCEPTION(v_lhs==NULL,std::logic_error,"ele_wise_divide(...), Error");
00283 #endif
00284 RTOpPack::TOpEleWiseDivide<Scalar> ele_wise_divide_op(alpha);
00285 const VectorBase<Scalar>* vecs[] = { &v_rhs1, &v_rhs2 };
00286 VectorBase<Scalar>* targ_vecs[] = { v_lhs };
00287 applyOp<Scalar>(ele_wise_divide_op,2,vecs,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00288 }
00289
00290 template<class Scalar>
00291 void Thyra::linear_combination(
00292 const int m
00293 ,const Scalar alpha[]
00294 ,const VectorBase<Scalar>* x[]
00295 ,const Scalar &beta
00296 ,VectorBase<Scalar> *y
00297 )
00298 {
00299 #ifdef TEUCHOS_DEBUG
00300 TEST_FOR_EXCEPTION(y==NULL,std::logic_error,"linear_combination(...), Error!");
00301 #endif
00302 if( beta == Teuchos::ScalarTraits<Scalar>::one() && m == 1 ) {
00303 Vp_StV( y, alpha[0], *x[0] );
00304 return;
00305 }
00306 else if( m == 0 ) {
00307 Vt_S( y, beta );
00308 return;
00309 }
00310 RTOpPack::TOpLinearCombination<Scalar> lin_comb_op(m,alpha,beta);
00311 VectorBase<Scalar>* targ_vecs[] = { y };
00312 applyOp<Scalar>(lin_comb_op,m,x,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00313 }
00314
00315 template<class Scalar>
00316 void Thyra::seed_randomize( unsigned int s )
00317 {
00318 RTOpPack::TOpRandomize<Scalar>::set_static_seed(s);
00319 }
00320
00321 template<class Scalar>
00322 void Thyra::randomize( Scalar l, Scalar u, VectorBase<Scalar>* v )
00323 {
00324 #ifdef TEUCHOS_DEBUG
00325 TEST_FOR_EXCEPTION(v==NULL,std::logic_error,"Vt_S(...), Error");
00326 #endif
00327 RTOpPack::TOpRandomize<Scalar> random_vector_op(l,u);
00328 VectorBase<Scalar>* targ_vecs[] = { v };
00329 applyOp<Scalar>(random_vector_op,0,(const VectorBase<Scalar>**)NULL,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00330
00331
00332
00333
00334
00335 }
00336
00337
00338
00339 template<class Scalar>
00340 void Thyra::assign( VectorBase<Scalar>* v_lhs, const Scalar& alpha )
00341 {
00342 put_scalar(alpha,v_lhs);
00343 }
00344
00345 template<class Scalar>
00346 void Thyra::assign( VectorBase<Scalar>* v_lhs, const VectorBase<Scalar>& v_rhs )
00347 {
00348 copy(v_rhs,v_lhs);
00349 }
00350
00351 template<class Scalar>
00352 void Thyra::Vp_S( VectorBase<Scalar>* v_lhs, const Scalar& alpha )
00353 {
00354 add_scalar(alpha,v_lhs);
00355 }
00356
00357 template<class Scalar>
00358 void Thyra::Vt_S(
00359 VectorBase<Scalar>* v_lhs, const Scalar& alpha )
00360 {
00361 scale(alpha,v_lhs);
00362 }
00363
00364 template<class Scalar>
00365 void Thyra::V_StV( VectorBase<Scalar>* y, const Scalar& alpha, const VectorBase<Scalar> &x )
00366 {
00367 linear_combination(
00368 1,Teuchos::arrayArg<Scalar>(alpha)(),Teuchos::arrayArg<const VectorBase<Scalar>*>(&x)()
00369 ,Teuchos::ScalarTraits<Scalar>::zero(),y
00370 );
00371 }
00372
00373 template<class Scalar>
00374 void Thyra::Vp_StV( VectorBase<Scalar>* v_lhs, const Scalar& alpha, const VectorBase<Scalar>& v_rhs )
00375 {
00376 #ifdef TEUCHOS_DEBUG
00377 TEST_FOR_EXCEPTION(v_lhs==NULL,std::logic_error,"Vp_StV(...), Error!");
00378 #endif
00379 RTOpPack::TOpAXPY<Scalar> axpy_op(alpha);
00380 const VectorBase<Scalar>* vecs[] = { &v_rhs };
00381 VectorBase<Scalar>* targ_vecs[] = { v_lhs };
00382 applyOp<Scalar>(axpy_op,1,vecs,1,targ_vecs,(RTOpPack::ReductTarget*)NULL);
00383 }
00384
00385 template<class Scalar>
00386 void Thyra::Vp_V( VectorBase<Scalar>* y, const VectorBase<Scalar>& x, const Scalar& beta )
00387 {
00388 linear_combination(
00389 1,Teuchos::arrayArg<Scalar>(Teuchos::ScalarTraits<Scalar>::one())()
00390 ,Teuchos::arrayArg<const VectorBase<Scalar>*>(&x)()
00391 ,beta,y
00392 );
00393 }
00394
00395 template<class Scalar>
00396 void Thyra::V_V( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00397 {
00398 assign(&*y,x);
00399 }
00400
00401 template<class Scalar>
00402 void Thyra::V_S( VectorBase<Scalar>* y, const Scalar& alpha )
00403 {
00404 assign(&*y,alpha);
00405 }
00406
00407 template<class Scalar>
00408 void Thyra::V_VpV( VectorBase<Scalar>* z, const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
00409 {
00410 typedef Teuchos::ScalarTraits<Scalar> ST;
00411 linear_combination(
00412 2,Teuchos::arrayArg<Scalar>(ST::one(),ST::one())()
00413 ,Teuchos::arrayArg<const VectorBase<Scalar>*>(&x,&y)()
00414 ,ST::zero(),z
00415 );
00416 }
00417
00418 template<class Scalar>
00419 void Thyra::V_VmV( VectorBase<Scalar>* z, const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
00420 {
00421 typedef Teuchos::ScalarTraits<Scalar> ST;
00422 linear_combination(
00423 2,Teuchos::arrayArg<Scalar>(ST::one(),Scalar(-ST::one()))()
00424 ,Teuchos::arrayArg<const VectorBase<Scalar>*>(&x,&y)()
00425 ,ST::zero(),z
00426 );
00427 }
00428
00429 template<class Scalar>
00430 void Thyra::V_StVpV( VectorBase<Scalar>* z, const Scalar &alpha, const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
00431 {
00432 linear_combination(
00433 2,Teuchos::arrayArg<Scalar>(alpha,Teuchos::ScalarTraits<Scalar>::one())()
00434 ,Teuchos::arrayArg<const VectorBase<Scalar>*>(&x,&y)()
00435 ,Teuchos::ScalarTraits<Scalar>::zero(),z
00436 );
00437 }
00438
00439 template<class Scalar>
00440 void Thyra::V_StVpStV( VectorBase<Scalar>* z, const Scalar &alpha, const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y )
00441 {
00442 linear_combination(
00443 2,Teuchos::arrayArg<Scalar>(alpha,beta)()
00444 ,Teuchos::arrayArg<const VectorBase<Scalar>*>(&x,&y)()
00445 ,Teuchos::ScalarTraits<Scalar>::zero(),z
00446 );
00447 }
00448
00449
00450
00451
00452
00453 template<class Scalar>
00454 Scalar Thyra::min( const VectorBase<Scalar>& x ) {
00455 RTOpPack::ROpMin<Scalar> min_op;
00456 Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
00457 const VectorBase<Scalar>* vecs[] = { &x };
00458 applyOp<Scalar>(min_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*min_targ);
00459 return min_op(*min_targ);
00460 }
00461
00462 template<class Scalar>
00463 void Thyra::min( const VectorBase<Scalar>& x, Scalar *minEle, Index *minIndex )
00464 {
00465 RTOpPack::ROpMinIndex<Scalar> min_op;
00466 Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
00467 const VectorBase<Scalar>* vecs[] = { &x };
00468 applyOp<Scalar>(min_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*min_targ);
00469 RTOpPack::ScalarIndex<Scalar> scalarIndex = min_op(*min_targ);
00470 *minEle = scalarIndex.scalar;
00471 *minIndex = scalarIndex.index;
00472 }
00473
00474 template<class Scalar>
00475 void Thyra::minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound, Scalar *minEle, Index *minIndex )
00476 {
00477 RTOpPack::ROpMinIndexGreaterThanBound<Scalar> min_op(bound);
00478 Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
00479 const VectorBase<Scalar>* vecs[] = { &x };
00480 applyOp<Scalar>(min_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*min_targ);
00481 RTOpPack::ScalarIndex<Scalar> scalarIndex = min_op(*min_targ);
00482 *minEle = scalarIndex.scalar;
00483 *minIndex = scalarIndex.index;
00484 }
00485
00486 template<class Scalar>
00487 Scalar Thyra::max( const VectorBase<Scalar>& x )
00488 {
00489 RTOpPack::ROpMax<Scalar> max_op;
00490 Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
00491 const VectorBase<Scalar>* vecs[] = { &x };
00492 applyOp<Scalar>(max_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*max_targ);
00493 return max_op(*max_targ);
00494 }
00495
00496 template<class Scalar>
00497 void Thyra::max( const VectorBase<Scalar>& x, Scalar *maxEle, Index *maxIndex )
00498 {
00499 RTOpPack::ROpMaxIndex<Scalar> max_op;
00500 Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
00501 const VectorBase<Scalar>* vecs[] = { &x };
00502 applyOp<Scalar>(max_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*max_targ);
00503 RTOpPack::ScalarIndex<Scalar> scalarIndex = max_op(*max_targ);
00504 *maxEle = scalarIndex.scalar;
00505 *maxIndex = scalarIndex.index;
00506 }
00507
00508 template<class Scalar>
00509 void Thyra::maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound, Scalar *maxEle, Index *maxIndex )
00510 {
00511 RTOpPack::ROpMaxIndexLessThanBound<Scalar> max_op(bound);
00512 Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
00513 const VectorBase<Scalar>* vecs[] = { &x };
00514 applyOp<Scalar>(max_op,1,vecs,0,static_cast<VectorBase<Scalar>**>(NULL),&*max_targ);
00515 RTOpPack::ScalarIndex<Scalar> scalarIndex = max_op(*max_targ);
00516 *maxEle = scalarIndex.scalar;
00517 *maxIndex = scalarIndex.index;
00518 }
00519
00520 #endif // THYRA_VECTOR_STD_OPS_HPP
00521
00522
00523