Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_VectorStdOps_def.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 #ifndef THYRA_VECTOR_STD_OPS_HPP
43 #define THYRA_VECTOR_STD_OPS_HPP
44 
45 #include "Thyra_VectorStdOps_decl.hpp"
46 #include "Thyra_VectorSpaceBase.hpp"
47 #include "Thyra_VectorBase.hpp"
48 #include "RTOpPack_ROpGetElement.hpp"
49 #include "RTOpPack_TOpSetElement.hpp"
50 #include "RTOpPack_ROpMin.hpp"
51 #include "RTOpPack_ROpMinIndex.hpp"
52 #include "RTOpPack_ROpMinIndexGreaterThanBound.hpp"
53 #include "RTOpPack_ROpMax.hpp"
54 #include "RTOpPack_ROpMaxIndex.hpp"
55 #include "RTOpPack_ROpMaxIndexLessThanBound.hpp"
56 #include "RTOpPack_ROpSum.hpp"
57 #include "RTOpPack_TOpAddScalar.hpp"
58 #include "RTOpPack_TOpEleWiseDivide.hpp"
59 #include "RTOpPack_TOpEleWiseProd.hpp"
60 #include "RTOpPack_TOpPairWiseMax.hpp"
61 #include "RTOpPack_TOpEleWiseConjProd.hpp"
62 #include "RTOpPack_TOpEleWiseProdUpdate.hpp"
63 #include "RTOpPack_TOpPairWiseMaxUpdate.hpp"
64 #include "RTOpPack_TOpRandomize.hpp"
65 #include "Teuchos_Assert.hpp"
66 #include "Teuchos_Assert.hpp"
67 
68 
69 //
70 // All scalar types
71 //
72 
73 
74 // Standard text names
75 
76 
77 // Reduction operations
78 
79 
80 template<class Scalar>
81 Scalar Thyra::sum( const VectorBase<Scalar>& v_rhs )
82 {
83  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
84  RTOpPack::ROpSum<Scalar> sum_op;
85  Teuchos::RCP<RTOpPack::ReductTarget> sum_targ = sum_op.reduct_obj_create();
86  applyOp<Scalar>(sum_op,
87  tuple(ptrInArg(v_rhs)),
88  ArrayView<Ptr<VectorBase<Scalar> > >(null),
89  sum_targ.ptr() );
90  return sum_op(*sum_targ);
91 }
92 
93 
94 template<class Scalar>
96 Thyra::norm_1( const VectorBase<Scalar>& v_rhs )
97 {
98  return v_rhs.norm_1();
99 }
100 
101 
102 template<class Scalar>
104 Thyra::norm_2( const VectorBase<Scalar>& v_rhs )
105 {
106  return v_rhs.norm_2();
107 }
108 
109 
110 template<class Scalar>
112 Thyra::norm_2( const VectorBase<Scalar>& w, const VectorBase<Scalar>& v )
113 {
114  return v.norm_2(w);
115 }
116 
117 
118 template<class Scalar>
120 Thyra::norm_inf( const VectorBase<Scalar>& v_rhs )
121 {
122  return v_rhs.norm_inf();
123 }
124 
125 
126 template<class Scalar>
127 Scalar Thyra::dot( const VectorBase<Scalar>& v_rhs1, const VectorBase<Scalar>& v_rhs2 )
128 {
129  return v_rhs2.dot(v_rhs1);
130 }
131 
132 
133 template<class Scalar>
134 Scalar Thyra::get_ele( const VectorBase<Scalar>& v, Ordinal i )
135 {
136  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
137 #ifdef THYRA_DEBUG
138  TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(i, 0, v.space()->dim());
139 #endif
140  RTOpPack::ROpGetElement<Scalar> get_ele_op(i);
141  Teuchos::RCP<RTOpPack::ReductTarget> get_ele_targ = get_ele_op.reduct_obj_create();
142  applyOp<Scalar>(get_ele_op, tuple(ptrInArg(v)),
143  ArrayView<Ptr<VectorBase<Scalar> > >(null),
144  get_ele_targ.ptr() );
145  return get_ele_op(*get_ele_targ);
146 }
147 
148 
149 // Transformation operations
150 
151 
152 template<class Scalar>
153 void Thyra::set_ele( Ordinal i, Scalar alpha, const Ptr<VectorBase<Scalar> > &v )
154 {
155  using Teuchos::tuple; using Teuchos::null;
156 #ifdef THYRA_DEBUG
157  TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(i, 0, v->space()->dim());
158 #endif
159  RTOpPack::TOpSetElement<Scalar> set_ele_op(i, alpha);
160  applyOp<Scalar>(set_ele_op,
161  ArrayView<Ptr<const VectorBase<Scalar> > >(null),
162  tuple(v),
163  null);
164 }
165 
166 
167 template<class Scalar>
168 void Thyra::put_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
169 {
170  v_lhs->assign(alpha);
171 }
172 
173 
174 template<class Scalar>
175 void Thyra::copy( const VectorBase<Scalar>& v_rhs,
176  const Ptr<VectorBase<Scalar> > &v_lhs )
177 {
178  v_lhs->assign(v_rhs);
179 }
180 
181 
182 template<class Scalar>
183 void Thyra::add_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
184 {
185  using Teuchos::tuple; using Teuchos::null;
186  RTOpPack::TOpAddScalar<Scalar> add_scalar_op(alpha);
187  applyOp<Scalar>(add_scalar_op,
188  ArrayView<Ptr<const VectorBase<Scalar> > >(null),
189  tuple(v_lhs), null );
190 }
191 
192 
193 template<class Scalar>
194 void Thyra::scale( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
195 {
196  v_lhs->scale(alpha);
197 }
198 
199 
200 template<class Scalar>
201 void Thyra::abs( const VectorBase<Scalar>& x, const Ptr<VectorBase<Scalar> > &y )
202 {
203  y->abs(x);
204 }
205 
206 
207 template<class Scalar>
208 void Thyra::reciprocal( const VectorBase<Scalar>& x, const Ptr<VectorBase<Scalar> > &y )
209 {
210  y->reciprocal(x);
211 }
212 
213 
214 template<class Scalar>
215 void Thyra::ele_wise_prod(
216  const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
217  const VectorBase<Scalar>& v_rhs2, const Ptr<VectorBase<Scalar> > &v_lhs
218  )
219 {
220  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
221  RTOpPack::TOpEleWiseProd<Scalar> ele_wise_prod_op(alpha);
222  applyOp<Scalar>( ele_wise_prod_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
223  tuple(v_lhs), null );
224 }
225 
226 template<class Scalar>
227 void Thyra::pair_wise_max(
228  const Scalar &alpha, const VectorBase<Scalar>& v_rhs1,
229  const VectorBase<Scalar>& v_rhs2, const Ptr<VectorBase<Scalar> > &v_lhs
230  )
231 {
232  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
233  RTOpPack::TOpPairWiseMax<Scalar> pair_wise_max_op(alpha);
234  applyOp<Scalar>( pair_wise_max_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
235  tuple(v_lhs), null );
236 }
237 
238 
239 template<class Scalar>
240 void Thyra::ele_wise_conj_prod(
241  const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
242  const VectorBase<Scalar>& v_rhs2, const Ptr<VectorBase<Scalar> > &v_lhs
243  )
244 {
245  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
246  RTOpPack::TOpEleWiseConjProd<Scalar> ele_wise_conj_prod_op(alpha);
247  applyOp<Scalar>( ele_wise_conj_prod_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
248  tuple(v_lhs), null );
249 }
250 
251 
252 template<class Scalar>
253 void Thyra::ele_wise_scale( const VectorBase<Scalar>& x,
254  const Ptr<VectorBase<Scalar> > &y )
255 {
256  y->ele_wise_scale(x);
257 }
258 
259 
260 template<class Scalar>
261 void Thyra::Vp_StVtV(
262  const Ptr<VectorBase<Scalar> > &v_lhs,
263  const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
264  const VectorBase<Scalar>& v_rhs2
265  )
266 {
267  ele_wise_prod(alpha,v_rhs1,v_rhs2,v_lhs);
268 }
269 
270 
271 template<class Scalar>
272 void Thyra::ele_wise_prod_update(
273  const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
274  const Ptr<VectorBase<Scalar> > &v_lhs
275  )
276 {
277  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
278  RTOpPack::TOpEleWiseProdUpdate<Scalar> ele_wise_prod_update_op(alpha);
279  applyOp<Scalar>( ele_wise_prod_update_op, tuple(ptrInArg(v_rhs1)),
280  tuple(v_lhs), null );
281 }
282 
283 
284 template<class Scalar>
285 void Thyra::pair_wise_max_update(
286  const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
287  const Ptr<VectorBase<Scalar> > &v_lhs
288  )
289 {
290  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
291  RTOpPack::TOpPairWiseMaxUpdate<Scalar> pair_wise_max_update_op(alpha);
292  applyOp<Scalar>( pair_wise_max_update_op, tuple(ptrInArg(v_rhs1)),
293  tuple(v_lhs), null );
294 }
295 
296 
297 
298 template<class Scalar>
299 void Thyra::Vt_StV(
300  const Ptr<VectorBase<Scalar> > &v_lhs,
301  const Scalar& alpha, const VectorBase<Scalar>& x )
302 {
303  ele_wise_prod_update(alpha,x,v_lhs);
304 }
305 
306 
307 template<class Scalar>
308 void Thyra::ele_wise_divide(
309  const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
310  const VectorBase<Scalar>& v_rhs2,
311  const Ptr<VectorBase<Scalar> > &v_lhs
312  )
313 {
314  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
315  RTOpPack::TOpEleWiseDivide<Scalar> ele_wise_divide_op(alpha);
316  applyOp<Scalar>( ele_wise_divide_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
317  tuple(v_lhs), null );
318 }
319 
320 
321 template<class Scalar>
322 void Thyra::linear_combination(
323  const ArrayView<const Scalar> &alpha,
324  const ArrayView<const Ptr<const VectorBase<Scalar> > > &x,
325  const Scalar &beta,
326  const Ptr<VectorBase<Scalar> > &y
327  )
328 {
329  y->linear_combination(alpha, x, beta);
330 }
331 
332 
333 template<class Scalar>
334 void Thyra::seed_randomize( unsigned int s )
335 {
337 }
338 
339 
340 template<class Scalar>
341 void Thyra::randomize( Scalar l, Scalar u, const Ptr<VectorBase<Scalar> > &v )
342 {
343  v->randomize(l, u);
344  // Warning! If the RTOpPack::TOpRandomize<Scalar> object is ever made
345  // static, the one must be careful to change the seed in between calls.
346  // Right now the seed is being incremented by the constructor automatically.
347  // It is important to generate different random vectors on each call
348  // (i.e. to generate different columns in a multi-vector).
349 }
350 
351 
352 // Linear algebra names
353 
354 
355 template<class Scalar>
356 void Thyra::assign( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
357 {
358  put_scalar(alpha,v_lhs);
359 }
360 
361 
362 template<class Scalar>
363 void Thyra::assign( const Ptr<VectorBase<Scalar> > &v_lhs, const VectorBase<Scalar>& v_rhs )
364 {
365  copy(v_rhs,v_lhs);
366 }
367 
368 
369 template<class Scalar>
370 void Thyra::Vp_S( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
371 {
372  add_scalar(alpha,v_lhs);
373 }
374 
375 
376 template<class Scalar>
377 void Thyra::Vt_S( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
378 {
379  scale(alpha,v_lhs);
380 }
381 
382 
383 template<class Scalar>
384 void Thyra::V_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
385  const VectorBase<Scalar> &x
386  )
387 {
388  using Teuchos::tuple; using Teuchos::ptrInArg;
389  linear_combination<Scalar>( tuple<Scalar>(alpha), tuple(ptrInArg(x)),
391 }
392 
393 
394 template<class Scalar>
395 void Thyra::Vp_StV( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha,
396  const VectorBase<Scalar>& v_rhs
397  )
398 {
399  v_lhs->update(alpha, v_rhs);
400 }
401 
402 
403 template<class Scalar>
404 void Thyra::Vp_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x,
405  const Scalar& beta
406  )
407 {
408  using Teuchos::tuple; using Teuchos::ptrInArg;
409  linear_combination<Scalar>(
410  tuple<Scalar>(Teuchos::ScalarTraits<Scalar>::one()),
411  tuple(ptrInArg(x)),
412  beta, y );
413 }
414 
415 
416 template<class Scalar>
417 void Thyra::V_V( const Ptr<VectorBase<Scalar> > &y, const VectorBase<Scalar>& x )
418 {
419  assign(y,x);
420 }
421 
422 
423 template<class Scalar>
424 void Thyra::V_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha )
425 {
426  assign(y,alpha);
427 }
428 
429 
430 template<class Scalar>
431 void Thyra::V_VpV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
432  const VectorBase<Scalar>& y
433  )
434 {
435  using Teuchos::tuple; using Teuchos::ptrInArg;
437  linear_combination<Scalar>(
438  tuple(ST::one(),ST::one()),
439  tuple(ptrInArg(x),ptrInArg(y)),
440  ST::zero(), z
441  );
442 }
443 
444 
445 template<class Scalar>
446 void Thyra::V_VmV( const Ptr<VectorBase<Scalar> > &z, const VectorBase<Scalar>& x,
447  const VectorBase<Scalar>& y
448  )
449 {
450  using Teuchos::tuple; using Teuchos::ptrInArg;
452  linear_combination<Scalar>(
453  tuple(ST::one(),Scalar(-ST::one())),
454  tuple(ptrInArg(x),ptrInArg(y)),
455  ST::zero(), z
456  );
457 }
458 
459 
460 template<class Scalar>
461 void Thyra::V_StVpV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
462  const VectorBase<Scalar>& x, const VectorBase<Scalar>& y
463  )
464 {
465  using Teuchos::tuple; using Teuchos::ptrInArg;
467  linear_combination<Scalar>(
468  tuple(alpha, ST::one()), tuple(ptrInArg(x),ptrInArg(y)),
469  ST::zero(), z
470  );
471 }
472 
473 
474 template<class Scalar>
475 void Thyra::V_VpStV( const Ptr<VectorBase<Scalar> > &z,
476  const VectorBase<Scalar>& x,
477  const Scalar &alpha, const VectorBase<Scalar>& y )
478 {
479  using Teuchos::tuple; using Teuchos::ptrInArg;
481  linear_combination<Scalar>(
482  tuple(ST::one(), alpha), tuple(ptrInArg(x),ptrInArg(y)),
483  ST::zero(), z
484  );
485 }
486 
487 
488 template<class Scalar>
489 void Thyra::V_StVpStV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
490  const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y
491  )
492 {
493  using Teuchos::tuple; using Teuchos::ptrInArg;
495  linear_combination<Scalar>(
496  tuple(alpha, beta), tuple(ptrInArg(x),ptrInArg(y)),
497  ST::zero(), z
498  );
499 }
500 
501 
502 //
503 // For real types only
504 //
505 
506 
507 template<class Scalar>
508 Scalar Thyra::min( const VectorBase<Scalar>& x ) {
509  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
510  RTOpPack::ROpMin<Scalar> min_op;
511  Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
512  applyOp<Scalar>( min_op, tuple(ptrInArg(x)),
513  ArrayView<const Ptr<VectorBase<Scalar> > >(null),
514  min_targ.ptr() );
515  return min_op(*min_targ);
516 }
517 
518 
519 template<class Scalar>
520 void Thyra::min( const VectorBase<Scalar>& x,
521  const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex
522  )
523 {
524  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
527  applyOp<Scalar>( min_op, tuple(ptrInArg(x)),
528  ArrayView<const Ptr<VectorBase<Scalar> > >(null),
529  min_targ.ptr() );
530  RTOpPack::ScalarIndex<Scalar> scalarIndex = min_op(*min_targ);
531  *minEle = scalarIndex.scalar;
532  *minIndex = scalarIndex.index;
533 }
534 
535 
536 template<class Scalar>
537 void Thyra::minGreaterThanBound( const VectorBase<Scalar>& x,
538  const Scalar &bound, const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex
539  )
540 {
541  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
543  Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
544  applyOp<Scalar>( min_op, tuple(ptrInArg(x)),
545  ArrayView<const Ptr<VectorBase<Scalar> > >(null),
546  min_targ.ptr() );
547  RTOpPack::ScalarIndex<Scalar> scalarIndex = min_op(*min_targ);
548  *minEle = scalarIndex.scalar;
549  *minIndex = scalarIndex.index;
550 }
551 
552 
553 template<class Scalar>
554 Scalar Thyra::max( const VectorBase<Scalar>& x )
555 {
556  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
557  RTOpPack::ROpMax<Scalar> max_op;
558  Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
559  applyOp<Scalar>( max_op, tuple(ptrInArg(x)),
560  ArrayView<const Ptr<VectorBase<Scalar> > >(null),
561  max_targ.ptr() );
562  return max_op(*max_targ);
563 }
564 
565 
566 template<class Scalar>
567 void Thyra::max( const VectorBase<Scalar>& x,
568  const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex
569  )
570 {
571  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
574  applyOp<Scalar>( max_op, tuple(ptrInArg(x)),
575  ArrayView<const Ptr<VectorBase<Scalar> > >(null),
576  max_targ.ptr() );
577  RTOpPack::ScalarIndex<Scalar> scalarIndex = max_op(*max_targ);
578  *maxEle = scalarIndex.scalar;
579  *maxIndex = scalarIndex.index;
580 }
581 
582 
583 template<class Scalar>
584 void Thyra::maxLessThanBound( const VectorBase<Scalar>& x,
585  const Scalar &bound, const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex
586  )
587 {
588  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
590  Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
591  applyOp<Scalar>( max_op, tuple(ptrInArg(x)),
592  ArrayView<const Ptr<VectorBase<Scalar> > >(null),
593  max_targ.ptr() );
594  RTOpPack::ScalarIndex<Scalar> scalarIndex = max_op(*max_targ);
595  *maxEle = scalarIndex.scalar;
596  *maxIndex = scalarIndex.index;
597 }
598 
599 
600 //
601 // Explicit instantiation macro
602 //
603 
604 
605 #define THYRA_VECTOR_STD_OPS_INSTANT(SCALAR) \
606  \
607  template SCALAR sum( const VectorBase<SCALAR >& v_rhs ); \
608  \
609  template ScalarTraits<SCALAR >::magnitudeType \
610  norm_1( const VectorBase<SCALAR >& v_rhs ); \
611  \
612  template ScalarTraits<SCALAR >::magnitudeType \
613  norm_2( const VectorBase<SCALAR >& v_rhs ); \
614  \
615  template ScalarTraits<SCALAR >::magnitudeType \
616  norm_2( const VectorBase<SCALAR >& w, const VectorBase<SCALAR >& v ); \
617  \
618  template ScalarTraits<SCALAR >::magnitudeType \
619  norm_inf( const VectorBase<SCALAR >& v_rhs ); \
620  \
621  template SCALAR dot( const VectorBase<SCALAR >& v_rhs1, const VectorBase<SCALAR >& v_rhs2 ); \
622  \
623  template SCALAR get_ele( const VectorBase<SCALAR >& v, Ordinal i ); \
624  \
625  template void set_ele( Ordinal i, SCALAR alpha, const Ptr<VectorBase<SCALAR > > &v ); \
626  \
627  template void put_scalar( const SCALAR& alpha, const Ptr<VectorBase<SCALAR > > &v_lhs ); \
628  \
629  template void copy( const VectorBase<SCALAR >& v_rhs, \
630  const Ptr<VectorBase<SCALAR > > &v_lhs ); \
631  \
632  template void add_scalar( const SCALAR& alpha, const Ptr<VectorBase<SCALAR > > &v_lhs ); \
633  \
634  template void scale( const SCALAR& alpha, const Ptr<VectorBase<SCALAR > > &v_lhs ); \
635  \
636  template void abs( const VectorBase< SCALAR > &x, const Ptr<VectorBase< SCALAR > > &y ); \
637  \
638  template void reciprocal( const VectorBase< SCALAR > &x, const Ptr<VectorBase< SCALAR > > &y ); \
639  \
640  template void ele_wise_prod( \
641  const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
642  const VectorBase<SCALAR >& v_rhs2, const Ptr<VectorBase<SCALAR > > &v_lhs \
643  ); \
644  \
645  template void ele_wise_conj_prod( \
646  const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
647  const VectorBase<SCALAR >& v_rhs2, const Ptr<VectorBase<SCALAR > > &v_lhs \
648  ); \
649  \
650  template void ele_wise_scale( const VectorBase<SCALAR>& x, \
651  const Ptr<VectorBase<SCALAR> > &y ); \
652  \
653  template void Vp_StVtV( \
654  const Ptr<VectorBase<SCALAR > > &v_lhs, \
655  const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
656  const VectorBase<SCALAR >& v_rhs2 \
657  ); \
658  \
659  template void ele_wise_prod_update( \
660  const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
661  const Ptr<VectorBase<SCALAR > > &v_lhs \
662  ); \
663  \
664  template void Vt_StV( \
665  const Ptr<VectorBase<SCALAR > > &v_lhs, \
666  const SCALAR& alpha, const VectorBase<SCALAR >& x ); \
667  \
668  template void ele_wise_divide( \
669  const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
670  const VectorBase<SCALAR >& v_rhs2, \
671  const Ptr<VectorBase<SCALAR > > &v_lhs \
672  ); \
673  \
674  template void linear_combination( \
675  const ArrayView<const SCALAR > &alpha, \
676  const ArrayView<const Ptr<const VectorBase<SCALAR > > > &x, \
677  const SCALAR &beta, \
678  const Ptr<VectorBase<SCALAR > > &y \
679  ); \
680  \
681  template void seed_randomize<SCALAR >( unsigned int s ); \
682  \
683  template void randomize( SCALAR l, SCALAR u, const Ptr<VectorBase<SCALAR > > &v ); \
684  \
685  template void assign( const Ptr<VectorBase<SCALAR > > &v_lhs, const SCALAR& alpha ); \
686  \
687  template void assign( const Ptr<VectorBase<SCALAR > > &v_lhs, const VectorBase<SCALAR >& v_rhs ); \
688  \
689  template void Vp_S( const Ptr<VectorBase<SCALAR > > &v_lhs, const SCALAR& alpha ); \
690  \
691  template void Vt_S( const Ptr<VectorBase<SCALAR > > &v_lhs, const SCALAR& alpha ); \
692  \
693  template void V_StV( const Ptr<VectorBase<SCALAR > > &y, const SCALAR& alpha, \
694  const VectorBase<SCALAR > &x \
695  ); \
696  \
697  template void Vp_StV( const Ptr<VectorBase<SCALAR > > &v_lhs, const SCALAR& alpha, \
698  const VectorBase<SCALAR >& v_rhs \
699  ); \
700  \
701  template void Vp_V( const Ptr<VectorBase<SCALAR > > &y, const VectorBase<SCALAR >& x, \
702  const SCALAR& beta \
703  ); \
704  \
705  template void V_V( const Ptr<VectorBase<SCALAR > > &y, const VectorBase<SCALAR >& x ); \
706  \
707  template void V_S( const Ptr<VectorBase<SCALAR > > &y, const SCALAR& alpha ); \
708  \
709  template void V_VpV( const Ptr<VectorBase<SCALAR > > &z, const VectorBase<SCALAR >& x, \
710  const VectorBase<SCALAR >& y \
711  ); \
712  \
713  template void V_VmV( const Ptr<VectorBase<SCALAR > > &z, const VectorBase<SCALAR >& x, \
714  const VectorBase<SCALAR >& y \
715  ); \
716  \
717  template void V_StVpV( const Ptr<VectorBase<SCALAR > > &z, const SCALAR &alpha, \
718  const VectorBase<SCALAR >& x, const VectorBase<SCALAR >& y \
719  ); \
720  \
721  template void V_VpStV( const Ptr<VectorBase<SCALAR > > &z, \
722  const VectorBase<SCALAR >& x, \
723  const SCALAR &alpha, const VectorBase<SCALAR >& y ); \
724  \
725  template void V_StVpStV( const Ptr<VectorBase<SCALAR > > &z, const SCALAR &alpha, \
726  const VectorBase<SCALAR >& x, const SCALAR &beta, const VectorBase<SCALAR >& y \
727  ); \
728 
729 
730 
731 #define THYRA_VECTOR_STD_OPS_REAL_INSTANT(SCALAR) \
732  \
733  template SCALAR min( const VectorBase<SCALAR >& x ); \
734  \
735  template void pair_wise_max( \
736  const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
737  const VectorBase<SCALAR >& v_rhs2, const Ptr<VectorBase<SCALAR > > &v_lhs \
738  ); \
739  \
740  template void pair_wise_max_update( \
741  const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
742  const Ptr<VectorBase<SCALAR > > &v_lhs \
743  ); \
744  \
745  template void min( const VectorBase<SCALAR >& x, \
746  const Ptr<SCALAR > &minEle, const Ptr<Ordinal> &minIndex \
747  ); \
748  \
749  template void minGreaterThanBound( const VectorBase<SCALAR >& x, \
750  const SCALAR &bound, const Ptr<SCALAR > &minEle, const Ptr<Ordinal> &minIndex \
751  ); \
752  \
753  template SCALAR max( const VectorBase<SCALAR >& x ); \
754  \
755  template void max( const VectorBase<SCALAR >& x, \
756  const Ptr<SCALAR > &maxEle, const Ptr<Ordinal> &maxIndex \
757  ); \
758  \
759  template void maxLessThanBound( const VectorBase<SCALAR >& x, \
760  const SCALAR &bound, const Ptr<SCALAR > &maxEle, const Ptr<Ordinal> &maxIndex \
761  ); \
762 
763 
764 #endif // THYRA_VECTOR_STD_OPS_HPP
void put_scalar(const Scalar &alpha, const Ptr< VectorBase< Scalar > > &y)
Assign all elements to a scalar: y(i) = alpha, i = 0...y-&gt;space()-&gt;dim()-1.
void ele_wise_prod_update(const Scalar &alpha, const VectorBase< Scalar > &x, const Ptr< VectorBase< Scalar > > &y)
Element-wise product update: y(i) *= alpha * x(i), i = 0...y-&gt;space()-&gt;dim()-1.
void assign(const Ptr< MultiVectorBase< Scalar > > &V, Scalar alpha)
V = alpha.
void copy(const VectorBase< Scalar > &x, const Ptr< VectorBase< Scalar > > &y)
Vector assignment: y(i) = x(i), i = 0...y-&gt;space()-&gt;dim()-1.
#define TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(index, lower_inclusive, upper_exclusive)
RCP< const LinearOpBase< Scalar > > scale(const Scalar &scalar, const RCP< const LinearOpBase< Scalar > > &Op, const std::string &label="")
Build an implicit const scaled linear operator.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Ptr< T > ptr() const
void add_scalar(const Scalar &alpha, const Ptr< VectorBase< Scalar > > &y)
Add a scalar to all elements: y(i) += alpha, i = 0...y-&gt;space()-&gt;dim()-1.
Teuchos::RCP< ReductTarget > reduct_obj_create() const
static void set_static_seed(const unsigned int static_seed)
void ele_wise_prod(const Scalar &alpha, const VectorBase< Scalar > &x, const VectorBase< Scalar > &v, const Ptr< VectorBase< Scalar > > &y)
Element-wise product update: y(i) += alpha * x(i) * v(i), i = 0...y-&gt;space()-&gt;dim()-1.