Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

tnt_vec.h

Go to the documentation of this file.
00001 /*
00002 *
00003 * Template Numerical Toolkit (TNT)
00004 *
00005 * Mathematical and Computational Sciences Division
00006 * National Institute of Technology,
00007 * Gaithersburg, MD USA
00008 *
00009 *
00010 * This software was developed at the National Institute of Standards and
00011 * Technology (NIST) by employees of the Federal Government in the course
00012 * of their official duties. Pursuant to title 17 Section 105 of the
00013 * United States Code, this software is not subject to copyright protection
00014 * and is in the public domain. NIST assumes no responsibility whatsoever for
00015 * its use by other parties, and makes no guarantees, expressed or implied,
00016 * about its quality, reliability, or any other characteristic.
00017 *
00018 */
00019 
00020 
00021 
00022 #ifndef TNT_VEC_H
00023 #define TNT_VEC_H
00024 
00025 #include "tnt_subscript.h"
00026 #include <cstdlib>
00027 #include <cassert>
00028 #include <iostream>
00029 #include <strstream>
00030 
00031 namespace TNT
00032 {
00033 
00040 
00041 template <class T>
00042 class Vector 
00043 {
00044 
00045 
00046   public:
00047 
00048     typedef Subscript   size_type;
00049     typedef         T   value_type;
00050     typedef         T   element_type;
00051     typedef         T*  pointer;
00052     typedef         T*  iterator;
00053     typedef         T&  reference;
00054     typedef const   T*  const_iterator;
00055     typedef const   T&  const_reference;
00056 
00057     Subscript lbound() const { return 1;}
00058  
00059 
00060 
00061   public:
00062 
00063     // access
00064 
00065     iterator begin() { return v_;}
00066     iterator end()   { return v_ + n_; }
00067     const iterator begin() const { return v_;}
00068     const iterator end() const  { return v_ + n_; }
00069 
00070     // destructor
00071 
00072     ~Vector() ;
00073 
00074     // constructors
00075 
00076     Vector();
00077 
00078     Vector(const Vector<T> &A);
00079 
00080     Vector(Subscript N, const T& value = T()) :  v_(0), vm1_(0), n_(0);
00081 
00082     Vector(Subscript N, const T* v) :  v_(0), vm1_(0), n_(0);
00083 
00084     Vector(Subscript N, char *s) :  v_(0), vm1_(0), n_(0);
00085 
00086     Vector<T>& newsize(Subscript N);
00087 
00088 
00089     Vector<T>& operator=(const Vector<T> &A);
00090     Vector<T>& operator=(const T& scalar);
00091 
00092     inline Subscript dim() const ;
00093 
00094     inline Subscript size() const ;
00095 
00096 
00097     inline reference operator()(Subscript i);
00098 
00099     inline const_reference operator() (Subscript i) const;
00100 
00101     inline reference operator[](Subscript i);
00102 
00103     inline const_reference operator[](Subscript i) const;
00104 
00105 
00106 
00107 };
00108 
00109 
00110 /* ***************************  I/O  ********************************/
00111 
00112 template <class T>
00113 std::ostream& operator<<(std::ostream &s, const Vector<T> &A);
00114 
00115 template <class T>
00116 std::istream & operator>>(std::istream &s, Vector<T> &A);
00117 
00118 // *******************[ basic matrix algorithms ]***************************
00119 
00120 
00121 template <class T>
00122 Vector<T> operator+(const Vector<T> &A, const Vector<T> &B);
00123 
00124 template <class T>
00125 Vector<T> operator-(const Vector<T> &A, const Vector<T> &B);
00126 
00127 
00128 template <class T>
00129 Vector<T> operator*(const Vector<T> &A, const Vector<T> &B);
00130 
00131 
00132 template <class T>
00133 T dot_prod(const Vector<T> &A, const Vector<T> &B);
00134 
00135 }   /* namespace TNT */
00136 
00137 #endif
00138 // TNT_VEC_H

Generated at Thu Jun 26 17:26:14 2003 for Template Numerical Toolkit (TNT) by doxygen1.2.5 written by Dimitri van Heesch, © 1997-2001