Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_VectorStdOps_def.hpp
1// @HEADER
2// *****************************************************************************
3// Thyra: Interfaces and Support for Abstract Numerical Algorithms
4//
5// Copyright 2004 NTESS and the Thyra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef THYRA_VECTOR_STD_OPS_HPP
11#define THYRA_VECTOR_STD_OPS_HPP
12
13#include "Thyra_VectorStdOps_decl.hpp"
14#include "Thyra_VectorSpaceBase.hpp"
15#include "Thyra_VectorBase.hpp"
16#include "RTOpPack_ROpGetElement.hpp"
17#include "RTOpPack_TOpSetElement.hpp"
18#include "RTOpPack_ROpMin.hpp"
19#include "RTOpPack_ROpMinIndex.hpp"
20#include "RTOpPack_ROpMinIndexGreaterThanBound.hpp"
21#include "RTOpPack_ROpMax.hpp"
22#include "RTOpPack_ROpMaxIndex.hpp"
23#include "RTOpPack_ROpMaxIndexLessThanBound.hpp"
24#include "RTOpPack_ROpSum.hpp"
25#include "RTOpPack_TOpAddScalar.hpp"
26#include "RTOpPack_TOpEleWiseDivide.hpp"
27#include "RTOpPack_TOpEleWiseProd.hpp"
28#include "RTOpPack_TOpPairWiseMax.hpp"
29#include "RTOpPack_TOpEleWiseConjProd.hpp"
30#include "RTOpPack_TOpEleWiseProdUpdate.hpp"
31#include "RTOpPack_TOpPairWiseMaxUpdate.hpp"
32#include "RTOpPack_TOpRandomize.hpp"
33#include "Teuchos_Assert.hpp"
34
35
36//
37// All scalar types
38//
39
40
41// Standard text names
42
43
44// Reduction operations
45
46
47template<class Scalar>
48Scalar Thyra::sum( const VectorBase<Scalar>& v_rhs )
49{
50 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
51 RTOpPack::ROpSum<Scalar> sum_op;
52 Teuchos::RCP<RTOpPack::ReductTarget> sum_targ = sum_op.reduct_obj_create();
53 applyOp<Scalar>(sum_op,
54 tuple(ptrInArg(v_rhs)),
56 sum_targ.ptr() );
57 return sum_op(*sum_targ);
58}
59
60
61template<class Scalar>
64{
65 return v_rhs.norm_1();
66}
67
68
69template<class Scalar>
72{
73 return v_rhs.norm_2();
74}
75
76
77template<class Scalar>
80{
81 return v.norm_2(w);
82}
83
84
85template<class Scalar>
88{
89 return v_rhs.norm_inf();
90}
91
92
93template<class Scalar>
94Scalar Thyra::dot( const VectorBase<Scalar>& v_rhs1, const VectorBase<Scalar>& v_rhs2 )
95{
96 return v_rhs2.dot(v_rhs1);
97}
98
99
100template<class Scalar>
101Scalar Thyra::get_ele( const VectorBase<Scalar>& v, Ordinal i )
102{
103 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
104#ifdef THYRA_DEBUG
106#endif
109 applyOp<Scalar>(get_ele_op, tuple(ptrInArg(v)),
111 get_ele_targ.ptr() );
112 return get_ele_op(*get_ele_targ);
113}
114
115
116// Transformation operations
117
118
119template<class Scalar>
120void Thyra::set_ele( Ordinal i, Scalar alpha, const Ptr<VectorBase<Scalar> > &v )
121{
122 using Teuchos::tuple; using Teuchos::null;
123#ifdef THYRA_DEBUG
124 TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(i, 0, v->space()->dim());
125#endif
126 RTOpPack::TOpSetElement<Scalar> set_ele_op(i, alpha);
127 applyOp<Scalar>(set_ele_op,
128 ArrayView<Ptr<const VectorBase<Scalar> > >(null),
129 tuple(v),
130 null);
131}
132
133
134template<class Scalar>
135void Thyra::put_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
136{
137 v_lhs->assign(alpha);
138}
139
140
141template<class Scalar>
143 const Ptr<VectorBase<Scalar> > &v_lhs )
144{
145 v_lhs->assign(v_rhs);
146}
147
148
149template<class Scalar>
150void Thyra::add_scalar( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
151{
152 using Teuchos::tuple; using Teuchos::null;
153 RTOpPack::TOpAddScalar<Scalar> add_scalar_op(alpha);
154 applyOp<Scalar>(add_scalar_op,
155 ArrayView<Ptr<const VectorBase<Scalar> > >(null),
156 tuple(v_lhs), null );
157}
158
159
160template<class Scalar>
161void Thyra::scale( const Scalar& alpha, const Ptr<VectorBase<Scalar> > &v_lhs )
162{
163 v_lhs->scale(alpha);
164}
165
166
167template<class Scalar>
169{
170 y->abs(x);
171}
172
173
174template<class Scalar>
176{
177 y->reciprocal(x);
178}
179
180
181template<class Scalar>
183 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
184 const VectorBase<Scalar>& v_rhs2, const Ptr<VectorBase<Scalar> > &v_lhs
185 )
186{
187 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
188 RTOpPack::TOpEleWiseProd<Scalar> ele_wise_prod_op(alpha);
189 applyOp<Scalar>( ele_wise_prod_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
190 tuple(v_lhs), null );
191}
192
193template<class Scalar>
195 const Scalar &alpha, const VectorBase<Scalar>& v_rhs1,
196 const VectorBase<Scalar>& v_rhs2, const Ptr<VectorBase<Scalar> > &v_lhs
197 )
198{
199 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
200 RTOpPack::TOpPairWiseMax<Scalar> pair_wise_max_op(alpha);
201 applyOp<Scalar>( pair_wise_max_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
202 tuple(v_lhs), null );
203}
204
205
206template<class Scalar>
208 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
209 const VectorBase<Scalar>& v_rhs2, const Ptr<VectorBase<Scalar> > &v_lhs
210 )
211{
212 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
213 RTOpPack::TOpEleWiseConjProd<Scalar> ele_wise_conj_prod_op(alpha);
214 applyOp<Scalar>( ele_wise_conj_prod_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
215 tuple(v_lhs), null );
216}
217
218
219template<class Scalar>
221 const Ptr<VectorBase<Scalar> > &y )
222{
223 y->ele_wise_scale(x);
224}
225
226
227template<class Scalar>
229 const Ptr<VectorBase<Scalar> > &v_lhs,
230 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
231 const VectorBase<Scalar>& v_rhs2
232 )
233{
234 ele_wise_prod(alpha,v_rhs1,v_rhs2,v_lhs);
235}
236
237
238template<class Scalar>
240 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
241 const Ptr<VectorBase<Scalar> > &v_lhs
242 )
243{
244 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
245 RTOpPack::TOpEleWiseProdUpdate<Scalar> ele_wise_prod_update_op(alpha);
246 applyOp<Scalar>( ele_wise_prod_update_op, tuple(ptrInArg(v_rhs1)),
247 tuple(v_lhs), null );
248}
249
250
251template<class Scalar>
253 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
254 const Ptr<VectorBase<Scalar> > &v_lhs
255 )
256{
257 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
258 RTOpPack::TOpPairWiseMaxUpdate<Scalar> pair_wise_max_update_op(alpha);
259 applyOp<Scalar>( pair_wise_max_update_op, tuple(ptrInArg(v_rhs1)),
260 tuple(v_lhs), null );
261}
262
263
264
265template<class Scalar>
267 const Ptr<VectorBase<Scalar> > &v_lhs,
268 const Scalar& alpha, const VectorBase<Scalar>& x )
269{
270 ele_wise_prod_update(alpha,x,v_lhs);
271}
272
273
274template<class Scalar>
276 const Scalar& alpha, const VectorBase<Scalar>& v_rhs1,
277 const VectorBase<Scalar>& v_rhs2,
278 const Ptr<VectorBase<Scalar> > &v_lhs
279 )
280{
281 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
282 RTOpPack::TOpEleWiseDivide<Scalar> ele_wise_divide_op(alpha);
283 applyOp<Scalar>( ele_wise_divide_op, tuple(ptrInArg(v_rhs1),ptrInArg(v_rhs2)),
284 tuple(v_lhs), null );
285}
286
287
288template<class Scalar>
290 const ArrayView<const Scalar> &alpha,
291 const ArrayView<const Ptr<const VectorBase<Scalar> > > &x,
292 const Scalar &beta,
293 const Ptr<VectorBase<Scalar> > &y
294 )
295{
296 y->linear_combination(alpha, x, beta);
297}
298
299
300template<class Scalar>
305
306
307template<class Scalar>
308void Thyra::randomize( Scalar l, Scalar u, const Ptr<VectorBase<Scalar> > &v )
309{
310 v->randomize(l, u);
311 // Warning! If the RTOpPack::TOpRandomize<Scalar> object is ever made
312 // static, the one must be careful to change the seed in between calls.
313 // Right now the seed is being incremented by the constructor automatically.
314 // It is important to generate different random vectors on each call
315 // (i.e. to generate different columns in a multi-vector).
316}
317
318
319// Linear algebra names
320
321
322template<class Scalar>
323void Thyra::assign( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
324{
325 put_scalar(alpha,v_lhs);
326}
327
328
329template<class Scalar>
330void Thyra::assign( const Ptr<VectorBase<Scalar> > &v_lhs, const VectorBase<Scalar>& v_rhs )
331{
332 copy(v_rhs,v_lhs);
333}
334
335
336template<class Scalar>
337void Thyra::Vp_S( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
338{
339 add_scalar(alpha,v_lhs);
340}
341
342
343template<class Scalar>
344void Thyra::Vt_S( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha )
345{
346 scale(alpha,v_lhs);
347}
348
349
350template<class Scalar>
351void Thyra::V_StV( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha,
352 const VectorBase<Scalar> &x
353 )
354{
355 using Teuchos::tuple; using Teuchos::ptrInArg;
356 linear_combination<Scalar>( tuple<Scalar>(alpha), tuple(ptrInArg(x)),
358}
359
360
361template<class Scalar>
362void Thyra::Vp_StV( const Ptr<VectorBase<Scalar> > &v_lhs, const Scalar& alpha,
363 const VectorBase<Scalar>& v_rhs
364 )
365{
366 v_lhs->update(alpha, v_rhs);
367}
368
369
370template<class Scalar>
372 const Scalar& beta
373 )
374{
375 using Teuchos::tuple; using Teuchos::ptrInArg;
377 tuple<Scalar>(Teuchos::ScalarTraits<Scalar>::one()),
378 tuple(ptrInArg(x)),
379 beta, y );
380}
381
382
383template<class Scalar>
385{
386 assign(y,x);
387}
388
389
390template<class Scalar>
391void Thyra::V_S( const Ptr<VectorBase<Scalar> > &y, const Scalar& alpha )
392{
393 assign(y,alpha);
394}
395
396
397template<class Scalar>
399 const VectorBase<Scalar>& y
400 )
401{
402 using Teuchos::tuple; using Teuchos::ptrInArg;
405 tuple(ST::one(),ST::one()),
406 tuple(ptrInArg(x),ptrInArg(y)),
407 ST::zero(), z
408 );
409}
410
411
412template<class Scalar>
414 const VectorBase<Scalar>& y
415 )
416{
417 using Teuchos::tuple; using Teuchos::ptrInArg;
420 tuple(ST::one(),Scalar(-ST::one())),
421 tuple(ptrInArg(x),ptrInArg(y)),
422 ST::zero(), z
423 );
424}
425
426
427template<class Scalar>
428void Thyra::V_StVpV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
429 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y
430 )
431{
432 using Teuchos::tuple; using Teuchos::ptrInArg;
435 tuple(alpha, ST::one()), tuple(ptrInArg(x),ptrInArg(y)),
436 ST::zero(), z
437 );
438}
439
440
441template<class Scalar>
443 const VectorBase<Scalar>& x,
444 const Scalar &alpha, const VectorBase<Scalar>& y )
445{
446 using Teuchos::tuple; using Teuchos::ptrInArg;
449 tuple(ST::one(), alpha), tuple(ptrInArg(x),ptrInArg(y)),
450 ST::zero(), z
451 );
452}
453
454
455template<class Scalar>
456void Thyra::V_StVpStV( const Ptr<VectorBase<Scalar> > &z, const Scalar &alpha,
457 const VectorBase<Scalar>& x, const Scalar &beta, const VectorBase<Scalar>& y
458 )
459{
460 using Teuchos::tuple; using Teuchos::ptrInArg;
463 tuple(alpha, beta), tuple(ptrInArg(x),ptrInArg(y)),
464 ST::zero(), z
465 );
466}
467
468
469//
470// For real types only
471//
472
473
474template<class Scalar>
475Scalar Thyra::min( const VectorBase<Scalar>& x ) {
476 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
477 RTOpPack::ROpMin<Scalar> min_op;
478 Teuchos::RCP<RTOpPack::ReductTarget> min_targ = min_op.reduct_obj_create();
479 applyOp<Scalar>( min_op, tuple(ptrInArg(x)),
480 ArrayView<const Ptr<VectorBase<Scalar> > >(null),
481 min_targ.ptr() );
482 return min_op(*min_targ);
483}
484
485
486template<class Scalar>
488 const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex
489 )
490{
491 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
494 applyOp<Scalar>( min_op, tuple(ptrInArg(x)),
495 ArrayView<const Ptr<VectorBase<Scalar> > >(null),
496 min_targ.ptr() );
497 RTOpPack::ScalarIndex<Scalar> scalarIndex = min_op(*min_targ);
498 *minEle = scalarIndex.scalar;
499 *minIndex = scalarIndex.index;
500}
501
502
503template<class Scalar>
505 const Scalar &bound, const Ptr<Scalar> &minEle, const Ptr<Ordinal> &minIndex
506 )
507{
508 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
511 applyOp<Scalar>( min_op, tuple(ptrInArg(x)),
512 ArrayView<const Ptr<VectorBase<Scalar> > >(null),
513 min_targ.ptr() );
514 RTOpPack::ScalarIndex<Scalar> scalarIndex = min_op(*min_targ);
515 *minEle = scalarIndex.scalar;
516 *minIndex = scalarIndex.index;
517}
518
519
520template<class Scalar>
522{
523 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
524 RTOpPack::ROpMax<Scalar> max_op;
525 Teuchos::RCP<RTOpPack::ReductTarget> max_targ = max_op.reduct_obj_create();
526 applyOp<Scalar>( max_op, tuple(ptrInArg(x)),
527 ArrayView<const Ptr<VectorBase<Scalar> > >(null),
528 max_targ.ptr() );
529 return max_op(*max_targ);
530}
531
532
533template<class Scalar>
535 const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex
536 )
537{
538 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
541 applyOp<Scalar>( max_op, tuple(ptrInArg(x)),
542 ArrayView<const Ptr<VectorBase<Scalar> > >(null),
543 max_targ.ptr() );
544 RTOpPack::ScalarIndex<Scalar> scalarIndex = max_op(*max_targ);
545 *maxEle = scalarIndex.scalar;
546 *maxIndex = scalarIndex.index;
547}
548
549
550template<class Scalar>
552 const Scalar &bound, const Ptr<Scalar> &maxEle, const Ptr<Ordinal> &maxIndex
553 )
554{
555 using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
558 applyOp<Scalar>( max_op, tuple(ptrInArg(x)),
559 ArrayView<const Ptr<VectorBase<Scalar> > >(null),
560 max_targ.ptr() );
561 RTOpPack::ScalarIndex<Scalar> scalarIndex = max_op(*max_targ);
562 *maxEle = scalarIndex.scalar;
563 *maxIndex = scalarIndex.index;
564}
565
566
567//
568// Explicit instantiation macro
569//
570
571
572#define THYRA_VECTOR_STD_OPS_INSTANT(SCALAR) \
573 \
574 template SCALAR sum( const VectorBase<SCALAR >& v_rhs ); \
575 \
576 template ScalarTraits<SCALAR >::magnitudeType \
577 norm_1( const VectorBase<SCALAR >& v_rhs ); \
578 \
579 template ScalarTraits<SCALAR >::magnitudeType \
580 norm_2( const VectorBase<SCALAR >& v_rhs ); \
581 \
582 template ScalarTraits<SCALAR >::magnitudeType \
583 norm_2( const VectorBase<SCALAR >& w, const VectorBase<SCALAR >& v ); \
584 \
585 template ScalarTraits<SCALAR >::magnitudeType \
586 norm_inf( const VectorBase<SCALAR >& v_rhs ); \
587 \
588 template SCALAR dot( const VectorBase<SCALAR >& v_rhs1, const VectorBase<SCALAR >& v_rhs2 ); \
589 \
590 template SCALAR get_ele( const VectorBase<SCALAR >& v, Ordinal i ); \
591 \
592 template void set_ele( Ordinal i, SCALAR alpha, const Ptr<VectorBase<SCALAR > > &v ); \
593 \
594 template void put_scalar( const SCALAR& alpha, const Ptr<VectorBase<SCALAR > > &v_lhs ); \
595 \
596 template void copy( const VectorBase<SCALAR >& v_rhs, \
597 const Ptr<VectorBase<SCALAR > > &v_lhs ); \
598 \
599 template void add_scalar( const SCALAR& alpha, const Ptr<VectorBase<SCALAR > > &v_lhs ); \
600 \
601 template void scale( const SCALAR& alpha, const Ptr<VectorBase<SCALAR > > &v_lhs ); \
602 \
603 template void abs( const VectorBase< SCALAR > &x, const Ptr<VectorBase< SCALAR > > &y ); \
604 \
605 template void reciprocal( const VectorBase< SCALAR > &x, const Ptr<VectorBase< SCALAR > > &y ); \
606 \
607 template void ele_wise_prod( \
608 const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
609 const VectorBase<SCALAR >& v_rhs2, const Ptr<VectorBase<SCALAR > > &v_lhs \
610 ); \
611 \
612 template void ele_wise_conj_prod( \
613 const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
614 const VectorBase<SCALAR >& v_rhs2, const Ptr<VectorBase<SCALAR > > &v_lhs \
615 ); \
616 \
617 template void ele_wise_scale( const VectorBase<SCALAR>& x, \
618 const Ptr<VectorBase<SCALAR> > &y ); \
619 \
620 template void Vp_StVtV( \
621 const Ptr<VectorBase<SCALAR > > &v_lhs, \
622 const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
623 const VectorBase<SCALAR >& v_rhs2 \
624 ); \
625 \
626 template void ele_wise_prod_update( \
627 const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
628 const Ptr<VectorBase<SCALAR > > &v_lhs \
629 ); \
630 \
631 template void Vt_StV( \
632 const Ptr<VectorBase<SCALAR > > &v_lhs, \
633 const SCALAR& alpha, const VectorBase<SCALAR >& x ); \
634 \
635 template void ele_wise_divide( \
636 const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
637 const VectorBase<SCALAR >& v_rhs2, \
638 const Ptr<VectorBase<SCALAR > > &v_lhs \
639 ); \
640 \
641 template void linear_combination( \
642 const ArrayView<const SCALAR > &alpha, \
643 const ArrayView<const Ptr<const VectorBase<SCALAR > > > &x, \
644 const SCALAR &beta, \
645 const Ptr<VectorBase<SCALAR > > &y \
646 ); \
647 \
648 template void seed_randomize<SCALAR >( unsigned int s ); \
649 \
650 template void randomize( SCALAR l, SCALAR u, const Ptr<VectorBase<SCALAR > > &v ); \
651 \
652 template void assign( const Ptr<VectorBase<SCALAR > > &v_lhs, const SCALAR& alpha ); \
653 \
654 template void assign( const Ptr<VectorBase<SCALAR > > &v_lhs, const VectorBase<SCALAR >& v_rhs ); \
655 \
656 template void Vp_S( const Ptr<VectorBase<SCALAR > > &v_lhs, const SCALAR& alpha ); \
657 \
658 template void Vt_S( const Ptr<VectorBase<SCALAR > > &v_lhs, const SCALAR& alpha ); \
659 \
660 template void V_StV( const Ptr<VectorBase<SCALAR > > &y, const SCALAR& alpha, \
661 const VectorBase<SCALAR > &x \
662 ); \
663 \
664 template void Vp_StV( const Ptr<VectorBase<SCALAR > > &v_lhs, const SCALAR& alpha, \
665 const VectorBase<SCALAR >& v_rhs \
666 ); \
667 \
668 template void Vp_V( const Ptr<VectorBase<SCALAR > > &y, const VectorBase<SCALAR >& x, \
669 const SCALAR& beta \
670 ); \
671 \
672 template void V_V( const Ptr<VectorBase<SCALAR > > &y, const VectorBase<SCALAR >& x ); \
673 \
674 template void V_S( const Ptr<VectorBase<SCALAR > > &y, const SCALAR& alpha ); \
675 \
676 template void V_VpV( const Ptr<VectorBase<SCALAR > > &z, const VectorBase<SCALAR >& x, \
677 const VectorBase<SCALAR >& y \
678 ); \
679 \
680 template void V_VmV( const Ptr<VectorBase<SCALAR > > &z, const VectorBase<SCALAR >& x, \
681 const VectorBase<SCALAR >& y \
682 ); \
683 \
684 template void V_StVpV( const Ptr<VectorBase<SCALAR > > &z, const SCALAR &alpha, \
685 const VectorBase<SCALAR >& x, const VectorBase<SCALAR >& y \
686 ); \
687 \
688 template void V_VpStV( const Ptr<VectorBase<SCALAR > > &z, \
689 const VectorBase<SCALAR >& x, \
690 const SCALAR &alpha, const VectorBase<SCALAR >& y ); \
691 \
692 template void V_StVpStV( const Ptr<VectorBase<SCALAR > > &z, const SCALAR &alpha, \
693 const VectorBase<SCALAR >& x, const SCALAR &beta, const VectorBase<SCALAR >& y \
694 ); \
695
696
697
698#define THYRA_VECTOR_STD_OPS_REAL_INSTANT(SCALAR) \
699 \
700 template SCALAR min( const VectorBase<SCALAR >& x ); \
701 \
702 template void pair_wise_max( \
703 const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
704 const VectorBase<SCALAR >& v_rhs2, const Ptr<VectorBase<SCALAR > > &v_lhs \
705 ); \
706 \
707 template void pair_wise_max_update( \
708 const SCALAR& alpha, const VectorBase<SCALAR >& v_rhs1, \
709 const Ptr<VectorBase<SCALAR > > &v_lhs \
710 ); \
711 \
712 template void min( const VectorBase<SCALAR >& x, \
713 const Ptr<SCALAR > &minEle, const Ptr<Ordinal> &minIndex \
714 ); \
715 \
716 template void minGreaterThanBound( const VectorBase<SCALAR >& x, \
717 const SCALAR &bound, const Ptr<SCALAR > &minEle, const Ptr<Ordinal> &minIndex \
718 ); \
719 \
720 template SCALAR max( const VectorBase<SCALAR >& x ); \
721 \
722 template void max( const VectorBase<SCALAR >& x, \
723 const Ptr<SCALAR > &maxEle, const Ptr<Ordinal> &maxIndex \
724 ); \
725 \
726 template void maxLessThanBound( const VectorBase<SCALAR >& x, \
727 const SCALAR &bound, const Ptr<SCALAR > &maxEle, const Ptr<Ordinal> &maxIndex \
728 ); \
729
730
731#endif // THYRA_VECTOR_STD_OPS_HPP
Teuchos::RCP< ReductTarget > reduct_obj_create() const
static void set_static_seed(const unsigned int static_seed)
Ptr< T > ptr() const
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.
void assign(const Ptr< MultiVectorBase< Scalar > > &V, Scalar alpha)
V = alpha.
void randomize(Scalar l, Scalar u, const Ptr< MultiVectorBase< Scalar > > &V)
Generate a random multi-vector with elements uniformly distributed elements.
void V_VpV(const Ptr< MultiVectorBase< Scalar > > &Z, const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y)
Z(i,j) = X(i,j) + Y(i,j), i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void Vt_S(const Ptr< MultiVectorBase< Scalar > > &Z, const Scalar &alpha)
Z(i,j) *= alpha, i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
ScalarTraits< Scalar >::magnitudeType norm_1(const MultiVectorBase< Scalar > &V)
Take the induced matrix one norm of a multi-vector.
void V_VmV(const Ptr< MultiVectorBase< Scalar > > &Z, const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y)
Z(i,j) = X(i,j) - Y(i,j), i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void linear_combination(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &X, const Scalar &beta, const Ptr< MultiVectorBase< Scalar > > &Y)
Y.col(j)(i) = beta*Y.col(j)(i) + sum( alpha[k]*X[k].col(j)(i), k=0...m-1 ), for i = 0....
void V_StVpV(const Ptr< MultiVectorBase< Scalar > > &Z, const Scalar &alpha, const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y)
Z(i,j) = alpha*X(i,j) + Y(i), i = 0...z->space()->dim()-1, , j = 0...Z->domain()->dim()-1.
void Vp_V(const Ptr< MultiVectorBase< Scalar > > &Z, const MultiVectorBase< Scalar > &X)
Z(i,j) += X(i,j), i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void Vp_S(const Ptr< MultiVectorBase< Scalar > > &Z, const Scalar &alpha)
Z(i,j) += alpha, i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
Abstract interface for finite-dimensional dense vectors.
void ele_wise_divide(const Scalar &alpha, const VectorBase< Scalar > &x, const VectorBase< Scalar > &v, const Ptr< VectorBase< Scalar > > &y)
Element-wise division update: y(i) += alpha * x(i) / v(i), i = 0...y->space()->dim()-1.
void scale(const Scalar &alpha, const Ptr< VectorBase< Scalar > > &y)
Scale all elements by a scalar: y(i) *= alpha, i = 0...y->space()->dim()-1.
void maxLessThanBound(const VectorBase< Scalar > &x, const Scalar &bound, const Ptr< Scalar > &maxEle, const Ptr< Ordinal > &maxIndex)
Max element less than bound and its index: Returns maxEle = x(k) and maxIndex = k such that x(k) >= x...
void abs(const VectorBase< Scalar > &x, const Ptr< VectorBase< Scalar > > &y)
Element-wise absolute value: y(i) = abs(x(i)), i = 0...y->space()->dim()-1.
void pair_wise_max_update(const Scalar &alpha, const VectorBase< Scalar > &x, const Ptr< VectorBase< Scalar > > &y)
Element-wise maximum update: y(i) = alpha * max(x(i), y(i)), i = 0...y->space()->dim()-1.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm_1() const
One (1) norm: result = ||v||1.
void Vp_StV(const Ptr< VectorBase< Scalar > > &y, const Scalar &alpha, const VectorBase< Scalar > &x)
AXPY: y(i) = alpha * x(i) + y(i), i = 0...y->space()->dim()-1.
void V_VpStV(const Ptr< VectorBase< Scalar > > &z, const VectorBase< Scalar > &x, const Scalar &alpha, const VectorBase< Scalar > &y)
z(i) = x(i) + alpha*y(i), i = 0...z->space()->dim()-1.
void set_ele(Ordinal i, Scalar alpha, const Ptr< VectorBase< Scalar > > &v)
Set single element: v(i) = alpha.
Scalar dot(const VectorBase< Scalar > &x) const
Euclidean dot product: result = x^H * this.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm_2(const VectorBase< Scalar > &v)
Euclidean (2) norm: result = ||v||2.
void ele_wise_scale(const VectorBase< Scalar > &x, const Ptr< VectorBase< Scalar > > &y)
Element-wise scaling: y(i) *= x(i), i = 0...y->space()->dim()-1.
void Vt_StV(const Ptr< VectorBase< Scalar > > &y, const Scalar &alpha, const VectorBase< Scalar > &x)
Element-wise product update: y(i) *= alpha * x(i), i = 0...y->space()->dim()-1.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm_inf(const VectorBase< Scalar > &v_rhs)
Infinity norm: result = ||v||inf.
void V_StV(const Ptr< VectorBase< Scalar > > &y, const Scalar &alpha, const VectorBase< Scalar > &x)
Assign scaled vector: y(i) = alpha * x(i), i = 0...y->space()->dim()-1.
void linear_combination(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const VectorBase< Scalar > > > &x, const Scalar &beta)
Linear combination:
Scalar min(const VectorBase< Scalar > &x)
Min element: result = min{ x(i), i = 0...x.space()->dim()-1 } .
Scalar sum(const VectorBase< Scalar > &v)
Sum of vector elements: result = sum( v(i), i = 0...v.space()->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->space()->dim()-1.
Scalar get_ele(const VectorBase< Scalar > &v, Ordinal i)
Get single element: result = v(i).
void seed_randomize(unsigned int s)
Seed the random number generator used in randomize().
void V_S(const Ptr< VectorBase< Scalar > > &y, const Scalar &alpha)
y(i) = alpha, i = 0...y->space()->dim()-1.
void pair_wise_max(const Scalar &alpha, const VectorBase< Scalar > &x, const VectorBase< Scalar > &v, const Ptr< VectorBase< Scalar > > &y)
Element-wise maximum: y(i) = alpha * max(x(i), v(i)), i = 0...y->space()->dim()-1.
void minGreaterThanBound(const VectorBase< Scalar > &x, const Scalar &bound, const Ptr< Scalar > &minEle, const Ptr< Ordinal > &minIndex)
Minimum element greater than some bound and its index: Returns minEle = x(k) and minIndex = k such th...
void V_V(const Ptr< VectorBase< Scalar > > &y, const VectorBase< Scalar > &x)
y(i) = x(i), i = 0...y->space()->dim()-1.
void put_scalar(const Scalar &alpha, const Ptr< VectorBase< Scalar > > &y)
Assign all elements to a scalar: y(i) = alpha, i = 0...y->space()->dim()-1.
void applyOp(const RTOpPack::RTOpT< Scalar > &op, const ArrayView< const Ptr< const VectorBase< Scalar > > > &vecs, const ArrayView< const Ptr< VectorBase< Scalar > > > &targ_vecs, const Ptr< RTOpPack::ReductTarget > &reduct_obj, const Ordinal global_offset) const
Calls applyOpImpl().
void ele_wise_conj_prod(const Scalar &alpha, const VectorBase< Scalar > &x, const VectorBase< Scalar > &v, const Ptr< VectorBase< Scalar > > &y)
Element-wise conjugate product update: y(i) += alpha * conj(x(i)) * v(i), i = 0......
void reciprocal(const VectorBase< Scalar > &x, const Ptr< VectorBase< Scalar > > &y)
Element-wise reciprocal: y(i) = 1/x(i), i = 0...y->space()->dim()-1.
void assign(const VectorBase< Scalar > &x)
Vector assignment:
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->space()->dim()-1.
void Vp_StVtV(const Ptr< VectorBase< Scalar > > &y, const Scalar &alpha, const VectorBase< Scalar > &x, const VectorBase< Scalar > &v)
Element-wise product update: y(i) += alpha * x(i) * v(i), i = 0...y->space()->dim()-1.
Scalar dot(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y)
Dot product: result = conj(x)'*y.
void copy(const VectorBase< Scalar > &x, const Ptr< VectorBase< Scalar > > &y)
Vector assignment: y(i) = x(i), i = 0...y->space()->dim()-1.
void V_StVpStV(const Ptr< VectorBase< Scalar > > &z, const Scalar &alpha, const VectorBase< Scalar > &x, const Scalar &beta, const VectorBase< Scalar > &y)
z(i) = alpha*x(i) + beta*y(i), i = 0...z->space()->dim()-1.
Scalar max(const VectorBase< Scalar > &x)
Max element: result = max{ x(i), i = 1...n } .
Teuchos::ScalarTraits< Scalar >::magnitudeType norm_2() const
Euclidean (2) norm: result = ||v||2.
virtual RCP< const VectorSpaceBase< Scalar > > space() const =0
Return a smart pointer to the vector space that this vector belongs to.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm_inf() const
Infinity norm: result = ||v||inf.
void add_scalar(const Scalar &alpha, const Ptr< VectorBase< Scalar > > &y)
Add a scalar to all elements: y(i) += alpha, i = 0...y->space()->dim()-1.
#define TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(index, lower_inclusive, upper_exclusive)