Skip to content
Snippets Groups Projects
Commit 4e60e974 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

pp

parent a4e96a8e
Branches
Tags
No related merge requests found
...@@ -54,14 +54,13 @@ class fullVector ...@@ -54,14 +54,13 @@ class fullVector
else else
for(int i = 0; i < _r; ++i) _data[i] *= s; for(int i = 0; i < _r; ++i) _data[i] *= s;
} }
inline scalar operator *(const fullVector<scalar> &other)
inline scalar operator *(const fullVector<scalar> & other)
{ {
scalar s = 0.0; scalar s = 0.;
for(int i = 0; i < _r; ++i) s += _data[i]*other._data[i]; for(int i = 0; i < _r; ++i) s += _data[i] * other._data[i];
return s; return s;
} }
void print(const char * name="") const void print(const char *name="") const
{ {
printf("Printing vector %s:\n", name); printf("Printing vector %s:\n", name);
printf(" "); printf(" ");
...@@ -87,7 +86,7 @@ class fullMatrix ...@@ -87,7 +86,7 @@ class fullMatrix
fullMatrix(const fullMatrix<scalar> &other) : _r(other._r), _c(other._c) fullMatrix(const fullMatrix<scalar> &other) : _r(other._r), _c(other._c)
{ {
_data = new scalar[_r * _c]; _data = new scalar[_r * _c];
gM_memcpy(other); for(int i = 0; i < _r * _c; ++i) _data[i] = other._data[i];
} }
fullMatrix() : _r(0), _c(0), _data(0) {} fullMatrix() : _r(0), _c(0), _data(0) {}
~fullMatrix() { if(_data) delete [] _data; } ~fullMatrix() { if(_data) delete [] _data; }
...@@ -99,14 +98,10 @@ class fullMatrix ...@@ -99,14 +98,10 @@ class fullMatrix
_r = other._r; _r = other._r;
_c = other._c; _c = other._c;
_data = new scalar[_r * _c]; _data = new scalar[_r * _c];
gM_memcpy(other); for(int i = 0; i < _r * _c; ++i) _data[i] = other._data[i];
} }
return *this; return *this;
} }
void gM_memcpy(const fullMatrix<scalar> &other)
{
for(int i = 0; i < _r * _c; ++i) _data[i] = other._data[i];
}
inline scalar operator () (int i, int j) const inline scalar operator () (int i, int j) const
{ {
return _data[i + _r * j]; return _data[i + _r * j];
...@@ -186,8 +181,8 @@ class fullMatrix ...@@ -186,8 +181,8 @@ class fullMatrix
} }
inline void transposeInPlace() inline void transposeInPlace()
{ {
if ( size1() != size2() ) { if(size1() != size2()){
Msg::Error("Not a square matrix (size1: %d, size2: %d)",size1(),size2()); Msg::Error("Not a square matrix (size1: %d, size2: %d)", size1(), size2());
} }
scalar t; scalar t;
for(int i = 0; i < size1(); i++) for(int i = 0; i < size1(); i++)
...@@ -262,9 +257,9 @@ class fullMatrix ...@@ -262,9 +257,9 @@ class fullMatrix
} }
#endif #endif
; ;
void print(const char * name="") const void print(const char *name="") const
{ {
printf("Printing matrix %s:\n",name); printf("Printing matrix %s:\n", name);
int ni = size1(); int ni = size1();
int nj = size2(); int nj = size2();
for(int I = 0; I < ni; I++){ for(int I = 0; I < ni; I++){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment