00001 #ifndef __FIdentity_H__ 00002 #define __FIdentity_H__ 00003 00004 00024 #include <stdio.h> 00025 #include <math.h> 00026 00027 #include "FloatVector.hpp" 00028 00029 #include "AFSymMatrix.hpp" 00030 00031 00032 class FIdentity : public AFSymMatrix 00033 { 00034 public: 00035 00036 FIdentity(int n):AFSymMatrix(n){} 00037 FIdentity(const FIdentity& m):AFSymMatrix(m){} 00038 FIdentity operator=(const FIdentity& m){ if(this!=NULL)width= m.width; return *this; } 00039 00040 virtual ~FIdentity(){} 00041 00042 virtual AFloatMatrix* copy(){ return new FIdentity(*this); } 00043 virtual AFloatMatrix* t(AFloatMatrix* result=0); 00044 00045 // base 0 00046 virtual void set0(int i, int j, float value){} 00047 virtual float get0(int i, int j){ return (i==j ? 1.0 : 0.0); } 00048 00049 // base 1 00050 virtual void set(int i, int j, float value){} 00051 virtual float get(int i, int j){ return (i==j ? 1.0 : 0.0); } 00052 00053 // computations 00054 virtual void setAll(float value=0.0){} 00055 00056 virtual float det(){return 1.0;} 00057 virtual float trace(){return getWidth();} 00058 00059 virtual float norme2(){return getWidth();} 00060 virtual float sum(){return getWidth();} 00061 virtual float sum2(){return getWidth();} 00062 00063 virtual float minimum(){return 0.0;} 00064 virtual float maximum(){return 1.0;} 00065 virtual float sigma(); 00066 00067 00068 // scalar single operations 00069 void operator+=(float value){} 00070 void operator-=(float value){} 00071 void operator*=(float value){} 00072 void operator/=(float value){} 00073 00074 virtual void add(float value){} 00075 virtual void subst(float value){} 00076 virtual void mult(float value){} 00077 virtual void div(float value){} 00078 00079 // vector single operations 00080 void operator+=(FIdentity& m){} 00081 void operator-=(FIdentity& m){} 00082 00083 virtual void add(AFloatMatrix& m){} 00084 virtual void subst(AFloatMatrix& m){} 00085 00086 00087 // u= A*v including implicit transposition 00088 virtual FloatVector* mult_Av(FloatVector* v, FloatVector* result=0); 00089 virtual FloatVector* mult_ATv(FloatVector* v, FloatVector* result=0){ return mult_Av(v, result); } 00090 // u= v*A 00091 virtual FloatVector* mult_vA(FloatVector* v, FloatVector* result=0){ return mult_ATv(v, result); } 00092 virtual FloatVector* mult_vAT(FloatVector* vt, FloatVector* result=0){ return mult_Av(vt, result); } 00093 00094 // sub vector usage 00095 // u= A*v 00096 virtual FloatVector* mult_Av(FloatVector* v, int col0, int row0, bool incremental=false, FloatVector* result=0); 00097 virtual FloatVector* mult_ATv(FloatVector* v, int col0, int row0, bool incremental=false, FloatVector* result=0) 00098 { return mult_Av(v, col0, row0, incremental, result); } 00099 00100 // u= v*A 00101 virtual FloatVector* mult_vA(FloatVector* v, int row0, int col0, bool incremental=false, FloatVector* result=0) 00102 { return mult_ATv(v, col0, row0, incremental, result); } 00103 virtual FloatVector* mult_vAT(FloatVector* vt, int row0, int col0, bool incremental=false, FloatVector* result=0) 00104 { return mult_Av(vt, col0, row0, incremental, result); } 00105 00106 virtual void output(){ printf("I(%d,%d)\n", getWidth(), getHeight()); } 00107 virtual void output(FILE* file){ fprintf(file, "I(%d,%d)\n", getWidth(), getHeight()); } 00108 }; 00109 00110 #endif 00111 00112