00001 /*============================================================================= 00002 * Product : OpenPL 00003 * File : plFloatVector.h 00004 * Author : Christophe Coue 00005 * Creation : Mar 12 2001 00006 * 00007 *============================================================================= 00008 * (c) Copyright 2000, Centre National de la Recherche Scientifique, 00009 * all rights reserved 00010 *============================================================================= 00011 * 00012 *------------------------- Description --------------------------------------- 00013 * for kalman filter 00014 * 00015 *----------------------------------------------------------------------------- 00016 */ 00017 00018 #ifndef __FLOAT_VECTOR_H 00019 #define __FLOAT_VECTOR_H 00020 00021 00022 #include <plObject.h> 00023 #include <plMath.h> 00024 #include <plError.h> 00025 00026 00027 00028 /***************************************************************************** 00029 * Classes Definitions 00030 *****************************************************************************/ 00031 00032 00033 #define Error_Number 15 00034 00035 00036 00038 class plFloatVector : public plObject 00039 { 00040 protected: 00042 void Output(ostream &out) const; 00043 00044 protected: 00045 void init(unsigned int r, bool init_to_zero); 00046 00047 protected: 00048 plFloat *v; //le vecteur 00049 00052 plFloat elem_check(unsigned int i) const; 00053 00055 plFloat& elem_check(unsigned int i); 00056 00057 unsigned int _size; 00058 00059 public: 00060 00062 unsigned int size()const{return _size;} 00063 00064 // Constructeurs 00065 00067 plFloatVector(); 00068 00070 plFloatVector(unsigned int r, float val); 00071 00073 plFloatVector(unsigned int r, double val); 00074 00076 plFloatVector(unsigned int r, long double val); 00077 00079 plFloatVector(unsigned int r, bool init_to_zero = false); 00080 00082 plFloatVector(unsigned int r, const float *float_vector); 00083 00085 plFloatVector(unsigned int r, const double *double_vector); 00086 00088 plFloatVector(unsigned int r, const long double *long_double_vector); 00089 00091 explicit plFloatVector(const vector <float> &float_vector); 00092 00094 explicit plFloatVector(const vector <double> &double_vector); 00095 00097 explicit plFloatVector(const vector <long double> &long_double_vector); 00098 00100 plFloatVector( const plFloatVector &v2); 00101 00103 virtual ~plFloatVector(); 00104 00106 void resize(unsigned int r); 00107 00108 // operators 00109 00111 plFloatVector& operator=(const plFloatVector &); 00112 00114 plFloatVector operator+(const plFloatVector&) const; 00115 00117 plFloatVector &operator+=(const plFloatVector&); 00118 00120 plFloatVector operator-(const plFloatVector&) const; 00121 00123 plFloatVector &operator-=(const plFloatVector&); 00124 00126 plFloatVector operator*(plFloat) const; 00127 00129 friend plFloatVector operator*(plFloat ,const plFloatVector&); 00130 00132 plFloat operator[](unsigned int i) const {return v[i];}; 00133 00135 plFloat& operator[](unsigned int i) {return v[i];}; 00136 00138 plFloat operator()(unsigned int i) const { return elem_check(i); }; 00139 00141 plFloat& operator()(unsigned int i) {return elem_check(i); }; 00142 00144 bool operator==(const plFloatVector&) const; 00145 00147 plFloat dot_product(const plFloatVector &a) const ; // pdt scalaire 00148 00150 plFloatVector cross_product(const plFloatVector &a) const; 00151 00153 plFloat normalize(plFloatVector &result) const; 00154 00156 plFloat product() const; 00157 00158 // friend class 00159 friend class plFloatMatrix; 00160 00162 void reset(float val); 00163 00165 void reset(double val); 00166 00168 void reset(long double val); 00169 00171 void reset(); 00172 }; 00173 00174 00175 #endif