KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
m_matrix_d.h
Go to the documentation of this file.
1 /* $Id: m_matrix_d.h 18376 2014-12-09 06:44:38Z ksimek $ */
2 /* {{{=========================================================================== *
3  |
4  | Copyright (c) 1994-2011 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== }}}*/
19 
20 // vim: tabstop=4 shiftwidth=4 foldmethod=marker
21 
22 #ifndef KJB_M_MATRIX_D_H
23 #define KJB_M_MATRIX_D_H
24 
25 
26 #include <l_cpp/l_exception.h>
27 #include <l_cpp/l_cxx11.h>
28 #include <m_cpp/m_vector_d.h>
29 
30 #ifdef TEST
31 #include <m_cpp/m_concept.h>
32 #endif
33 
34 #include <boost/array.hpp>
35 
36 #include <algorithm>
37 
38 #ifdef KJB_HAVE_BST_SERIAL
39 #include <boost/serialization/access.hpp>
40 #include <boost/serialization/array.hpp>
41 #endif
42 
43 namespace kjb
44 {
45 
46 
47 class Vector;
48 class Matrix;
49 
75 template <std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED = false>
76 class Matrix_d : public boost::array<Vector_d<NCOLS>, NROWS>
77 {
78  typedef Matrix_d Self;
79  typedef boost::array<Vector_d<NCOLS>, NROWS> Base;
80 
81 public:
82  template <bool condition, std::size_t value1, std::size_t value2>
83  struct if_then_ { static const std::size_t value = value1;};
84 
85  template <std::size_t value1, std::size_t value2>
86  struct if_then_<false, value1, value2>{ static const std::size_t value = value2;};
87 
90 
91  // types
92  using typename Base::value_type;
93  using typename Base::iterator;
94  using typename Base::const_iterator;
95  using typename Base::reverse_iterator;
96  using typename Base::const_reverse_iterator;
97  using typename Base::reference;
98  using typename Base::const_reference;
99  using typename Base::size_type;
100  using typename Base::difference_type;
101 
102  using Base::begin;
103  using Base::end;
104  using Base::rbegin;
105  using Base::rend;
106  using Base::size;
107  using Base::empty;
108  using Base::max_size;
109  using Base::operator[];
110  using Base::at;
111  using Base::front;
112  using Base::back;
113  using Base::data;
114  using Base::c_array;
115  using Base::swap;
116  using Base::assign;
117 
118 
119  Matrix_d();
120  Matrix_d(const Matrix_d& m);
122 
126  template <class Iterator>
127  explicit Matrix_d(Iterator begin) :
128  Base()
129  {
130 #ifdef TEST
131  typedef typename std::iterator_traits<Iterator>::value_type RowVector;
132 
133  BOOST_CONCEPT_ASSERT((kjb::SimpleVector<RowVector>));
134 #endif /*TEST */
135 
136  Iterator it = begin;
137  typename Base::iterator oit = this->begin();
138  for (size_t i = 0; i < NROWS; ++i, ++it, ++oit)
139  {
140  if (it->size() != NCOLS)
142  std::copy(it->begin(), it->end(), oit->begin());
143 
144  }
145  }
146 
150  explicit Matrix_d(const Matrix& m);
151 
152  // @brief initialize all elements with value init
153  explicit Matrix_d(double value);
154 
155 // template <class VectorType>
156 // Matrix_d(const VectorType& row) :
157 // Base()
158 // {
159 // KJB_STATIC_ASSERT(NROWS == 1, "Constructor invalid for NROWS!=1");
160 //
161 //#ifdef TEST
162 // BOOST_CONCEPT_ASSERT((kjb::SimpleVector<VectorType>));
163 //#endif //TEST
164 //
165 // assert(row.size() == NCOLS);
166 //
167 // std::copy(row.begin(), row.end(), (*this)[0].begin());
168 // }
169 //
170 //
171 // /**
172 // * Construct a Matrix from two rows. This constructor only exists if NROWS == 2. Both rows must have size == NCOLS
173 // *
174 // * @note in transpose mode, r1 and r2 represent columns
175 // *
176 // * @pre r1.size() == r2.size == NCOLS
177 // */
178 // template <class VectorType>
179 // Matrix_d( const VectorType& r1, const VectorType& r2) :
180 // Base()
181 // {
182 // KJB_STATIC_ASSERT(NROWS == 2, "Constructor invalid for NROWS!=2");
183 //
184 //#ifdef TEST
185 // BOOST_CONCEPT_ASSERT((kjb::SimpleVector<VectorType>));
186 //#endif // TEST
187 //
188 // assert(r1.size() == NCOLS);
189 // assert(r2.size() == NCOLS);
190 //
191 // std::copy(r1.begin(), r1.end(), (*this)[0].begin());
192 // std::copy(r2.begin(), r2.end(), (*this)[1].begin());
193 // }
194 //
195 // /**
196 // * Construct a Matrix from three rows. This constructor only exists if NROWS == 3. All rows must have size == NCOLS
197 // *
198 // * @note in transpose mode, r1 and r2 represent columns
199 // *
200 // * @pre r*.size() == NCOLS
201 // */
202 // template <class VectorType>
203 // Matrix_d(
204 // const VectorType& r1,
205 // const VectorType& r2,
206 // const VectorType& r3) :
207 // Base()
208 // {
209 // KJB_STATIC_ASSERT(NROWS == 3, "Constructor invalid for NROWS!=3");
210 //#ifdef TEST
211 // BOOST_CONCEPT_ASSERT((kjb::SimpleVector<VectorType>));
212 //#endif // TEST
213 //
214 // assert(r1.size() == NCOLS);
215 // assert(r2.size() == NCOLS);
216 // assert(r3.size() == NCOLS);
217 //
218 // std::copy(r1.begin(), r1.end(), (*this)[0].begin());
219 // std::copy(r2.begin(), r2.end(), (*this)[1].begin());
220 // std::copy(r3.begin(), r3.end(), (*this)[2].begin());
221 // }
222 //
223 //
224 // /**
225 // * Construct a Matrix from four rows. This constructor only exists if NROWS == 4. All rows must have size == NCOLS
226 // *
227 // * @note in transpose mode, r1 and r2 represent columns
228 // *
229 // * @pre r*.size() == NCOLS
230 // */
231 // template <class VectorType>
232 // Matrix_d(
233 // const VectorType& r1,
234 // const VectorType& r2,
235 // const VectorType& r3,
236 // const VectorType& r4) :
237 // Base()
238 // {
239 // KJB_STATIC_ASSERT(NROWS == 4, "Constructor invalid for NROWS!=4");
240 //#ifdef TEST
241 // BOOST_CONCEPT_ASSERT((kjb::SimpleVector<VectorType>));
242 //#endif // TEST
243 //
244 // assert(r1.size() == NCOLS);
245 // assert(r2.size() == NCOLS);
246 // assert(r3.size() == NCOLS);
247 // assert(r4.size() == NCOLS);
248 //
249 // std::copy(r1.begin(), r1.end(), (*this)[0].begin());
250 // std::copy(r2.begin(), r2.end(), (*this)[1].begin());
251 // std::copy(r3.begin(), r3.end(), (*this)[2].begin());
252 // std::copy(r4.begin(), r4.end(), (*this)[3].begin());
253 // }
254 
263  void resize(size_t rows, size_t cols)
264  {
265  assert(rows == get_num_rows());
266  assert(cols == get_num_cols());
267  }
268 
276  {
277  swap(other);
278  return *this;
279  }
280 
282  {
283  return static_cast<Matrix_d<NROWS, NCOLS, !TRANSPOSED>&>(
284  static_cast<Base&>(*this));
285 // return reinterpret_cast<Matrix_d<NROWS, NCOLS, !TRANSPOSED>&>(*this);
286  }
287 
289  {
290  return static_cast<const Matrix_d<NROWS, NCOLS, !TRANSPOSED>&>(
291  static_cast<const Base&>(*this));
292 // return reinterpret_cast<const Matrix_d<NROWS, NCOLS, !TRANSPOSED>&>(*this);
293  }
294 
296  inline Matrix_d& operator=(const Matrix_d& other)
297  {
298  Base::operator=(other);
299  return *this;
300  }
301 
304 
308  Matrix_d& operator=(const Matrix& other);
309 
310  inline Matrix_d& operator-=(const Matrix_d& second)
311  {
312  return minus_equals_dispatch_(second);
313  }
314 
315  inline Matrix_d operator-(const Matrix_d& second) const
316  {
317  return Matrix_d(*this) -= second;
318  }
319 
321  {
322  return minus_equals_dispatch_(second);
323  }
324 
326  {
327  return Matrix_d(*this) -= second;
328  }
329 
330  inline Matrix_d& operator-=(const Matrix& second);
331 
332  inline Matrix_d operator-(const Matrix& second) const
333  {
334  return Matrix_d(*this) -= second;
335  }
336 
338  Matrix_d operator-() const;
339 
340 
341  inline Matrix_d& operator+=(const Matrix_d& second)
342  {
343  return plus_equals_dispatch_(second);
344  }
345 
346  inline Matrix_d operator+(const Matrix_d& second) const
347  {
348  return Matrix_d(*this) += second;
349  }
350 
352  {
353  return plus_equals_dispatch_(second);
354  }
355 
357  {
358  return Matrix_d(*this) += second;
359  }
360 
361  inline Matrix_d& operator+=(const Matrix& second);
362 
363  inline Matrix_d operator+(const Matrix& second) const;
364 
365  // STATIC MATRIX-MATRIX MULTIPLICATION
366  // the next two methods handle the four special cases separately:
367  // 1. normal * normal
368  // 2. normal * transposed
369  // 3. transposed * normal
370  // 4. transposed * transposed
371  //
372  // Cases 1 and 3 are handled by the first signature, 2 and 4 are handled by the second case.
373  // Dimension mismatches should be caught at compile time.
374  //
375  // These should all be inlined, and all special cases should be resolved at compile-time, so no overhead should occur for handling these indivisually.
376  //
377  // Possible improvements:
378  // A. using dot-product for cases 2 and 3
379  // B. Handle all cases in a single signature?
380 
382  template <std::size_t IN_COLS>
384  {
385  return matrix_multiply_dispatch_(*this, second);
386  }
387 
389  template <std::size_t IN_COLS>
391  {
392  return matrix_multiply_dispatch_(*this, second);
393  }
394 
395 
397  Matrix_d& operator*=(double s);
398 
408  template <std::size_t IN_ROWS, bool IN_TRANSPOSED>
410  {
411  KJB_STATIC_ASSERT(IN_ROWS == NROWS && IN_ROWS == NCOLS, "Dimension mismatch");
412  return *this = *this * other;
413 
414  }
415 
416  inline Matrix_d operator*(double s) const
417  {
418  return Matrix_d(*this) *= s;
419  }
420 
426  // This is easier to implement as a member as opposed to a free
427  // function, due to need to access static members of Self.
429  {
430  Vector_d<num_rows> result(0.0);
431  if (TRANSPOSED)
432  {
433  // should be better cache consistency indexing in this order
434  for (size_t col = 0; col < get_num_cols(); col++)
435  for (size_t row = 0; row < get_num_rows(); row++)
436  result[row] += (*this)(row, col) * v[col];
437  }
438  else
439  {
440  for (size_t row = 0; row < get_num_rows(); row++)
441  for (size_t col = 0; col < get_num_cols(); col++)
442  result[row] += (*this)(row, col) * v[col];
443  }
444 
445  return result;
446  }
447 
448  inline Matrix_d& operator/=(double s)
449  {
450  return (*this) *= 1/s;
451  }
452 
453  inline Matrix_d operator/(double s) const
454  {
455  return Matrix_d(*this) /= s;
456  }
457 
458  static inline size_t get_num_rows()
459  {
460  return num_rows;
461  }
462 
463  static inline size_t get_num_cols()
464  {
465  return num_cols;
466  }
467 
468  inline double& operator()(size_t row, size_t col)
469  {
470  // "if" is optimized out
471  if (TRANSPOSED)
472  {
473  return (*this)[col][row];
474  }
475  else
476  {
477  return (*this)[row][col];
478  }
479  }
480 
481  inline const double& operator()(size_t row, size_t col) const
482  {
483  // "if" is optimized out
484  if (TRANSPOSED)
485  {
486  return (*this)[col][row];
487  }
488  else
489  {
490  return (*this)[row][col];
491  }
492  }
493 
495  {
496  Vector_d<num_cols> row;
497  for(size_t c = 0; c < num_cols; ++c)
498  {
499  row[c] = TRANSPOSED ? (*this)[c][r] : (*this)[r][c];
500  }
501 
502  return row;
503  }
504 
505  template <size_t D>
506  void set_row(size_t r, const Vector_d<D>& row);
507 
508  Vector_d<num_rows> get_col(size_t c) const
509  {
510  Vector_d<num_rows> col;
511  for(size_t r = 0; r < num_rows; ++r)
512  {
513  col[r] = TRANSPOSED ? (*this)[c][r] : (*this)[r][c];
514  }
515 
516  return col;
517  }
518 
519  template <size_t D>
520  void set_col(size_t c, const Vector_d<D>& col);
521 
522  inline bool operator==( const Matrix_d& op2) const
523  {
524  return matrix_equality_dispatch_(op2);
525  }
526 
527  inline bool operator==( const Matrix_d<NCOLS, NROWS, !TRANSPOSED>& op2) const
528  {
529  return matrix_equality_dispatch_(op2);
530  }
531 
532  bool operator==(const Matrix& op2) const;
533 
534  inline bool operator!=(const Matrix_d& op2) const
535  {
536  return !((*this) == op2);
537  }
538 
539  inline bool operator!=( const Matrix_d<NCOLS, NROWS, !TRANSPOSED>& op2) const
540  {
541  return !((*this) == op2);
542  }
543 
544  inline bool operator!=(const Matrix& op2) const;
545 
546 private:
548  // DISPATCH METHODS
549  //
550  // These should work the same for normal and transposed
551  // static matrices and for dynamic kjb::Matrix's.
552  //
553  // The all assume that dimension checking has already occurred by
554  // the caller.
555  //
557  template <class Matrix_type>
558  Matrix_d& assignment_dispatch_(Matrix_type& other);
559 
560  template <class Matrix_op>
561  Matrix_d& plus_equals_dispatch_(const Matrix_op& second);
562 
563  template <class Matrix_op>
564  Matrix_d& minus_equals_dispatch_(const Matrix_op& second);
565 
566 
567  template <class Matrix2>
568  bool matrix_equality_dispatch_(const Matrix2& m2) const;
569 
570 
571 #ifdef KJB_HAVE_BST_SERIAL
572  template <class Archive>
573  void serialize(Archive &ar, const unsigned int /* version */)
574  {
575  ar & ::boost::serialization::base_object<Base>(*this);
576  }
577 #endif
578 };
579 
582 typedef Matrix_d<4,4> Matrix4;
583 
585 // SCALAR OPERATIONS
587 
588 template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
590 operator*(double scalar, const Matrix_d<NROWS, NCOLS, TRANSPOSED>& mat);
591 
593 // Matrix multiplication
595 //
602 template <class Matrix_type_1, class Matrix_type_2>
603 Matrix_d<Matrix_type_1::num_rows, Matrix_type_2::num_cols> matrix_multiply_dispatch_(const Matrix_type_1& m1, const Matrix_type_2& m2);
604 
605 
606 template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
607 inline Matrix operator*(const Matrix_d<NROWS, NCOLS, TRANSPOSED>& op1, const Matrix& op2);
608 
609 template<std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
610 inline Matrix operator*(const kjb::Matrix& op1, const Matrix_d<NROWS, NCOLS, TRANSPOSED>& op2);
611 
612 
613 template <std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
614 inline bool operator==(const Matrix& op2, const Matrix_d<NROWS, NCOLS, TRANSPOSED>& op1);
615 
616 template <std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
617 inline bool operator!=(const Matrix& op2, const Matrix_d<NROWS, NCOLS, TRANSPOSED>& op1);
618 
619 template <std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
621 
622 template <std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
624 
626 // I/O functions
628 template <std::size_t NROWS, std::size_t NCOLS, bool TRANSPOSED>
629 std::ostream& operator<<(std::ostream& ost, const Matrix_d<NROWS, NCOLS, TRANSPOSED>& mat);
630 
632 // Utility functions
634 
635 template <std::size_t D>
637 
641 template <std::size_t D>
642 inline Matrix_d<D, D> outer_product(const Vector_d<D>& v1, const Vector_d<D>& v2);
643 
644 template <std::size_t NROWS, std::size_t NCOLS>
646 
647 template <size_t D>
648 double trace(const Matrix_d<D,D>& m);
649 
651 // A few hard-coded numerical functions
653 
655 
657 
659 void symmetric_eigs(const kjb::Matrix3& A, double& eig1, double& eig2, double& eig3);
660 
664 template <std::size_t R, std::size_t C, bool T>
665 double accumulate(const Matrix_d<R,C, T>& mat, double init);
666 
670 template <std::size_t R, std::size_t C, bool T, class Binary_function>
671 double accumulate(const Matrix_d<R,C, T>& mat, double init,
672  Binary_function binary_op)
673 {
674  double result = init;
675  for (size_t r = 0; r < R; r++)
676  {
677  for (size_t c = 0; c < C; c++)
678  {
679  result = binary_op(result, mat(r,c));
680  }
681  }
682 
683  return result;
684 }
685 
686 template <std::size_t R, std::size_t C>
687 double max_abs_difference( const Matrix_d<R,C,false>& op1, const Matrix_d<R,C,false>& op2 );
688 
692 template <std::size_t R, std::size_t C, bool T>
693 double max(const Matrix_d<R,C, T>& mat);
694 
698 template <std::size_t R, std::size_t C, bool T>
699 double min(const Matrix_d<R,C, T>& mat);
700 
701 /*
702  * NOTE TO IMPLEMENTERS
703  *
704  * If oyu want to add new generic free functions, please consider moving
705  * the implementation into m_matrix_d.impl.h, and adding it to the list
706  * of explicit instantiations in m_matrix_d.cpp.
707  *
708  * This should help keep the compile-time for this file low when common
709  * matrix sizes are used.
710  */
711 
714 } // namespace kjb
715 
716 //#include <m_cpp/m_matrix_d.impl.h>
717 #endif
Vector_d< num_cols > get_row(size_t r) const
Definition: m_matrix_d.h:494
Definition: gr_opengl.h:41
Matrix_d< 2, 2 > Matrix2
Definition: m_matrix_d.h:580
Matrix_d operator+(const Matrix_d< NCOLS, NROWS,!TRANSPOSED > &second) const
Definition: m_matrix_d.h:356
bool operator!=(const Matrix_d &op2) const
Definition: m_matrix_d.h:534
static size_t get_num_cols()
Definition: m_matrix_d.h:463
Matrix_d operator-(const Matrix_d &second) const
Definition: m_matrix_d.h:315
Int_matrix::Value_type max(const Int_matrix &mat)
Return the maximum value in this matrix.
Definition: l_int_matrix.h:1397
Matrix_d< 4, 4, false > Matrix4
Definition: gr_opengl.h:41
double trace(const Matrix_d< D, D > &m)
Definition: m_matrix_d.impl.h:421
Matrix_d & swap(Matrix_d &other)
Definition: m_matrix_d.h:275
Matrix_d< num_rows, IN_COLS > operator*(const Matrix_d< num_cols, IN_COLS, false > &second) const
Definition: m_matrix_d.h:383
const Matrix_d< NROWS, NCOLS,!TRANSPOSED > & transpose() const
Definition: m_matrix_d.h:288
double accumulate(const Matrix_d< R, C, T > &mat, double init)
Definition: m_matrix_d.impl.h:432
Definition: m_concept.h:30
void set_col(size_t c, const Vector_d< D > &col)
Definition: m_matrix_d.impl.h:169
Object thrown when an argument is of the wrong size or dimensions.
Definition: l_exception.h:426
Vector_d< num_rows > get_col(size_t c) const
Definition: m_matrix_d.h:508
Matrix_d operator*(double s) const
Definition: m_matrix_d.h:416
Matrix_d operator-(const Matrix &second) const
Definition: m_matrix_d.h:332
Matrix_d operator/(double s) const
Definition: m_matrix_d.h:453
Int_matrix::Value_type max_abs_difference(const Int_matrix &op1, const Int_matrix &op2)
Find the largest difference between two matrices.
Definition: l_int_matrix.h:1364
void swap(Perspective_camera &cam1, Perspective_camera &cam2)
Swap two cameras.
Definition: perspective_camera.h:599
Matrix_d & operator*=(const Matrix_d< IN_ROWS, IN_ROWS, IN_TRANSPOSED > &other)
Definition: m_matrix_d.h:409
Matrix_d< Matrix_type_1::num_rows, Matrix_type_2::num_cols > matrix_multiply_dispatch_(const Matrix_type_1 &m1, const Matrix_type_2 &m2)
Definition: m_matrix_d.impl.h:257
Matrix_d & operator/=(double s)
Definition: m_matrix_d.h:448
r
Definition: APPgetLargeConnectedEdges.m:127
bool operator==(const Matrix_d< NCOLS, NROWS,!TRANSPOSED > &op2) const
Definition: m_matrix_d.h:527
Image operator-(const Image &im1, const Image &im2)
Subtract two images.
Definition: i_image.h:843
#define KJB_THROW(ex)
Definition: l_exception.h:46
Matrix outer_product(const Vector &v1, const Vector &v2)
Definition: m_matrix.h:2293
#define KJB_STATIC_ASSERT(x, y)
Definition: l_cxx11.h:55
Matrix_d operator-() const
negation
Definition: m_matrix_d.impl.h:107
Image operator+(const Image &op1, const Image &op2)
Add two images.
Definition: i_image.h:834
Matrix_d< 3, 3 > Matrix3
Definition: m_matrix_d.h:581
Matrix_d & operator+=(const Matrix_d &second)
Definition: m_matrix_d.h:341
Matrix_d(Iterator begin)
Fill constructor.
Definition: m_matrix_d.h:127
Matrix matrix_inverse(const Matrix &op1)
Invert this matrix.
Definition: m_matrix.cpp:730
Matrix_d & operator-=(const Matrix_d< NCOLS, NROWS,!TRANSPOSED > &second)
Definition: m_matrix_d.h:320
Matrix_d< num_rows, IN_COLS > operator*(const Matrix_d< IN_COLS, num_cols, true > &second) const
Definition: m_matrix_d.h:390
static size_t get_num_rows()
Definition: m_matrix_d.h:458
bool operator!=(const Matrix_d< NCOLS, NROWS,!TRANSPOSED > &op2) const
Definition: m_matrix_d.h:539
void symmetric_eigs(const kjb::Matrix3 &A, double &eig1, double &eig2, double &eig3)
get eigenvalues of symmetric matrix A in ascending order
Definition: m_matrix_d.cpp:160
Matrix_d()
Definition: m_matrix_d.impl.h:37
static const std::size_t value
Definition: m_matrix_d.h:83
Matrix_d & operator=(const Matrix_d &other)
assignment
Definition: m_matrix_d.h:296
Matrix_d operator+(const Matrix_d &second) const
Definition: m_matrix_d.h:346
Matrix create_identity_matrix(int rank)
Construct an identity matrix of specified rank.
Definition: m_matrix.h:1795
Matrix_d operator-(const Matrix_d< NCOLS, NROWS,!TRANSPOSED > &second) const
Definition: m_matrix_d.h:325
bool operator!=(const Int_matrix &op1, const Int_matrix::Impl_type &op2)
Test for any difference between two matrices.
Definition: l_int_matrix.h:1274
void set_row(size_t r, const Vector_d< D > &row)
Definition: m_matrix_d.impl.h:151
bool operator==(const Matrix_d &op2) const
Definition: m_matrix_d.h:522
bool operator==(const Int_matrix &op1, const Int_matrix::Impl_type &op2)
Test for exact equality between two matrices.
Definition: l_int_matrix.cpp:218
Vector_d< num_rows > operator*(const Vector_d< num_cols > &v) const
Definition: m_matrix_d.h:428
Int_matrix::Value_type min(const Int_matrix &mat)
Return the minimum value in this matrix.
Definition: l_int_matrix.h:1385
Matrix_d & operator*=(double s)
multiplication by a scalar
Definition: m_matrix_d.impl.h:139
Matrix_d & operator-=(const Matrix_d &second)
Definition: m_matrix_d.h:310
static const std::size_t num_cols
Definition: m_matrix_d.h:88
Definition: m_matrix_d.h:83
double & operator()(size_t row, size_t col)
Definition: m_matrix_d.h:468
void resize(size_t rows, size_t cols)
Definition: m_matrix_d.h:263
Definition: g_quaternion.h:37
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
Matrix_d< NROWS, NCOLS,!TRANSPOSED > & transpose()
Definition: m_matrix_d.h:281
for m
Definition: APPgetLargeConnectedEdges.m:64
const double & operator()(size_t row, size_t col) const
Definition: m_matrix_d.h:481
Support for error handling exception classes in libKJB.
Gsl_Vector operator*(double scalar, const Gsl_Vector &vector)
multiply scalar and vector, scalar written on the left side
Definition: gsl_vector.h:661
Matrix_d & operator+=(const Matrix_d< NCOLS, NROWS,!TRANSPOSED > &second)
Definition: m_matrix_d.h:351
static const std::size_t num_rows
Definition: m_matrix_d.h:89
Matrix create_random_matrix(int num_rows, int num_cols)
Definition: m_matrix.h:1853