Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
91 norm( const VectorBase<Scalar>& v );
92 
93 
98 template<class Scalar>
100 norm_1( const VectorBase<Scalar>& v );
101 
102 
107 template<class Scalar>
109 norm_2( const VectorBase<Scalar>& v );
110 
111 
117 template<class Scalar>
119 norm_2( const VectorBase<Scalar> &w, const VectorBase<Scalar>& v );
120 
121 
126 template<class Scalar>
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 pair_wise_max(const Scalar& alpha, const VectorBase<Scalar>& x,
230  const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
231 
237 template<class Scalar>
238 void ele_wise_conj_prod( const Scalar& alpha, const VectorBase<Scalar>& x,
239  const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
240 
241 
247 template<class Scalar>
248 void ele_wise_scale( const VectorBase<Scalar>& x, const Ptr<VectorBase<Scalar> > &y );
249 
250 
256 template<class Scalar>
257 void Vp_StVtV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
258  const VectorBase<Scalar>& x, const VectorBase<Scalar>& v);
259 
260 
266 template<class Scalar>
267 void ele_wise_prod_update( const Scalar& alpha, const VectorBase<Scalar>& x,
268  const Ptr<VectorBase<Scalar> > &y );
269 
270 
276 template<class Scalar>
277 void pair_wise_max_update( const Scalar& alpha, const VectorBase<Scalar>& x,
278  const Ptr<VectorBase<Scalar> > &y );
279 
285 template<class Scalar>
286 void Vt_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
287  const VectorBase<Scalar> &x );
288 
289 
295 template<class Scalar>
296 void ele_wise_divide( const Scalar& alpha, const VectorBase<Scalar>& x,
297  const VectorBase<Scalar>& v, const Ptr<VectorBase<Scalar> > &y );
298 
299 
322 template<class Scalar>
323 void linear_combination(
324  const ArrayView<const Scalar> &alpha,
325  const ArrayView<const Ptr<const VectorBase<Scalar> > > &x,
326  const Scalar &beta,
327  const Ptr<VectorBase<Scalar> > &y
328  );
329 
330 
340 template<class Scalar>
341 void seed_randomize( unsigned int s );
342 
343 
354 template<class Scalar>
355 void randomize( Scalar l, Scalar u, const Ptr<VectorBase<Scalar> > &v );
356 
357 
363 template<class Scalar>
364 void assign( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
365 
366 
372 template<class Scalar>
373 void assign( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
374 
375 
381 template<class Scalar>
382 void Vp_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
383 
384 
394 template<class Scalar>
395 void Vt_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
396 
397 
403 template<class Scalar>
404 void V_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
405  const VectorBase<Scalar> &x );
406 
407 
413 template<class Scalar>
414 void Vp_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
415  const VectorBase<Scalar>& x );
416 
417 
422 template<class Scalar>
423 void Vp_V(
424  const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x,
425  const Scalar& beta = static_cast<Scalar>(1.0)
426  );
427 
428 
433 template<class Scalar>
434 void V_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x );
435 
436 
441 template<class Scalar>
442 void V_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha );
443 
444 
449 template<class Scalar>
450 void V_VpV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
451  const VectorBase<Scalar>& y );
452 
453 
458 template<class Scalar>
459 void V_VmV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
460  const VectorBase<Scalar>& y );
461 
462 
467 template<class Scalar>
468 void V_StVpV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
469  const VectorBase<Scalar>& x, const VectorBase<Scalar>& y );
470 
471 
476 template<class Scalar>
477 void V_VpStV( const Ptr<VectorBase<Scalar> > &z,
478  const VectorBase<Scalar>& x,
479  const Scalar &alpha, const VectorBase<Scalar>& y );
480 
481 
486 template<class Scalar>
487 void V_StVpStV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
488  const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y );
489 
490 
495 template<class Scalar>
496 Scalar min( const VectorBase<Scalar>& x );
497 
498 
518 template<class Scalar>
519 void min( const VectorBase<Scalar>& x,
520  const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex );
521 
522 
552 template<class Scalar>
553 void minGreaterThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
554  const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex );
555 
556 
561 template<class Scalar>
562 Scalar max( const VectorBase<Scalar>& x );
563 
564 
584 template<class Scalar>
585 void max( const VectorBase<Scalar>& x,
586  const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex );
587 
588 
617 template<class Scalar>
618 void maxLessThanBound( const VectorBase<Scalar>& x, const Scalar &bound,
619  const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex );
620 
621 
622 
623 
624 } // end namespace Thyra
625 
626 
627 // /////////////////////////
628 // Inline functions
629 
630 
631 template<class Scalar>
632 inline
633 Scalar Thyra::scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
634 {
635  return x.space()->scalarProd(x, y);
636 }
637 
638 
639 template<class Scalar>
640 inline
641 Scalar Thyra::inner( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y )
642 {
643  return x.space()->scalarProd(x, y);
644 }
645 
646 
647 template<class Scalar>
648 inline
650 Thyra::norm( const VectorBase<Scalar>& v )
651 {
653  return ST::magnitude(ST::squareroot(v.space()->scalarProd(v, v)));
654 }
655 
656 
657 #endif // THYRA_VECTOR_STD_OPS_DECL_HPP
KOKKOS_INLINE_FUNCTION RealType abs(const complex< RealType > &x)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.