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_DECL_HPP
00030 #define THYRA_VECTOR_STD_OPS_DECL_HPP
00031
00032
00033 #include "Thyra_OperatorVectorTypes.hpp"
00034
00035
00036 namespace Thyra {
00037
00038
00056
00057
00061 template<class Scalar>
00062 Scalar sum( const VectorBase<Scalar>& v );
00063
00064
00069 template<class Scalar>
00070 Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
00071
00072
00078 template<class Scalar>
00079 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00080 norm( const VectorBase<Scalar>& v );
00081
00082
00085 template<class Scalar>
00086 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00087 norm_1( const VectorBase<Scalar>& v );
00088
00089
00092 template<class Scalar>
00093 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00094 norm_2( const VectorBase<Scalar>& v );
00095
00096
00100 template<class Scalar>
00101 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00102 norm_2( const VectorBase<Scalar> &w, const VectorBase<Scalar>& v );
00103
00104
00107 template<class Scalar>
00108 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00109 norm_inf( const VectorBase<Scalar>& v_rhs );
00110
00111
00114 template<class Scalar>
00115 Scalar dot( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
00116
00117
00120 template<class Scalar>
00121 Scalar get_ele( const VectorBase<Scalar>& v, Index i );
00122
00123
00126 template<class Scalar>
00127 void set_ele( Index i, Scalar alpha, const Ptr<VectorBase<Scalar> > &v );
00128
00129
00133 template<class Scalar>
00134 void put_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
00135
00136
00140 template<class Scalar>
00141 void copy( const VectorBase<Scalar>& x, const Ptr<VectorBase<Scalar> > &y );
00142
00143
00147 template<class Scalar>
00148 void add_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
00149
00150
00158 template<class Scalar>
00159 void scale( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
00160
00161
00165 template<class Scalar>
00166 void abs( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
00167
00168
00172 template<class Scalar>
00173 void reciprocal( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
00174
00175
00179 template<class Scalar>
00180 void ele_wise_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
00181 const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
00182
00183
00187 template<class Scalar>
00188 void ele_wise_conj_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
00189 const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
00190
00191
00195 template<class Scalar>
00196 void Vp_StVtV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00197 const VectorBase<Scalar>& x, const VectorBase<Scalar>& v);
00198
00199
00203 template<class Scalar>
00204 void ele_wise_prod_update( const Scalar& alpha, const VectorBase<Scalar>& x,
00205 const Ptr<VectorBase<Scalar> > &y );
00206
00207
00211 template<class Scalar>
00212 void Vt_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00213 const VectorBase<Scalar> &x );
00214
00215
00219 template<class Scalar>
00220 void ele_wise_divide( const Scalar& alpha, const VectorBase<Scalar>& x,
00221 const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
00222
00223
00244 template<class Scalar>
00245 void linear_combination(
00246 const ArrayView<const Scalar> &alpha,
00247 const ArrayView<const Ptr<const VectorBase<Scalar> > > &x,
00248 const Scalar &beta,
00249 const Ptr<VectorBase<Scalar> > &y
00250 );
00251
00252
00260 template<class Scalar>
00261 void seed_randomize( unsigned int s );
00262
00263
00272 template<class Scalar>
00273 void randomize( Scalar l, Scalar u, const Ptr<VectorBase<Scalar> > &v );
00274
00275
00277
00278
00291
00292
00296 template<class Scalar>
00297 void assign( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
00298
00299
00303 template<class Scalar>
00304 void assign( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
00305
00306
00310 template<class Scalar>
00311 void Vp_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
00312
00313
00321 template<class Scalar>
00322 void Vt_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
00323
00324
00328 template<class Scalar>
00329 void V_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00330 const VectorBase<Scalar> &x );
00331
00332
00336 template<class Scalar>
00337 void Vp_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00338 const VectorBase<Scalar>& x );
00339
00340
00343 template<class Scalar>
00344 void Vp_V(
00345 const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x,
00346 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::one()
00347 );
00348
00349
00352 template<class Scalar>
00353 void V_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
00354
00355
00358 template<class Scalar>
00359 void V_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
00360
00361
00364 template<class Scalar>
00365 void V_VpV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
00366 const VectorBase<Scalar>& y );
00367
00368
00371 template<class Scalar>
00372 void V_VmV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
00373 const VectorBase<Scalar>& y );
00374
00375
00378 template<class Scalar>
00379 void V_StVpV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
00380 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
00381
00382
00385 template<class Scalar>
00386 void V_VpStV( const Ptr<VectorBase<Scalar> > &z,
00387 const VectorBase<Scalar>& x,
00388 const Scalar &alpha, const VectorBase<Scalar>& y );
00389
00390
00393 template<class Scalar>
00394 void V_StVpStV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
00395 const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y );
00396
00397
00399
00400
00409
00410
00413 template<class Scalar>
00414 Scalar min( const VectorBase<Scalar>& x );
00415
00416
00434 template<class Scalar>
00435 void min( const VectorBase<Scalar>& x,
00436 const Ptr<Scalar> &maxEle, const Ptr<Index> &maxIndex );
00437
00438
00466 template<class Scalar>
00467 void minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
00468 const Ptr<Scalar> &minEle, const Ptr<Index> &minIndex );
00469
00470
00473 template<class Scalar>
00474 Scalar max( const VectorBase<Scalar>& x );
00475
00476
00494 template<class Scalar>
00495 void max( const VectorBase<Scalar>& x,
00496 const Ptr<Scalar> &maxEle, const Ptr<Index> &maxIndex );
00497
00498
00525 template<class Scalar>
00526 void maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
00527 const Ptr<Scalar> &maxEle, const Ptr<Index> &maxIndex );
00528
00529
00531
00532
00538
00539
00541 template<class Scalar>
00542 void set_ele( Index i, Scalar alpha, VectorBase<Scalar>* v )
00543 { set_ele(i, alpha, Teuchos::ptr(v)); }
00544
00545
00547 template<class Scalar> inline
00548 void put_scalar( const Scalar& alpha, VectorBase<Scalar>* y )
00549 { put_scalar<Scalar>(alpha,Teuchos::ptr(y)); }
00550
00551
00553 template<class Scalar> inline
00554 void copy( const VectorBase<Scalar>& x, VectorBase<Scalar>* y )
00555 { copy(x,Teuchos::ptr(y)); }
00556
00557
00559 template<class Scalar> inline
00560 void add_scalar( const Scalar& alpha, VectorBase<Scalar>* y )
00561 { add_scalar(alpha,Teuchos::ptr(y)); }
00562
00563
00565 template<class Scalar> inline
00566 void scale( const Scalar& alpha, VectorBase<Scalar>* y )
00567 { scale(alpha,Teuchos::ptr(y)); }
00568
00569
00571 template<class Scalar> inline
00572 void abs( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00573 { abs(Teuchos::ptr(y),x); }
00574
00575
00577 template<class Scalar> inline
00578 void reciprocal( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00579 { reciprocal(Teuchos::ptr(y),x); }
00580
00581
00583 template<class Scalar> inline
00584 void ele_wise_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
00585 const VectorBase<Scalar>& v, VectorBase<Scalar>* y )
00586 { ele_wise_prod(alpha, x, v, Teuchos::ptr(y)); }
00587
00588
00590 template<class Scalar> inline
00591 void ele_wise_conj_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
00592 const VectorBase<Scalar>& v, VectorBase<Scalar>* y )
00593 { ele_wise_conj_prod(alpha,x,v,Teuchos::ptr(y)); }
00594
00595
00597 template<class Scalar> inline
00598 void Vp_StVtV( VectorBase<Scalar>* y, const Scalar& alpha,
00599 const VectorBase<Scalar>& x, const VectorBase<Scalar>& v)
00600 { Vp_StVtV(Teuchos::ptr(y),alpha,x,v); }
00601
00602
00604 template<class Scalar> inline
00605 void ele_wise_prod_update( const Scalar& alpha, const VectorBase<Scalar>& x,
00606 VectorBase<Scalar>* y )
00607 { ele_wise_prod_update(alpha,x,Teuchos::ptr(y)); }
00608
00609
00611 template<class Scalar> inline
00612 void Vt_StV( VectorBase<Scalar>* y, const Scalar& alpha,
00613 const VectorBase<Scalar> &x )
00614 { Vt_StV(Teuchos::ptr(y),alpha,x); }
00615
00616
00618 template<class Scalar>
00619 void ele_wise_divide( const Scalar& alpha, const VectorBase<Scalar>& x,
00620 const VectorBase<Scalar>& v, VectorBase<Scalar>* y )
00621 { ele_wise_divide(alpha,x,v,Teuchos::ptr(y)); }
00622
00623
00625 template<class Scalar>
00626 void linear_combination(
00627 const int m
00628 ,const Scalar alpha_in[]
00629 ,const VectorBase<Scalar>* x_in[]
00630 ,const Scalar &beta
00631 ,VectorBase<Scalar> *y
00632 )
00633 {
00634 Array<Scalar> alpha(m);
00635 Array<Ptr<const VectorBase<Scalar> > > x(m);
00636 for (int k = 0; k < m; ++k) {
00637 alpha[k] = alpha_in[k];
00638 x[k] = Teuchos::ptr(x_in[k]);
00639 }
00640 linear_combination<Scalar>( alpha, x, beta, Teuchos::ptr(y) );
00641 }
00642
00643
00645 template<class Scalar> inline
00646 void randomize( Scalar l, Scalar u, VectorBase<Scalar>* v )
00647 { randomize(l,u,Teuchos::ptr(v)); }
00648
00649
00651 template<class Scalar> inline
00652 void assign( VectorBase<Scalar>* y, const Scalar& alpha )
00653 { assign(Teuchos::ptr(y),alpha); }
00654
00655
00657 template<class Scalar>
00658 void assign( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00659 { assign(Teuchos::ptr(y), x); }
00660
00661
00663 template<class Scalar>
00664 void Vp_S( VectorBase<Scalar>* y, const Scalar& alpha )
00665 { Vp_S(Teuchos::ptr(y), alpha); }
00666
00667
00669 template<class Scalar>
00670 void Vt_S( VectorBase<Scalar>* y, const Scalar& alpha )
00671 { Vt_S(Teuchos::ptr(y), alpha); }
00672
00673
00675 template<class Scalar>
00676 void V_StV( VectorBase<Scalar>* y, const Scalar& alpha,
00677 const VectorBase<Scalar> &x )
00678 { V_StV(Teuchos::ptr(y), alpha, x); }
00679
00680
00682 template<class Scalar>
00683 void Vp_StV( VectorBase<Scalar>* y, const Scalar& alpha,
00684 const VectorBase<Scalar>& x )
00685 { Vp_StV(Teuchos::ptr(y), alpha, x); }
00686
00687
00689 template<class Scalar>
00690 void Vp_V(
00691 VectorBase<Scalar>* y, const VectorBase<Scalar>& x,
00692 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::one()
00693 )
00694 { Vp_V(Teuchos::ptr(y), x, beta); }
00695
00696
00698 template<class Scalar>
00699 void V_V( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00700 { V_V(Teuchos::ptr(y), x); }
00701
00702
00704 template<class Scalar>
00705 void V_S( VectorBase<Scalar>* y, const Scalar& alpha )
00706 { V_S(Teuchos::ptr(y), alpha); }
00707
00708
00710 template<class Scalar>
00711 void V_VpV( VectorBase<Scalar>* z, const VectorBase<Scalar>& x,
00712 const VectorBase<Scalar>& y )
00713 { V_VpV(Teuchos::ptr(z), x, y); }
00714
00715
00717 template<class Scalar>
00718 void V_VmV( VectorBase<Scalar>* z, const VectorBase<Scalar>& x,
00719 const VectorBase<Scalar>& y )
00720 { V_VmV(Teuchos::ptr(z), x, y); }
00721
00722
00724 template<class Scalar>
00725 void V_StVpV( VectorBase<Scalar>* z, const Scalar &alpha,
00726 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
00727 { V_StVpV(Teuchos::ptr(z), alpha, x, y); }
00728
00729
00731 template<class Scalar>
00732 void V_StVpStV( VectorBase<Scalar>* z, const Scalar &alpha,
00733 const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y )
00734 { V_StVpStV(Teuchos::ptr(z), alpha, x, beta, y); }
00735
00736
00738 template<class Scalar>
00739 void min( const VectorBase<Scalar>& x, Scalar *maxEle, Index *maxIndex )
00740 { min(x, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); }
00741
00742
00744 template<class Scalar>
00745 void minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
00746 Scalar *minEle, Index *minIndex )
00747 { minGreaterThanBound(x, bound, Teuchos::ptr(minEle), Teuchos::ptr(minIndex)); }
00748
00749
00751 template<class Scalar>
00752 void max( const VectorBase<Scalar>& x, Scalar *maxEle, Index *maxIndex )
00753 { max(x, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); }
00754
00755
00757 template<class Scalar>
00758 void maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
00759 Scalar *maxEle, Index *maxIndex )
00760 { maxLessThanBound(x, bound, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); }
00761
00762
00764
00765
00766 }
00767
00768
00769
00770
00771
00772
00773 template<class Scalar>
00774 inline
00775 Scalar Thyra::scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
00776 {
00777 return x.space()->scalarProd(x,y);
00778 }
00779
00780
00781 template<class Scalar>
00782 inline
00783 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00784 Thyra::norm( const VectorBase<Scalar>& v )
00785 {
00786 typedef Teuchos::ScalarTraits<Scalar> ST;
00787 return ST::magnitude(ST::squareroot(v.space()->scalarProd(v,v)));
00788 }
00789
00790
00791 #endif // THYRA_VECTOR_STD_OPS_DECL_HPP