23 #ifndef SG_UT_MATRIX_H
24 #define SG_UT_MATRIX_H
60 inline SgUtMatrix(
unsigned int N,
bool IsNeedClear=
true);
80 inline unsigned int n()
const;
87 inline double&
operator()(
unsigned int i,
unsigned int j);
93 inline double getElement(
unsigned int i,
unsigned int j)
const;
100 inline void setElement(
unsigned int i,
unsigned int j,
double d);
204 inline const double*
const*
base_c()
const {
return B_;};
241 for (
unsigned int i=0; i<
NCol_; i++,w++)
243 *w =
new double[i+1];
245 memset((
void*)(*w), 0,
sizeof(
double)*(i+1));
258 double **w=
B_, **q=R.
B_;
259 for (
unsigned int i=0; i<
NCol_; i++,w++,q++)
262 memcpy((
void*)(*w), (
const void*)(*q), (i+1)*
sizeof(
double));
274 for (
unsigned int i=0; i<
NCol_; i++,w++)
302 std::cerr <<
"WARNING: double& SgUtMatrix::operator()(unsigned int, unsigned int):"
303 <<
" row's index [" << i <<
"] greater than the column index [" << j <<
"]\n";
305 std::cerr <<
"WARNING: double& SgUtMatrix::operator()(unsigned int, unsigned int):"
306 <<
" row's index [" << i <<
"] out of range [0.." <<
NRow_-1 <<
"]\n";
308 std::cerr <<
"WARNING: double& SgUtMatrix::operator()(unsigned int, unsigned int):"
309 <<
" column's index [" << j <<
"] out of range [0.." <<
NCol_-1 <<
"]\n";
322 std::cerr <<
"WARNING: SgUtMatrix::getElement(i,j):"
323 <<
" row index [" << i <<
"] out of range [0.." <<
NRow_-1 <<
"]\n";
325 std::cerr <<
"WARNING: SgUtMatrix::getElement(i,j):"
326 <<
" column index [" << j <<
"] out of range [0.." <<
NCol_-1 <<
"]\n";
328 std::cerr <<
"WARNING: SgUtMatrix::getElement(i,j):"
329 <<
" row's index [" << i <<
"] greater than the column index [" << j <<
"]\n";
332 return (i<=j && j<
NCol_)?*(*(
B_+j)+i):0.0;
342 std::cerr <<
"WARNING: void SgUtMatrix::set(unsigned int, unsigned int, double):"
343 <<
" row's index [" << i <<
"] greater than the column index [" << j <<
"]\n";
345 std::cerr <<
"WARNING: void SgUtMatrix::set(unsigned int, unsigned int, double):"
346 <<
" row's index [" << i <<
"] out of range [0.." <<
NRow_-1 <<
"]\n";
348 std::cerr <<
"WARNING: void SgUtMatrix::set(unsigned int, unsigned int, double):"
349 <<
" column's index [" << j <<
"] out of range [0.." <<
NCol_-1 <<
"]\n";
367 for (
unsigned int i=0; i<
NCol_; i++, w++)
368 memset((
void*)(*w), 0,
sizeof(
double)*(i+1));
378 for (j=0; j<M.
nCol(); j++)
379 for (i=0; i<M.
nRow(); i++)
391 for (i=0; i<
NCol_; i++,w++)
392 for (ww=*w,j=0; j<=i; j++,w++)
404 std::cerr <<
"WARNING: SgUtMatrix& SgUtMatrix::operator+= (const SgUtMatrix&):"
405 <<
" ranges of matrices are different (rows): " <<
NRow_ <<
" and "
408 std::cerr <<
"WARNING: SgUtMatrix& SgUtMatrix::operator+= (const SgUtMatrix&):"
409 <<
" ranges of matrices are different (columns): " <<
NCol_ <<
" and "
413 double **w=
B_, **q=R.
B_, *ww, *qq;
415 for (i=0; i<N; i++,w++,q++)
416 for (ww=*w,qq=*q,j=0; j<=i; j++)
428 std::cerr <<
"WARNING: SgUtMatrix& SgUtMatrix::operator-= (const SgUtMatrix&):"
429 <<
" ranges of matrices are different (rows): " <<
NRow_ <<
" and " << R.
NRow_
432 std::cerr <<
"WARNING: SgUtMatrix& SgUtMatrix::operator-= (const SgUtMatrix&):"
433 <<
" ranges of matrices are different (columns): " <<
NCol_ <<
" and " << R.
NCol_
437 double **w=
B_, **q=R.
B_, *ww, *qq;
439 for(i=0; i<N; i++,w++,q++)
440 for(ww=*w,qq=*q,j=0; j<=i; j++)
452 for (i=0; i<
NCol_; i++,w++)
453 for (ww=*w,j=0; j<=i; j++)
465 for (i=0; i<
NCol_; i++,w++)
466 for (ww=*w,j=0; j<=i; j++)
std::ostream & operator<<(std::ostream &s, const SgUtMatrix &R)
SgVector & solveEquation(const SgUtMatrix &R, SgVector &x, const SgVector &z)
SgUtMatrix operator+(const SgUtMatrix &R1, const SgUtMatrix &R2)
SgUtMatrix operator*(const SgUtMatrix &R, double d)
SgUtMatrix operator-(const SgUtMatrix &R)
SgUtMatrix operator/(const SgUtMatrix &R, double d)
double dTmp_
Local temporary variable.
unsigned int NCol_
An number of columns in a matrix.
unsigned int nRow() const
void setElement(unsigned int i, unsigned int j, double d)
double ** B_
A pointer on a pointer of a first element of the matrix.
unsigned int nCol() const
unsigned int NRow_
An number of rows in a matrix.
SgUtMatrix & operator*=(double d)
SgUtMatrix & operator-=(const SgUtMatrix &R)
friend SgUtMatrix operator+(const SgUtMatrix &R1, const SgUtMatrix &R2)
friend SgUtMatrix operator*(const SgUtMatrix &R, double d)
double & operator()(unsigned int i, unsigned int j)
void setElement(unsigned int i, unsigned int j, double d)
friend SgMatrix calcProduct_mat_x_mat(const SgUtMatrix &R1, const SgMatrix &M2)
friend SgUtMatrix operator-(const SgUtMatrix &R)
SgUtMatrix & operator=(const SgUtMatrix &R)
const double *const * base_c() const
SgUtMatrix & operator/=(double d)
friend SgUtMatrix operator~(const SgUtMatrix &R)
friend SgUtMatrix operator/(const SgUtMatrix &R, double d)
double getElement(unsigned int i, unsigned int j) const
SgUtMatrix & operator+=(const SgUtMatrix &R)