Public Member Functions | Static Public Member Functions | Private Member Functions | Related Functions
TSFExtended::Vector< Scalar > Class Template Reference

User-level vector class. More...

Inheritance diagram for TSFExtended::Vector< Scalar >:
Sundance::Handle< Thyra::VectorBase< Scalar > > Sundance::ObjectWithVerbosityBase

List of all members.

Public Member Functions

VectorSpace< Scalar > space () const
int dim () const
 Return the dimension of the vector.
Vector< Scalar > eval () const
bool containsVector (const Thyra::VectorBase< Scalar > *vec) const
void evalInto (Vector< Scalar > &other) const
void addInto (Vector< Scalar > &other, TSFExtendedOps::LCSign sign) const
std::string description () const
 Describe the vector.
void print (std::ostream &os) const
 Print to a stream using the Printable interface.
Constructors, Destructors, and Assignment Operators
 Vector ()
 Empty ctor.
 Vector (Handleable< Thyra::VectorBase< Scalar > > *rawPtr)
 Construct a Vector<Scalar> with a raw pointer to a Thyra::VectorBase<Scalar>
 Vector (const RefCountPtr< Thyra::VectorBase< Scalar > > &smartPtr)
 Construct a Vector<Scalar> with a smart pointer to a Thyra::VectorBase<Scalar>
template<class Node1 , class Node2 >
 Vector (const TSFExtendedOps::LC2< Scalar, Node1, Node2 > &x)
 Construct a vector from a 2-term LC.
template<class Node >
 Vector (const TSFExtendedOps::OpTimesLC< Scalar, Node > &x)
 Construct a vector from an operator times a linear combination.
template<class Node1 , class Node2 >
Vectoroperator= (const TSFExtendedOps::LC2< Scalar, Node1, Node2 > &x)
 Assign a linear combination of vectors to this vector.
template<class Node >
Vectoroperator= (const TSFExtendedOps::OpTimesLC< Scalar, Node > &x)
 Assign a scaled linear combination to this vector.
ProductVector operations
void setBlock (int i, const Vector< Scalar > &v)
 set block
Vector< Scalar > getBlock (int i) const
 get block
Math operations
Vector< Scalar > & scale (const Scalar &alpha)
 Multiply this vector by a constant scalar factor.
Vector< Scalar > & update (const Scalar &alpha, const Vector< Scalar > &x)
 Add a scaled vector to this vector:
Vector< Scalar > & update (const Scalar &alpha, const Vector< Scalar > &x, const Scalar &gamma)
 Add a scaled vector to this vector times a constant:
Vector< Scalar > & update (const Scalar &alpha, const Vector< Scalar > &x, const Scalar &beta, const Vector< Scalar > &y, const Scalar &gamma)
 Add two scaled vectors to this vector times a constant:
Vector< Scalar > & acceptCopyOf (const Vector< Scalar > &x)
 Copy the values of another vector into this vector.
Vector< Scalar > copy () const
 Create a new vector that is a copy of this vector.
Vector< Scalar > dotStar (const Vector< Scalar > &other) const
 Element-by-element product (Matlab dot-star operator)
void dotStarInto (const Vector< Scalar > &a, const Vector< Scalar > &b) const
 Write the elementwise product of $a$ and $b$ into <t>this.
Vector< Scalar > dotSlash (const Vector< Scalar > &other) const
 Element-by-element division (Matlab dot-slash operator)
Vector< Scalar > reciprocal () const
 Return element-by-element reciprocal as a new vector.
Vector< Scalar > abs () const
 Return element-by-element absolute value as a new vector.
Vector< Scalar > & reciprocal ()
 Overwrite self with element-by-element reciprocal.
Vector< Scalar > & abs ()
 Overwrite self with element-by-element absolute value.
void setToConstant (const Scalar &alpha)
 Set all elements to a constant value.
Scalar dot (const Vector< Scalar > &other) const
 Take dot product with another vector.
Scalar operator* (const Vector< Scalar > &other) const
 Overloaded operator for dot product.
Scalar norm1 () const
 Compute the 1-norm of this vector.
Scalar norm2 () const
 Compute the 2-norm of this vector.
Scalar norm2 (const Vector< Scalar > &weights) const
 Compute the weighted 2-norm of this vector.
Scalar normInf () const
 Compute the infinity-norm of this vector.
void zero ()
 Set all elements to zero.
Scalar max () const
 Retuen the max element.
Scalar max (int &index) const
 Return the max element and the corresponding index.
Scalar max (const Scalar &bound, int &index) const
 Return the max element less than bound and the corresponding index.
