Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __VECTOR_HPP
00030 #define __VECTOR_HPP
00031
00032 #define Assert assert
00033 #include <assert.h>
00034
00035
00036 namespace pcl
00037 {
00038 namespace poisson
00039 {
00040 template<class T>
00041 class Vector
00042 {
00043 public:
00044 Vector();
00045 Vector( const Vector<T>& V );
00046 Vector( size_t N );
00047 Vector( size_t N, T* pV );
00048 ~Vector();
00049
00050 const T& operator () (size_t i) const;
00051 T& operator () (size_t i);
00052 const T& operator [] (size_t i) const;
00053 T& operator [] (size_t i);
00054
00055 void SetZero();
00056
00057 size_t Dimensions() const;
00058 void Resize( size_t N );
00059
00060 Vector operator * (const T& A) const;
00061 Vector operator / (const T& A) const;
00062 Vector operator - (const Vector& V) const;
00063 Vector operator + (const Vector& V) const;
00064
00065 Vector& operator *= (const T& A);
00066 Vector& operator /= (const T& A);
00067 Vector& operator += (const Vector& V);
00068 Vector& operator -= (const Vector& V);
00069
00070 Vector& AddScaled(const Vector& V,const T& scale);
00071 Vector& SubtractScaled(const Vector& V,const T& scale);
00072 static void Add(const Vector& V1,const T& scale1,const Vector& V2,const T& scale2,Vector& Out);
00073 static void Add(const Vector& V1,const T& scale1,const Vector& V2,Vector& Out);
00074
00075 Vector operator - () const;
00076
00077 Vector& operator = (const Vector& V);
00078
00079 T Dot( const Vector& V ) const;
00080
00081 T Length() const;
00082
00083 T Norm( size_t Ln ) const;
00084 void Normalize();
00085
00086 bool write( FILE* fp ) const;
00087 bool write( const char* fileName ) const;
00088 bool read( FILE* fp );
00089 bool read( const char* fileName );
00090
00091 T* m_pV;
00092 protected:
00093 size_t m_N;
00094
00095 };
00096
00097 template<class T,int Dim>
00098 class NVector
00099 {
00100 public:
00101 NVector();
00102 NVector( const NVector& V );
00103 NVector( size_t N );
00104 NVector( size_t N, T* pV );
00105 ~NVector();
00106
00107 const T* operator () (size_t i) const;
00108 T* operator () (size_t i);
00109 const T* operator [] (size_t i) const;
00110 T* operator [] (size_t i);
00111
00112 void SetZero();
00113
00114 size_t Dimensions() const;
00115 void Resize( size_t N );
00116
00117 NVector operator * (const T& A) const;
00118 NVector operator / (const T& A) const;
00119 NVector operator - (const NVector& V) const;
00120 NVector operator + (const NVector& V) const;
00121
00122 NVector& operator *= (const T& A);
00123 NVector& operator /= (const T& A);
00124 NVector& operator += (const NVector& V);
00125 NVector& operator -= (const NVector& V);
00126
00127 NVector& AddScaled(const NVector& V,const T& scale);
00128 NVector& SubtractScaled(const NVector& V,const T& scale);
00129 static void Add(const NVector& V1,const T& scale1,const NVector& V2,const T& scale2,NVector& Out);
00130 static void Add(const NVector& V1,const T& scale1,const NVector& V2, NVector& Out);
00131
00132 NVector operator - () const;
00133
00134 NVector& operator = (const NVector& V);
00135
00136 T Dot( const NVector& V ) const;
00137
00138 T Length() const;
00139
00140 T Norm( size_t Ln ) const;
00141 void Normalize();
00142
00143 T* m_pV;
00144 protected:
00145 size_t m_N;
00146
00147 };
00148
00149 }
00150 }
00151
00152
00153 #include "vector.hpp"
00154
00155 #endif