Thyra  Version of the Day
Thyra_VectorStdOps_decl.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 
43 #ifndef THYRA_VECTOR_STD_OPS_DECL_HPP
44 #define THYRA_VECTOR_STD_OPS_DECL_HPP
45 
46 
47 #include "Thyra_OperatorVectorTypes.hpp"
48 
49 
50 namespace Thyra {
51 
52 
58 template<class Scalar>
59 Scalar sum( const VectorBase<Scalar>& v );
60 
61 
68 template<class Scalar>
69 Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
70 
71 
78 template<class Scalar>
79 Scalar inner( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
80 
81 
89 template<class Scalar>
90 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
91 norm( const VectorBase<Scalar>& v );
92 
93 
98 template<class Scalar>
99 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
100 norm_1( const VectorBase<Scalar>& v );
101 
102 
107 template<class Scalar>
108 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
109 norm_2( const VectorBase<Scalar>& v );
110 
111 
117 template<class Scalar>
118 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
119 norm_2( const VectorBase<Scalar> &w, const VectorBase<Scalar>& v );
120 
121 
126 template<class Scalar>
127 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
128 norm_inf( const VectorBase<Scalar>& v_rhs );
129 
130 
135 template<class Scalar>
136 Scalar dot( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
137 
138 
143 template<class Scalar>
144 Scalar get_ele( const VectorBase<Scalar>& v, Ordinal i );
145 
146 
151 template<class Scalar>
152 void set_ele( Ordinal i, Scalar alpha, const Ptr<VectorBase<Scalar> > &v );
153 
154 
160 template<class Scalar>
161 void put_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
162 
163 
169 template<class Scalar>
170 void copy( const VectorBase<Scalar>& x, const Ptr<VectorBase<Scalar> > &y );
171 
172 
178 template<class Scalar>
179 void add_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
180 
181 
191 template<class Scalar>
192 void scale( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &y );
193 
194 
200 template<class Scalar>
201 void abs( const VectorBase<Scalar> &x, const Ptr<VectorBase<Scalar> > &y );
202 
203 
209 template<class Scalar>
210 void reciprocal( const VectorBase<Scalar> &x, const Ptr<VectorBase<Scalar> > &y );
211 
212 
218 template<class Scalar>
219 void ele_wise_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
220  const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
221 
222 
228 template<class Scalar>
229 void ele_wise_conj_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
230  const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
231 
232 
238 template<class Scalar>
239 void ele_wise_scale( const VectorBase<Scalar>& x, const Ptr<VectorBase<Scalar> > &y );
240 
241 
247 template<class Scalar>
248 void Vp_StVtV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
249  const VectorBase<Scalar>& x, const VectorBase<Scalar>& v);
250 
251 
257 template<class Scalar>
258 void ele_wise_prod_update( const Scalar& alpha, const VectorBase<Scalar>& x,
259  const Ptr<VectorBase<Scalar> > &y );
260 
261 
267 template<class Scalar>
268 void Vt_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
269  const VectorBase<Scalar> &x );
270 
271 
277 template<class Scalar>
278 void ele_wise_divide( const Scalar& alpha, const VectorBase<Scalar>& x,
279  const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
280 
281 
304 template<class Scalar>
305 void linear_combination(
306  const ArrayView<const Scalar> &alpha,
307  const ArrayView<const Ptr<const VectorBase<Scalar> > > &x,
308  const Scalar &beta,
309  const Ptr<VectorBase<Scalar> > &y
310  );
311 
312 
322 template<class Scalar>
323 void seed_randomize( unsigned int s );
324 
325 
336 template<class Scalar>
337 void randomize( Scalar l, Scalar u, const Ptr<VectorBase<Scalar> > &v );
338 
339 
345 template<class Scalar>
346 void assign( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
347 
348 
354 template<class Scalar>
355 void assign( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
356 
357 
363 template<class Scalar>
364 void Vp_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
365 
366 
376 template<class Scalar>
377 void Vt_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
378 
379 
385 template<class Scalar>
386 void V_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
387  const VectorBase<Scalar> &x );
388 
389 
395 template<class Scalar>
396 void Vp_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
397  const VectorBase<Scalar>& x );
398 
399 
404 template<class Scalar>
405 void Vp_V(
406  const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x,
407  const Scalar& beta = static_cast<Scalar>(1.0)
408  );
409 
410 
415 template<class Scalar>
416 void V_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
417 
418 
423 template<class Scalar>
424 void V_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
425 
426 
431 template<class Scalar>
432 void V_VpV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
433  const VectorBase<Scalar>& y );
434 
435 
440 template<class Scalar>
441 void V_VmV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
442  const VectorBase<Scalar>& y );
443 
444 
449 template<class Scalar>
450 void V_StVpV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
451  const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
452 
453 
458 template<class Scalar>
459 void V_VpStV( const Ptr<VectorBase<Scalar> > &z,
460  const VectorBase<Scalar>& x,
461  const Scalar &alpha, const VectorBase<Scalar>& y );
462 
463 
468 template<class Scalar>
469 void V_StVpStV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
470  const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y );
471 
472 
477 template<class Scalar>
478 Scalar min( const VectorBase<Scalar>& x );
479 
480 
500 template<class Scalar>
501 void min( const VectorBase<Scalar>& x,
502  const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex );
503 
504 
534 template<class Scalar>
535 void minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
536  const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex );
537 
538 
543 template<class Scalar>
544 Scalar max( const VectorBase<Scalar>& x );
545 
546 
566 template<class Scalar>
567 void max( const VectorBase<Scalar>& x,
568  const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex );
569 
570 
599 template<class Scalar>
600 void maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
601  const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex );
602 
603 
604 
605 
606 } // end namespace Thyra
607 
608 
609 // /////////////////////////
610 // Inline functions
611 
612 
613 template<class Scalar>
614 inline
615 Scalar Thyra::scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
616 {
617  return x.space()->scalarProd(x, y);
618 }
619 
620 
621 template<class Scalar>
622 inline
623 Scalar Thyra::inner( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
624 {
625  return x.space()->scalarProd(x, y);
626 }
627 
628 
629 template<class Scalar>
630 inline
631 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
632 Thyra::norm( const VectorBase<Scalar>& v )
633 {
634  typedef Teuchos::ScalarTraits<Scalar> ST;
635  return ST::magnitude(ST::squareroot(v.space()->scalarProd(v, v)));
636 }
637 
638 
639 #endif // THYRA_VECTOR_STD_OPS_DECL_HPP
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.