TVector.h
Go to the documentation of this file.00001 #pragma once
00002
00007 #include <iostream>
00008 #include <fstream>
00009 #include "random.h"
00010 #include <string>
00011 #include "parseTools.h"
00012
00013
00014 using namespace std;
00015
00016
00017
00024 template <class TRing>
00025 class TVector
00026 {
00027 public:
00028 typedef typename TRing::ElementType TNum;
00029
00030 private:
00031 const TRing* ring;
00032
00033 size_t size;
00034 TNum* data;
00035
00036 string name;
00037
00038 protected:
00039
00042 template <class _istream>
00043 void createFromStream(_istream& _vectorStream);
00048 void checkBounds(size_t pos) const;
00051 public:
00054 TVector( size_t _size, const TRing* _ring, string _name = "unnamedVector" );
00055
00056 template <class _istream>
00057 TVector( const TRing* _ring, _istream& _vectorStream, string _name = "unnamedVector");
00058
00059 TVector( string _vectorStr, const TRing* _ring, string _name = "unnamedVector");
00060
00061 virtual ~TVector();
00067 inline size_t getSize() const ;
00068
00069 string getName() const { return name; };
00070 void setName(string _name) { name = _name; };
00071 inline const TRing * getRing() const { return ring ; }
00077 void fillZero();
00078
00079 void randomInit(long * _pRandomSeed);
00085 inline TNum & operator[] (const size_t pos);
00086
00087 inline TNum getVal (const size_t _pos) const;
00088
00089 inline const TNum& getConstValRef (const size_t _pos) const;
00090
00091 inline TNum& getValRef (const size_t _pos);
00092
00093 inline void setVal (const size_t _pos,const TNum _z );
00094
00095 inline void setValByRef (const size_t _pos,const TNum & _z);
00096
00102 bool isZero() const;
00103 bool isNotZero() const;
00104 bool operator==(TVector & vec) const;
00105 bool operator!=(TVector & vec) const;
00113 void outputAsMatrix(ostream & _os);
00115 };
00116
00117
00118 #include "TVector.cpp"
00119