00001 #ifndef __RealVectorT_H__ 00002 #define __RealVectorT_H__ 00003 00004 00005 00024 #include <stdio.h> 00025 00026 class RealVector; 00027 00028 class RealVectorT 00029 { 00030 private: 00031 00032 int dataSize; 00033 double* data; 00034 00035 double* data1; 00036 00037 public: 00038 00039 RealVectorT(){dataSize=0; data=0;} 00040 RealVectorT(int size); 00041 RealVectorT(int size, double adata); 00042 RealVectorT(const RealVectorT& v); 00043 RealVectorT operator=(const RealVectorT& v); 00044 00045 ~RealVectorT(){ data=0; delete[] data1; } 00046 00047 RealVector t(); 00048 00049 RealVectorT* sub(int start, int step, int end); 00050 00051 inline int size()const { return dataSize; } 00052 00053 void load(RealVectorT* v); 00054 00055 // base 0 00056 inline void set0(int index, double value){ data[index]= value; } 00057 inline double get0(int index)const { return data[index]; } 00058 00059 // base 1 00060 inline void set(int index, double value){ data[index-1]= value; } 00061 inline double get(int index)const { return data[index-1]; } 00062 00063 // computations 00064 double vT_v(); 00065 double norme2(); 00066 double sum(); 00067 00068 double minimum(); 00069 double maximum(); 00070 double mean(){ return sum()/dataSize; } 00071 double sigma(); 00072 00073 // math vectorial op 00074 RealVectorT sqrt(); 00075 RealVectorT pow(double pow); 00076 RealVectorT sqr(); 00077 RealVectorT exp(); 00078 RealVectorT log(); 00079 RealVectorT log(double base); 00080 00081 RealVectorT sin(); 00082 RealVectorT cos(); 00083 RealVectorT tan(); 00084 00085 // differences 00086 double undividedDiff(int cellj, int order); 00087 double dividedDiff(int cellj, int order, double dx=1.0); 00088 00089 // scalar single operations 00090 void operator+=(double value); 00091 void operator-=(double value); 00092 void operator*=(double value); 00093 void operator/=(double value); 00094 00095 // vector single operations 00096 void operator+=(const RealVectorT& v); 00097 void operator-=(const RealVectorT& v); 00098 void operator*=(const RealVectorT& v); 00099 void operator/=(const RealVectorT& v); 00100 00101 // friends 00102 friend double operator*(const RealVectorT& vt, const RealVector& u); // scalar product 00103 00104 friend RealVectorT operator+(const RealVectorT& v, double a); // v<op>a 00105 friend RealVectorT operator+(double a, const RealVectorT& v); // a<op>v 00106 friend RealVectorT operator-(const RealVectorT& v, double a); // v<op>a 00107 friend RealVectorT operator-(double a, const RealVectorT& v); // a<op>v 00108 friend RealVectorT operator*(const RealVectorT& v, double a); // v<op>a 00109 friend RealVectorT operator*(double a, const RealVectorT& v); // a<op>v 00110 friend RealVectorT operator/(const RealVectorT& v, double a); // v<op>a 00111 00112 friend RealVectorT operator+(const RealVectorT& v1, const RealVectorT& v2); // v1<op>v2 00113 friend RealVectorT operator-(const RealVectorT& v1, const RealVectorT& v2); // v1<op>v2 00114 00115 void output(); 00116 void output(FILE* file); 00117 }; 00118 00119 #endif 00120 00121