Scalar min () const
 Retuen the min element.
Scalar min (int &index) const
 Return the min element and the corresponding index.
Scalar min (const Scalar &bound, int &index) const
 Return the min element greater than bound and the corresponding index.
Element loading interface
void setElement (OrdType globalIndex, const Scalar &value)
 set a single element at the given global index
void addToElement (OrdType globalIndex, const Scalar &value)
 add to the existing value of a single element at the given global index
void setElements (OrdType numElems, const OrdType *globalIndices, const Scalar *values)
 set a group of elements
void addToElements (OrdType numElems, const OrdType *globalIndices, const Scalar *values)
 add to a group of elements
void finalizeAssembly ()
 Do whatever finalization steps are needed by the implementation, for instance, synchronizing border elements.
Element access interface
Scalar getElement (OrdType globalIndex) const
 get the element at the given global index
void getElements (const int *globalIndices, int numElems, Teuchos::Array< Scalar > &elems) const
 Get a batch of elements.
const Scalar & operator[] (const SequentialIterator< Scalar > &index) const
 const bracket operator
Scalar & operator[] (const SequentialIterator< Scalar > &index)
 non - const bracket operator
Raw data access interface
const Scalar * dataPtr () const
Scalar * dataPtr ()

Static Public Member Functions

static RCP< Time > & opTimer ()
 Get a stopwtach for timing vector operations.

Private Member Functions

const AccessibleVector< Scalar > * castToAccessible () const
 Cross-cast vector pointer to an accessible vector.
LoadableVector< Scalar > * castToLoadable ()
 Cross-cast vector to a loadable vector.
const RawDataAccessibleVector
< Scalar > * 
castToRawDataAccessible () const
 Cross-cast vector pointer to a raw data accessible vector.
RawDataAccessibleVector< Scalar > * castToRawDataAccessible ()
 Cross-cast vector to a raw data accessible vector.
void boundscheck (OrdType i, int dim) const
 Test for valid index.
const Scalar & localElement (const OrdType &blockIndex, const OrdType &indexInBlock) const
Scalar & localElement (const OrdType &blockIndex, const OrdType &indexInBlock)

Related Functions

(Note that these are not member functions.)

template<class Scalar >
void randomize (Vector< Scalar > &x)

Detailed Description

template<class Scalar>
class TSFExtended::Vector< Scalar >

User-level vector class.

Creating vectors

Ordinarily, you will never construct a Vector directly from a derived type. Rather, the createMember() method of VectorSpace is used to build a vector of the appropriate type, for example,

 VectorType<double> vecType = new EpetraVectorType();
 int dimension = 100;
 VectorSpace<double> space = vecType.createSpace(dimension);
 Vector<double> x = space.createMember(); 
 Vector<double> y = space.createMember(); 

This hides from you all the ugly details of creating a particular concrete type.

You will frequently create an empty vector to be filled in later, for example,

 Vector<double> y;

Note that this vector isn't just empty, it's null. Not only does it have no values assigned, it does not have a concrete type. An call a method on a null vector will result in an error. What you <it>can</it> do with a null vector is

Definition at line 105 of file TSFVectorDecl.hpp.


Constructor & Destructor Documentation

template<class Scalar>
TSFExtended::Vector< Scalar >::Vector ( ) [inline]

Empty ctor.

Definition at line 110 of file TSFVectorDecl.hpp.

template<class Scalar>
TSFExtended::Vector< Scalar >::Vector ( Handleable< Thyra::VectorBase< Scalar > > *  rawPtr) [inline]

Construct a Vector<Scalar> with a raw pointer to a Thyra::VectorBase<Scalar>

Definition at line 110 of file TSFVectorDecl.hpp.

template<class Scalar>
TSFExtended::Vector< Scalar >::Vector ( const RefCountPtr< Thyra::VectorBase< Scalar > > &  smartPtr) [inline]

Construct a Vector<Scalar> with a smart pointer to a Thyra::VectorBase<Scalar>

Definition at line 110 of file TSFVectorDecl.hpp.

template<class Scalar>
template<class Node1 , class Node2 >
TSFExtended::Vector< Scalar >::Vector ( const TSFExtendedOps::LC2< Scalar, Node1, Node2 > &  x) [inline]

Construct a vector from a 2-term LC.

Definition at line 574 of file TSFLinearCombinationImpl.hpp.

template<class Scalar>
template<class Node >
TSFExtended::Vector< Scalar >::Vector ( const TSFExtendedOps::OpTimesLC< Scalar, Node > &  x) [inline]

