cgv
cgv::math::vec< T > Class Template Reference

A column vector class. More...

#include <vec.h>

Inheritance diagram for cgv::math::vec< T >:
cgv::math::qem< T >

Public Member Functions

unsigned size () const
 number of elements
 
unsigned dim () const
 number of elements
 
 vec ()
 standard constructor
 
 vec (unsigned dim, const T &value=T(0))
 creates a vector with dim elements
 
 vec (unsigned dim, const T *marray)
 creates a vector with dim elements from an array
 
 vec (const vec< T > &v)
 copy constructor for vectors with equal element type

 
template<typename S >
 vec (const vec< S > &v)
 copy constructor for vectors with different element type
 
 vec (const T &c0, const T &c1)
 creates a 3d vector (c0,c1,c2)^T
 
 vec (const T &c0, const T &c1, const T &c2)
 creates a 3d vector (c0,c1,c2)^T
 
 vec (const T &c0, const T &c1, const T &c2, const T &c3)
 creates a 4d vector (c0,c1,c2,c3)^T
 
void set (const T &c0, const T &c1)
 set entries of a 2d vector
 
void set (const T &c0, const T &c1, const T &c2)
 set entries of a 3d vector
 
void set (const T &c0, const T &c1, const T &c2, const T &c3)
 set entries of a 4d vector
 
void set_extern_data (unsigned dim, T *data)
 set data pointer to an external data array
 
virtual ~vec ()
 destructor
 
 operator T* ()
 cast into non const array
 
 operator const T * () const
 cast into const array
 
vec< T > & operator= (const vec< T > &v)
 assignment of a vector v
 
vec< T > & operator= (const T &s)
 assignment of a scalar s
 
template<typename S >
vec< T > & operator= (const vec< S > &v)
 assignment of a vector v
 
T & operator() (unsigned i)
 element accessor
 
const T & operator() (unsigned i) const
 const element accessor
 
T & first ()
 element accessor for the first element
 
const T & first () const
 const element accessor for the first element
 
T & last ()
 element accessor for the flast element
 
const T & last () const
 const element accessor for the last element
 
T & x ()
 element accessor for the first element
 
const T & x () const
 const element accessor for the first element
 
T & y ()
 element accessor for the second element
 
const T & y () const
 const element accessor for the second element
 
T & z ()
 element accessor for the third element
 
const T & z () const
 const element accessor for the third element
 
T & w ()
 element accessor for the fourth element
 
const T & w () const
 const element accessor for the fourth element
 
vec< T > & operator+= (const T &s)
 in place addition of a scalar s
 
vec< T > & operator-= (const T &s)
 in place subtraction by scalar s
 
vec< T > & operator*= (const T &s)
 in place multiplication with s
 
vec< T > & operator/= (const T &s)
 in place division by scalar s
 
template<typename S >
vec< T > & operator+= (const vec< S > &v)
 in place vector addition
 
template<typename S >
vec< T > & operator-= (const vec< S > &v)
 in place vector subtraction
 
template<typename S >
vec< T > & operator*= (const vec< S > &v)
 in place componentwise vector multiplication
 
template<typename S >
vec< T > & operator/= (const vec< S > &v)
 in place componentwise vector division
 
template<typename S >
const vec< T > operator+ (const vec< S > &v) const
 vector addition
 
const vec< T > operator+ (const T &s) const
 componentwise addition of scalar
 
const vec< T > operator- (const T &s) const
 componentwise subtraction of scalar
 
template<typename S >
vec< T > operator- (const vec< S > &v) const
 vector subtraction
 
template<typename S >
const vec< T > operator* (const vec< S > &v) const
 componentwise vector multiplication
 
template<typename S >
const vec< T > operator/ (const vec< S > &v) const
 componentwise vector division
 
vec< T > operator- (void) const
 negates the vector
 
vec< T > operator* (const T &s) const
 multiplication with scalar s
 
vec< T > operator/ (const T &s) const
 divides vector by scalar s
 
void fill (const T &v)
 fill elements of vector with scalar v
 
void zeros ()
 fill the vector with zeros
 
void ones ()
 fill the vector with ones
 
void zeros (unsigned n)
 resize the vector to size n and fills the vector with zeros
 
void ones (unsigned n)
 resize the vector to size n and fills thevector with ones
 
void resize (unsigned dim)
 resize the vector
 
template<typename S >
bool operator== (const vec< S > &v) const
 test for equality
 
template<typename S >
bool operator!= (const vec< S > &v) const
 test for inequality
 
length () const
 length of the vector L2-Norm
 
void abs ()
 componentwise absolute values
 
void ceil ()
 ceil componentwise
 
void floor ()
 floor componentwise
 
void round ()
 round componentwise
 
sqr_length () const
 square length of vector
 
void normalize ()
 normalize the vector using the L2-Norm
 
vec< T > sub_vec (unsigned ifrom, unsigned size) const
 extracts sub vector beginning at index ifrom with given size
 
void copy (unsigned ifrom, unsigned s, vec< T > &subvec) const
 copy sub vector beginning at index ifrom with given size s into subvec
 
void paste (unsigned ifrom, const vec< T > &v)
 paste v into vector beginning at index pos ifrom
 

Protected Attributes

T * _data
 pointer to _data storage
 
unsigned _size
 number or elements
 
bool data_is_external
 store whether data is not owned by vector
 

Detailed Description

template<typename T>
class cgv::math::vec< T >

A column vector class.


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