61 T tmp0,tmp1, tmp2, tmp3;
104 inline T& operator [] (
int );
105 inline const T& operator [] (
int )
const;
106 inline T& operator () (
int );
107 inline const T& operator () (
int )
const;
114 if ( sz != a.
size() )
error(
"operator-=(const Vector< T >& a), size error");
115 for (
int i=0; i<sz; ++i) (*
this)[i] += a[i];
122 if ( sz != a.
size() )
error(
"operator-=(const Vector< T >& a), size error");
123 for (
int i=0; i<sz; ++i) (*
this)[i] -= a[i];
129 inline int empty()
const {
return (!size());}
130 inline void reserve(
int );
131 inline void resize(
int );
132 inline int size()
const {
return capacity();}
133 inline int length()
const {
return capacity();}
134 inline int capacity()
const;
135 inline T* begin()
const;
136 inline T*
end()
const {
return ptr_to_data + num_elts;}
137 inline void destroy();
138 inline int no(
const T * ptr)
const {
return (ptr - begin());}
153 if ( sz!=y.
size() )
error(
"operator+(const Vector<T> & x, const Vector<T> & y), size error");
157 for (
int i=0; i<sz; ++i)
166 if ( sz!=y.
size() )
error(
"operator+(const Vector<T> & x, const Vector<T> & y), size error");
170 for (
int i=0; i<sz; ++i)
181 for (
int i=0; i<sz; ++i)
187 template <
class T>
inline std::ostream& operator << (std::ostream& os, const Vector<T>& x)
189 os.setf(std::ios::fixed,std::ios::floatfield);
192 os << sz << std::endl;
195 for (
int i=0; i< sz; ++i) {
197 os << x[i] << std::endl;
213 std::cerr <<
"Vector<>::Vector() |default constructor|";
226 std::cerr <<
"Vector<>::Vector(int ) |size constructor |";
246 std::cerr <<
"Vector<>::Vector(const Vector< T >& ) |copy constructor |";
264 fprintf(stderr,
"Vector<>::destroy() | | adr = %x \n",
ptr_to_data);
285 if ( !( (i >= 0) && (i <
num_elts) ) )
error(
"Vector<>::operator[], index out of bound");
301 if ( !( (i >= 0) && (i <
num_elts) ) )
error(
"Vector<>::operator[], index out of bound");
322 if (
ptr_to_data != 0 )
error(
"Vector<>::reserve(), array already allocted");
324 if ( ssize <0 )
error(
"Vector<>::reserve(), negative size");
334 fprintf(stderr,
"Vector<>::reserve() | | adr = %x \n",
ptr_to_data);
342 if ( ssize <0 )
error(
"Vector<>::reserve(), negative size");
358 fprintf(stderr,
"Vector<>::reserve() | | adr = %x \n",
ptr_to_data);
379 std::cerr <<
"Vector<>::Vector(int, const T& )|size constructor |";
408 std::cerr <<
"Vector<>::~Vector() |destructor |" << std::endl;;
422 if ( a.
num_elts == 0 )
return (*
this);
446 else error(
"Vector< T >& Vector< T >::operator = (const T& val), unallocated vector");
int no(const T *ptr) const
Vector< T > operator-(const Vector< T > &x, const Vector< T > &y)
const value_type & const_reference
REAL val(STATE &number)
Returns value of the variable.
Vector< T > operator+(const Vector< T > &x, const Vector< T > &y)
const value_type * const_iterator
Vector< T > operator*(const T &a, const Vector< T > &x)
void copy(const Vector< T > &a)
const value_type * const_pointer
Vector< T > & operator+=(const Vector< T > &a)
Vector< T > & operator=(const Vector< T > &a)
static void copy(T *RESTRICT dest, const T *src, const int N)
Vector< T > & operator-=(const Vector< T > &a)
ptrdiff_t difference_type