Matrix.cpp File Reference

#include "../header/Matrix.h"

Include dependency graph for Matrix.cpp:

Go to the source code of this file.

Functions

ostream & operator<< (ostream &flux, Matrix M)
Matrix operator* (const Matrix &M1, const Matrix &M2)
Matrix operator* (const Matrix &M1, const double &alpha)
Matrix operator* (const double &alpha, const Matrix &M1)
V_3D operator* (const Matrix &_M, const V_3D &_V)
V_3D operator* (const V_3D &_V, const Matrix &_M)
Matrix operator+ (const Matrix &M1, const Matrix &M2)
Matrix operator- (const Matrix &M1, const Matrix &M2)
int operator== (const Matrix &M1, const Matrix &M2)
int operator!= (const Matrix &M1, const Matrix &M2)


Function Documentation

int operator!= ( const Matrix M1,
const Matrix M2 
)

Definition at line 557 of file Matrix.cpp.

00558 {
00559   return 1-(M1==M2);
00560 }

V_3D operator* ( const V_3D _V,
const Matrix _M 
)

Definition at line 332 of file Matrix.cpp.

References Matrix::M, and V_3D::set().

00333 {
00334   V_3D result;
00335   int k_y=0;
00336   for(k_y=0;k_y<3;k_y++)
00337     result.set(k_y,_V[0]*_M.M[k_y+4*0]+_V[1]*_M.M[k_y+4*1]+_V[2]*_M.M[k_y+4*2]);
00338 
00339   return result;
00340 }

Here is the call graph for this function:

V_3D operator* ( const Matrix _M,
const V_3D _V 
)

Definition at line 320 of file Matrix.cpp.

References V_3D::get(), Matrix::M, and V_3D::set().

00321 {
00322   V_3D result;
00323   V_3D copy = _V;
00324   int k_x=0;
00325   for(k_x=0;k_x<3;k_x++)
00326     result.set(k_x,_M.M[0+4*k_x]*copy.get(0)+_M.M[1+4*k_x]*copy.get(1)+_M.M[2+4*k_x]*copy.get(2)+_M.M[3+4*k_x]);
00327   
00328   return result;
00329 }

Here is the call graph for this function:

Matrix operator* ( const double &  alpha,
const Matrix M1 
)

Definition at line 310 of file Matrix.cpp.

References Matrix::M, and Matrix::set_value().

00311 {
00312   Matrix Z;
00313   int k_x=0,k_y=0;
00314   for(k_x=0;k_x<4;k_x++)
00315     for(k_y=0;k_y<4;k_y++)
00316       Z.set_value(alpha*M1.M[k_x+4*k_y],k_x,k_y);
00317   return Z;
00318 }

Here is the call graph for this function:

Matrix operator* ( const Matrix M1,
const double &  alpha 
)

Definition at line 299 of file Matrix.cpp.

References Matrix::M, and Matrix::set_value().

00300 {
00301   Matrix Z;
00302   int k_x=0,k_y=0;
00303   for(k_x=0;k_x<4;k_x++)
00304     for(k_y=0;k_y<4;k_y++)
00305       Z.set_value(alpha*M1.M[k_x+4*k_y],k_x,k_y);
00306   return Z;
00307 }

Here is the call graph for this function:

Matrix operator* ( const Matrix M1,
const Matrix M2 
)

Definition at line 272 of file Matrix.cpp.

References Matrix::M, and Matrix::set_value().

00273 {
00274   double temp_M[16];
00275 
00276   int k_x=0,k_y=0,k_m=0;
00277   double temp=0;
00278 
00279   //all index
00280   for(k_x=0;k_x<4;k_x++)
00281     for(k_y=0;k_y<4;k_y++)
00282       {
00283         //multiply
00284         for(k_m=0,temp=0;k_m<4;k_m++)
00285           {
00286             temp += M1.M[k_m+4*k_y] * (M2.M[k_x+4*k_m]);
00287           }
00288         temp_M[k_x+4*k_y] = temp;
00289       }
00290 
00291   Matrix Z;
00292   //set new matrix
00293   for(int k=0;k<16;k++)
00294     Z.set_value(temp_M[k],k,0);
00295 
00296   return Z;
00297 }

Here is the call graph for this function:

Matrix operator+ ( const Matrix M1,
const Matrix M2 
)

Definition at line 342 of file Matrix.cpp.

References Matrix::M, and Matrix::set_value().

00343 {
00344   Matrix Z;
00345   
00346   int k_x=0,k_y=0;
00347   for(k_x=0;k_x<4;k_x++)
00348     for(k_y=0;k_y<4;k_y++)
00349       {
00350         Z.set_value(M1.M[k_x+4*k_y]+M2.M[k_x+4*k_y],k_x,k_y);
00351       }
00352 
00353   return Z;
00354 }

Here is the call graph for this function:

Matrix operator- ( const Matrix M1,
const Matrix M2 
)

Definition at line 357 of file Matrix.cpp.

References Matrix::M, and Matrix::set_value().

00358 {
00359   Matrix Z;
00360   
00361   int k_x=0,k_y=0;
00362   for(k_x=0;k_x<4;k_x++)
00363     for(k_y=0;k_y<4;k_y++)
00364       {
00365         Z.set_value(M1.M[k_x+4*k_y]-M2.M[k_x+4*k_y],k_x,k_y);
00366       }
00367 
00368   return Z;
00369 }

Here is the call graph for this function:

ostream& operator<< ( ostream &  flux,
Matrix  M 
)

Definition at line 122 of file Matrix.cpp.

References Matrix::value().

00123 {
00124   for(int k=0;k<4;k++)
00125     flux<<"("<<M.value(0,k)<<","<<M.value(1,k)<<","<<M.value(2,k)<<","<<M.value(3,k)<<")\n";
00126   return flux;
00127 }

Here is the call graph for this function:

int operator== ( const Matrix M1,
const Matrix M2 
)

Definition at line 547 of file Matrix.cpp.

References Matrix::M.

00548 {
00549   double epsilon=0.000001;
00550   int k=0;
00551   for(k=0;k<16;k++)
00552     if(fabs(M1.M[k]-M2.M[k])>epsilon)
00553       return 0;
00554   return 1;
00555 }


Generated on Mon Mar 30 16:56:13 2009 by  doxygen 1.5.6