Public Member Functions

QuadProgPP::Vector< T > Class Template Reference

#include <Array.h>

Inheritance diagram for QuadProgPP::Vector< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Vector ()
 Vector (const unsigned int n)
 Vector (const T &a, const unsigned int n)
 Vector (const T *a, const unsigned int n)
 Vector (const Vector &rhs)
 ~Vector ()
void set (const T *a, const unsigned int n)
Vector< T > extract (const std::set< unsigned int > &indexes) const
T & operator[] (const unsigned int &i)
const T & operator[] (const unsigned int &i) const
unsigned int size () const
void resize (const unsigned int n)
void resize (const T &a, const unsigned int n)
Vector< T > & operator= (const Vector< T > &rhs)
Vector< T > & operator= (const T &a)
Vector< T > & operator+= (const Vector< T > &rhs)
Vector< T > & operator-= (const Vector< T > &rhs)
Vector< T > & operator*= (const Vector< T > &rhs)
Vector< T > & operator/= (const Vector< T > &rhs)
Vector< T > & operator^= (const Vector< T > &rhs)
Vector< T > & operator+= (const T &a)
Vector< T > & operator-= (const T &a)
Vector< T > & operator*= (const T &a)
Vector< T > & operator/= (const T &a)
Vector< T > & operator^= (const T &a)

Detailed Description

template<typename T>
class QuadProgPP::Vector< T >

Definition at line 35 of file Array.h.


Constructor & Destructor Documentation

template<typename T >
QuadProgPP::Vector< T >::Vector (  )

Definition at line 73 of file Array.h.

  : v(0), n(0)
{} 
template<typename T >
QuadProgPP::Vector< T >::Vector ( const unsigned int  n )

Definition at line 78 of file Array.h.

  : v(new T[n]) 
{
  this->n = n;
} 
template<typename T>
QuadProgPP::Vector< T >::Vector ( const T &  a,
const unsigned int  n 
)

Definition at line 85 of file Array.h.

  : v(new T[n])
{ 
  this->n = n;
  for (unsigned int i = 0; i < n; i++) 
    v[i] = a; 
} 
template<typename T>
QuadProgPP::Vector< T >::Vector ( const T *  a,
const unsigned int  n 
)

Definition at line 94 of file Array.h.

  : v(new T[n])
{ 
  this->n = n;
  for (unsigned int i = 0; i < n; i++) 
    v[i] = *a++; 
} 
template<typename T>
QuadProgPP::Vector< T >::Vector ( const Vector< T > &  rhs )

Definition at line 103 of file Array.h.

  : v(new T[rhs.n])
{ 
  this->n = rhs.n;
  for (unsigned int     i = 0; i < n; i++) 
    v[i] = rhs[i]; 
} 
template<typename T >
QuadProgPP::Vector< T >::~Vector (  )

Definition at line 112 of file Array.h.

{ 
  if (v != 0) 
    delete[] (v); 
} 

Member Function Documentation

template<typename T >
Vector< T > QuadProgPP::Vector< T >::extract ( const std::set< unsigned int > &  indexes ) const [inline]

Definition at line 188 of file Array.h.

