CARMA C++
carma::services::Vector< T > Class Template Reference

This class handles standard mathematical vector operations. More...

#include <carma/services/Vector.h>

Public Member Functions

const Vector< type > cross (const Vector< type > &vec)
 Assignment void operator=(const Vector<type>& vec);. More...
 
double magnitude ()
 Get the magnitude of a vector. More...
 
const type operator* (const Vector< type > &vec)
 Vector multiplication, aka dot product. More...
 
const Vector< type > operator* (const type factor)
 ...................................................................... More...
 
const Vector< type > operator+ (const Vector< type > &vec)
 Vector addition. More...
 
const Vector< type > operator+ (const type offset)
 ...................................................................... More...
 
const Vector< type > operator- (const Vector< type > &vec)
 ...................................................................... More...
 
const Vector< type > operator- (const type offset)
 ...................................................................... More...
 
const Vector< type > operator/ (const type factor)
 ...................................................................... More...
 
type & operator[] (unsigned i)
 Define an operator for accessing elements of the vector. More...
 
type operator[] (unsigned i) const
 
void resize (unsigned n)
 Private resize operator. More...
 
unsigned size () const
 Query the size of the vector. More...
 
 Vector (unsigned n)
 Constructor. More...
 
 Vector (unsigned n, type initializer)
 Constructor for class types without default constructor. More...
 
 Vector (type el0, type el1, type el2)
 Constructor. More...
 
 Vector (const Vector< type > &vec)
 Copy constructor. More...
 
 Vector ()
 Private constructor with no arguments. More...
 
virtual ~Vector ()
 Destructor. More...
 

Protected Attributes

std::vector< type > data_
 
unsigned nEl_
 Store the length. More...
 

Friends

std::ostream & carma::services::operator<< (std::ostream &os, const Vector< type > &vec)
 Declare a vector printing method. More...
 
std::ostringstream & carma::services::operator<< (std::ostringstream &os, const Vector< type > &vec)
 Declare a vector printing method. More...
 
class Matrix< type >
 Only Matrix can resize us. More...
 

Detailed Description

template<typename T>
class carma::services::Vector< T >

This class handles standard mathematical vector operations.

Definition at line 21 of file Location.h.

Constructor & Destructor Documentation

template<class type >
carma::services::Vector< type >::Vector ( unsigned  n)

Constructor.

......................................................................

Constructor

Definition at line 207 of file Vector.h.

template<class type >
carma::services::Vector< type >::Vector ( unsigned  n,
type  initializer 
)

Constructor for class types without default constructor.

......................................................................

Constructor for class types without default constructors

Definition at line 217 of file Vector.h.

template<class type >
carma::services::Vector< type >::Vector ( type  el0,
type  el1,
type  el2 
)

Constructor.

......................................................................

Constructor with three arguments

Definition at line 193 of file Vector.h.

template<class type >
carma::services::Vector< type >::Vector ( const Vector< type > &  vec)

Copy constructor.

......................................................................

Copy constructor

Definition at line 227 of file Vector.h.

template<class type >
carma::services::Vector< type >::~Vector ( )
virtual

Destructor.

......................................................................

Assignment

template<class type> void Vector<type>::operator=(const Vector<type>& vec) { cout << "Inside Vector assignment operator" << endl; cout << "vec.data_.size() = " << vec.data_.size() << endl;

    data_.resize(vec.data_.size());
    for(unsigned i=0; i < vec.data_.size(); i++) 
      data_[i] = vec.data_[i];

cout << "data_.size() = " << data_.size() << endl; }....................................................................... Destructor

Definition at line 253 of file Vector.h.

template<class type >
carma::services::Vector< type >::Vector ( )

Private constructor with no arguments.

......................................................................

Constructor

Definition at line 184 of file Vector.h.

Member Function Documentation

template<class type >
const Vector< type > carma::services::Vector< type >::cross ( const Vector< type > &  vec)

Assignment void operator=(const Vector<type>& vec);.

Cross product of two Vectors.

Definition at line 270 of file Vector.h.

template<class type >
double carma::services::Vector< type >::magnitude ( )

Get the magnitude of a vector.

Definition at line 259 of file Vector.h.

template<class type >
const type carma::services::Vector< type >::operator* ( const Vector< type > &  vec)

Vector multiplication, aka dot product.

......................................................................

Multiply two vectors together

Definition at line 345 of file Vector.h.

template<class type >
const Vector< type > carma::services::Vector< type >::operator* ( const type  factor)

......................................................................

Multiply a vector by a constant

Definition at line 425 of file Vector.h.

template<class type >
const Vector< type > carma::services::Vector< type >::operator+ ( const Vector< type > &  vec)

Vector addition.

......................................................................

Add two vectors together

Definition at line 370 of file Vector.h.

template<class type >
const Vector< type > carma::services::Vector< type >::operator+ ( const type  offset)

......................................................................

Add a constant to a vector

Definition at line 467 of file Vector.h.

template<class type >
const Vector< type > carma::services::Vector< type >::operator- ( const Vector< type > &  vec)

......................................................................

Subtraction

Subtract two vectors

Definition at line 398 of file Vector.h.

template<class type >
const Vector< type > carma::services::Vector< type >::operator- ( const type  offset)

......................................................................

Subtract a constant to a vector

Subtract a constant from a vector

Definition at line 488 of file Vector.h.

template<class type >
const Vector< type > carma::services::Vector< type >::operator/ ( const type  factor)

......................................................................

Divide a vector by a constant

Definition at line 446 of file Vector.h.

template<class type >
type & carma::services::Vector< type >::operator[] ( unsigned  i)

Define an operator for accessing elements of the vector.

......................................................................

Define an operator for accessing elements of the vector

Definition at line 318 of file Vector.h.

template<typename T>
void carma::services::Vector< T >::resize ( unsigned  n)

Private resize operator.

Definition at line 156 of file Vector.h.

template<typename T>
unsigned carma::services::Vector< T >::size ( ) const

Query the size of the vector.

Definition at line 71 of file Vector.h.

Friends And Related Function Documentation

template<typename T>
std::ostream& carma::services::operator<< ( std::ostream &  os,
const Vector< type > &  vec 
)
friend

Declare a vector printing method.

template<typename T>
std::ostringstream& carma::services::operator<< ( std::ostringstream &  os,
const Vector< type > &  vec 
)
friend

Declare a vector printing method.

template<typename T>
friend class Matrix< type >
friend

Only Matrix can resize us.

Definition at line 175 of file Vector.h.

Member Data Documentation

template<typename T>
unsigned carma::services::Vector< T >::nEl_
protected

Store the length.

Definition at line 170 of file Vector.h.


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