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
00077 template<class Scalar>
00078 Scalar inner( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
00079
00080
00086 template<class Scalar>
00087 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00088 norm( const VectorBase<Scalar>& v );
00089
00090
00093 template<class Scalar>
00094 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00095 norm_1( const VectorBase<Scalar>& v );
00096
00097
00100 template<class Scalar>
00101 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00102 norm_2( const VectorBase<Scalar>& v );
00103
00104
00108 template<class Scalar>
00109 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00110 norm_2( const VectorBase<Scalar> &w, const VectorBase<Scalar>& v );
00111
00112
00115 template<class Scalar>
00116 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00117 norm_inf( const VectorBase<Scalar>& v_rhs );
00118
00119
00122 template<class Scalar>
00123 Scalar dot( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
00124
00125
00128 template<class Scalar>
00129 Scalar get_ele( const VectorBase<Scalar>& v, Index i );
00130
00131
00134 template<class Scalar>
00135 void set_ele( Index i, Scalar alpha, const Ptr<VectorBase<Scalar> > &v );
00136
00137
00141 template<class Scalar>
00142 void put_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
00143
00144
00148 template<class Scalar>
00149 void copy( const VectorBase<Scalar>& x, const Ptr<VectorBase<Scalar> > &y );
00150
00151
00155 template<class Scalar>
00156 void add_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
00157
00158
00166 template<class Scalar>
00167 void scale( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
00168
00169
00173 template<class Scalar>
00174 void abs( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
00175
00176
00180 template<class Scalar>
00181 void reciprocal( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
00182
00183
00187 template<class Scalar>
00188 void ele_wise_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 ele_wise_conj_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
00197 const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
00198
00199
00203 template<class Scalar>
00204 void Vp_StVtV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00205 const VectorBase<Scalar>& x, const VectorBase<Scalar>& v);
00206
00207
00211 template<class Scalar>
00212 void ele_wise_prod_update( const Scalar& alpha, const VectorBase<Scalar>& x,
00213 const Ptr<VectorBase<Scalar> > &y );
00214
00215
00219 template<class Scalar>
00220 void Vt_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00221 const VectorBase<Scalar> &x );
00222
00223
00227 template<class Scalar>
00228 void ele_wise_divide( const Scalar& alpha, const VectorBase<Scalar>& x,
00229 const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
00230
00231
00252 template<class Scalar>
00253 void linear_combination(
00254 const ArrayView<const Scalar> &alpha,
00255 const ArrayView<const Ptr<const VectorBase<Scalar> > > &x,
00256 const Scalar &beta,
00257 const Ptr<VectorBase<Scalar> > &y
00258 );
00259
00260
00268 template<class Scalar>
00269 void seed_randomize( unsigned int s );
00270
00271
00280 template<class Scalar>
00281 void randomize( Scalar l, Scalar u, const Ptr<VectorBase<Scalar> > &v );
00282
00283
00285
00286
00299
00300
00304 template<class Scalar>
00305 void assign( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
00306
00307
00311 template<class Scalar>
00312 void assign( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
00313
00314
00318 template<class Scalar>
00319 void Vp_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
00320
00321
00329 template<class Scalar>
00330 void Vt_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
00331
00332
00336 template<class Scalar>
00337 void V_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00338 const VectorBase<Scalar> &x );
00339
00340
00344 template<class Scalar>
00345 void Vp_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
00346 const VectorBase<Scalar>& x );
00347
00348
00351 template<class Scalar>
00352 void Vp_V(
00353 const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x,
00354 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::one()
00355 );
00356
00357
00360 template<class Scalar>
00361 void V_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
00362
00363
00366 template<class Scalar>
00367 void V_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
00368
00369
00372 template<class Scalar>
00373 void V_VpV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
00374 const VectorBase<Scalar>& y );
00375
00376
00379 template<class Scalar>
00380 void V_VmV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
00381 const VectorBase<Scalar>& y );
00382
00383
00386 template<class Scalar>
00387 void V_StVpV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
00388 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
00389
00390
00393 template<class Scalar>
00394 void V_VpStV( const Ptr<VectorBase<Scalar> > &z,
00395 const VectorBase<Scalar>& x,
00396 const Scalar &alpha, const VectorBase<Scalar>& y );
00397
00398
00401 template<class Scalar>
00402 void V_StVpStV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
00403 const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y );
00404
00405
00407
00408
00417
00418
00421 template<class Scalar>
00422 Scalar min( const VectorBase<Scalar>& x );
00423
00424
00442 template<class Scalar>
00443 void min( const VectorBase<Scalar>& x,
00444 const Ptr<Scalar> &maxEle, const Ptr<Index> &maxIndex );
00445
00446
00474 template<class Scalar>
00475 void minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
00476 const Ptr<Scalar> &minEle, const Ptr<Index> &minIndex );
00477
00478
00481 template<class Scalar>
00482 Scalar max( const VectorBase<Scalar>& x );
00483
00484
00502 template<class Scalar>
00503 void max( const VectorBase<Scalar>& x,
00504 const Ptr<Scalar> &maxEle, const Ptr<Index> &maxIndex );
00505
00506
00533 template<class Scalar>
00534 void maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
00535 const Ptr<Scalar> &maxEle, const Ptr<Index> &maxIndex );
00536
00537
00539
00540
00546
00547
00549 template<class Scalar>
00550 void set_ele( Index i, Scalar alpha, VectorBase<Scalar>* v )
00551 { set_ele(i, alpha, Teuchos::ptr(v)); }
00552
00553
00555 template<class Scalar> inline
00556 void put_scalar( const Scalar& alpha, VectorBase<Scalar>* y )
00557 { put_scalar<Scalar>(alpha,Teuchos::ptr(y)); }
00558
00559
00561 template<class Scalar> inline
00562 void copy( const VectorBase<Scalar>& x, VectorBase<Scalar>* y )
00563 { copy(x,Teuchos::ptr(y)); }
00564
00565
00567 template<class Scalar> inline
00568 void add_scalar( const Scalar& alpha, VectorBase<Scalar>* y )
00569 { add_scalar(alpha,Teuchos::ptr(y)); }
00570
00571
00573 template<class Scalar> inline
00574 void scale( const Scalar& alpha, VectorBase<Scalar>* y )
00575 { scale(alpha,Teuchos::ptr(y)); }
00576
00577
00579 template<class Scalar> inline
00580 void abs( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00581 { abs(Teuchos::ptr(y),x); }
00582
00583
00585 template<class Scalar> inline
00586 void reciprocal( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00587 { reciprocal(Teuchos::ptr(y),x); }
00588
00589
00591 template<class Scalar> inline
00592 void ele_wise_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
00593 const VectorBase<Scalar>& v, VectorBase<Scalar>* y )
00594 { ele_wise_prod(alpha, x, v, Teuchos::ptr(y)); }
00595
00596
00598 template<class Scalar> inline
00599 void ele_wise_conj_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
00600 const VectorBase<Scalar>& v, VectorBase<Scalar>* y )
00601 { ele_wise_conj_prod(alpha,x,v,Teuchos::ptr(y)); }
00602
00603
00605 template<class Scalar> inline
00606 void Vp_StVtV( VectorBase<Scalar>* y, const Scalar& alpha,
00607 const VectorBase<Scalar>& x, const VectorBase<Scalar>& v)
00608 { Vp_StVtV(Teuchos::ptr(y),alpha,x,v); }
00609
00610
00612 template<class Scalar> inline
00613 void ele_wise_prod_update( const Scalar& alpha, const VectorBase<Scalar>& x,
00614 VectorBase<Scalar>* y )
00615 { ele_wise_prod_update(alpha,x,Teuchos::ptr(y)); }
00616
00617
00619 template<class Scalar> inline
00620 void Vt_StV( VectorBase<Scalar>* y, const Scalar& alpha,
00621 const VectorBase<Scalar> &x )
00622 { Vt_StV(Teuchos::ptr(y),alpha,x); }
00623
00624
00626 template<class Scalar>
00627 void ele_wise_divide( const Scalar& alpha, const VectorBase<Scalar>& x,
00628 const VectorBase<Scalar>& v, VectorBase<Scalar>* y )
00629 { ele_wise_divide(alpha,x,v,Teuchos::ptr(y)); }
00630
00631
00633 template<class Scalar>
00634 void linear_combination(
00635 const int m
00636 ,const Scalar alpha_in[]
00637 ,const VectorBase<Scalar>* x_in[]
00638 ,const Scalar &beta
00639 ,VectorBase<Scalar> *y
00640 )
00641 {
00642 Array<Scalar> alpha(m);
00643 Array<Ptr<const VectorBase<Scalar> > > x(m);
00644 for (int k = 0; k < m; ++k) {
00645 alpha[k] = alpha_in[k];
00646 x[k] = Teuchos::ptr(x_in[k]);
00647 }
00648 linear_combination<Scalar>( alpha, x, beta, Teuchos::ptr(y) );
00649 }
00650
00651
00653 template<class Scalar> inline
00654 void randomize( Scalar l, Scalar u, VectorBase<Scalar>* v )
00655 { randomize(l,u,Teuchos::ptr(v)); }
00656
00657
00659 template<class Scalar> inline
00660 void assign( VectorBase<Scalar>* y, const Scalar& alpha )
00661 { assign(Teuchos::ptr(y),alpha); }
00662
00663
00665 template<class Scalar>
00666 void assign( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00667 { assign(Teuchos::ptr(y), x); }
00668
00669
00671 template<class Scalar>
00672 void Vp_S( VectorBase<Scalar>* y, const Scalar& alpha )
00673 { Vp_S(Teuchos::ptr(y), alpha); }
00674
00675
00677 template<class Scalar>
00678 void Vt_S( VectorBase<Scalar>* y, const Scalar& alpha )
00679 { Vt_S(Teuchos::ptr(y), alpha); }
00680
00681
00683 template<class Scalar>
00684 void V_StV( VectorBase<Scalar>* y, const Scalar& alpha,
00685 const VectorBase<Scalar> &x )
00686 { V_StV(Teuchos::ptr(y), alpha, x); }
00687
00688
00690 template<class Scalar>
00691 void Vp_StV( VectorBase<Scalar>* y, const Scalar& alpha,
00692 const VectorBase<Scalar>& x )
00693 { Vp_StV(Teuchos::ptr(y), alpha, x); }
00694
00695
00697 template<class Scalar>
00698 void Vp_V(
00699 VectorBase<Scalar>* y, const VectorBase<Scalar>& x,
00700 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::one()
00701 )
00702 { Vp_V(Teuchos::ptr(y), x, beta); }
00703
00704
00706 template<class Scalar>
00707 void V_V( VectorBase<Scalar>* y, const VectorBase<Scalar>& x )
00708 { V_V(Teuchos::ptr(y), x); }
00709
00710
00712 template<class Scalar>
00713 void V_S( VectorBase<Scalar>* y, const Scalar& alpha )
00714 { V_S(Teuchos::ptr(y), alpha); }
00715
00716
00718 template<class Scalar>
00719 void V_VpV( VectorBase<Scalar>* z, const VectorBase<Scalar>& x,
00720 const VectorBase<Scalar>& y )
00721 { V_VpV(Teuchos::ptr(z), x, y); }
00722
00723
00725 template<class Scalar>
00726 void V_VmV( VectorBase<Scalar>* z, const VectorBase<Scalar>& x,
00727 const VectorBase<Scalar>& y )
00728 { V_VmV(Teuchos::ptr(z), x, y); }
00729
00730
00732 template<class Scalar>
00733 void V_StVpV( VectorBase<Scalar>* z, const Scalar &alpha,
00734 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
00735 { V_StVpV(Teuchos::ptr(z), alpha, x, y); }
00736
00737
00739 template<class Scalar>
00740 void V_StVpStV( VectorBase<Scalar>* z, const Scalar &alpha,
00741 const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y )
00742 { V_StVpStV(Teuchos::ptr(z), alpha, x, beta, y); }
00743
00744
00746 template<class Scalar>
00747 void min( const VectorBase<Scalar>& x, Scalar *maxEle, Index *maxIndex )
00748 { min(x, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); }
00749
00750
00752 template<class Scalar>
00753 void minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
00754 Scalar *minEle, Index *minIndex )
00755 { minGreaterThanBound(x, bound, Teuchos::ptr(minEle), Teuchos::ptr(minIndex)); }
00756
00757
00759 template<class Scalar>
00760 void max( const VectorBase<Scalar>& x, Scalar *maxEle, Index *maxIndex )
00761 { max(x, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); }
00762
00763
00765 template<class Scalar>
00766 void maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
00767 Scalar *maxEle, Index *maxIndex )
00768 { maxLessThanBound(x, bound, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); }
00769
00770
00772
00773
00774 }
00775
00776
00777
00778
00779
00780
00781 template<class Scalar>
00782 inline
00783 Scalar Thyra::scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
00784 {
00785 return x.space()->scalarProd(x,y);
00786 }
00787
00788
00789 template<class Scalar>
00790 inline
00791 Scalar Thyra::inner( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
00792 {
00793 return x.space()->scalarProd(x,y);
00794 }
00795
00796
00797 template<class Scalar>
00798 inline
00799 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00800 Thyra::norm( const VectorBase<Scalar>& v )
00801 {
00802 typedef Teuchos::ScalarTraits<Scalar> ST;
00803 return ST::magnitude(ST::squareroot(v.space()->scalarProd(v,v)));
00804 }
00805
00806
00807 #endif // THYRA_VECTOR_STD_OPS_DECL_HPP