00001 #ifndef __BFloatSMatrix_H__
00002 #define __BFloatSMatrix_H__
00003
00004
00005
00027 #include <stdio.h>
00028 #include "AFSymMatrix.hpp"
00029
00030 class BFloatSMatrix
00031 {
00032 private:
00033
00034 int width;
00035
00036 int totalWidth;
00037 int widthSubMatrix;
00038
00039 AFSymMatrix** p1;
00040 AFSymMatrix*** data;
00041
00042 public:
00043
00044 BFloatSMatrix(int n, int nsub);
00045 BFloatSMatrix(int n, int nsub, float value);
00046 BFloatSMatrix(int n, AFSymMatrix& m);
00047 BFloatSMatrix(const BFloatSMatrix& bm);
00048 BFloatSMatrix operator=(const BFloatSMatrix& bm);
00049
00050 ~BFloatSMatrix();
00051
00052 BFloatSMatrix* copy();
00053
00054
00055 int getWidth(){ return totalWidth; }
00056 int getHeight(){ return totalWidth; }
00057
00058
00059 int getItemWidth(){ return widthSubMatrix; }
00060 int getItemHeight(){ return widthSubMatrix; }
00061
00062
00063 int getBlockWidth(){ return width; }
00064 int getBlockHeight(){ return width; }
00065 int size(){ return width*width; }
00066
00067
00068
00069 void setBlock0(int i, int j, AFSymMatrix* value){ data[i][j]= value; }
00070 AFSymMatrix* getBlock0(int i, int j){ return data[i][j]; }
00071
00072
00073 void setBlock(int i, int j, AFSymMatrix* value){ data[i-1][j-1]= value; }
00074 AFSymMatrix* getBlock(int i, int j){ return data[i-1][j-1]; }
00075
00076
00077
00078 void set0(int i, int j, float value)
00079 {
00080 int ix= i/widthSubMatrix;
00081 int iy= j/widthSubMatrix;
00082 data[ix][iy]->set0(i%widthSubMatrix, j%widthSubMatrix, value);
00083 }
00084 float get0(int i, int j)
00085 {
00086 int ix= i/widthSubMatrix;
00087 int iy= j/widthSubMatrix;
00088 return data[ix][iy]->get0(i%widthSubMatrix, j%widthSubMatrix); }
00089
00090
00091 void set(int i, int j, float value)
00092 {
00093 int ix= (i-1)/widthSubMatrix;
00094 int iy= (j-1)/widthSubMatrix;
00095 if( data[ix][iy] != 0 )
00096 data[ix][iy]->set0((i-1)%widthSubMatrix, (j-1)%widthSubMatrix, value);
00097 }
00098 float get(int i, int j)
00099 {
00100 int ix= (i-1)/widthSubMatrix;
00101 int iy= (j-1)/widthSubMatrix;
00102 if( data[ix][iy] == 0 ) return 0.0;
00103 return data[ix][iy]->get0((i-1)%widthSubMatrix, (j-1)%widthSubMatrix);
00104 }
00105
00106
00107 void setAll(float value=0.0);
00108 void setAll(AFSymMatrix& m);
00109
00110 float det();
00111 float trace();
00112
00113 float norme2();
00114 float sum();
00115
00116 float minimum();
00117 float maximum();
00118 float mean(){ return sum()/size(); }
00119 float sigma(){return 0.0;}
00120
00121
00122
00123 void operator+=(float value);
00124 void operator-=(float value);
00125 void operator*=(float value);
00126 void operator/=(float value);
00127
00128
00129 FloatVector* mult_Av(FloatVector* v, FloatVector* result=0);
00130 FloatVector* mult_ATv(FloatVector* v, FloatVector* result=0);
00131
00132 FloatVector* mult_vA(FloatVector* v, FloatVector* result=0) { return mult_ATv(v, result); }
00133 FloatVector* mult_vAT(FloatVector* vt, FloatVector* result=0){ return mult_Av(vt, result); }
00134
00135
00136
00137 FloatVector* mult_Av(FloatVector* v, int col0, int row0, FloatVector* result=0);
00138 FloatVector* mult_ATv(FloatVector* v, int col0, int row0, FloatVector* result=0);
00139
00140 FloatVector* mult_vA(FloatVector* v, int col0, int row0, FloatVector* result=0)
00141 { return mult_ATv(v, row0, col0, result); }
00142 FloatVector* mult_vAT(FloatVector* vt, int col0, int row0, FloatVector* result=0)
00143 { return mult_Av(vt, row0, col0, result); }
00144
00145 void output();
00146 void output(FILE* file);
00147 };
00148
00149 #endif
00150