yat  0.14.5pre
Public Types | Public Member Functions | Protected Attributes | Related Functions | List of all members
theplu::yat::utility::VectorConstView Class Reference

Read-only view. More...

#include <yat/utility/VectorConstView.h>

Inheritance diagram for theplu::yat::utility::VectorConstView:
theplu::yat::utility::VectorBase

Public Types

typedef double value_type
 
typedef const double & const_reference
 
typedef StrideIterator< const
double * > 
const_iterator
 VectorBase::const_iterator.
 

Public Member Functions

 VectorConstView (const VectorConstView &other)
 The copy constructor.
 
 VectorConstView (const VectorBase &other)
 Copy a VectorBase.
 
 VectorConstView (const VectorBase &v, size_t offset, size_t n, size_t stride=1)
 const view into a vector More...
 
 VectorConstView (const Matrix &m, size_t i, bool row=true)
 Matrix row/column view constructor. More...
 
 ~VectorConstView (void)
 
bool isview (void) const
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
bool equal (const VectorBase &, const double precision=0) const
 Check whether VectorBases are equal within a user defined precision, set by precision. More...
 
const gsl_vector * gsl_vector_p (void) const
 
size_t size (void) const
 
const double & operator() (size_t i) const
 Element access operator. More...
 
bool operator== (const VectorBase &) const
 Comparison operator. Takes linear time. More...
 
bool operator!= (const VectorBase &) const
 Comparison operator. Takes linear time. More...
 
double operator* (const VectorBase &) const
 

Protected Attributes

const gsl_vector * const_vec_
 pointer to underlying GSL vector
 

Related Functions

(Note that these are not member functions.)

Vector operator* (const VectorBase &, const Matrix &)
 Matrix Vector multiplication.
 
bool isnull (const VectorBase &)
 Check if all elements of the VectorBase are zero. More...
 
double max (const VectorBase &)
 Get the maximum value of the VectorBase. More...
 
size_t max_index (const VectorBase &)
 Locate the maximum value in the VectorBase. More...
 
double min (const VectorBase &)
 Get the minimum value of the VectorBase. More...
 
size_t min_index (const VectorBase &)
 Locate the minimum value in the VectorBase. More...
 
bool nan (const VectorBase &templat, Vector &flag)
 Create a VectorBase flag indicating NaN's in another VectorBase templat. More...
 
void sort_index (std::vector< size_t > &sort_index, const VectorBase &invec)
 
void sort_smallest_index (std::vector< size_t > &sort_index, size_t k, const VectorBase &invec)
 
void sort_largest_index (std::vector< size_t > &sort_index, size_t k, const VectorBase &invec)
 
double sum (const VectorBase &)
 Calculate the sum of all VectorBase elements. More...
 
std::ostream & operator<< (std::ostream &s, const VectorBase &v)
 The output operator for the VectorBase class. More...
 

Detailed Description

Read-only view.

Wrapper to gsl_vector_const_view

With this class you can create a view into const objects - either a vector or matrix. By design all functionality in this class is const to guarantee that the viewed object is not modified.

Note
that view vectors do not own the underlying data, and a view is not valid if the vector/matrix owing the data is deallocated.

Member Typedef Documentation

typedef const double& theplu::yat::utility::VectorBase::const_reference
inherited

const_reference type is const double&

Since
New in yat 0.5

value_type is double

Since
New in yat 0.5

Constructor & Destructor Documentation

theplu::yat::utility::VectorConstView::VectorConstView ( const VectorBase v,
size_t  offset,
size_t  n,
size_t  stride = 1 
)

const view into a vector

Create a const view of VectorBase v, with starting index offset, size n, and an optional stride.

Note
If the object viewed by the view goes out of scope or is deleted, the view becomes invalid and the result of further use is undefined.
Exceptions
GSL_errorif a view cannot be set up.
theplu::yat::utility::VectorConstView::VectorConstView ( const Matrix m,
size_t  i,
bool  row = true 
)

Matrix row/column view constructor.

Create a view into a row/column of a matrix.

Parameters
mmatrix to view into.
iindex telling which row/column to view into
rowif true (defult) created view is a row vector, i.e., viewing into row i, and, naturally, a column vector otherwise.
See Also
matrix::column_const_view(size_t) and matrix::row_const_view(size_t)
Note
If the object viewed by the view goes out of scope or is deleted, the view becomes invalid and the result of further use is undefined.
theplu::yat::utility::VectorConstView::~VectorConstView ( void  )

The destructor.

Member Function Documentation

