KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
kjb::Generic_vector_view< Vector_type > Class Template Reference

#include <m_vec_view.h>

Public Types

typedef Generic_vector_view Self
 
typedef Vector_type::value_type Value_type
 
typedef int Size_type
 

Public Member Functions

 Generic_vector_view (Vector_type &vec, const Index_range &indices)
 
 Generic_vector_view (Vector_type &vec)
 
 Generic_vector_view (const Generic_vector_view &src)
 
bool operator== (const Self &other)
 
bool operator== (const Vector_type &other)
 
bool operator!= (const Self &other)
 
bool operator!= (const Vector_type &other)
 
Value_typeoperator[] (int i)
 
Value_type operator[] (int i) const
 
Size_type size () const
 
Selfoperator= (const Vector_type &vec)
 
Selfoperator= (const Self &vec)
 
Selfoperator= (const Value_type &s)
 
Selfoperator= (const std::vector< double > &v)
 
Selfoperator= (const std::vector< float > &v)
 
Selfoperator*= (Value_type s)
 
double dot (const Self &s)
 
double dot (const Vector_type &s)
 
Selfoperator/= (Value_type s)
 
Selfoperator+= (const Self &s)
 
Selfoperator+= (const Vector_type &s)
 
Selfoperator-= (const Self &s)
 
Selfoperator-= (const Vector_type &s)
 

Protected Member Functions

template<class Generic_vector >
bool equality (const Generic_vector &mat)
 
template<class Generic_vector >
Selfassign (const Generic_vector &vec)
 
template<class Generic_vector >
Selfplus_equals (const Generic_vector &vec)
 
template<class Generic_vector >
double dot_with_ (const Generic_vector &vec)
 
template<class Generic_vector >
Selfminus_equals (const Generic_vector &vec)
 

Protected Attributes

Index_range indices_
 
Vector_type & vec_
 

Detailed Description

template<class Vector_type>
class kjb::Generic_vector_view< Vector_type >

Represents a filtered "view" of another vector. This object has the same semantics as a real vector, but altering it will alter the "visible" elements of the underlying vector. Here's an example

Vector vec(5, 1.0); Index_range I(2,3); Vector_view vec_view = vec(I); vec_view *= -1; assert(vec[0]) == 1); assert(vec[1]) == 1); assert(vec[2]) == -1); assert(vec[3]) == -1); assert(vec[4]) == 1);

Matlab-style indexing is possible, by leveraging the implicit conversion constructor from string to Index_range:

vec("2:3") *= -1;

Member Typedef Documentation

template<class Vector_type >
typedef Generic_vector_view kjb::Generic_vector_view< Vector_type >::Self
template<class Vector_type >
typedef int kjb::Generic_vector_view< Vector_type >::Size_type
template<class Vector_type >
typedef Vector_type::value_type kjb::Generic_vector_view< Vector_type >::Value_type

Constructor & Destructor Documentation

template<class Vector_type >
kjb::Generic_vector_view< Vector_type >::Generic_vector_view ( Vector_type &  vec,
const Index_range indices 
)
inline
template<class Vector_type >
kjb::Generic_vector_view< Vector_type >::Generic_vector_view ( Vector_type &  vec)
inline
template<class Vector_type >
kjb::Generic_vector_view< Vector_type >::Generic_vector_view ( const Generic_vector_view< Vector_type > &  src)
inline

Member Function Documentation

template<class Vector_type >
template<class Generic_vector >
Self& kjb::Generic_vector_view< Vector_type >::assign ( const Generic_vector &  vec)
inlineprotected

generic version of operator=(). Made private to avoid unwanted template instantiation.

template<class Vector_type >
double kjb::Generic_vector_view< Vector_type >::dot ( const Self s)
inline
template<class Vector_type >
double kjb::Generic_vector_view< Vector_type >::dot ( const Vector_type &  s)
inline
template<class Vector_type >
template<class Generic_vector >
double kjb::Generic_vector_view< Vector_type >::dot_with_ ( const Generic_vector &  vec)
inlineprotected

generic version of dot(). Made private to avoid unwanted template instantiation

template<class Vector_type >
template<class Generic_vector >
bool kjb::Generic_vector_view< Vector_type >::equality ( const Generic_vector &  mat)
inlineprotected

generic version of operator=(). Made private to avoid unwanted template instantiation.

template<class Vector_type >
template<class Generic_vector >
Self& kjb::Generic_vector_view< Vector_type >::minus_equals ( const Generic_vector &  vec)
inlineprotected

generic version of operator-=(). Made private to avoid unwanted template instantiation

template<class Vector_type >
bool kjb::Generic_vector_view< Vector_type >::operator!= ( const Self other)
inline
template<class Vector_type >
bool kjb::Generic_vector_view< Vector_type >::operator!= ( const Vector_type &  other)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator*= ( Value_type  s)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator+= ( const Self s)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator+= ( const Vector_type &  s)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator-= ( const Self s)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator-= ( const Vector_type &  s)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator/= ( Value_type  s)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator= ( const Vector_type &  vec)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator= ( const Self vec)
inline
template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator= ( const Value_type s)
inline

Set all elements to s

template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator= ( const std::vector< double > &  v)
inline

If this object has only 1 column or 1 row, set it equal to v or v', respectively.

template<class Vector_type >
Self& kjb::Generic_vector_view< Vector_type >::operator= ( const std::vector< float > &  v)
inline

If this object has only 1 column or 1 row, set it equal to v or v', respectively.

template<class Vector_type >
bool kjb::Generic_vector_view< Vector_type >::operator== ( const Self other)
inline
template<class Vector_type >
bool kjb::Generic_vector_view< Vector_type >::operator== ( const Vector_type &  other)
inline
template<class Vector_type >
Value_type& kjb::Generic_vector_view< Vector_type >::operator[] ( int  i)
inline
Warning
Bounds-checking is enabled, so expect a performance hit
template<class Vector_type >
Value_type kjb::Generic_vector_view< Vector_type >::operator[] ( int  i) const
inline
Warning
Bounds-checking is enabled, so expect a performance hit
template<class Vector_type >
template<class Generic_vector >
Self& kjb::Generic_vector_view< Vector_type >::plus_equals ( const Generic_vector &  vec)
inlineprotected

generic version of operator+=. Made private to avoid unwanted template instantiation

template<class Vector_type >
Size_type kjb::Generic_vector_view< Vector_type >::size ( ) const
inline

Member Data Documentation

template<class Vector_type >
Index_range kjb::Generic_vector_view< Vector_type >::indices_
protected
template<class Vector_type >
Vector_type& kjb::Generic_vector_view< Vector_type >::vec_
protected

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