Thyra  Version of the Day
Thyra_VectorDefaultBase_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_DEFAULT_BASE_DEF_HPP
43 #define THYRA_VECTOR_DEFAULT_BASE_DEF_HPP
44 
45 
46 // Define to make some verbose output
47 //#define THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
48 
49 
50 #include "Thyra_VectorDefaultBase_decl.hpp"
51 #include "Thyra_VectorSpaceFactoryBase.hpp"
52 #include "Thyra_VectorBase.hpp"
53 #include "Thyra_VectorStdOps.hpp"
54 #include "Thyra_MultiVectorDefaultBase.hpp"
55 #include "Thyra_AssertOp.hpp"
56 #include "Thyra_MultiVectorBase.hpp"
57 #include "Thyra_DetachedVectorView.hpp"
58 #include "RTOpPack_ROpGetSubVector.hpp"
59 #include "RTOpPack_TOpSetSubVector.hpp"
60 #include "RTOpPack_ROpNorm1.hpp"
61 #include "RTOpPack_ROpNorm2.hpp"
62 #include "RTOpPack_ROpWeightedNorm2.hpp"
63 #include "RTOpPack_ROpNormInf.hpp"
64 #include "RTOpPack_TOpAbs.hpp"
65 #include "RTOpPack_TOpAssignVectors.hpp"
66 #include "RTOpPack_TOpAXPY.hpp"
67 #include "RTOpPack_TOpEleWiseScale.hpp"
68 #include "RTOpPack_TOpLinearCombination.hpp"
69 #include "RTOpPack_TOpScaleVector.hpp"
70 #include "RTOpPack_TOpReciprocal.hpp"
71 #include "RTOpPack_TOpRandomize.hpp"
72 #include "Teuchos_Assert.hpp"
73 
74 
75 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
76 # include "Teuchos_VerboseObject.hpp"
77 # define THYRA_VECTOR_VERBOSE_OUT_STATEMENT \
78  RCP<Teuchos::FancyOStream> dbgout = Teuchos::VerboseObjectBase::getDefaultOStream()
79 #endif // THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
80 
81 
82 
83 namespace Thyra {
84 
85 
86 // Overridden from Teuchos::Describable
87 
88 
89 template<class Scalar>
91 {
92  std::ostringstream oss;
93  const RCP<const VectorSpaceBase<Scalar> > vs = this->space();
95  if(is_null(vs)) {
96  oss << "{space=NULL}";
97  }
98  else {
99  const Ordinal dim = vs->dim();
100  oss << "{dim=" << dim << "}";
101  }
102  return oss.str();
103 }
104 
105 
106 template<class Scalar>
108  Teuchos::FancyOStream &out_arg,
109  const Teuchos::EVerbosityLevel verbLevel
110  ) const
111 {
112  using Teuchos::FancyOStream;
113  using Teuchos::OSTab;
114  RCP<FancyOStream> out = Teuchos::rcpFromRef(out_arg);
115  OSTab tab(out);
116  *out << this->description() << "\n";
117  if (this->space()->dim()) {
118  tab.incrTab();
119  if (verbLevel >= Teuchos::VERB_HIGH) {
120  const ConstDetachedVectorView<Scalar> dvv(*this);
121  for( Ordinal i = 0; i < dvv.subDim(); ++i )
122  *out << i << ":" << dvv[i] << std::endl;
123  }
124  }
125 }
126 
127 
128 // Overridden from LinearOpBase
129 
130 
131 template<class Scalar>
134 {
135 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
136  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
137  *dbgout << "\nThyra::VectorDefaultBase<"
139  <<">::range() called!\n";
140 #endif
141  return this->space();
142 }
143 
144 
145 template<class Scalar>
148 {
149 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
150  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
151  *dbgout << "\nThyra::VectorDefaultBase<"
153  <<">::domain() called!\n";
154 #endif
155  if(!domain_.get()) {
156  domain_ = range()->smallVecSpcFcty()->createVecSpc(1);
157  }
158  return domain_;
159 }
160 
161 
162 // Overridden from MultiVectorBase
163 
164 
165 template<class Scalar>
168 {
169 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
170  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
171  *dbgout << "\nThyra::VectorDefaultBase<"
173  <<">::clone_mv() called!\n";
174 #endif
175  return this->clone_v();
176 }
177 
178 
179 // Overridden from VectorBase
180 
181 
182 template<class Scalar>
185 {
186 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
187  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
188  *dbgout << "\nThyra::VectorDefaultBase<"
190  <<">::clone_v() called!\n";
191 #endif
192  const RCP<VectorBase<Scalar> > copy = createMember(this->space());
193  ::Thyra::assign<Scalar>(copy.ptr(), *this);
194  return copy;
195 }
196 
197 
198 // protected
199 
200 
201 template<class Scalar>
203 {
204  this->assign(static_cast<const MultiVectorBase<Scalar>& >(x));
205 }
206 
207 
208 template<class Scalar>
210 {
211  using Teuchos::tuple; using Teuchos::null;
212  RTOpPack::TOpRandomize<Scalar> random_vector_op(l,u);
213  Thyra::applyOp<Scalar>(random_vector_op,
214  ArrayView<Ptr<const VectorBase<Scalar> > >(null),
215  tuple<Ptr<VectorBase<Scalar> > >(ptr(this)),
216  null);
217 }
218 
219 
220 template<class Scalar>
222 {
223  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
224  RTOpPack::TOpAbs<Scalar> abs_op;
225  Thyra::applyOp<Scalar>(abs_op, tuple(ptrInArg(x)),
226  tuple<Ptr<VectorBase<Scalar> > >(ptr(this)), null);
227 }
228 
229 
230 template<class Scalar>
232 {
233  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
234  RTOpPack::TOpReciprocal<Scalar> recip_op;
235  Thyra::applyOp<Scalar>(recip_op, tuple(ptrInArg(x)),
236  tuple<Ptr<VectorBase<Scalar> > >(ptr(this)), null);
237 }
238 
239 
240 template<class Scalar>
242 {
243  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
245  Thyra::applyOp<Scalar>(scale_op, tuple(ptrInArg(x)),
246  tuple<Ptr<VectorBase<Scalar> > >(ptr(this)), null);
247 }
248 
249 
250 template<class Scalar>
252  Scalar alpha,
253  const VectorBase<Scalar>& x)
254 {
255  this->update(alpha, static_cast<const MultiVectorBase<Scalar>& >(x));
256 }
257 
258 
259 template<class Scalar>
261  const ArrayView<const Scalar>& alpha,
262  const ArrayView<const Ptr<const VectorBase<Scalar> > >& x,
263  const Scalar& beta
264  )
265 {
267  for (Ordinal i = 0; i < x.size(); ++i)
268  mv[i] = Teuchos::ptr_static_cast<const MultiVectorBase<Scalar> >(x[i]);
269  this->linear_combination(alpha, mv(), beta);
270 }
271 
272 
273 template<class Scalar>
275 {
276  Scalar prod;
277  this->dots(x, Teuchos::arrayView(&prod, 1));
278  return prod;
279 }
280 
281 
282 template<class Scalar>
285 {
287  this->norms_1(Teuchos::arrayView(&norm, 1));
288  return norm;
289 }
290 
291 
292 template<class Scalar>
295 {
297  this->norms_2(Teuchos::arrayView(&norm, 1));
298  return norm;
299 }
300 
301 
302 template<class Scalar>
305 {
306  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
309  Thyra::applyOp<Scalar>(norm_op,
310  tuple(ptrInArg(x), ptrInArg<const VectorBase<Scalar> >(*this)),
311  ArrayView<const Ptr<VectorBase<Scalar> > >(null),
312  norm_targ.ptr());
313  return norm_op(*norm_targ);
314 }
315 
316 template<class Scalar>
319 {
321  this->norms_inf(Teuchos::arrayView(&norm, 1));
322  return norm;
323 }
324 
325 
326 // Overridden protected functions from MultiVectorVectorBase
327 
328 
329 template<class Scalar>
332 {
333 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
334  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
335  *dbgout << "\nThyra::VectorDefaultBase<"
336  <<Teuchos::ScalarTraits<Scalar>::name()<<">::nonconstColImpl(j) called!\n";
337 #endif
338 #ifdef TEUCHOS_DEBUG
339  TEUCHOS_TEST_FOR_EXCEPT( j != 0 );
340 #endif
341  return Teuchos::rcp(this,false);
342 }
343 
344 
345 template<class Scalar>
348 {
349 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
350  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
351  *dbgout << "\nThyra::VectorDefaultBase<"
353  <<">::contigSubViewImpl(col_rng) const called!\n";
354 #endif
355  validateColRng(col_rng);
356  return Teuchos::rcp(this,false);
357 }
358 
359 
360 template<class Scalar>
363 {
364 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
365  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
366  *dbgout << "\nThyra::VectorDefaultBase<"
368  <<">::nonconstContigSubViewImpl(col_rng) called!\n";
369 #endif
370  validateColRng(col_rng);
371  return Teuchos::rcp(this,false);
372 }
373 
374 
375 template<class Scalar>
378  const ArrayView<const int> &cols ) const
379 {
380 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
381  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
382  *dbgout << "\nThyra::VectorDefaultBase<"
384  <<">::nonContigSubViewImpl(cols) called!\n";
385 #endif
386  validateColIndexes(cols);
387  return Teuchos::rcp(this,false);
388 }
389 
390 
391 template<class Scalar>
394  const ArrayView<const int> &cols )
395 {
396 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
397  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
398  *dbgout << "\nThyra::VectorDefaultBase<"
400  <<">::nonconstNonContigSubViewImpl(cols) called!\n";
401 #endif
402  validateColIndexes(cols);
403  return Teuchos::rcp(this,false);
404 }
405 
406 
407 template<class Scalar>
409  const Range1D &rowRng,
410  const Range1D &colRng,
412  ) const
413 {
414 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
415  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
416  *dbgout << "\nThyra::VectorDefaultBase<"
418  <<">::acquireDetachedMultiVectorViewImpl() const called!\n";
419 #endif
420 #ifdef TEUCHOS_DEBUG
421  TEUCHOS_TEST_FOR_EXCEPT(sub_mv==NULL);
422 #endif
423  validateColRng(colRng);
425  this->acquireDetachedView(rowRng,&sv);
426 #ifdef TEUCHOS_DEBUG
427  TEUCHOS_TEST_FOR_EXCEPT( sv.stride() != 1 ); // Can't handle non-unit stride yet but we could
428 #endif
429  sub_mv->initialize( sv.globalOffset(), sv.subDim(), 0, 1, sv.values(), sv.subDim() );
430 }
431 
432 
433 template<class Scalar>
436  ) const
437 {
438  TEUCHOS_TEST_FOR_EXCEPT(sub_mv == 0);
439  sub_mv->uninitialize();
440 }
441 
442 
443 template<class Scalar>
445  const Range1D &rowRng,
446  const Range1D &colRng,
448  )
449 {
450 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
451  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
452  *dbgout << "\nThyra::VectorDefaultBase<"
454  <<">::acquireNonconstDetachedMultiVectorViewImpl() called!\n";
455 #endif
456 #ifdef TEUCHOS_DEBUG
457  TEUCHOS_TEST_FOR_EXCEPT(sub_mv==NULL);
458 #endif
459  validateColRng(colRng);
461  this->acquireDetachedView(rowRng,&sv);
462 #ifdef TEUCHOS_DEBUG
463  TEUCHOS_TEST_FOR_EXCEPT( sv.stride() != 1 ); // Can't handle non-unit stride yet but we could
464 #endif
465  sub_mv->initialize( sv.globalOffset(), sv.subDim(), 0, 1, sv.values(), sv.subDim() );
466 }
467 
468 
469 template<class Scalar>
472  )
473 {
474 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
475  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
476  *dbgout << "\nThyra::VectorDefaultBase<"
478  <<">::commitNonconstDetachedMultiVectorViewImpl() called!\n";
479 #endif
480 #ifdef TEUCHOS_DEBUG
481  TEUCHOS_TEST_FOR_EXCEPT(sub_mv==NULL);
482 #endif
484  sub_mv->globalOffset(),sub_mv->subDim(),sub_mv->values(),1);
485  this->commitDetachedView(&sv);
486  sub_mv->uninitialize();
487 }
488 
489 
490 // Overridden protected functions from VectorBase
491 
492 
493 template<class Scalar>
495  const Range1D& rng_in, RTOpPack::ConstSubVectorView<Scalar>* sub_vec_inout
496  ) const
497 {
498  using Teuchos::dyn_cast;
499  using Teuchos::tuple;
500  const Range1D rng = rng_in.full_range() ? Range1D(0,this->space()->dim()-1) : rng_in;
501 #ifdef TEUCHOS_DEBUG
503  !(rng.ubound() < this->space()->dim()), std::out_of_range
504  ,"VectorDefaultBase<Scalar>::acquireDetachedVectorViewImpl(rng,...):"
505  " Error, rng = ["<<rng.lbound()<<","<<rng.ubound()
506  <<"] is not in range = [0,"<<(this->space()->dim()-1)<<"]" );
507 #endif
508  // Initialize the operator
509  RTOpPack::ROpGetSubVector<Scalar> get_sub_vector_op(rng.lbound(),rng.ubound());
510  // Create the reduction object (another sub_vec)
512  reduct_obj = get_sub_vector_op.reduct_obj_create(); // This is really of type RTOpPack::ConstSubVectorView<Scalar>!
513  // Perform the reduction (get the sub-vector requested)
514  ::Thyra::applyOp<Scalar>(get_sub_vector_op, tuple(Teuchos::ptr<const VectorBase<Scalar> >(this))(),
515  Teuchos::null, reduct_obj.ptr());
516  // Get the sub-vector.
517  *sub_vec_inout = get_sub_vector_op(*reduct_obj);
518 }
519 
520 
521 template<class Scalar>
524  ) const
525 {
526  TEUCHOS_TEST_FOR_EXCEPT(sub_vec == 0);
527  sub_vec->uninitialize();
528 }
529 
530 
531 template<class Scalar>
533  const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec_inout
534  )
535 {
536  //
537  // Here we get a copy of the data for the sub-vector that the
538  // client will modify. We must later commit these changes to the
539  // actual vector when the client calls commitDetachedView(...).
540  // Note, this implementation is very dependent on the behavior of
541  // the default implementation of constant version of
542  // VectorDefaultBase<Scalar>::acquireDetachedView(...) and the implementation of
543  // VectorDefaultBase<Scalar>::setSubVector(...)!
544  //
547  sub_vec_inout->initialize(
548  sub_vec.globalOffset(), sub_vec.subDim(),
549  Teuchos::arcp_const_cast<Scalar>(sub_vec.values()), sub_vec.stride()
550  );
551 }
552 
553 
554 template<class Scalar>
556  RTOpPack::SubVectorView<Scalar>* sub_vec_inout
557  )
558 {
559  TEUCHOS_TEST_FOR_EXCEPT(sub_vec_inout == 0);
561  sub_vec_inout->globalOffset(), sub_vec_inout->subDim()
562  ,sub_vec_inout->values(), sub_vec_inout->stride()
563  );
564  VectorDefaultBase<Scalar>::setSubVectorImpl(spc_sub_vec); // Commit the changes!
565  sub_vec_inout->uninitialize(); // Make null as promised!
566 }
567 
568 
569 template<class Scalar>
571 {
572  RTOpPack::TOpSetSubVector<Scalar> set_sub_vector_op(sub_vec);
573  ::Thyra::applyOp<Scalar>(set_sub_vector_op, Teuchos::null,
574  Teuchos::tuple(Teuchos::ptr<VectorBase<Scalar> >(this))(), Teuchos::null);
575 }
576 
577 
578 // Overridden protected functions from LinearOpBase
579 
580 
581 template<class Scalar>
583 {
585  return ( ST::isComplex ? ( M_trans==NOTRANS || M_trans==CONJTRANS ) : true );
586 }
587 
588 
589 template<class Scalar>
591  const EOpTransp M_trans,
592  const MultiVectorBase<Scalar> &X,
593  const Ptr<MultiVectorBase<Scalar> > &Y,
594  const Scalar alpha,
595  const Scalar beta
596  ) const
597 {
598 
600 
601  // Validate input
602 #ifdef TEUCHOS_DEBUG
604  "VectorDefaultBase<Scalar>::apply()", *this, M_trans, X, &*Y);
605 #endif
606 
607  const Ordinal numCols = X.domain()->dim();
608 
609  for (Ordinal col_j = 0; col_j < numCols; ++col_j) {
610 
611  // Get single column vectors
612  const RCP<const VectorBase<Scalar> > x = X.col(col_j);
613  const RCP<VectorBase<Scalar> > y = Y->col(col_j);
614 
615  // Here M = m (where m is a column vector)
616  if( M_trans == NOTRANS || (M_trans == CONJ && !ST::isComplex) ) {
617  // y = beta*y + alpha*m*x (x is a scalar!)
618 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
619  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
620  *dbgout << "\nThyra::VectorDefaultBase<"
622  <<">::apply(...) : y = beta*y + alpha*m*x (x is a scalar!)\n";
623 #endif
624  Vt_S( y.ptr(), beta );
625  Vp_StV( y.ptr(), Scalar(alpha*get_ele(*x,0)), *this );
626  }
627  else if( M_trans == CONJTRANS || (M_trans == TRANS && !ST::isComplex) ) {
628  // y = beta*y + alpha*m'*x (y is a scalar!)
629 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
630  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
631  *dbgout << "\nThyra::VectorDefaultBase<"
633  <<">::apply(...) : y = beta*y + alpha*m'*x (y is a scalar!)\n";
634 #endif
635  Scalar y_inout;
636  if( beta == ST::zero() ) {
637  y_inout = ST::zero();
638  }
639  else {
640  y_inout = beta*get_ele(*y,0);
641  }
642 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_SPMD_APPLY_OP_DUMP)
643  RTOpPack::show_spmd_apply_op_dump = true;
644 #endif
645 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_RTOPT_HELPER_DUMP_OUTPUT)
646  RTOpPack::rtop_helpers_dump_all = true;
647 #endif
648  y_inout += alpha * this->space()->scalarProd(*this, *x);
649 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_SPMD_APPLY_OP_DUMP)
650  RTOpPack::show_spmd_apply_op_dump = false;
651 #endif
652 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_RTOPT_HELPER_DUMP_OUTPUT)
653  RTOpPack::rtop_helpers_dump_all = false;
654 #endif
655  set_ele(0, y_inout, y.ptr());
656 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
657  *dbgout
658  << "\nThyra::VectorDefaultBase<"<<ST::name()<<">::apply(...) : y_inout = "
659  << y_inout << "\n";
660 #endif
661  }
662  else {
663  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
664  "VectorBase<"<<ST::name()<<">::apply(M_trans,...): Error, M_trans="
665  <<toString(M_trans)<<" not supported!" );
666  }
667 
668  }
669 
670 }
671 
672 
673 // private
674 
675 
676 template<class Scalar>
677 inline
678 void VectorDefaultBase<Scalar>::validateColRng( const Range1D &col_rng ) const
679 {
680 #ifdef TEUCHOS_DEBUG
682  !( col_rng.full_range() || ( col_rng.lbound() == 0 && col_rng.ubound() == 0) ) );
683 #endif
684 }
685 
686 
687 template<class Scalar>
688 inline
689 void VectorDefaultBase<Scalar>::validateColIndexes(
690  const ArrayView<const int>&cols ) const
691 {
692 #ifdef TEUCHOS_DEBUG
693  TEUCHOS_TEST_FOR_EXCEPT( cols.size() != 1 || cols[0] != 0 );
694 #endif
695 }
696 
697 
698 } // end namespace Thyra
699 
700 
701 #endif // THYRA_VECTOR_DEFAULT_BASE_DEF_HPP
Teuchos::Range1D::lbound
Ordinal lbound() const
Thyra::VectorDefaultBase::nonContigSubViewImpl
virtual RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols) const
Returns Teuchos::rcp(this,false).
Definition: Thyra_VectorDefaultBase_def.hpp:377
Thyra::VectorDefaultBase::eleWiseScaleImpl
virtual void eleWiseScaleImpl(const VectorBase< Scalar > &x)
Default implementation of ele_wise_scale using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:241
is_null
bool is_null(const boost::shared_ptr< T > &p)
Thyra::VectorDefaultBase::normInfImpl
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType normInfImpl() const
Default implementation of norm_inf using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:318
FancyOStream
basic_FancyOStream< char > FancyOStream
Thyra::VectorDefaultBase::norm2Impl
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2Impl() const
Default implementation of norm_2 using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:294
RTOpPack::SubVectorView::values
const ArrayRCP< Scalar > values() const
TEUCHOS_TEST_FOR_EXCEPT
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Thyra::VectorDefaultBase
Convenient node subclass for concrete VectorBase subclasses that relies on a default MultiVectorBase ...
Definition: Thyra_VectorDefaultBase_decl.hpp:73
Thyra::VectorDefaultBase::domain
virtual RCP< const VectorSpaceBase< Scalar > > domain() const
Returns a DefaultSerialVectorSpace object with dimension 1.
Definition: Thyra_VectorDefaultBase_def.hpp:147
Thyra::EOpTransp
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Definition: Thyra_OperatorVectorTypes.hpp:160
Thyra::VectorDefaultBase::absImpl
virtual void absImpl(const VectorBase< Scalar > &x)
Default implementation of abs using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:221
Teuchos::Describable::description
virtual std::string description() const
Thyra::LinearOpBase::domain
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
Thyra::VectorDefaultBase::reciprocalImpl
virtual void reciprocalImpl(const VectorBase< Scalar > &x)
Default implementation of reciprocal using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:231
Teuchos::Range1D::ubound
Ordinal ubound() const
RTOpPack::SubVectorView::initialize
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, const ArrayRCP< Scalar > &values_in, ptrdiff_t stride_in)
RTOpPack::ConstSubMultiVectorView::subDim
Ordinal subDim() const
Thyra::VectorDefaultBase::acquireNonconstDetachedVectorViewImpl
virtual void acquireNonconstDetachedVectorViewImpl(const Range1D &rng, RTOpPack::SubVectorView< Scalar > *sub_vec)
Definition: Thyra_VectorDefaultBase_def.hpp:532
Thyra::VectorDefaultBase::opSupportedImpl
bool opSupportedImpl(EOpTransp M_trans) const
For complex Scalar types returns true for NOTRANS and CONJTRANS and for real types returns true for a...
Definition: Thyra_VectorDefaultBase_def.hpp:582
Thyra::VectorDefaultBase::acquireDetachedMultiVectorViewImpl
virtual void acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
Implemented in terms of this->acquireDetachedView().
Definition: Thyra_VectorDefaultBase_def.hpp:408
RTOpPack::ConstSubVectorView
RTOpPack::ConstSubVectorView::uninitialize
void uninitialize()
Teuchos::EVerbosityLevel
EVerbosityLevel
RTOpPack::ConstSubVectorView::globalOffset
Ordinal globalOffset() const
Teuchos::Range1D::full_range
bool full_range() const
Thyra::VectorDefaultBase::acquireDetachedVectorViewImpl
virtual void acquireDetachedVectorViewImpl(const Range1D &rng, RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
Definition: Thyra_VectorDefaultBase_def.hpp:494
Thyra::VectorDefaultBase::description
virtual std::string description() const
Default description that gives the label, type, and dimenstion .
Definition: Thyra_VectorDefaultBase_def.hpp:90
Teuchos::ArrayView
RTOpPack::SubMultiVectorView
RTOpPack::ROpWeightedNorm2
Teuchos::RCP
Thyra::VectorDefaultBase::nonconstNonContigSubViewImpl
virtual RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols)
Returns Teuchos::rcp(this,false).
Definition: Thyra_VectorDefaultBase_def.hpp:393
VERB_HIGH
VERB_HIGH
Teuchos::Ptr
Thyra::Ordinal
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Definition: Thyra_OperatorVectorTypes.hpp:127
Teuchos::Array
Thyra::VectorDefaultBase::randomizeImpl
virtual void randomizeImpl(Scalar l, Scalar u)
Default implementation of randomize using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:209
RTOpPack::TOpRandomize
Thyra::VectorDefaultBase::updateVecImpl
virtual void updateVecImpl(Scalar alpha, const VectorBase< Scalar > &x)
Default implementation of update using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:251
RTOpPack::SubMultiVectorView::values
const ArrayRCP< Scalar > values() const
Thyra::ConstDetachedVectorView
Create an explicit non-mutable (const) view of a VectorBase object.
Definition: Thyra_DetachedVectorView.hpp:72
Teuchos::basic_FancyOStream
Thyra::CONJTRANS
Use the transposed operator with complex-conjugate clements (same as TRANS for real scalar types).
Definition: Thyra_OperatorVectorTypes.hpp:172
Thyra::VectorDefaultBase::releaseDetachedVectorViewImpl
virtual void releaseDetachedVectorViewImpl(RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
Definition: Thyra_VectorDefaultBase_def.hpp:522
Thyra::MultiVectorBase::col
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
Definition: Thyra_MultiVectorBase_decl.hpp:641
Thyra::MultiVectorBase
Interface for a collection of column vectors called a multi-vector.
Definition: Thyra_MultiVectorBase_decl.hpp:493
Teuchos::ScalarTraits< Scalar >
RTOpPack::RTOpT< Scalar >::reduct_obj_create
Teuchos::RCP< ReductTarget > reduct_obj_create() const
RTOpPack::TOpSetSubVector
RTOpPack::ConstSubVectorView::values
const ArrayRCP< const Scalar > values() const
Thyra::VectorDefaultBase::norm1Impl
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm1Impl() const
Default implementation of norm_1 using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:284
Thyra::VectorDefaultBase::releaseDetachedMultiVectorViewImpl
virtual void releaseDetachedMultiVectorViewImpl(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
Implemented in terms of this->releaseDetachedView().
Definition: Thyra_VectorDefaultBase_def.hpp:434
RTOpPack::ConstSubMultiVectorView::uninitialize
void uninitialize()
Thyra::VectorDefaultBase::nonconstColImpl
virtual RCP< VectorBase< Scalar > > nonconstColImpl(Ordinal j)
Returns Teuchos::rcp(this,false).
Definition: Thyra_VectorDefaultBase_def.hpp:331
RTOpPack::ROpGetSubVector
Thyra::VectorDefaultBase::nonconstContigSubViewImpl
virtual RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &col_rng)
Returns Teuchos::rcp(this,false).
Definition: Thyra_VectorDefaultBase_def.hpp:362
Thyra::VectorDefaultBase::linearCombinationVecImpl
virtual void linearCombinationVecImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const VectorBase< Scalar > > > &x, const Scalar &beta)
Default implementation of linear_combination using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:260
Thyra::VectorDefaultBase::norm2WeightedImpl
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2WeightedImpl(const VectorBase< Scalar > &x) const
Default implementation of norm_2 (weighted) using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:304
Thyra::VectorDefaultBase::describe
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Generates a default outputting for all vectors.
Definition: Thyra_VectorDefaultBase_def.hpp:107
Thyra::NOTRANS
Use the non-transposed operator.
Definition: Thyra_OperatorVectorTypes.hpp:162
RTOpPack::SubVectorView
Thyra::VectorDefaultBase::clone_v
RCP< VectorBase< Scalar > > clone_v() const
Simply creates a new vector and copies the contents from *this.
Definition: Thyra_VectorDefaultBase_def.hpp:184
RTOpPack::SubMultiVectorView::initialize
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< Scalar > &values_in, Ordinal leadingDim_in)
RTOpPack::TOpEleWiseScale
RTOpPack::SparseSubVectorT
Thyra::VectorDefaultBase::commitNonconstDetachedMultiVectorViewImpl
virtual void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Implemented in terms of this->commitDetachedView().
Definition: Thyra_VectorDefaultBase_def.hpp:470
Thyra::VectorDefaultBase::clone_mv
RCP< MultiVectorBase< Scalar > > clone_mv() const
Returns this->clone_v().
Definition: Thyra_VectorDefaultBase_def.hpp:167
toString
TEUCHOSCORE_LIB_DLL_EXPORT std::string toString(const EVerbosityLevel verbLevel)
Thyra::ConstDetachedVectorView::subDim
Teuchos_Ordinal subDim() const
Returns the dimension of the explicit view.
Definition: Thyra_DetachedVectorView.hpp:178
Teuchos::ScalarTraits::name
static std::string name()
Thyra::VectorBase
Abstract interface for finite-dimensional dense vectors.
Definition: Thyra_OperatorVectorTypes.hpp:370
RTOpPack::ConstSubMultiVectorView::globalOffset
Ordinal globalOffset() const
Thyra::VectorDefaultBase::setSubVectorImpl
virtual void setSubVectorImpl(const RTOpPack::SparseSubVectorT< Scalar > &sub_vec)
Definition: Thyra_VectorDefaultBase_def.hpp:570
Thyra::VectorDefaultBase::assignVecImpl
virtual void assignVecImpl(const VectorBase< Scalar > &x)
Default implementation of assign(vector) using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:202
RTOpPack::ConstSubVectorView::subDim
Ordinal subDim() const
Thyra::VectorDefaultBase::applyImpl
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
. Applies vector or its adjoint (transpose) as a linear operator.
Definition: Thyra_VectorDefaultBase_def.hpp:590
Thyra::VectorDefaultBase::range
virtual RCP< const VectorSpaceBase< Scalar > > range() const
Returns this->space().
Definition: Thyra_VectorDefaultBase_def.hpp:133
RTOpPack::ConstSubMultiVectorView
RTOpPack::ConstSubVectorView::stride
ptrdiff_t stride() const
Teuchos::ScalarTraits::magnitudeType
T magnitudeType
Teuchos::RCP::ptr
Ptr< T > ptr() const
dyn_cast
T_To & dyn_cast(T_From &from)
Thyra::VectorDefaultBase::acquireNonconstDetachedMultiVectorViewImpl
virtual void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Implemented in terms of this->acquireDetachedView().
Definition: Thyra_VectorDefaultBase_def.hpp:444
Thyra::VectorDefaultBase::commitNonconstDetachedVectorViewImpl
virtual void commitNonconstDetachedVectorViewImpl(RTOpPack::SubVectorView< Scalar > *sub_vec)
Definition: Thyra_VectorDefaultBase_def.hpp:555
Thyra::CONJ
Use the non-transposed operator with complex-conjugate elements (same as NOTRANS for real scalar type...
Definition: Thyra_OperatorVectorTypes.hpp:166
THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES
#define THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES(FUNC_NAME, M, M_T, X, Y)
This is a very useful macro that should be used to validate that the spaces for the multi-vector vers...
Definition: Thyra_AssertOp.hpp:250
Thyra::VectorDefaultBase::dotImpl
virtual Scalar dotImpl(const VectorBase< Scalar > &x) const
Default implementation of dot using RTOps.
Definition: Thyra_VectorDefaultBase_def.hpp:274
Teuchos::Range1D
Thyra::Range1D
Teuchos::Range1D Range1D
Definition: Thyra_OperatorVectorTypes.hpp:97
TEUCHOS_TEST_FOR_EXCEPTION
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Thyra::TRANS
Use the transposed operator.
Definition: Thyra_OperatorVectorTypes.hpp:168
OSTab
basic_OSTab< char > OSTab
Thyra::VectorDefaultBase::contigSubViewImpl
virtual RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &col_rng) const
Returns Teuchos::rcp(this,false).
Definition: Thyra_VectorDefaultBase_def.hpp:347
RTOpPack::ConstSubMultiVectorView::initialize
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< const Scalar > &values_in, Ordinal leadingDim_in)