Construct a vector from an operator times a linear combination.

Definition at line 580 of file TSFLinearCombinationImpl.hpp.


Member Function Documentation

template<class Scalar >
Vector< Scalar > TSFExtended::Vector< Scalar >::abs ( ) const [inline]

Return element-by-element absolute value as a new vector.

Definition at line 298 of file TSFVectorImpl.hpp.

References TSFExtended::Vector< Scalar >::abs(), and TSFExtended::Vector< Scalar >::acceptCopyOf().

Referenced by TSFExtended::Vector< Scalar >::abs().

template<class Scalar >
Vector< Scalar > & TSFExtended::Vector< Scalar >::abs ( ) [inline]

Overwrite self with element-by-element absolute value.

Definition at line 330 of file TSFVectorImpl.hpp.

template<class Scalar>
Vector< Scalar > & TSFExtended::Vector< Scalar >::acceptCopyOf ( const Vector< Scalar > &  x) [inline]
template<class Scalar>
void TSFExtended::Vector< Scalar >::addInto ( Vector< Scalar > &  other,
TSFExtendedOps::LCSign  sign 
) const [inline]

Definition at line 377 of file TSFVectorDecl.hpp.

template<class Scalar>
void TSFExtended::Vector< Scalar >::addToElement ( OrdType  globalIndex,
const Scalar &  value 
) [inline]
template<class Scalar>
void TSFExtended::Vector< Scalar >::addToElements ( OrdType  numElems,
const OrdType globalIndices,
const Scalar *  values 
) [inline]

add to a group of elements

Definition at line 317 of file TSFVectorDecl.hpp.

template<class Scalar >
void TSFExtended::Vector< Scalar >::boundscheck ( OrdType  i,
int  dim 
) const [inline, private]

Test for valid index.

Definition at line 875 of file TSFVectorImpl.hpp.

template<class Scalar >
const AccessibleVector< Scalar > * TSFExtended::Vector< Scalar >::castToAccessible ( ) const [inline, private]

Cross-cast vector pointer to an accessible vector.

Definition at line 131 of file TSFVectorImpl.hpp.

Referenced by TSFExtended::Vector< double >::getElements().

template<class Scalar >
LoadableVector< Scalar > * TSFExtended::Vector< Scalar >::castToLoadable ( ) [inline, private]
template<class Scalar >
RawDataAccessibleVector< Scalar > * TSFExtended::Vector< Scalar >::castToRawDataAccessible ( ) [inline, private]

Cross-cast vector to a raw data accessible vector.

Definition at line 169 of file TSFVectorImpl.hpp.

template<class Scalar >
const RawDataAccessibleVector< Scalar > * TSFExtended::Vector< Scalar >::castToRawDataAccessible ( ) const [inline, private]

Cross-cast vector pointer to a raw data accessible vector.

Definition at line 156 of file TSFVectorImpl.hpp.

Referenced by TSFExtended::Vector< double >::dataPtr().

template<class Scalar>
bool TSFExtended::Vector< Scalar >::containsVector ( const Thyra::VectorBase< Scalar > *  vec) const [inline]

Definition at line 372 of file TSFVectorDecl.hpp.

template<class Scalar >
Vector< Scalar > TSFExtended::Vector< Scalar >::copy ( ) const [inline]
template<class Scalar>
const Scalar* TSFExtended::Vector< Scalar >::dataPtr ( ) const [inline]

Definition at line 350 of file TSFVectorDecl.hpp.

template<class Scalar>
Scalar* TSFExtended::Vector< Scalar >::dataPtr ( ) [inline]

Definition at line 354 of file TSFVectorDecl.hpp.

template<class Scalar>
std::string TSFExtended::Vector< Scalar >::description ( ) const [inline]
template<class Scalar>
int TSFExtended::Vector< Scalar >::dim ( ) const [inline]

Return the dimension of the vector.

Definition at line 134 of file TSFVectorDecl.hpp.

template<class Scalar>
Scalar TSFExtended::Vector< Scalar >::dot ( const Vector< Scalar > &  other) const [inline]
template<class Scalar>
Vector< Scalar > TSFExtended::Vector< Scalar >::dotSlash ( const Vector< Scalar > &  other) const [inline]

Element-by-element division (Matlab dot-slash operator)

Definition at line 281 of file TSFVectorImpl.hpp.

References Sundance::Handle< Thyra::VectorBase< Scalar > >::ptr().

Referenced by TSFExtended::VectorTester< Scalar >::dotSlashTest().

