109 |
|
~DynamicRectMatrix() { deallocate();} |
110 |
|
|
111 |
|
/** copy assignment operator */ |
112 |
< |
DynamicRectMatrix<Real> operator =(const DynamicRectMatrix<Real> m) { |
112 |
> |
DynamicRectMatrix<Real> operator =(const DynamicRectMatrix<Real> &m) { |
113 |
|
if (this == &m) |
114 |
|
return *this; |
115 |
|
if (nrow_ != m.getNRow() || ncol_ != m.getNCol()) { |
237 |
|
* |
238 |
|
* @todo replace operator == by template function equal |
239 |
|
*/ |
240 |
< |
bool operator ==(const DynamicRectMatrix<Real> m) { |
240 |
> |
bool operator ==(const DynamicRectMatrix<Real> &m) { |
241 |
|
assert(nrow_ == m.getNRow() && ncol_ == m.getNCol()); |
242 |
|
for (unsigned int i = 0; i < nrow_; i++) |
243 |
|
for (unsigned int j = 0; j < ncol_; j++) |
252 |
|
* @return true if this matrix is not equal to the matrix m, return false otherwise |
253 |
|
* @param m matrix to be compared |
254 |
|
*/ |
255 |
< |
bool operator !=(const DynamicRectMatrix<Real> m) { |
255 |
> |
bool operator !=(const DynamicRectMatrix<Real> &m) { |
256 |
|
return !(*this == m); |
257 |
|
} |
258 |
|
|
267 |
|
* Sets the value of this matrix to the negation of matrix m. |
268 |
|
* @param m the source matrix |
269 |
|
*/ |
270 |
< |
inline void negate(const DynamicRectMatrix<Real> m) { |
270 |
> |
inline void negate(const DynamicRectMatrix<Real> &m) { |
271 |
|
for (unsigned int i = 0; i < nrow_; i++) |
272 |
|
for (unsigned int j = 0; j < ncol_; j++) |
273 |
|
this->data_[i][j] = -m.data_[i][j]; |
277 |
|
* Sets the value of this matrix to the sum of itself and m (*this += m). |
278 |
|
* @param m the other matrix |
279 |
|
*/ |
280 |
< |
inline void add( const DynamicRectMatrix<Real> m ) { |
280 |
> |
inline void add( const DynamicRectMatrix<Real> &m ) { |
281 |
|
assert(nrow_ == m.getNRow() && ncol_ == m.getNCol()); |
282 |
|
for (unsigned int i = 0; i < nrow_; i++) |
283 |
|
for (unsigned int j = 0; j < ncol_; j++) |
289 |
|
* @param m1 the first matrix |
290 |
|
* @param m2 the second matrix |
291 |
|
*/ |
292 |
< |
inline void add( const DynamicRectMatrix<Real> m1, const DynamicRectMatrix<Real> m2 ) { |
292 |
> |
inline void add( const DynamicRectMatrix<Real> &m1, const DynamicRectMatrix<Real> &m2 ) { |
293 |
|
assert(m1.getNRow() == m2.getNRow() && m1.getNCol() == m2.getNCol()); |
294 |
|
for (unsigned int i = 0; i < nrow_; i++) |
295 |
|
for (unsigned int j = 0; j < ncol_; j++) |
300 |
|
* Sets the value of this matrix to the difference of itself and m (*this -= m). |
301 |
|
* @param m the other matrix |
302 |
|
*/ |
303 |
< |
inline void sub( const DynamicRectMatrix<Real> m ) { |
303 |
> |
inline void sub( const DynamicRectMatrix<Real> &m ) { |
304 |
|
assert(nrow_ == m.getNRow() && ncol_ == m.getNCol()); |
305 |
|
for (unsigned int i = 0; i < nrow_; i++) |
306 |
|
for (unsigned int j = 0; j < ncol_; j++) |
312 |
|
* @param m1 the first matrix |
313 |
|
* @param m2 the second matrix |
314 |
|
*/ |
315 |
< |
inline void sub( const DynamicRectMatrix<Real> m1, const DynamicRectMatrix<Real> m2){ |
315 |
> |
inline void sub( const DynamicRectMatrix<Real> &m1, const DynamicRectMatrix<Real> &m2){ |
316 |
|
assert(m1.getNRow() == m2.getNRow() && m1.getNCol() == m2.getNCol()); |
317 |
|
for (unsigned int i = 0; i < nrow_; i++) |
318 |
|
for (unsigned int j = 0; j < ncol_; j++) |
334 |
|
* @param s the scalar value |
335 |
|
* @param m the matrix |
336 |
|
*/ |
337 |
< |
inline void mul( Real s, const DynamicRectMatrix<Real> m ) { |
337 |
> |
inline void mul( Real s, const DynamicRectMatrix<Real> &m ) { |
338 |
|
assert(nrow_ == m.getNRow() && ncol_ == m.getNCol()); |
339 |
|
for (unsigned int i = 0; i < nrow_; i++) |
340 |
|
for (unsigned int j = 0; j < ncol_; j++) |
356 |
|
* @param s the scalar value |
357 |
|
* @param m the matrix |
358 |
|
*/ |
359 |
< |
inline void div( Real s, const DynamicRectMatrix<Real> m ) { |
359 |
> |
inline void div( Real s, const DynamicRectMatrix<Real> &m ) { |
360 |
|
assert(nrow_ == m.getNRow() && ncol_ == m.getNCol()); |
361 |
|
for (unsigned int i = 0; i < nrow_; i++) |
362 |
|
for (unsigned int j = 0; j < ncol_; j++) |
462 |
|
|
463 |
|
/** Negate the value of every element of this matrix. */ |
464 |
|
template<typename Real> |
465 |
< |
inline DynamicRectMatrix<Real> operator -(const DynamicRectMatrix<Real> m) { |
465 |
> |
inline DynamicRectMatrix<Real> operator -(const DynamicRectMatrix<Real> &m) { |
466 |
|
DynamicRectMatrix<Real> result(m); |
467 |
|
|
468 |
|
result.negate(); |
477 |
|
* @param m2 the second matrix |
478 |
|
*/ |
479 |
|
template<typename Real> |
480 |
< |
inline DynamicRectMatrix<Real> operator + (const DynamicRectMatrix<Real> m1,const DynamicRectMatrix<Real> m2) { |
480 |
> |
inline DynamicRectMatrix<Real> operator + (const DynamicRectMatrix<Real> &m1, const DynamicRectMatrix<Real> &m2) { |
481 |
|
|
482 |
|
DynamicRectMatrix<Real> result(m1.getNRow(), m1.getNCol()); |
483 |
|
|
493 |
|
* @param m2 the second matrix |
494 |
|
*/ |
495 |
|
template<typename Real> |
496 |
< |
inline DynamicRectMatrix<Real> operator - (const DynamicRectMatrix<Real> m1, const DynamicRectMatrix<Real> m2) { |
496 |
> |
inline DynamicRectMatrix<Real> operator - (const DynamicRectMatrix<Real> &m1, const DynamicRectMatrix<Real> &m2) { |
497 |
|
DynamicRectMatrix<Real> result(m1.getNRow(), m1.getNCol()); |
498 |
|
|
499 |
|
result.sub(m1, m2); |
508 |
|
* @param s the scalar |
509 |
|
*/ |
510 |
|
template<typename Real> |
511 |
< |
inline DynamicRectMatrix<Real> operator *(const DynamicRectMatrix<Real> m, Real s) { |
511 |
> |
inline DynamicRectMatrix<Real> operator *(const DynamicRectMatrix<Real> &m, Real s) { |
512 |
|
DynamicRectMatrix<Real> result(m.getNRow(), m.getNCol()); |
513 |
|
|
514 |
|
result.mul(s, m); |
523 |
|
* @param m the matrix |
524 |
|
*/ |
525 |
|
template<typename Real> |
526 |
< |
inline DynamicRectMatrix<Real> operator *(Real s, const DynamicRectMatrix<Real> m) { |
526 |
> |
inline DynamicRectMatrix<Real> operator *(Real s, const DynamicRectMatrix<Real> &m) { |
527 |
|
DynamicRectMatrix<Real> result(m.getNRow(), m.getNCol()); |
528 |
|
|
529 |
|
result.mul(s, m); |
559 |
|
* @param v the vector |
560 |
|
*/ |
561 |
|
template<typename Real> |
562 |
< |
inline DynamicVector<Real> operator *(const DynamicRectMatrix<Real> m, const DynamicVector<Real>& v) { |
562 |
> |
inline DynamicVector<Real> operator *(const DynamicRectMatrix<Real> &m, const DynamicVector<Real> &v) { |
563 |
|
int nrow = m.getNRow(); |
564 |
|
int ncol = m.getNCol(); |
565 |
< |
assert(ncol = v.size()); |
565 |
> |
assert(ncol == v.size()); |
566 |
|
DynamicVector<Real> result(nrow); |
567 |
|
|
568 |
|
for (unsigned int i = 0; i < nrow ; i++) |
579 |
|
* @param s the scalar |
580 |
|
*/ |
581 |
|
template<typename Real> |
582 |
< |
inline DynamicRectMatrix<Real> operator /(const DynamicRectMatrix<Real> m, Real s) { |
582 |
> |
inline DynamicRectMatrix<Real> operator /(const DynamicRectMatrix<Real> &m, Real s) { |
583 |
|
DynamicRectMatrix<Real> result(m.getNRow(), m.getNCol()); |
584 |
|
|
585 |
|
result.div(s, m); |
591 |
|
* Write to an output stream |
592 |
|
*/ |
593 |
|
template<typename Real> |
594 |
< |
std::ostream &operator<< ( std::ostream& o, const DynamicRectMatrix<Real> m) { |
594 |
> |
std::ostream &operator<< ( std::ostream& o, const DynamicRectMatrix<Real> &m) { |
595 |
|
for (unsigned int i = 0; i < m.getNRow() ; i++) { |
596 |
|
o << "("; |
597 |
|
for (unsigned int j = 0; j < m.getNCol() ; j++) { |