Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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,
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)),
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 #else
341  (void)j;
342 #endif
343  return Teuchos::rcp(this,false);
344 }
345 
346 
347 template<class Scalar>
350 {
351 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
352  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
353  *dbgout << "\nThyra::VectorDefaultBase<"
355  <<">::contigSubViewImpl(col_rng) const called!\n";
356 #endif
357  validateColRng(col_rng);
358  return Teuchos::rcp(this,false);
359 }
360 
361 
362 template<class Scalar>
365 {
366 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
367  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
368  *dbgout << "\nThyra::VectorDefaultBase<"
370  <<">::nonconstContigSubViewImpl(col_rng) called!\n";
371 #endif
372  validateColRng(col_rng);
373  return Teuchos::rcp(this,false);
374 }
375 
376 
377 template<class Scalar>
380  const ArrayView<const int> &cols ) const
381 {
382 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
383  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
384  *dbgout << "\nThyra::VectorDefaultBase<"
386  <<">::nonContigSubViewImpl(cols) called!\n";
387 #endif
388  validateColIndexes(cols);
389  return Teuchos::rcp(this,false);
390 }
391 
392 
393 template<class Scalar>
396  const ArrayView<const int> &cols )
397 {
398 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
399  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
400  *dbgout << "\nThyra::VectorDefaultBase<"
402  <<">::nonconstNonContigSubViewImpl(cols) called!\n";
403 #endif
404  validateColIndexes(cols);
405  return Teuchos::rcp(this,false);
406 }
407 
408 
409 template<class Scalar>
411  const Range1D &rowRng,
412  const Range1D &colRng,
414  ) const
415 {
416 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
417  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
418  *dbgout << "\nThyra::VectorDefaultBase<"
420  <<">::acquireDetachedMultiVectorViewImpl() const called!\n";
421 #endif
422 #ifdef TEUCHOS_DEBUG
423  TEUCHOS_TEST_FOR_EXCEPT(sub_mv==NULL);
424 #endif
425  validateColRng(colRng);
427  this->acquireDetachedView(rowRng,&sv);
428 #ifdef TEUCHOS_DEBUG
429  TEUCHOS_TEST_FOR_EXCEPT( sv.stride() != 1 ); // Can't handle non-unit stride yet but we could
430 #endif
431  sub_mv->initialize( sv.globalOffset(), sv.subDim(), 0, 1, sv.values(), sv.subDim() );
432 }
433 
434 
435 template<class Scalar>
438  ) const
439 {
440  TEUCHOS_TEST_FOR_EXCEPT(sub_mv == 0);
441  sub_mv->uninitialize();
442 }
443 
444 
445 template<class Scalar>
447  const Range1D &rowRng,
448  const Range1D &colRng,
450  )
451 {
452 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
453  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
454  *dbgout << "\nThyra::VectorDefaultBase<"
456  <<">::acquireNonconstDetachedMultiVectorViewImpl() called!\n";
457 #endif
458 #ifdef TEUCHOS_DEBUG
459  TEUCHOS_TEST_FOR_EXCEPT(sub_mv==NULL);
460 #endif
461  validateColRng(colRng);
463  this->acquireDetachedView(rowRng,&sv);
464 #ifdef TEUCHOS_DEBUG
465  TEUCHOS_TEST_FOR_EXCEPT( sv.stride() != 1 ); // Can't handle non-unit stride yet but we could
466 #endif
467  sub_mv->initialize( sv.globalOffset(), sv.subDim(), 0, 1, sv.values(), sv.subDim() );
468 }
469 
470 
471 template<class Scalar>
474  )
475 {
476 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
477  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
478  *dbgout << "\nThyra::VectorDefaultBase<"
480  <<">::commitNonconstDetachedMultiVectorViewImpl() called!\n";
481 #endif
482 #ifdef TEUCHOS_DEBUG
483  TEUCHOS_TEST_FOR_EXCEPT(sub_mv==NULL);
484 #endif
486  sub_mv->globalOffset(),sub_mv->subDim(),sub_mv->values(),1);
487  this->commitDetachedView(&sv);
488  sub_mv->uninitialize();
489 }
490 
491 
492 // Overridden protected functions from VectorBase
493 
494 
495 template<class Scalar>
497  const Range1D& rng_in, RTOpPack::ConstSubVectorView<Scalar>* sub_vec_inout
498  ) const
499 {
500  using Teuchos::dyn_cast;
501  using Teuchos::tuple;
502  const Range1D rng = rng_in.full_range() ? Range1D(0,this->space()->dim()-1) : rng_in;
503 #ifdef TEUCHOS_DEBUG
505  !(rng.ubound() < this->space()->dim()), std::out_of_range
506  ,"VectorDefaultBase<Scalar>::acquireDetachedVectorViewImpl(rng,...):"
507  " Error, rng = ["<<rng.lbound()<<","<<rng.ubound()
508  <<"] is not in range = [0,"<<(this->space()->dim()-1)<<"]" );
509 #endif
510  // Initialize the operator
511  RTOpPack::ROpGetSubVector<Scalar> get_sub_vector_op(rng.lbound(),rng.ubound());
512  // Create the reduction object (another sub_vec)
514  reduct_obj = get_sub_vector_op.reduct_obj_create(); // This is really of type RTOpPack::ConstSubVectorView<Scalar>!
515  // Perform the reduction (get the sub-vector requested)
516  ::Thyra::applyOp<Scalar>(get_sub_vector_op, tuple(Teuchos::ptr<const VectorBase<Scalar> >(this))(),
517  Teuchos::null, reduct_obj.ptr());
518  // Get the sub-vector.
519  *sub_vec_inout = get_sub_vector_op(*reduct_obj);
520 }
521 
522 
523 template<class Scalar>
526  ) const
527 {
528  TEUCHOS_TEST_FOR_EXCEPT(sub_vec == 0);
529  sub_vec->uninitialize();
530 }
531 
532 
533 template<class Scalar>
535  const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec_inout
536  )
537 {
538  //
539  // Here we get a copy of the data for the sub-vector that the
540  // client will modify. We must later commit these changes to the
541  // actual vector when the client calls commitDetachedView(...).
542  // Note, this implementation is very dependent on the behavior of
543  // the default implementation of constant version of
544  // VectorDefaultBase<Scalar>::acquireDetachedView(...) and the implementation of
545  // VectorDefaultBase<Scalar>::setSubVector(...)!
546  //
549  sub_vec_inout->initialize(
550  sub_vec.globalOffset(), sub_vec.subDim(),
551  Teuchos::arcp_const_cast<Scalar>(sub_vec.values()), sub_vec.stride()
552  );
553 }
554 
555 
556 template<class Scalar>
558  RTOpPack::SubVectorView<Scalar>* sub_vec_inout
559  )
560 {
561  TEUCHOS_TEST_FOR_EXCEPT(sub_vec_inout == 0);
563  sub_vec_inout->globalOffset(), sub_vec_inout->subDim()
564  ,sub_vec_inout->values(), sub_vec_inout->stride()
565  );
566  VectorDefaultBase<Scalar>::setSubVectorImpl(spc_sub_vec); // Commit the changes!
567  sub_vec_inout->uninitialize(); // Make null as promised!
568 }
569 
570 
571 template<class Scalar>
573 {
574  RTOpPack::TOpSetSubVector<Scalar> set_sub_vector_op(sub_vec);
575  ::Thyra::applyOp<Scalar>(set_sub_vector_op, Teuchos::null,
576  Teuchos::tuple(Teuchos::ptr<VectorBase<Scalar> >(this))(), Teuchos::null);
577 }
578 
579 
580 // Overridden protected functions from LinearOpBase
581 
582 
583 template<class Scalar>
585 {
587  return ( ST::isComplex ? ( M_trans==NOTRANS || M_trans==CONJTRANS ) : true );
588 }
589 
590 
591 template<class Scalar>
593  const EOpTransp M_trans,
594  const MultiVectorBase<Scalar> &X,
595  const Ptr<MultiVectorBase<Scalar> > &Y,
596  const Scalar alpha,
597  const Scalar beta
598  ) const
599 {
600 
602 
603  // Validate input
604 #ifdef TEUCHOS_DEBUG
606  "VectorDefaultBase<Scalar>::apply()", *this, M_trans, X, &*Y);
607 #endif
608 
609  const Ordinal numCols = X.domain()->dim();
610 
611  for (Ordinal col_j = 0; col_j < numCols; ++col_j) {
612 
613  // Get single column vectors
614  const RCP<const VectorBase<Scalar> > x = X.col(col_j);
615  const RCP<VectorBase<Scalar> > y = Y->col(col_j);
616 
617  // Here M = m (where m is a column vector)
618  if( M_trans == NOTRANS || (M_trans == CONJ && !ST::isComplex) ) {
619  // y = beta*y + alpha*m*x (x is a scalar!)
620 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
621  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
622  *dbgout << "\nThyra::VectorDefaultBase<"
624  <<">::apply(...) : y = beta*y + alpha*m*x (x is a scalar!)\n";
625 #endif
626  Vt_S( y.ptr(), beta );
627  Vp_StV( y.ptr(), Scalar(alpha*get_ele(*x,0)), *this );
628  }
629  else if( M_trans == CONJTRANS || (M_trans == TRANS && !ST::isComplex) ) {
630  // y = beta*y + alpha*m'*x (y is a scalar!)
631 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
632  THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
633  *dbgout << "\nThyra::VectorDefaultBase<"
635  <<">::apply(...) : y = beta*y + alpha*m'*x (y is a scalar!)\n";
636 #endif
637  Scalar y_inout;
638  if( beta == ST::zero() ) {
639  y_inout = ST::zero();
640  }
641  else {
642  y_inout = beta*get_ele(*y,0);
643  }
644 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_SPMD_APPLY_OP_DUMP)
645  RTOpPack::show_spmd_apply_op_dump = true;
646 #endif
647 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_RTOPT_HELPER_DUMP_OUTPUT)
648  RTOpPack::rtop_helpers_dump_all = true;
649 #endif
650  y_inout += alpha * this->space()->scalarProd(*this, *x);
651 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_SPMD_APPLY_OP_DUMP)
652  RTOpPack::show_spmd_apply_op_dump = false;
653 #endif
654 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_RTOPT_HELPER_DUMP_OUTPUT)
655  RTOpPack::rtop_helpers_dump_all = false;
656 #endif
657  set_ele(0, y_inout, y.ptr());
658 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT
659  *dbgout
660  << "\nThyra::VectorDefaultBase<"<<ST::name()<<">::apply(...) : y_inout = "
661  << y_inout << "\n";
662 #endif
663  }
664  else {
665  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
666  "VectorBase<"<<ST::name()<<">::apply(M_trans,...): Error, M_trans="
667  <<toString(M_trans)<<" not supported!" );
668  }
669 
670  }
671 
672 }
673 
674 
675 // private
676 
677 
678 template<class Scalar>
679 inline
680 void VectorDefaultBase<Scalar>::validateColRng( const Range1D &col_rng ) const
681 {
682 #ifdef TEUCHOS_DEBUG
684  !( col_rng.full_range() || ( col_rng.lbound() == 0 && col_rng.ubound() == 0) ) );
685 #else
686  (void)col_rng;
687 #endif
688 }
689 
690 
691 template<class Scalar>
692 inline
693 void VectorDefaultBase<Scalar>::validateColIndexes(
694  const ArrayView<const int>&cols ) const
695 {
696 #ifdef TEUCHOS_DEBUG
697  TEUCHOS_TEST_FOR_EXCEPT( cols.size() != 1 || cols[0] != 0 );
698 #else
699  (void)cols;
700 #endif
701 }
702 
703 
704 } // end namespace Thyra
705 
706 
707 #endif // THYRA_VECTOR_DEFAULT_BASE_DEF_HPP
ptrdiff_t stride() const
virtual Scalar dotImpl(const VectorBase< Scalar > &x) const
Default implementation of dot using RTOps.
RCP< MultiVectorBase< Scalar > > clone_mv() const
Returns this-&gt;clone_v().
virtual RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &col_rng)
Returns Teuchos::rcp(this,false).
bool is_null(const boost::shared_ptr< T > &p)
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
basic_OSTab< char > OSTab
virtual void acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
Implemented in terms of this-&gt;acquireDetachedView().
#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...
virtual std::string description() const
Default description that gives the label, type, and dimenstion .
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Generates a default outputting for all vectors.
virtual void releaseDetachedVectorViewImpl(RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
basic_FancyOStream< char > FancyOStream
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Use the non-transposed operator.
T_To & dyn_cast(T_From &from)
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm1Impl() const
Default implementation of norm_1 using RTOps.
virtual void eleWiseScaleImpl(const VectorBase< Scalar > &x)
Default implementation of ele_wise_scale using RTOps.
virtual void reciprocalImpl(const VectorBase< Scalar > &x)
Default implementation of reciprocal using RTOps.
Create an explicit non-mutable (const) view of a VectorBase object.
Use the transposed operator with complex-conjugate clements (same as TRANS for real scalar types)...
const ArrayRCP< Scalar > values() const
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2Impl() const
Default implementation of norm_2 using RTOps.
virtual void absImpl(const VectorBase< Scalar > &x)
Default implementation of abs using RTOps.
RCP< VectorBase< Scalar > > clone_v() const
Simply creates a new vector and copies the contents from *this.
static std::string name()
Use the non-transposed operator with complex-conjugate elements (same as NOTRANS for real scalar type...
Ordinal ubound() const
Use the transposed operator.
bool full_range() const
virtual RCP< const VectorSpaceBase< Scalar > > range() const
Returns this-&gt;space().
virtual RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols) const
Returns Teuchos::rcp(this,false).
const ArrayRCP< Scalar > values() const
virtual void releaseDetachedMultiVectorViewImpl(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
Implemented in terms of this-&gt;releaseDetachedView().
virtual void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Implemented in terms of this-&gt;acquireDetachedView().
Convenient node subclass for concrete VectorBase subclasses that relies on a default MultiVectorBase ...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
Teuchos_Ordinal subDim() const
Returns the dimension of the explicit view.
Ptr< T > ptr() const
virtual RCP< VectorBase< Scalar > > nonconstColImpl(Ordinal j)
Returns Teuchos::rcp(this,false).
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< Scalar > &values_in, Ordinal leadingDim_in)
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, const ArrayRCP< Scalar > &values_in, ptrdiff_t stride_in)
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
virtual std::string description() const
Abstract interface for finite-dimensional dense vectors.
TEUCHOSCORE_LIB_DLL_EXPORT std::string toString(const EVerbosityLevel verbLevel)
bool opSupportedImpl(EOpTransp M_trans) const
For complex Scalar types returns true for NOTRANS and CONJTRANS and for real types returns true for a...
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.
virtual RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &col_rng) const
Returns Teuchos::rcp(this,false).
Ordinal globalOffset() const
virtual void assignVecImpl(const VectorBase< Scalar > &x)
Default implementation of assign(vector) using RTOps.
Teuchos::RCP< ReductTarget > reduct_obj_create() const
Ordinal lbound() const
virtual void updateVecImpl(Scalar alpha, const VectorBase< Scalar > &x)
Default implementation of update using RTOps.
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType normInfImpl() const
Default implementation of norm_inf using RTOps.
virtual RCP< const VectorSpaceBase< Scalar > > domain() const
Returns a DefaultSerialVectorSpace object with dimension 1.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2WeightedImpl(const VectorBase< Scalar > &x) const
Default implementation of norm_2 (weighted) using RTOps.
virtual void acquireDetachedVectorViewImpl(const Range1D &rng, RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< const Scalar > &values_in, Ordinal leadingDim_in)
virtual void setSubVectorImpl(const RTOpPack::SparseSubVectorT< Scalar > &sub_vec)
virtual void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Implemented in terms of this-&gt;commitDetachedView().
virtual void acquireNonconstDetachedVectorViewImpl(const Range1D &rng, RTOpPack::SubVectorView< Scalar > *sub_vec)
virtual void randomizeImpl(Scalar l, Scalar u)
Default implementation of randomize using RTOps.
virtual RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols)
Returns Teuchos::rcp(this,false).
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
const ArrayRCP< const Scalar > values() const
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.
Teuchos::Range1D Range1D
virtual void commitNonconstDetachedVectorViewImpl(RTOpPack::SubVectorView< Scalar > *sub_vec)