{
  Vector<T> tmp(indexes.size());
  unsigned int i = 0;
        
  for (std::set<unsigned int>::const_iterator el = indexes.begin(); el != indexes.end(); el++)
    {
      if (*el >= n)
        throw std::logic_error("Error extracting subvector: the indexes are out of vector bounds");
      tmp[i++] = v[*el];
    }
        
  return tmp;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator*= ( const T &  a ) [inline]

Definition at line 334 of file Array.h.

{
  for (unsigned int i = 0; i < n; i++)
    v[i] *= a;
        
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator*= ( const Vector< T > &  rhs ) [inline]

Definition at line 322 of file Array.h.

References QuadProgPP::Vector< T >::size().

{
  if (this->size() != rhs.size())
    throw std::logic_error("Operator*=: vectors have different sizes");
  for (unsigned int i = 0; i < n; i++)
    v[i] *= rhs[i];
        
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator+= ( const Vector< T > &  rhs ) [inline]

Definition at line 204 of file Array.h.

References QuadProgPP::Vector< T >::size().

{
  if (this->size() != rhs.size())
    throw std::logic_error("Operator+=: vectors have different sizes");
  for (unsigned int i = 0; i < n; i++)
    v[i] += rhs[i];
        
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator+= ( const T &  a ) [inline]

Definition at line 216 of file Array.h.

{
  for (unsigned int i = 0; i < n; i++)
    v[i] += a;
        
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator-= ( const T &  a ) [inline]

Definition at line 275 of file Array.h.

{
  for (unsigned int i = 0; i < n; i++)
    v[i] -= a;
        
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator-= ( const Vector< T > &  rhs ) [inline]

Definition at line 263 of file Array.h.

References QuadProgPP::Vector< T >::size().

{
  if (this->size() != rhs.size())
    throw std::logic_error("Operator-=: vectors have different sizes");
  for (unsigned int i = 0; i < n; i++)
    v[i] -= rhs[i];
        
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator/= ( const T &  a ) [inline]

Definition at line 387 of file Array.h.

{
  for (unsigned int i = 0; i < n; i++)
    v[i] /= a;
        
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator/= ( const Vector< T > &  rhs ) [inline]

Definition at line 375 of file Array.h.

References QuadProgPP::Vector< T >::size().

{
  if (this->size() != rhs.size())
    throw std::logic_error("Operator/=: vectors have different sizes");
  for (unsigned int i = 0; i < n; i++)
    v[i] /= rhs[i];
        
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator= ( const T &  a ) [inline]

Definition at line 154 of file Array.h.

{ 
  for (unsigned int i = 0; i < n; i++) 
    v[i] = a; 
  return *this; 
} 
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator= ( const Vector< T > &  rhs ) [inline]

Definition at line 139 of file Array.h.

                : normal assignment via copying has been performed; 
// if vector and rhs were different sizes, vector 
// has been resized to match the size of rhs 
{ 
  if (this != &rhs) 
    { 
      resize(rhs.n);
      for (unsigned int i = 0; i < n; i++) 
        v[i] = rhs[i]; 
    } 
  return *this; 
} 
template<typename T >
T & QuadProgPP::Vector< T >::operator[] ( const unsigned int &  i ) [inline]

Definition at line 162 of file Array.h.

{ 
  return v[i]; 
}
template<typename T >
const T & QuadProgPP::Vector< T >::operator[] ( const unsigned int &  i ) const [inline]

Definition at line 168 of file Array.h.

{ 
  return v[i]; 
} 
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator^= ( const T &  a ) [inline]

Definition at line 471 of file Array.h.

References QuadProgPP::pow().

{
  for (unsigned int i = 0; i < n; i++)
    v[i] = pow(v[i], a);
                
  return *this;
}
template<typename T>
Vector< T > & QuadProgPP::Vector< T >::operator^= ( const Vector< T > &  rhs ) [inline]

Definition at line 460 of file Array.h.

References QuadProgPP::pow(), and QuadProgPP::Vector< T >::size().

{
  if (this->size() != rhs.size())
    throw std::logic_error("Operator^=: vectors have different sizes");
  for (unsigned int i = 0; i < n; i++)
    v[i] = pow(v[i], rhs[i]);
                
  return *this;
}
template<typename T>
void QuadProgPP::Vector< T >::resize ( const T &  a,
const unsigned int  n 
) [inline]

Definition at line 130 of file Array.h.

{
  resize(n);
  for (unsigned int i = 0; i < n; i++)
    v[i] = a;
} 
template<typename T >
void QuadProgPP::Vector< T >::resize ( const unsigned int  n ) [inline]

Definition at line 119 of file Array.h.

Referenced by QuadProgPP::backward_elimination(), QuadProgPP::forward_elimination(), QuadProgPP::lu(), QuadProgPP::operator>>(), QuadProgPP::QuadProg::solve_quadprog(), and QuadProgPP::svd().

{
  if (n == this->n)
    return;
  if (v != 0) 
    delete[] (v); 
  v = new T[n];
  this->n = n;
} 
template<typename T>
void QuadProgPP::Vector< T >::set ( const T *  a,
const unsigned int  n 
) [inline]

Definition at line 180 of file Array.h.

{ 
  resize(n);
  for (unsigned int i = 0; i < n; i++) 
    v[i] = a[i]; 
} 
template<typename T >
unsigned int QuadProgPP::Vector< T >::size (  ) const [inline]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines