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 Color_SOURCES
00027 #define Color_SOURCES
00028
00029 #include "color.h"
00030
00031 #include "barray.cpp"
00032 #include "barray2d.cpp"
00033 #include "matrix.cpp"
00034 #include "vector.cpp"
00035
00038 namespace PLib {
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 double
00054 Matrix<Color>::norm(void) {
00055 #ifdef USE_EXCEPTION
00056 throw MatrixErr();
00057 #else
00058 Error error("Matrix<Color>::norm()") ;
00059 error << "ERROR: you can't get the norm of a Color matrix\n" ;
00060 error.fatal() ;
00061 #endif
00062 return 0 ;
00063 }
00064
00065 Matrix<Color>& Matrix<Color>::operator+=(double a)
00066 {
00067 #ifdef USE_EXCEPTION
00068 throw MatrixErr();
00069 #else
00070 Error error("Matrix<Color>::operator+=()") ;
00071 error << "ERROR: you can't increment by a double a Color matrix\n" ;
00072 error.fatal() ;
00073 #endif
00074 return *this ;
00075 }
00076
00077 Matrix<Color>& Matrix<Color>::operator-=(double a)
00078 {
00079 #ifdef USE_EXCEPTION
00080 throw MatrixErr();
00081 #else
00082 Error error("Matrix<Color>::operator+=()") ;
00083 error << "ERROR: you can't decrement by a double a Color matrix\n" ;
00084 error.fatal() ;
00085 #endif
00086 return *this ;
00087 }
00088
00089
00090 #ifndef USING_VCC
00091 int Matrix<Color>::read(char* filename,int r, int c) {
00092 ifstream fin(filename) ;
00093 if(!fin) {
00094 resize(1,1) ;
00095 return 0 ;
00096 }
00097 resize(r,c) ;
00098 Matrix<unsigned char> T(r,c) ;
00099 unsigned char* p = T[0] ;
00100 if(!fin.read((char*)p,sizeof(unsigned char)*r*c)) return 0 ;
00101 int i,j ;
00102 for(i=0;i<r ;++i)
00103 for(j=0;j<c ;++j)
00104 elem(i,j).r = T(i,j) ;
00105 if(!fin.read((char*)p,sizeof(unsigned char)*r*c)) return 0 ;
00106 for(i=0;i<r ;i++)
00107 for(j=0;j<c ;++j)
00108 elem(i,j).g = T(i,j) ;
00109 if(!fin.read((char*)p,sizeof(unsigned char)*r*c)) return 0 ;
00110 for(i=0;i<r ;i++)
00111 for(j=0;j<c ;++j)
00112 elem(i,j).b = T(i,j) ;
00113 return 1 ;
00114 }
00115 #endif
00116
00117 int Vector<Color>::minIndex() const {
00118 #ifdef USE_EXCEPTION
00119 throw MatrixErr() ;
00120 #else
00121 Error error("Vector<color>::minIndex") ;
00122 error << "ERROR: you can't get the minIndex of a vector of Colors!\n" ;
00123 error.fatal() ;
00124 #endif
00125 return 0 ;
00126 }
00127
00128
00129
00130
00131 #ifdef NO_IMPLICIT_TEMPLATES
00132
00133
00134 template class BasicArray<Color>;
00135 template void resizeBasicArray<Color>(BasicArray<Color>&,int) ;
00136 template int operator==(const BasicArray<Color>&,const BasicArray<Color>&);
00137 template istream& operator>>(istream& is, BasicArray<Color>& ary);
00138 template ostream& operator<<(ostream& os, const BasicArray<Color>& ary);
00139
00140
00141 template class Basic2DArray<Color> ;
00142 template void initBasic2DArray<Color>(Basic2DArray<Color>&,const int,const int) ;
00143 template void resizeKeepBasic2DArray<Color>(Basic2DArray<Color>&,const int,const int) ;
00144 template istream& operator>>(istream& is, Basic2DArray<Color>& ary);
00145 template ostream& operator<<(ostream& os, const Basic2DArray<Color>& ary);
00146
00147
00148 template class Matrix<Color> ;
00149
00150 template Matrix<Color> operator+(const Matrix<Color>&,const Matrix<Color>&);
00151 template Matrix<Color> operator-(const Matrix<Color>&,const Matrix<Color>&);
00152 template Matrix<Color> operator*(const Matrix<Color>&,const Matrix<Color>&);
00153 template Matrix<Color> operator*(const double,const Matrix<Color>&);
00154 template int operator==(const Matrix<Color>&,const Matrix<Color>&);
00155
00156 template Matrix<Color> comm(const Matrix<Color>&,const Matrix<Color>&);
00157
00158
00159
00160
00161 template class Vector<Color> ;
00162
00163 template Vector<Color> operator+(const Vector<Color>&, const Vector<Color>&);
00164 template Vector<Color> operator-(const Vector<Color>&, const Vector<Color>&);
00165 template Color operator*(const Vector<Color>&,const Vector<Color>&);
00166 template Vector<Color> operator*(const Vector<Color>& v, const double d);
00167 template Vector<Color> operator*(const Vector<Color>& v, const Complex d);
00168 template int operator==(const Vector<Color>&,const Vector<Color>&);
00169 template int operator!=(const Vector<Color>&,const Vector<Color>&);
00170 template void swap(Color&,Color&) ;
00171
00172 #endif
00173
00174 }
00175
00176 #ifdef NO_IMPLICIT_TEMPLATES
00177
00178
00179
00180 #endif
00181
00182 #endif
00183
00184