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
#ifndef _Matrix_vector_h_
00027
#define _Matrix_vector_h_
00028
00029
#include <math.h>
00030
#include "barray.h"
00031
#include "specialType.h"
00032
00033
00034
00035
00038
namespace PLib {
00039
00040
template <
class T>
class Vector ;
00041
00042
template <
class T> Vector<T> operator+(
const Vector<T>&,
const Vector<T>&);
00043
template <
class T> Vector<T> operator-(
const Vector<T>&,
const Vector<T>&);
00044
00045
template <
class T> T operator*(
const Vector<T>&,
const Vector<T>&);
00046
template <
class T> Vector<T> operator*(
const Vector<T>& v,
const double d);
00047
template <
class T> Vector<T> operator*(
const Vector<T>& v,
const Complex d);
00048
00049
template <
class T> Vector<T> operator*(
const double d,
const Vector<T>& v) ;
00050
template <
class T> Vector<T> operator*(
const Complex d,
const Vector<T>& v) ;
00051
00052
template<> Vector<Complex> operator*(
const Vector<Complex>& v,
const double d);
00053
template <> Vector<Complex> operator*(
const Vector<Complex>& v,
const Complex d);
00054
00055
template <
class T>
int operator==(
const Vector<T>&,
const Vector<T>&);
00056
template <
class T>
int operator!=(
const Vector<T>& a,
const Vector<T>& b);
00057
00058
00068 template<
class T>
class Vector :
public BasicArray<T>
00069 {
00070
public:
00071 int rows() const
00072 {
return sze ;}
00073 Vector() :
BasicArray<T>(1) {}
00074
Vector(
const int r) :
BasicArray<T>(r) {}
00075
Vector(
const Vector<T>& v) : BasicArray<T>(v) {}
00076
Vector(
const BasicArray<T>& v) :
BasicArray<T>(v) {}
00077
Vector(T* ap,
const int size) :
BasicArray<T>(ap,size) {}
00078
Vector(
BasicList<T>& list) :
BasicArray<T>(list) {}
00079
00080
virtual ~
Vector() {}
00081
00082 Vector<T>&
operator=(
const Vector<T>& v);
00083 Vector<T>&
operator=(
const BasicArray<T>& b);
00084
00085 Vector<T>&
operator+=(
const Vector<T>& a);
00086 Vector<T>&
operator-=(
const Vector<T>& a);
00087
00088 T
operator=(
const T d);
00089
void as(
int i,
const Vector<T>& b);
00090 Vector<T>
get(
int i,
int l);
00091
00092
int minIndex() const ;
00093 T minimum()
const {
return operator[](
minIndex()) ; }
00094
00095
void qSortStd() ;
00096
void qSort(
int M=7) ;
00097
void sortIndex(Vector<int>& index,
int M=7)
const;
00098
00099
00100
#ifdef HAVE_ISO_FRIEND_DECL
00101
friend Vector<T> operator+ <>(
const Vector<T> &a,
const Vector<T> &b);
00102
friend Vector<T> operator- <>(
const Vector<T> &a,
const Vector<T> &b);
00103
friend T operator* <>(
const Vector<T> &a,
const Vector<T> &b);
00104
00105
friend Vector<T> operator* <>(
const Vector<T>& v,
const double d);
00106
friend Vector<T> operator* <>(
const Vector<T>& v,
const Complex d);
00107
00108
friend Vector<T> operator* <>(
const double d,
const Vector<T>& v) ;
00109
friend Vector<T> operator* <>(
const Complex d,
const Vector<T>& v) ;
00110
00111
friend int operator== <>(
const Vector<T> &a,
const Vector<T> &b);
00112
friend int operator!= <>(
const Vector<T>& a,
const Vector<T>& b);
00113
00114
#else
00115
friend Vector<T>
operator+(
const Vector<T> &a,
const Vector<T> &b);
00116
friend Vector<T>
operator-(
const Vector<T> &a,
const Vector<T> &b);
00117
friend T operator* (
const Vector<T> &a,
const Vector<T> &b);
00118
00119
friend Vector<T> operator*(
const Vector<T>& v,
const double d);
00120
friend Vector<T> operator*(
const Vector<T>& v,
const Complex d);
00121
00122
friend Vector<T> operator*(
const double d,
const Vector<T>& v) ;
00123
friend Vector<T> operator*(
const Complex d,
const Vector<T>& v) ;
00124
00125
friend int operator==(
const Vector<T> &a,
const Vector<T> &b);
00126
friend int operator!=(
const Vector<T>& a,
const Vector<T>& b);
00127
00128
#endif
00129
00130 };
00131
00132
00133
template<
class T>
inline
00134
int operator!=(
const Vector<T>& a,
const Vector<T>& b)
00135 {
00136
return (a==b)?0:1 ;
00137 }
00138
00139
template<
class T>
inline
00140 Vector<T> operator*(
const double d,
const Vector<T>& v)
00141 {
00142
return v*d ;
00143 }
00144
00145
template<
class T>
inline
00146 Vector<T> operator*(
const Complex d,
const Vector<T>& v)
00147 {
00148
return v*d ;
00149 }
00150
00151 }
00152
00153
00154
typedef PLib::Vector<int> Vector_INT ;
00155
typedef PLib::Vector<char> Vector_BYTE ;
00156
typedef PLib::Vector<float> Vector_FLOAT ;
00157
typedef PLib::Vector<double> Vector_DOUBLE ;
00158
typedef PLib::Vector<Complex> Vector_COMPLEX ;
00159
typedef PLib::Vector<unsigned char> Vector_UBYTE ;
00160
typedef PLib::Vector<PLib::HPoint3Df> Vector_HPoint3Df;
00161
typedef PLib::Vector<PLib::Point3Df> Vector_Point3Df ;
00162
typedef PLib::Vector<PLib::HPoint3Dd> Vector_HPoint3Dd;
00163
typedef PLib::Vector<PLib::Point3Dd> Vector_Point3Dd ;
00164
typedef PLib::Vector<PLib::HPoint2Df> Vector_HPoint2Df;
00165
typedef PLib::Vector<PLib::Point2Df> Vector_Point2Df ;
00166
typedef PLib::Vector<PLib::HPoint2Dd> Vector_HPoint2Dd;
00167
typedef PLib::Vector<PLib::Point2Dd> Vector_Point2Dd ;
00168
00169
typedef PLib::Vector<int> PlVector_int ;
00170
typedef PLib::Vector<char> PlVector_byte ;
00171
typedef PLib::Vector<float> PlVector_float ;
00172
typedef PLib::Vector<double> PlVector_double ;
00173
typedef PLib::Vector<Complex> PlVector_complex ;
00174
typedef PLib::Vector<unsigned char> PlVector_ubyte ;
00175
typedef PLib::Vector<PLib::HPoint3Df> PlVector_HPoint3Df;
00176
typedef PLib::Vector<PLib::Point3Df> PlVector_Point3Df ;
00177
typedef PLib::Vector<PLib::HPoint3Dd> PlVector_HPoint3Dd;
00178
typedef PLib::Vector<PLib::Point3Dd> PlVector_Point3Dd ;
00179
typedef PLib::Vector<PLib::HPoint2Df> PlVector_HPoint2Df;
00180
typedef PLib::Vector<PLib::Point2Df> PlVector_Point2Df ;
00181
typedef PLib::Vector<PLib::HPoint2Dd> PlVector_HPoint2Dd;
00182
typedef PLib::Vector<PLib::Point2Dd> PlVector_Point2Dd ;
00183
00184
00185
#ifdef INCLUDE_TEMPLATE_SOURCE
00186
#include "vector.cpp"
00187
#endif
00188
00189
#endif