template<class Scalar>
Vector< Scalar > TSFExtended::Vector< Scalar >::dotStar ( const Vector< Scalar > &  other) const [inline]
template<class Scalar>
void TSFExtended::Vector< Scalar >::dotStarInto ( const Vector< Scalar > &  a,
const Vector< Scalar > &  b 
) const [inline]

Write the elementwise product of $a$ and $b$ into <t>this.

</t>

Definition at line 267 of file TSFVectorImpl.hpp.

References Sundance::Handle< Thyra::VectorBase< Scalar > >::ptr().

template<class Scalar>
Vector<Scalar> TSFExtended::Vector< Scalar >::eval ( ) const [inline]
template<class Scalar>
void TSFExtended::Vector< Scalar >::evalInto ( Vector< Scalar > &  other) const [inline]

Definition at line 375 of file TSFVectorDecl.hpp.

template<class Scalar>
void TSFExtended::Vector< Scalar >::finalizeAssembly ( ) [inline]

Do whatever finalization steps are needed by the implementation, for instance, synchronizing border elements.

The default implementation is a no-op.

Definition at line 324 of file TSFVectorDecl.hpp.

template<class Scalar >
Vector< Scalar > TSFExtended::Vector< Scalar >::getBlock ( int  i) const
template<class Scalar >
Scalar TSFExtended::Vector< Scalar >::getElement ( OrdType  globalIndex) const [inline]
template<class Scalar>
void TSFExtended::Vector< Scalar >::getElements ( const int *  globalIndices,
int  numElems,
Teuchos::Array< Scalar > &  elems 
) const [inline]

Get a batch of elements.

Definition at line 334 of file TSFVectorDecl.hpp.

template<class Scalar >
const Scalar & TSFExtended::Vector< Scalar >::localElement ( const OrdType blockIndex,
const OrdType indexInBlock 
) const [inline, private]

Definition at line 741 of file TSFVectorImpl.hpp.

template<class Scalar >
Scalar & TSFExtended::Vector< Scalar >::localElement ( const OrdType blockIndex,
const OrdType indexInBlock 
) [inline, private]
template<class Scalar >
Scalar TSFExtended::Vector< Scalar >::max ( int &  index) const [inline]

Return the max element and the corresponding index.

Definition at line 507 of file TSFVectorImpl.hpp.

template<class Scalar >
Scalar TSFExtended::Vector< Scalar >::max ( ) const [inline]

Retuen the max element.

Definition at line 498 of file TSFVectorImpl.hpp.

template<class Scalar>
Scalar TSFExtended::Vector< Scalar >::max ( const Scalar &  bound,
int &  index 
) const [inline]

Return the max element less than bound and the corresponding index.

Definition at line 522 of file TSFVectorImpl.hpp.

template<class Scalar>
Scalar TSFExtended::Vector< Scalar >::min ( const Scalar &  bound,
int &  index 
) const [inline]

Return the min element greater than bound and the corresponding index.

Definition at line 562 of file TSFVectorImpl.hpp.

template<class Scalar >
Scalar TSFExtended::Vector< Scalar >::min ( int &  index) const [inline]

Return the min element and the corresponding index.

Definition at line 547 of file TSFVectorImpl.hpp.

template<class Scalar >
Scalar TSFExtended::Vector< Scalar >::min ( ) const [inline]

Retuen the min element.

Definition at line 538 of file TSFVectorImpl.hpp.

template<class Scalar >
Scalar TSFExtended::Vector< Scalar >::norm1 ( ) const [inline]

Compute the 1-norm of this vector.

Definition at line 425 of file TSFVectorImpl.hpp.

template<class Scalar>
Scalar TSFExtended::Vector< Scalar >::norm2 ( const Vector< Scalar > &  weights) const [inline]

Compute the weighted 2-norm of this vector.

Definition at line 448 of file TSFVectorImpl.hpp.

References Sundance::Handle< Thyra::VectorBase< Scalar > >::ptr().

template<class Scalar >
Scalar TSFExtended::Vector< Scalar >::norm2 ( ) const [inline]
template<class Scalar >
Scalar TSFExtended::Vector< Scalar >::normInf ( ) const [inline]

Compute the infinity-norm of this vector.

Definition at line 461 of file TSFVectorImpl.hpp.

template<class Scalar>
Scalar TSFExtended::Vector< Scalar >::operator* ( const Vector< Scalar > &  other) const [inline]

Overloaded operator for dot product.

Definition at line 415 of file TSFVectorImpl.hpp.

