|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Thyra: Interfaces and Support for Abstract Numerical Algorithms 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details// 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00022 // USA 00023 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00024 // 00025 // *********************************************************************** 00026 // @HEADER 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 00044 template<class Scalar> 00045 Scalar sum( const VectorBase<Scalar>& v ); 00046 00047 00054 template<class Scalar> 00055 Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ); 00056 00057 00064 template<class Scalar> 00065 Scalar inner( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ); 00066 00067 00075 template<class Scalar> 00076 typename Teuchos::ScalarTraits<Scalar>::magnitudeType 00077 norm( const VectorBase<Scalar>& v ); 00078 00079 00084 template<class Scalar> 00085 typename Teuchos::ScalarTraits<Scalar>::magnitudeType 00086 norm_1( const VectorBase<Scalar>& v ); 00087 00088 00093 template<class Scalar> 00094 typename Teuchos::ScalarTraits<Scalar>::magnitudeType 00095 norm_2( const VectorBase<Scalar>& v ); 00096 00097 00103 template<class Scalar> 00104 typename Teuchos::ScalarTraits<Scalar>::magnitudeType 00105 norm_2( const VectorBase<Scalar> &w, const VectorBase<Scalar>& v ); 00106 00107 00112 template<class Scalar> 00113 typename Teuchos::ScalarTraits<Scalar>::magnitudeType 00114 norm_inf( const VectorBase<Scalar>& v_rhs ); 00115 00116 00121 template<class Scalar> 00122 Scalar dot( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ); 00123 00124 00129 template<class Scalar> 00130 Scalar get_ele( const VectorBase<Scalar>& v, Ordinal i ); 00131 00132 00137 template<class Scalar> 00138 void set_ele( Ordinal i, Scalar alpha, const Ptr<VectorBase<Scalar> > &v ); 00139 00140 00146 template<class Scalar> 00147 void put_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y ); 00148 00149 00155 template<class Scalar> 00156 void copy( const VectorBase<Scalar>& x, const Ptr<VectorBase<Scalar> > &y ); 00157 00158 00164 template<class Scalar> 00165 void add_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y ); 00166 00167 00177 template<class Scalar> 00178 void scale( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y ); 00179 00180 00186 template<class Scalar> 00187 void abs( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x ); 00188 00189 00195 template<class Scalar> 00196 void reciprocal( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x ); 00197 00198 00204 template<class Scalar> 00205 void ele_wise_prod( const Scalar& alpha, const VectorBase<Scalar>& x, 00206 const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y ); 00207 00208 00214 template<class Scalar> 00215 void ele_wise_conj_prod( const Scalar& alpha, const VectorBase<Scalar>& x, 00216 const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y ); 00217 00218 00224 template<class Scalar> 00225 void Vp_StVtV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha, 00226 const VectorBase<Scalar>& x, const VectorBase<Scalar>& v); 00227 00228 00234 template<class Scalar> 00235 void ele_wise_prod_update( const Scalar& alpha, const VectorBase<Scalar>& x, 00236 const Ptr<VectorBase<Scalar> > &y ); 00237 00238 00244 template<class Scalar> 00245 void Vt_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha, 00246 const VectorBase<Scalar> &x ); 00247 00248 00254 template<class Scalar> 00255 void ele_wise_divide( const Scalar& alpha, const VectorBase<Scalar>& x, 00256 const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y ); 00257 00258 00281 template<class Scalar> 00282 void linear_combination( 00283 const ArrayView<const Scalar> &alpha, 00284 const ArrayView<const Ptr<const VectorBase<Scalar> > > &x, 00285 const Scalar &beta, 00286 const Ptr<VectorBase<Scalar> > &y 00287 ); 00288 00289 00299 template<class Scalar> 00300 void seed_randomize( unsigned int s ); 00301 00302 00313 template<class Scalar> 00314 void randomize( Scalar l, Scalar u, const Ptr<VectorBase<Scalar> > &v ); 00315 00316 00322 template<class Scalar> 00323 void assign( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha ); 00324 00325 00331 template<class Scalar> 00332 void assign( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x ); 00333 00334 00340 template<class Scalar> 00341 void Vp_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha ); 00342 00343 00353 template<class Scalar> 00354 void Vt_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha ); 00355 00356 00362 template<class Scalar> 00363 void V_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha, 00364 const VectorBase<Scalar> &x ); 00365 00366 00372 template<class Scalar> 00373 void Vp_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha, 00374 const VectorBase<Scalar>& x ); 00375 00376 00381 template<class Scalar> 00382 void Vp_V( 00383 const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x, 00384 const Scalar& beta = static_cast<Scalar>(1.0) 00385 ); 00386 00387 00392 template<class Scalar> 00393 void V_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x ); 00394 00395 00400 template<class Scalar> 00401 void V_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha ); 00402 00403 00408 template<class Scalar> 00409 void V_VpV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x, 00410 const VectorBase<Scalar>& y ); 00411 00412 00417 template<class Scalar> 00418 void V_VmV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x, 00419 const VectorBase<Scalar>& y ); 00420 00421 00426 template<class Scalar> 00427 void V_StVpV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha, 00428 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ); 00429 00430 00435 template<class Scalar> 00436 void V_VpStV( const Ptr<VectorBase<Scalar> > &z, 00437 const VectorBase<Scalar>& x, 00438 const Scalar &alpha, const VectorBase<Scalar>& y ); 00439 00440 00445 template<class Scalar> 00446 void V_StVpStV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha, 00447 const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y ); 00448 00449 00454 template<class Scalar> 00455 Scalar min( const VectorBase<Scalar>& x ); 00456 00457 00477 template<class Scalar> 00478 void min( const VectorBase<Scalar>& x, 00479 const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex ); 00480 00481 00511 template<class Scalar> 00512 void minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound, 00513 const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex ); 00514 00515 00520 template<class Scalar> 00521 Scalar max( const VectorBase<Scalar>& x ); 00522 00523 00543 template<class Scalar> 00544 void max( const VectorBase<Scalar>& x, 00545 const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex ); 00546 00547 00576 template<class Scalar> 00577 void maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound, 00578 const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex ); 00579 00580 00582 template<class Scalar> 00583 THYRA_DEPRECATED 00584 void set_ele( Ordinal i, Scalar alpha, VectorBase<Scalar>* v ) 00585 { set_ele(i, alpha, Teuchos::ptr(v)); } 00586 00587 00589 template<class Scalar> inline 00590 THYRA_DEPRECATED 00591 void put_scalar( const Scalar& alpha, VectorBase<Scalar>* y ) 00592 { put_scalar<Scalar>(alpha,Teuchos::ptr(y)); } 00593 00594 00596 template<class Scalar> inline 00597 THYRA_DEPRECATED 00598 void copy( const VectorBase<Scalar>& x, VectorBase<Scalar>* y ) 00599 { copy(x,Teuchos::ptr(y)); } 00600 00601 00603 template<class Scalar> inline 00604 THYRA_DEPRECATED 00605 void add_scalar( const Scalar& alpha, VectorBase<Scalar>* y ) 00606 { add_scalar(alpha,Teuchos::ptr(y)); } 00607 00608 00610 template<class Scalar> inline 00611 THYRA_DEPRECATED 00612 void scale( const Scalar& alpha, VectorBase<Scalar>* y ) 00613 { scale(alpha,Teuchos::ptr(y)); } 00614 00615 00617 template<class Scalar> inline 00618 THYRA_DEPRECATED 00619 void abs( VectorBase<Scalar>* y, const VectorBase<Scalar>& x ) 00620 { abs(Teuchos::ptr(y),x); } 00621 00622 00624 template<class Scalar> inline 00625 THYRA_DEPRECATED 00626 void reciprocal( VectorBase<Scalar>* y, const VectorBase<Scalar>& x ) 00627 { reciprocal(Teuchos::ptr(y),x); } 00628 00629 00631 template<class Scalar> inline 00632 THYRA_DEPRECATED 00633 void ele_wise_prod( const Scalar& alpha, const VectorBase<Scalar>& x, 00634 const VectorBase<Scalar>& v, VectorBase<Scalar>* y ) 00635 { ele_wise_prod(alpha, x, v, Teuchos::ptr(y)); } 00636 00637 00639 template<class Scalar> inline 00640 THYRA_DEPRECATED 00641 void ele_wise_conj_prod( const Scalar& alpha, const VectorBase<Scalar>& x, 00642 const VectorBase<Scalar>& v, VectorBase<Scalar>* y ) 00643 { ele_wise_conj_prod(alpha,x,v,Teuchos::ptr(y)); } 00644 00645 00647 template<class Scalar> inline 00648 THYRA_DEPRECATED 00649 void Vp_StVtV( VectorBase<Scalar>* y, const Scalar& alpha, 00650 const VectorBase<Scalar>& x, const VectorBase<Scalar>& v) 00651 { Vp_StVtV(Teuchos::ptr(y),alpha,x,v); } 00652 00653 00655 template<class Scalar> inline 00656 THYRA_DEPRECATED 00657 void ele_wise_prod_update( const Scalar& alpha, const VectorBase<Scalar>& x, 00658 VectorBase<Scalar>* y ) 00659 { ele_wise_prod_update(alpha,x,Teuchos::ptr(y)); } 00660 00661 00663 template<class Scalar> inline 00664 THYRA_DEPRECATED 00665 void Vt_StV( VectorBase<Scalar>* y, const Scalar& alpha, 00666 const VectorBase<Scalar> &x ) 00667 { Vt_StV(Teuchos::ptr(y),alpha,x); } 00668 00669 00671 template<class Scalar> 00672 THYRA_DEPRECATED 00673 void ele_wise_divide( const Scalar& alpha, const VectorBase<Scalar>& x, 00674 const VectorBase<Scalar>& v, VectorBase<Scalar>* y ) 00675 { ele_wise_divide(alpha,x,v,Teuchos::ptr(y)); } 00676 00677 00679 template<class Scalar> 00680 THYRA_DEPRECATED 00681 void linear_combination( 00682 const int m 00683 ,const Scalar alpha_in[] 00684 ,const VectorBase<Scalar>* x_in[] 00685 ,const Scalar &beta 00686 ,VectorBase<Scalar> *y 00687 ) 00688 { 00689 Array<Scalar> alpha(m); 00690 Array<Ptr<const VectorBase<Scalar> > > x(m); 00691 for (int k = 0; k < m; ++k) { 00692 alpha[k] = alpha_in[k]; 00693 x[k] = Teuchos::ptr(x_in[k]); 00694 } 00695 linear_combination<Scalar>( alpha, x, beta, Teuchos::ptr(y) ); 00696 } 00697 00698 00700 template<class Scalar> inline 00701 THYRA_DEPRECATED 00702 void randomize( Scalar l, Scalar u, VectorBase<Scalar>* v ) 00703 { randomize(l,u,Teuchos::ptr(v)); } 00704 00705 00707 template<class Scalar> inline 00708 THYRA_DEPRECATED 00709 void assign( VectorBase<Scalar>* y, const Scalar& alpha ) 00710 { assign(Teuchos::ptr(y),alpha); } 00711 00712 00714 template<class Scalar> 00715 THYRA_DEPRECATED 00716 void assign( VectorBase<Scalar>* y, const VectorBase<Scalar>& x ) 00717 { assign(Teuchos::ptr(y), x); } 00718 00719 00721 template<class Scalar> 00722 THYRA_DEPRECATED 00723 void Vp_S( VectorBase<Scalar>* y, const Scalar& alpha ) 00724 { Vp_S(Teuchos::ptr(y), alpha); } 00725 00726 00728 template<class Scalar> 00729 THYRA_DEPRECATED 00730 void Vt_S( VectorBase<Scalar>* y, const Scalar& alpha ) 00731 { Vt_S(Teuchos::ptr(y), alpha); } 00732 00733 00735 template<class Scalar> 00736 THYRA_DEPRECATED 00737 void V_StV( VectorBase<Scalar>* y, const Scalar& alpha, 00738 const VectorBase<Scalar> &x ) 00739 { V_StV(Teuchos::ptr(y), alpha, x); } 00740 00741 00743 template<class Scalar> 00744 THYRA_DEPRECATED 00745 void Vp_StV( VectorBase<Scalar>* y, const Scalar& alpha, 00746 const VectorBase<Scalar>& x ) 00747 { Vp_StV(Teuchos::ptr(y), alpha, x); } 00748 00749 00751 template<class Scalar> 00752 THYRA_DEPRECATED 00753 void Vp_V( 00754 VectorBase<Scalar>* y, const VectorBase<Scalar>& x, 00755 const Scalar& beta = static_cast<Scalar>(1.0) 00756 ) 00757 { Vp_V(Teuchos::ptr(y), x, beta); } 00758 00759 00761 template<class Scalar> 00762 THYRA_DEPRECATED 00763 void V_V( VectorBase<Scalar>* y, const VectorBase<Scalar>& x ) 00764 { V_V(Teuchos::ptr(y), x); } 00765 00766 00768 template<class Scalar> 00769 THYRA_DEPRECATED 00770 void V_S( VectorBase<Scalar>* y, const Scalar& alpha ) 00771 { V_S(Teuchos::ptr(y), alpha); } 00772 00773 00775 template<class Scalar> 00776 THYRA_DEPRECATED 00777 void V_VpV( VectorBase<Scalar>* z, const VectorBase<Scalar>& x, 00778 const VectorBase<Scalar>& y ) 00779 { V_VpV(Teuchos::ptr(z), x, y); } 00780 00781 00783 template<class Scalar> 00784 THYRA_DEPRECATED 00785 void V_VmV( VectorBase<Scalar>* z, const VectorBase<Scalar>& x, 00786 const VectorBase<Scalar>& y ) 00787 { V_VmV(Teuchos::ptr(z), x, y); } 00788 00789 00791 template<class Scalar> 00792 THYRA_DEPRECATED 00793 void V_StVpV( VectorBase<Scalar>* z, const Scalar &alpha, 00794 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) 00795 { V_StVpV(Teuchos::ptr(z), alpha, x, y); } 00796 00797 00799 template<class Scalar> 00800 THYRA_DEPRECATED 00801 void V_StVpStV( VectorBase<Scalar>* z, const Scalar &alpha, 00802 const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y ) 00803 { V_StVpStV(Teuchos::ptr(z), alpha, x, beta, y); } 00804 00805 00807 template<class Scalar> 00808 THYRA_DEPRECATED 00809 void min( const VectorBase<Scalar>& x, Scalar *maxEle, Ordinal *maxIndex ) 00810 { min(x, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); } 00811 00812 00814 template<class Scalar> 00815 THYRA_DEPRECATED 00816 void minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound, 00817 Scalar *minEle, Ordinal *minIndex ) 00818 { minGreaterThanBound(x, bound, Teuchos::ptr(minEle), Teuchos::ptr(minIndex)); } 00819 00820 00822 template<class Scalar> 00823 THYRA_DEPRECATED 00824 void max( const VectorBase<Scalar>& x, Scalar *maxEle, Ordinal *maxIndex ) 00825 { max(x, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); } 00826 00827 00829 template<class Scalar> 00830 THYRA_DEPRECATED 00831 void maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound, 00832 Scalar *maxEle, Ordinal *maxIndex ) 00833 { maxLessThanBound(x, bound, Teuchos::ptr(maxEle), Teuchos::ptr(maxIndex)); } 00834 00835 00836 } // end namespace Thyra 00837 00838 00839 // ///////////////////////// 00840 // Inline functions 00841 00842 00843 template<class Scalar> 00844 inline 00845 Scalar Thyra::scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) 00846 { 00847 return x.space()->scalarProd(x, y); 00848 } 00849 00850 00851 template<class Scalar> 00852 inline 00853 Scalar Thyra::inner( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) 00854 { 00855 return x.space()->scalarProd(x, y); 00856 } 00857 00858 00859 template<class Scalar> 00860 inline 00861 typename Teuchos::ScalarTraits<Scalar>::magnitudeType 00862 Thyra::norm( const VectorBase<Scalar>& v ) 00863 { 00864 typedef Teuchos::ScalarTraits<Scalar> ST; 00865 return ST::magnitude(ST::squareroot(v.space()->scalarProd(v, v))); 00866 } 00867 00868 00869 #endif // THYRA_VECTOR_STD_OPS_DECL_HPP
1.7.4