00001 00004 #ifndef PtvDIM 00005 #define PtvDIM 3 00006 #endif 00007 00008 00009 00010 00011 00012 00013 00014 00015 #if PtvDIM == 0 00016 class Ptv(Type),1; 00017 class Ptv(Type),2; 00018 class Ptv(Type),3; 00019 class Ptm(Type); 00020 #else 00021 class Ptv(Type),0; 00022 #endif 00023 00024 00025 00026 class Ptv(Type) 00027 00028 { 00029 00030 #if PtvDIM == 0 00031 int n; 00032 Type x[PtvDIM]; 00033 Type* v; 00034 00035 bool internal; 00036 #else 00037 static int n; 00038 Type v[PtvDIM]; 00039 #endif 00040 00041 00042 #if PtvDIM == 0 00043 bool allocate (int n_); 00044 void deallocate (); 00045 bool pureRedim (int n_); 00046 #else 00047 bool redim(int n_); 00048 #endif 00049 00050 public: 00051 00052 #if PtvDIM == 0 00053 Ptv(Type) (); 00054 Ptv(Type)(int n_); 00055 00056 Ptv(Type)(Type x_, Type y_); 00057 Ptv(Type)(Type x_, Type y_, Type z_); 00058 Ptv(Type)(Type a[], int n_, bool copy = true); 00059 Ptv(Type)(const Ptv(Type)& X); 00060 Ptv(Type)(const Ptv(Type),1& X); 00061 Ptv(Type)(const Ptv(Type),2& X); 00062 Ptv(Type)(const Ptv(Type),3& X); 00063 Ptv(Type)(const VecSimple(Type)& v); 00064 ~Ptv(Type) (); 00065 bool redim(int n_); 00066 bool redim(Type a[], int n_, bool copy = false); 00067 #elif PtvDIM == 1 00068 Ptv(Type) (); 00069 Ptv(Type)(Type x_); 00070 Ptv(Type)(Type a[], int n); 00071 Ptv(Type)(const Ptv(Type)& X); 00072 Ptv(Type)(const Ptv(Type),0& X); 00073 ~Ptv(Type) () {} 00074 #elif PtvDIM == 2 00075 Ptv(Type) (); 00076 Ptv(Type)(Type x_, Type y_); 00077 Ptv(Type)(Type a[], int n); 00078 Ptv(Type)(const Ptv(Type)& X); 00079 Ptv(Type)(const Ptv(Type),0& X); 00080 ~Ptv(Type) () {} 00081 #elif PtvDIM == 3 00082 Ptv(Type) (); 00083 Ptv(Type)(Type x_, Type y_, Type z_); 00084 Ptv(Type)(Type a[], int n); 00085 Ptv(Type)(const Ptv(Type)& X); 00086 Ptv(Type)(const Ptv(Type),0& X); 00087 ~Ptv(Type) () {} 00088 #endif 00089 00090 bool ok() const; 00091 int size() const; 00092 void fill (Type value); 00093 00094 #if PtvDIM == 0 00095 void fill (Type v1, Type v2); 00096 void fill (Type v1, Type v2, Type v3); 00097 void fill (Type a[], int n); 00098 void fill (const VecSimple(Type)& v_); 00099 void fill (const Ptv(Type)& X); 00100 #elif PtvDIM == 2 00101 void fill (Type v1, Type v2); 00102 #elif PtvDIM == 3 00103 void fill (Type v1, Type v2, Type v3); 00104 #endif 00105 00106 Type& operator () (int i); 00107 Type operator () (int i) const; 00108 bool indexOk (int i) const; 00109 00110 00111 Ptv(Type)& operator = (const Type& value); 00112 Ptv(Type)& operator = (const Ptv(Type)& X); 00113 void operator = (const VecSimple(Type)& X); 00114 00115 friend void setEqual (VecSimple(Type)& V, 00116 const Ptv(Type)& X); 00117 00118 bool operator == (const Ptv(Type)& X) const; 00119 bool operator != (const Ptv(Type)& X) const; 00120 00121 bool operator > (const Ptv(Type)& y) const; 00122 bool operator >= (const Ptv(Type)& y) const; 00123 bool operator < (const Ptv(Type)& y) const; 00124 bool operator <= (const Ptv(Type)& y) const; 00125 00126 bool eq (const Ptv(Type)& y, 00127 real tolerance = comparison_tolerance) const; 00128 bool lt (const Ptv(Type)& y, 00129 real tolerance = comparison_tolerance) const; 00130 bool le (const Ptv(Type)& y, 00131 real tolerance = comparison_tolerance) const; 00132 bool gt (const Ptv(Type)& y, 00133 real tolerance = comparison_tolerance) const; 00134 bool ge (const Ptv(Type)& y, 00135 real tolerance = comparison_tolerance) const; 00136 00137 Ptv(Type) operator+ (const Ptv(Type)& X) const; 00138 Ptv(Type) operator- (const Ptv(Type)& X) const; 00139 00140 Ptv(Type) operator+ (const Type& value) const; 00141 Ptv(Type) operator- (const Type& value) const; 00142 Ptv(Type) operator* (const Type& value) const; 00143 Ptv(Type) operator/ (const Type& value) const; 00144 00145 void add (Ptv(Type)& X, 00146 Ptv(Type)& Y); 00147 void add (Type a, Ptv(Type)& X, 00148 Type b, Ptv(Type)& Y); 00149 void add (const Ptv(Type)& X); 00150 void add (Type a, Ptv(Type)& X); 00151 00152 void fillMin (const Ptv(Type)& X); 00153 void fillMax (const Ptv(Type)& X); 00154 00155 Type inner (const Ptv(Type)& X) const; 00156 00157 #if PtvDIM == 0 || PtvDIM == 3 00158 void prod (const Ptv(Type)& X, 00159 const Ptv(Type)& Y); 00160 #endif 00161 00162 real distance (const Ptv(Type)& y) const; 00163 real distance2 (const Ptv(Type)& y) const; 00164 real norm (Norm_type lp) const; 00165 real norm () const; 00166 void mult (Type a); 00167 real sqr () const; 00168 Type sum () const; 00169 00170 void printAsIndex (Os os) const; 00171 String printAsIndex () const; 00172 void print (Os os) const; 00173 void scan (Is is); 00174 00175 Type* getPtr0 (); 00176 Type* getPtr1 (); 00177 00178 friend Os& operator << (Os& os, const Ptv(Type)& x); 00179 friend Is& operator >> (Is& is, Ptv(Type)& x); 00180 00181 00182 #if PtvDIM == 0 00183 friend class Ptv(Type),1; 00184 friend class Ptv(Type),2; 00185 friend class Ptv(Type),3; 00186 friend class Ptm(Type); 00187 #else 00188 friend class Ptv(Type),0; 00189 #endif 00190 }; 00191 00192