const_iterator theplu::yat::utility::VectorBase::begin ( void  ) const
inherited
Returns
read-only iterator to start of VectorBase
const_iterator theplu::yat::utility::VectorBase::end ( void  ) const
inherited
Returns
read-only iterator to end of VectorBase
bool theplu::yat::utility::VectorBase::equal ( const VectorBase ,
const double  precision = 0 
) const
inherited

Check whether VectorBases are equal within a user defined precision, set by precision.

Returns
True if each element deviates less or equal than d. If any VectorBase contain a NaN, false is always returned.
See Also
operator== and operator!=
const gsl_vector* theplu::yat::utility::VectorBase::gsl_vector_p ( void  ) const
inherited
Returns
A const pointer to the internal GSL vector,
bool theplu::yat::utility::VectorConstView::isview ( void  ) const
virtual
Returns
true

Implements theplu::yat::utility::VectorBase.

bool theplu::yat::utility::VectorBase::operator!= ( const VectorBase ) const
inherited

Comparison operator. Takes linear time.

Checks are performed with exact matching, i.e., rounding off effects may destroy comparison. Use the equal function for comparing elements within a user defined precision.

Returns
False if all elements are equal otherwise true.
See Also
equal(const VectorBase&, const double precision=0)
const double& theplu::yat::utility::VectorBase::operator() ( size_t  i) const
inherited

Element access operator.

Returns
Const reference to element i.
Exceptions
IfGSL range checks are enabled in the underlying GSL library a GSL_error exception is thrown if either index is out of range.
double theplu::yat::utility::VectorBase::operator* ( const VectorBase ) const
inherited
Returns
The dot product.
bool theplu::yat::utility::VectorBase::operator== ( const VectorBase ) const
inherited

Comparison operator. Takes linear time.

Checks are performed with exact matching, i.e., rounding off effects may destroy comparison. Use the equal function for comparing elements within a user defined precision.

Returns
True if all elements are equal otherwise false.
See Also
equal(const VectorBase&, const double precision=0)
size_t theplu::yat::utility::VectorBase::size ( void  ) const
inherited
Returns
number of elements in the VectorBase.

Friends And Related Function Documentation

bool isnull ( const VectorBase )
related

Check if all elements of the VectorBase are zero.

Returns
True if all elements in the VectorBase is zero, false othwerwise.
double max ( const VectorBase )
related

Get the maximum value of the VectorBase.

Returns
The maximum value of the VectorBase.
size_t max_index ( const VectorBase )
related

Locate the maximum value in the VectorBase.

Returns
The index to the maximum value of the VectorBase.
Note
Lower index has precedence.
double min ( const VectorBase )
related

Get the minimum value of the VectorBase.

Returns
The minimum value of the VectorBase.
size_t min_index ( const VectorBase )
related

Locate the minimum value in the VectorBase.

Returns
The index to the minimum value of the VectorBase.
Note
Lower index has precedence.
bool nan ( const VectorBase templat,
Vector flag 
)
related

Create a VectorBase flag indicating NaN's in another VectorBase templat.

The flag VectorBase is changed to contain 1's and 0's only. A 1 means that the corresponding element in the templat VectorBase is valid and a zero means that the corresponding element is a NaN.

Note
Space for vector flag is reallocated to fit the size of VectorBase templat if sizes mismatch.
Returns
True if the templat VectorBase contains at least one NaN.
std::ostream & operator<< ( std::ostream &  s,
const VectorBase v 
)
related

The output operator for the VectorBase class.

Elements in VectorBase v are sent to ostream s and separated with the fill character of stream s, s.fill(). If you, for example, want to print the VectorBase v with the elements separated by a ':', you do so by:

s << setfill(':') << v;
void sort_index ( std::vector< size_t > &  sort_index,
const VectorBase invec 
)
related

Create a vector sort_index containing the indeces of elements in a another VectorBase invec. The elements of sort_index give the index of the VectorBase element which would have been stored in that position if the VectorBase had been sorted in place. The first element of sort_index gives the index of the least element in invec, and the last element of sort_index gives the index of the greatest element in invec . The VectorBase invec is not changed.

void sort_largest_index ( std::vector< size_t > &  sort_index,
size_t  k,
const VectorBase invec 
)
related

Similar to sort_index but creates a VectorBase with indices to the k largest elements in invec.

void sort_smallest_index ( std::vector< size_t > &  sort_index,
size_t  k,
const VectorBase invec 
)
related

Similar to sort_index but creates a VectorBase with indices to the k smallest elements in invec.

double sum ( const VectorBase )
related

Calculate the sum of all VectorBase elements.

Returns
The sum.

The documentation for this class was generated from the following file:

Generated on Tue Sep 26 2017 02:33:31 for yat by  doxygen 1.8.5