template<class Scalar>
template<class Node >
Vector< Scalar > & TSFExtended::Vector< Scalar >::operator= ( const TSFExtendedOps::OpTimesLC< Scalar, Node > &  x) [inline]
template<class Scalar>
template<class Node1 , class Node2 >
Vector< Scalar > & TSFExtended::Vector< Scalar >::operator= ( const TSFExtendedOps::LC2< Scalar, Node1, Node2 > &  x) [inline]
template<class Scalar>
Scalar & TSFExtended::Vector< Scalar >::operator[] ( const SequentialIterator< Scalar > &  index) [inline]
template<class Scalar>
const Scalar & TSFExtended::Vector< Scalar >::operator[] ( const SequentialIterator< Scalar > &  index) const [inline]
template<class Scalar>
static RCP<Time>& TSFExtended::Vector< Scalar >::opTimer ( ) [inline, static]

Get a stopwtach for timing vector operations.

Definition at line 361 of file TSFVectorDecl.hpp.

template<class Scalar >
void TSFExtended::Vector< Scalar >::print ( std::ostream &  os) const

Print to a stream using the Printable interface.

If the contents of the handle cannot be downcasted or crosscasted to a Printable*, an exception will be thrown

Reimplemented from Sundance::Handle< Thyra::VectorBase< Scalar > >.

Definition at line 92 of file TSFVectorImpl.hpp.

References Sundance::Printable::print().

Referenced by NOX::TSF::Group::applyJacobianInverse(), TSFExtended::NonlinearOperatorBase< double >::getFunctionValue(), and TSFExtended::NonlinearOperatorBase< double >::setEvalPt().

template<class Scalar >
Vector< Scalar > & TSFExtended::Vector< Scalar >::reciprocal ( ) [inline]

Overwrite self with element-by-element reciprocal.

Definition at line 345 of file TSFVectorImpl.hpp.

template<class Scalar >
Vector< Scalar > TSFExtended::Vector< Scalar >::reciprocal ( ) const [inline]

Return element-by-element reciprocal as a new vector.

Definition at line 315 of file TSFVectorImpl.hpp.

References TSFExtended::Vector< Scalar >::acceptCopyOf(), and TSFExtended::Vector< Scalar >::reciprocal().

Referenced by TSFExtended::Vector< Scalar >::reciprocal().

template<class Scalar>
Vector< Scalar > & TSFExtended::Vector< Scalar >::scale ( const Scalar &  alpha) [inline]
template<class Scalar>
void TSFExtended::Vector< Scalar >::setBlock ( int  i,
const Vector< Scalar > &  v 
)
template<class Scalar>
void TSFExtended::Vector< Scalar >::setElement ( OrdType  globalIndex,
const Scalar &  value 
) [inline]
template<class Scalar>
void TSFExtended::Vector< Scalar >::setElements ( OrdType  numElems,
const OrdType globalIndices,
const Scalar *  values 
) [inline]

set a group of elements

Definition at line 312 of file TSFVectorDecl.hpp.

template<class Scalar>
void TSFExtended::Vector< Scalar >::setToConstant ( const Scalar &  alpha) [inline]
template<class Scalar>
VectorSpace<Scalar> TSFExtended::Vector< Scalar >::space ( ) const [inline]
template<class Scalar>
Vector< Scalar > & TSFExtended::Vector< Scalar >::update ( const Scalar &  alpha,
const Vector< Scalar > &  x,
const Scalar &  gamma 
) [inline]

Add a scaled vector to this vector times a constant:

 this = gamma*this + alpha*x 

Definition at line 357 of file TSFVectorImpl.hpp.

References Sundance::Handle< Thyra::VectorBase< Scalar > >::ptr().

template<class Scalar>
Vector< Scalar > & TSFExtended::Vector< Scalar >::update ( const Scalar &  alpha,
const Vector< Scalar > &  x,
const Scalar &  beta,
const Vector< Scalar > &  y,
const Scalar &  gamma 
) [inline]

Add two scaled vectors to this vector times a constant:

 this = alpha*x + beta*y + gamma*this

Definition at line 377 of file TSFVectorImpl.hpp.

References Sundance::Handle< Thyra::VectorBase< Scalar > >::ptr().

template<class Scalar>
Vector< Scalar > & TSFExtended::Vector< Scalar >::update ( const Scalar &  alpha,
const Vector< Scalar > &  x 
) [inline]
template<class Scalar >
void TSFExtended::Vector< Scalar >::zero ( ) [inline]

Friends And Related Function Documentation

template<class Scalar >
void randomize ( Vector< Scalar > &  x) [related]

Definition at line 43 of file TSFVectorOpsImpl.hpp.

Site Contact