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 #include "vector.cpp"
00027
00028 namespace PLib {
00029
00030 template<>
00031 Vector<Complex> operator*(const Vector<Complex>& v, const double d)
00032 {
00033 int i, sz = v.size();
00034 Vector<Complex> b(v.size());
00035
00036 Complex *aptr,*bptr ;
00037 aptr = v.x-1 ;
00038 bptr = b.x-1 ;
00039 for (i = sz; i > 0; --i){
00040 *(++bptr) = (Complex)(d * (*(++aptr)) ) ;
00041 }
00042
00043 return b;
00044
00045 }
00046
00047 template <>
00048 Vector<Complex> operator*(const Vector<Complex>& v,
00049 const Complex d)
00050 {
00051 int i, sz = v.size();
00052 Vector<Complex> b = v;
00053
00054 Complex *bptr=b.x ;
00055 for (i = sz; i > 0; --i)
00056 *(++bptr) *= d;
00057
00058 return b;
00059
00060 }
00061
00062 template <>
00063 int Vector<Complex>::minIndex() const {
00064 Complex min = x[0] ;
00065 int index = 0 ;
00066
00067 Complex *p ;
00068 p = x-1 ;
00069
00070 for(int i=1;i<n();i++){
00071 if(abs(*(++p))<abs(min)){
00072 min = *p ;
00073 index = i ;
00074 }
00075 }
00076 return index ;
00077 }
00078
00079 template <>
00080 void Vector<Complex>::qSort(int){
00081 #ifdef USE_EXCEPTION
00082 throw MatrixErr() ;
00083 #else
00084 Error error("Vector<Complex>::qSort()");
00085 error << "Sorry! The complex quick sort operator isn't working.\n" ;
00086 error.fatal() ;
00087 #endif
00088 }
00089
00090 template <>
00091 void Vector<Complex>::sortIndex(Vector<int>&, int) const {
00092 #ifdef USE_EXCEPTION
00093 throw MatrixErr() ;
00094 #else
00095 Error error("Vector<Complex>::sortIndex()");
00096 error << "Sorry! The complex quick sort operator isn't working.\n" ;
00097 error.fatal() ;
00098 #endif
00099 }
00100
00101
00102 #ifdef NO_IMPLICIT_TEMPLATES
00103
00104 template class Vector<Complex> ;
00105
00106 template Vector<Complex> operator+(const Vector<Complex>&, const Vector<Complex>&);
00107 template Vector<Complex> operator-(const Vector<Complex>&, const Vector<Complex>&);
00108 template Complex operator*(const Vector<Complex>&,const Vector<Complex>&);
00109 template int operator==(const Vector<Complex>&,const Vector<Complex>&);
00110 template int operator!=(const Vector<Complex>&,const Vector<Complex>&);
00111
00112 #endif
00113
00114 }