SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Matrix.hpp
Go to the documentation of this file.
1 /*
2  * Copyright(c):
3  * Signal Image and Communications (SIC) Department
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * - University of Poitiers, France http://www.univ-poitiers.fr
6  * - XLIM Institute UMR CNRS 7252 http://www.xlim.fr/
7  *
8  * and
9  *
10  * D2 Fluid, Thermic and Combustion
11  * - University of Poitiers, France http://www.univ-poitiers.fr
12  * - PPRIME Institute - UPR CNRS 3346 http://www.pprime.fr
13  * - ISAE-ENSMA http://www.ensma.fr
14  *
15  * Contributor(s):
16  * The SLIP team,
17  * Benoit Tremblais <tremblais_AT_sic.univ-poitiers.fr>,
18  * Laurent David <laurent.david_AT_lea.univ-poitiers.fr>,
19  * Ludovic Chatellier <ludovic.chatellier_AT_univ-poitiers.fr>,
20  * Lionel Thomas <lionel.thomas_AT_univ-poitiers.fr>,
21  * Denis Arrivault <arrivault_AT_sic.univ-poitiers.fr>,
22  * Julien Dombre <julien.dombre_AT_univ-poitiers.fr>.
23  *
24  * Description:
25  * The Simple Library of Image Processing (SLIP) is a new image processing
26  * library. It is written in the C++ language following as much as possible
27  * the ISO/ANSI C++ standard. It is consequently compatible with any system
28  * satisfying the ANSI C++ complience. It works on different Unix , Linux ,
29  * Mircrosoft Windows and Mac OS X plateforms. SLIP is a research library that
30  * was created by the Signal, Image and Communications (SIC) departement of
31  * the XLIM, UMR 7252 CNRS Institute in collaboration with the Fluids, Thermic
32  * and Combustion departement of the P', UPR 3346 CNRS Institute of the
33  * University of Poitiers.
34  *
35  * The SLIP Library source code has been registered to the APP (French Agency
36  * for the Protection of Programs) by the University of Poitiers and CNRS,
37  * under registration number IDDN.FR.001.300034.000.S.P.2010.000.21000.
38 
39  * http://www.sic.sp2mi.univ-poitiers.fr/slip/
40  *
41  * This software is governed by the CeCILL-C license under French law and
42  * abiding by the rules of distribution of free software. You can use,
43  * modify and/ or redistribute the software under the terms of the CeCILL-C
44  * license as circulated by CEA, CNRS and INRIA at the following URL
45  * http://www.cecill.info.
46  * As a counterpart to the access to the source code and rights to copy,
47  * modify and redistribute granted by the license, users are provided only
48  * with a limited warranty and the software's author, the holder of the
49  * economic rights, and the successive licensors have only limited
50  * liability.
51  *
52  * In this respect, the user's attention is drawn to the risks associated
53  * with loading, using, modifying and/or developing or reproducing the
54  * software by the user in light of its specific status of free software,
55  * that may mean that it is complicated to manipulate, and that also
56  * therefore means that it is reserved for developers and experienced
57  * professionals having in-depth computer knowledge. Users are therefore
58  * encouraged to load and test the software's suitability as regards their
59  * requirements in conditions enabling the security of their systems and/or
60  * data to be ensured and, more generally, to use and operate it in the
61  * same conditions as regards security.
62  *
63  * The fact that you are presently reading this means that you have had
64  * knowledge of the CeCILL-C license and that you accept its terms.
65  */
66 
67 
68 
75 #ifndef SLIP_MATRIX_HPP
76 #define SLIP_MATRIX_HPP
77 
78 #include <iostream>
79 #include <iterator>
80 #include <cassert>
81 #include <numeric>
82 #include <algorithm>
83 #include <cmath>
84 #include <string>
85 #include <cstddef>
86 #include "Array2d.hpp"
87 #include "Point2d.hpp"
88 #include "DPoint2d.hpp"
89 #include "stride_iterator.hpp"
90 #include "iterator2d_box.hpp"
91 #include "Range.hpp"
92 #include "iterator2d_range.hpp"
93 #include "apply.hpp"
94 #include "norms.hpp"
95 #include "linear_algebra.hpp"
97 #include "linear_algebra_eigen.hpp"
98 #include "linear_algebra_svd.hpp"
99 #include "complex_cast.hpp"
100 
101 
102 #include <boost/serialization/access.hpp>
103 #include <boost/serialization/split_member.hpp>
104 #include <boost/serialization/string.hpp>
105 #include <boost/serialization/complex.hpp>
106 #include <boost/serialization/version.hpp>
107 
108 namespace slip
109 {
110 
111 template<class T>
112 class stride_iterator;
113 
114 template<class T>
115 class iterator2d_box;
116 
117 template<class T>
118 class iterator2d_range;
119 
120 template<class T>
121 class const_iterator2d_box;
122 
123 template<class T>
124 class const_iterator2d_range;
125 
126 template <class T>
127 class DPoint2d;
128 
129 template <class T>
130 class Point2d;
131 
132 template <class T>
133 class Box2d;
134 
135 template <typename T>
136 class Matrix;
137 
138 template <typename T>
139 class Array2d;
140 
141 template <typename T>
142 std::ostream& operator<<(std::ostream & out, const slip::Matrix<T>& a);
143 
144 template<typename T>
145 bool operator==(const slip::Matrix<T>& x,
146  const slip::Matrix<T>& y);
147 
148 template<typename T>
149 bool operator!=(const slip::Matrix<T>& x,
150  const slip::Matrix<T>& y);
151 
152 template<typename T>
153 bool operator<(const slip::Matrix<T>& x,
154  const slip::Matrix<T>& y);
155 
156 template<typename T>
157 bool operator>(const slip::Matrix<T>& x,
158  const slip::Matrix<T>& y);
159 
160 template<typename T>
161 bool operator<=(const slip::Matrix<T>& x,
162  const slip::Matrix<T>& y);
163 
164 template<typename T>
165 bool operator>=(const slip::Matrix<T>& x,
166  const slip::Matrix<T>& y);
167 
189 template <typename T>
190 class Matrix
191 {
192 public :
193 
194  typedef T value_type;
195  typedef Matrix<T> self;
196  typedef const Matrix<T> const_self;
197 
198  typedef value_type* pointer;
199  typedef value_type const * const_pointer;
201  typedef value_type const & const_reference;
202 
203  typedef ptrdiff_t difference_type;
204  typedef std::size_t size_type;
205 
206  typedef pointer iterator;
208 
209  typedef std::reverse_iterator<iterator> reverse_iterator;
210  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
211 
216 
217 
226 
227 
228  typedef std::reverse_iterator<iterator> reverse_row_iterator;
229  typedef std::reverse_iterator<const_iterator> const_reverse_row_iterator;
230  typedef std::reverse_iterator<col_iterator> reverse_col_iterator;
231  typedef std::reverse_iterator<const_col_iterator> const_reverse_col_iterator;
232  typedef std::reverse_iterator<iterator2d> reverse_iterator2d;
233  typedef std::reverse_iterator<const_iterator2d> const_reverse_iterator2d;
234  typedef std::reverse_iterator<row_range_iterator> reverse_row_range_iterator;
235  typedef std::reverse_iterator<const_row_range_iterator> const_reverse_row_range_iterator;
236  typedef std::reverse_iterator<col_range_iterator> reverse_col_range_iterator;
237  typedef std::reverse_iterator<const_col_range_iterator> const_reverse_col_range_iterator;
238  typedef std::reverse_iterator<iterator2d_range> reverse_iterator2d_range;
239  typedef std::reverse_iterator<const_iterator2d_range> const_reverse_iterator2d_range;
240 
242 
243 
244  //default iterator of the container
247 
248  static const std::size_t DIM = 2;
249 public:
254 
258  Matrix();
259 
265  Matrix(const size_type d1,
266  const size_type d2);
267 
274  Matrix(const size_type d1,
275  const size_type d2,
276  const T& val);
277 
284  Matrix(const size_type d1,
285  const size_type d2,
286  const T* val);
287 
298  template<typename InputIterator>
299  Matrix(const size_type d1,
300  const size_type d2,
301  InputIterator first,
302  InputIterator last)
303  {
304  array_ = new slip::Array2d<T>(d1,d2,first,last);
305  }
309  Matrix(const self& rhs);
310 
314  ~Matrix();
315 
316 
326  void resize(const size_type d1,
327  const size_type d2,
328  const T& val = T());
329 
330 
335 
355  iterator begin();
356 
357 
377  iterator end();
378 
399  const_iterator begin() const;
400 
401 
421  const_iterator end() const;
422 
444 
466 
488 
489 
511 
512 
532  row_iterator row_begin(const size_type row);
533 
534 
554  row_iterator row_end(const size_type row);
555 
556 
576  const_row_iterator row_begin(const size_type row) const;
577 
578 
598  const_row_iterator row_end(const size_type row) const;
599 
619  col_iterator col_begin(const size_type col);
620 
621 
641  col_iterator col_end(const size_type col);
642 
662  const_col_iterator col_begin(const size_type col) const;
663 
664 
665 
685  const_col_iterator col_end(const size_type col) const;
686 
687 
713  const slip::Range<int>& range);
714 
715 
716 
742  const slip::Range<int>& range);
743 
744 
770  const slip::Range<int>& range) const;
771 
772 
797  const slip::Range<int>& range) const;
798 
799 
825  const slip::Range<int>& range);
826 
853  const slip::Range<int>& range);
854 
855 
856 
857 
883  const slip::Range<int>& range) const;
884 
885 
912  const slip::Range<int>& range) const;
913 
914 
915 
928 
929 
942 
955 
968 
982 
983 
997 
1011 
1012 
1026 
1027 
1043  const slip::Range<int>& range);
1044 
1045 
1062  const slip::Range<int>& range);
1063 
1064 
1065 
1079  const slip::Range<int>& range) const;
1080 
1081 
1097  const slip::Range<int>& range) const;
1098 
1099 
1100 
1101 
1117  const slip::Range<int>& range);
1118 
1135  const slip::Range<int>& range);
1136 
1137 
1153  col_rbegin(const size_type col,
1154  const slip::Range<int>& range) const;
1155 
1156 
1172  const slip::Range<int>& range) const;
1173 
1174 
1193 
1194 
1213 
1214 
1232  const_iterator2d upper_left() const;
1233 
1234 
1253 
1277  iterator2d upper_left(const Box2d<int>& box);
1278 
1279 
1304  iterator2d bottom_right(const Box2d<int>& box);
1305 
1306 
1331  const_iterator2d upper_left(const Box2d<int>& box) const;
1332 
1333 
1358  const_iterator2d bottom_right(const Box2d<int>& box) const;
1359 
1360 
1388  iterator2d_range upper_left(const Range<int>& row_range,
1389  const Range<int>& col_range);
1390 
1418  iterator2d_range bottom_right(const Range<int>& row_range,
1419  const Range<int>& col_range);
1420 
1421 
1449  const_iterator2d_range upper_left(const Range<int>& row_range,
1450  const Range<int>& col_range) const;
1451 
1452 
1481  const Range<int>& col_range) const;
1482 
1483 
1484 
1485 
1486 
1511  iterator2d_range upper_left(const Range<int>& range);
1512 
1513 
1540 
1541 
1542 
1543 
1568  const_iterator2d_range upper_left(const Range<int>& range) const;
1569 
1570 
1571 
1597  const_iterator2d_range bottom_right(const Range<int>& range) const;
1598 
1599 
1610 
1621 
1632 
1633 
1644 
1645 
1661 
1677 
1693 
1694 
1710 
1711 
1729  const Range<int>& col_range);
1730 
1731 
1732 
1750  const Range<int>& col_range);
1751 
1752 
1753 
1771  const Range<int>& col_range) const;
1772 
1790  const Range<int>& col_range) const;
1791 
1792 
1793 
1810 
1811 
1812 
1830 
1831 
1849 
1850 
1868 
1869 
1870 
1882  friend std::ostream& operator<< <>(std::ostream & out,
1883  const self& a);
1884 
1899  Matrix& operator=(const self & rhs);
1900 
1906  self& operator=(const T& val);
1907 
1908 
1909 
1915  void fill(const T& value)
1916  {
1917  std::fill_n(this->begin(),this->size(),value);
1918  }
1919 
1926  void fill(const T* value)
1927  {
1928  std::copy(value,value + this->size(), this->begin());
1929  }
1930 
1939  template<typename InputIterator>
1940  void fill(InputIterator first,
1941  InputIterator last)
1942  {
1943  std::copy(first,last, this->begin());
1944  }
1952 
1959  friend bool operator== <>(const Matrix<T>& x,
1960  const Matrix<T>& y);
1961 
1968  friend bool operator!= <>(const Matrix<T>& x,
1969  const Matrix<T>& y);
1970 
1977  friend bool operator< <>(const Matrix<T>& x,
1978  const Matrix<T>& y);
1979 
1986  friend bool operator> <>(const Matrix<T>& x,
1987  const Matrix<T>& y);
1988 
1995  friend bool operator<= <>(const Matrix<T>& x,
1996  const Matrix<T>& y);
1997 
2004  friend bool operator>= <>(const Matrix<T>& x,
2005  const Matrix<T>& y);
2006 
2007 
2024  pointer operator[](const size_type i);
2025 
2036  const_pointer operator[](const size_type i) const;
2037 
2038 
2051  reference operator()(const size_type i,
2052  const size_type j);
2053 
2067  const size_type j) const;
2068 
2080  reference operator()(const Point2d<size_type>& point2d);
2081 
2093  const_reference operator()(const Point2d<size_type>& point2d) const;
2094 
2095 
2108  self operator()(const Range<int>& row_range,
2109  const Range<int>& col_range);
2110 
2111 
2118  std::string name() const;
2119 
2124  size_type dim1() const;
2125 
2130  size_type rows() const;
2131 
2136  size_type dim2() const;
2137 
2142  size_type columns() const;
2143 
2148  size_type cols() const;
2149 
2153  size_type size() const;
2154 
2158  size_type max_size() const;
2159 
2163  bool empty()const;
2164 
2169  void swap(self& M);
2170 
2171 
2181  self& operator+=(const T& val);
2182  self& operator-=(const T& val);
2183  self& operator*=(const T& val);
2184  self& operator/=(const T& val);
2185 // self& operator%=(const T& val);
2186 // self& operator^=(const T& val);
2187 // self& operator&=(const T& val);
2188 // self& operator|=(const T& val);
2189 // self& operator<<=(const T& val);
2190 // self& operator>>=(const T& val);
2191 
2192 
2193  self operator-() const;
2194  //self operator!() const;
2195 
2196 
2197 
2198  self& operator+=(const self& rhs);
2199  self& operator-=(const self& rhs);
2200  self& operator*=(const self& rhs);
2201  self& operator/=(const self& rhs);
2202 
2203 
2216  T& min() const;
2217 
2218 
2225  T& max() const;
2226 
2231  T sum() const;
2232 
2238  T trace() const;
2239 
2245  T det() const;
2246 
2252  norm_type cond() const;
2253 
2254 
2261  size_type rank() const;
2262 
2268  self inv() const;
2269 
2275  {
2276  assert(this->size() != 0);
2277  return slip::row_norm(*this);
2278  }
2279 
2285  {
2286  assert(this->size() != 0);
2287  slip::Array2d<T> U(this->rows(),this->cols());
2288  slip::Array2d<T> V(this->cols(),this->cols());
2289  slip::Array<T> W(this->cols());
2290  slip::svd(*this,U,W.begin(),W.end(),V);
2291  return std::abs(W[0]);
2292  }
2293 
2299  {
2300  return slip::col_norm(*this);
2301  }
2302 
2308  {
2309  return slip::frobenius_norm(*this);
2310  }
2311 
2318  {
2319  return slip::spectral_radius(*this);
2320  }
2321 
2337  Matrix<T>& apply(T (*fun)(T));
2338 
2354  Matrix<T>& apply(T (*fun)(const T&));
2355 
2358  private:
2359  Array2d<T>* array_;
2360 
2361  private:
2362  friend class boost::serialization::access;
2363  template<class Archive>
2364  void save(Archive & ar, const unsigned int version) const
2365  {
2366  ar & this->array_;
2367  }
2368  template<class Archive>
2369  void load(Archive & ar, const unsigned int version)
2370  {
2371  ar & this->array_;
2372  }
2373  BOOST_SERIALIZATION_SPLIT_MEMBER();
2374 };
2375 
2396 
2397 }//slip::
2398 namespace slip{
2411 template<typename T>
2412 Matrix<T> operator+(const Matrix<T>& M1,
2413  const Matrix<T>& M2);
2414 
2421 template<typename T>
2422 Matrix<T> operator+(const Matrix<T>& M1,
2423  const T& val);
2424 
2431  template<typename T>
2432  Matrix<T> operator+(const T& val,
2433  const Matrix<T>& M1);
2434 
2443 template<typename T>
2444 Matrix<T> operator-(const Matrix<T>& M1,
2445  const Matrix<T>& M2);
2446 
2453 template<typename T>
2454 Matrix<T> operator-(const Matrix<T>& M1,
2455  const T& val);
2456 
2463  template<typename T>
2464  Matrix<T> operator-(const T& val,
2465  const Matrix<T>& M1);
2466 
2475  template<typename T>
2476  Matrix<T> operator*(const Matrix<T>& M1,
2477  const Matrix<T>& M2);
2478 
2485  template<typename T>
2486  Matrix<T> operator*(const Matrix<T>& M1,
2487  const T& val);
2488 
2495  template<typename T>
2496  Matrix<T> operator*(const T& val,
2497  const Matrix<T>& M1);
2498 
2507  template<typename T>
2508  Matrix<T> operator/(const Matrix<T>& M1,
2509  const Matrix<T>& M2);
2510 
2517  template<typename T>
2518  Matrix<T> operator/(const Matrix<T>& M1,
2519  const T& val);
2520 /* @} */
2521 
2528  template<typename T>
2529  T& min(const Matrix<T>& M1);
2530 
2538  template<typename T>
2539  T& max(const Matrix<T>& M1);
2540 
2547  template<typename T>
2548  Matrix<typename slip::lin_alg_traits<T>::value_type> abs(const Matrix<T>& V);
2549 
2556  template<typename T>
2557  Matrix<T> sqrt(const Matrix<T>& V);
2558 
2565  template<typename T>
2566  Matrix<T> cos(const Matrix<T>& V);
2567 
2574  Matrix<float> acos(const Matrix<float>& V);
2581  Matrix<double> acos(const Matrix<double>& V);
2588  Matrix<long double> acos(const Matrix<long double>& V);
2589 
2590 
2597  template<typename T>
2598  Matrix<T> sin(const Matrix<T>& V);
2599 
2600 
2607  Matrix<float> asin(const Matrix<float>& V);
2614  Matrix<double> asin(const Matrix<double>& V);
2621  Matrix<long double> asin(const Matrix<long double>& V);
2622 
2623 
2630  template<typename T>
2631  Matrix<T> tan(const Matrix<T>& V);
2632 
2633 
2640  Matrix<float> atan(const Matrix<float>& V);
2647  Matrix<double> atan(const Matrix<double>& V);
2654  Matrix<long double> atan(const Matrix<long double>& V);
2655 
2656 
2663  template<typename T>
2664  Matrix<T> exp(const Matrix<T>& V);
2665 
2672  template<typename T>
2673  Matrix<T> log(const Matrix<T>& V);
2674 
2681  template<typename T>
2682  Matrix<T> cosh(const Matrix<T>& V);
2683 
2690  template<typename T>
2691  Matrix<T> sinh(const Matrix<T>& V);
2692 
2699  template<typename T>
2700  Matrix<T> tanh(const Matrix<T>& V);
2701 
2708  template<typename T>
2709  Matrix<T> log10(const Matrix<T>& V);
2710 
2711 
2712 }//slip::
2713 
2714 namespace slip
2715 {
2716  template<typename T>
2717  inline
2719  array_(new slip::Array2d<T>())
2720  {}
2721 
2722  template<typename T>
2723  inline
2725  const typename Matrix<T>::size_type d2):
2726  array_(new slip::Array2d<T>(d1,d2))
2727  {}
2728 
2729  template<typename T>
2730  inline
2732  const typename Matrix<T>::size_type d2,
2733  const T& val):
2734  array_(new slip::Array2d<T>(d1,d2,val))
2735  {}
2736 
2737  template<typename T>
2738  inline
2740  const typename Matrix<T>::size_type d2,
2741  const T* val):
2742  array_(new slip::Array2d<T>(d1,d2,val))
2743  {}
2744 
2745  template<typename T>
2746  inline
2748  array_(new slip::Array2d<T>((*rhs.array_)))
2749  {}
2750 
2751  template<typename T>
2752  inline
2754  {
2755  delete array_;
2756  }
2757 
2758  template<typename T>
2759  inline
2761  {
2762  if(this != &rhs)
2763  {
2764  *array_ = *(rhs.array_);
2765  }
2766  return *this;
2767  }
2768 
2769  template<typename T>
2770  inline
2772  {
2773  std::fill_n((*array_)[0],array_->size(),val);
2774  return *this;
2775  }
2776 
2777  template<typename T>
2778  inline
2779  void Matrix<T>::resize(const typename Matrix<T>::size_type d1,
2780  const typename Matrix<T>::size_type d2,
2781  const T& val)
2782  {
2783  array_->resize(d1,d2,val);
2784  }
2785 
2786 
2787  template<typename T>
2788  inline
2790  {
2791  return array_->begin();
2792  }
2793 
2794  template<typename T>
2795  inline
2797  {
2798  return array_->end();
2799  }
2800 
2801  template<typename T>
2802  inline
2804  {
2805  Array2d<T> const * tp(array_);
2806  return tp->begin();
2807  }
2808 
2809  template<typename T>
2810  inline
2812  {
2813  Array2d<T> const * tp(array_);
2814  return tp->end();
2815  }
2816 
2817 
2818  template<typename T>
2819  inline
2821  {
2822  return typename Matrix<T>::reverse_iterator(this->end());
2823  }
2824 
2825  template<typename T>
2826  inline
2828  {
2829  return typename Matrix<T>::reverse_iterator(this->begin());
2830  }
2831 
2832  template<typename T>
2833  inline
2835  {
2836  return typename Matrix<T>::const_reverse_iterator(this->end());
2837  }
2838 
2839  template<typename T>
2840  inline
2842  {
2843  return typename Matrix<T>::const_reverse_iterator(this->begin());
2844  }
2845 
2846  template<typename T>
2847  inline
2848  typename Matrix<T>::row_iterator
2849  Matrix<T>::row_begin(const typename Matrix<T>::size_type row)
2850  {
2851  return array_->row_begin(row);
2852  }
2853 
2854  template<typename T>
2855  inline
2856  typename Matrix<T>::row_iterator
2857  Matrix<T>::row_end(const typename Matrix<T>::size_type row)
2858  {
2859  return array_->row_end(row);
2860  }
2861 
2862  template<typename T>
2863  inline
2864  typename Matrix<T>::col_iterator
2865  Matrix<T>::col_begin(const typename Matrix<T>::size_type col)
2866  {
2867  return array_->col_begin(col);
2868  }
2869 
2870 
2871  template<typename T>
2872  inline
2873  typename Matrix<T>::col_iterator
2874  Matrix<T>::col_end(const typename Matrix<T>::size_type col)
2875  {
2876  return array_->col_end(col);
2877  }
2878 
2879 
2880  template<typename T>
2881  inline
2883  Matrix<T>::row_begin(const typename Matrix<T>::size_type row) const
2884  {
2885  Array2d<T> const * tp(array_);
2886  return tp->row_begin(row);
2887  }
2888 
2889  template<typename T>
2890  inline
2892  Matrix<T>::row_end(const typename Matrix<T>::size_type row) const
2893  {
2894  Array2d<T> const * tp(array_);
2895  return tp->row_end(row);
2896  }
2897 
2898  template<typename T>
2899  inline
2901  {
2902  Array2d<T> const * tp(array_);
2903  return tp->col_begin(col);
2904  }
2905 
2906  template<typename T>
2907  inline
2908  typename Matrix<T>::const_col_iterator Matrix<T>::col_end(const typename Matrix<T>::size_type col) const
2909  {
2910  Array2d<T> const * tp(array_);
2911  return tp->col_end(col);
2912  }
2913 
2914 
2915  template<typename T>
2916  inline
2918  Matrix<T>::row_rbegin(const typename Matrix<T>::size_type row)
2919  {
2920  return array_->row_rbegin(row);
2921  }
2922 
2923  template<typename T>
2924  inline
2926  Matrix<T>::row_rbegin(const typename Matrix<T>::size_type row) const
2927  {
2928  Array2d<T> const * tp(array_);
2929  return tp->row_rbegin(row);
2930  }
2931 
2932  template<typename T>
2933  inline
2935  {
2936  return array_->row_rend(row);
2937  }
2938 
2939  template<typename T>
2940  inline
2942  Matrix<T>::row_rend(const typename Matrix<T>::size_type row) const
2943  {
2944  Array2d<T> const * tp(array_);
2945  return tp->row_rend(row);
2946  }
2947 
2948 
2949  template<typename T>
2950  inline
2952  {
2953  return array_->col_rbegin(col);
2954  }
2955 
2956  template<typename T>
2957  inline
2959  Matrix<T>::col_rbegin(const typename Matrix<T>::size_type col) const
2960  {
2961  Array2d<T> const * tp(array_);
2962  return tp->col_rbegin(col);
2963  }
2964 
2965  template<typename T>
2966  inline
2968  Matrix<T>::col_rend(const typename Matrix<T>::size_type col)
2969  {
2970  return array_->col_rend(col);
2971  }
2972 
2973  template<typename T>
2974  inline
2976  Matrix<T>::col_rend(const typename Matrix<T>::size_type col) const
2977  {
2978  Array2d<T> const * tp(array_);
2979  return tp->col_rend(col);
2980  }
2981 
2982  template<typename T>
2983  inline
2985  Matrix<T>::row_begin(const typename Matrix<T>::size_type row,
2986  const slip::Range<int>& range)
2987  {
2988  return array_->row_begin(row,range);
2989  }
2990 
2991  template<typename T>
2992  inline
2994  Matrix<T>::row_begin(const typename Matrix<T>::size_type row,
2995  const slip::Range<int>& range) const
2996  {
2997  Array2d<T> const * tp(array_);
2998  return tp->row_begin(row,range);
2999  }
3000 
3001  template<typename T>
3002  inline
3004  Matrix<T>::col_begin(const typename Matrix<T>::size_type col,
3005  const slip::Range<int>& range)
3006  {
3007  return array_->col_begin(col,range);
3008  }
3009 
3010  template<typename T>
3011  inline
3013  Matrix<T>::col_begin(const typename Matrix<T>::size_type col,
3014  const slip::Range<int>& range) const
3015  {
3016  Array2d<T> const * tp(array_);
3017  return tp->col_begin(col,range);
3018  }
3019 
3020 
3021  template<typename T>
3022  inline
3024  Matrix<T>::row_end(const typename Matrix<T>::size_type row,
3025  const slip::Range<int>& range)
3026  {
3027  return array_->row_end(row,range);
3028  }
3029 
3030  template<typename T>
3031  inline
3033  Matrix<T>::row_end(const typename Matrix<T>::size_type row,
3034  const slip::Range<int>& range) const
3035  {
3036  Array2d<T> const * tp(array_);
3037  return tp->row_end(row,range);
3038  }
3039 
3040  template<typename T>
3041  inline
3043  Matrix<T>::col_end(const typename Matrix<T>::size_type col,
3044  const slip::Range<int>& range)
3045  {
3046  return array_->col_end(col,range);
3047  }
3048 
3049  template<typename T>
3050  inline
3052  Matrix<T>::col_end(const typename Matrix<T>::size_type col,
3053  const slip::Range<int>& range) const
3054  {
3055  Array2d<T> const * tp(array_);
3056  return tp->col_end(col,range);
3057  }
3058 
3059  template<typename T>
3060  inline
3062  Matrix<T>::row_rbegin(const typename Matrix<T>::size_type row,
3063  const slip::Range<int>& range)
3064  {
3065  return typename Matrix<T>::reverse_row_range_iterator(this->row_end(row,range));
3066  }
3067 
3068  template<typename T>
3069  inline
3071  Matrix<T>::row_rbegin(const typename Matrix<T>::size_type row,
3072  const slip::Range<int>& range) const
3073  {
3074  return typename Matrix<T>::const_reverse_row_range_iterator(this->row_end(row,range));
3075  }
3076 
3077 
3078  template<typename T>
3079  inline
3081  Matrix<T>::col_rbegin(const typename Matrix<T>::size_type col,
3082  const slip::Range<int>& range)
3083  {
3084  return typename Matrix<T>::reverse_col_range_iterator(this->col_end(col,range));
3085  }
3086 
3087  template<typename T>
3088  inline
3090  Matrix<T>::col_rbegin(const typename Matrix<T>::size_type col,
3091  const slip::Range<int>& range) const
3092  {
3093  return typename Matrix<T>::const_reverse_col_range_iterator(this->col_end(col,range));
3094  }
3095 
3096  template<typename T>
3097  inline
3099  Matrix<T>::row_rend(const typename Matrix<T>::size_type row,
3100  const slip::Range<int>& range)
3101  {
3102  return typename Matrix<T>::reverse_row_range_iterator(this->row_begin(row,range));
3103  }
3104 
3105  template<typename T>
3106  inline
3108  Matrix<T>::row_rend(const typename Matrix<T>::size_type row,
3109  const slip::Range<int>& range) const
3110  {
3111  return typename Matrix<T>::const_reverse_row_range_iterator(this->row_begin(row,range));
3112  }
3113 
3114 
3115  template<typename T>
3116  inline
3118  Matrix<T>::col_rend(const typename Matrix<T>::size_type col,
3119  const slip::Range<int>& range)
3120  {
3121  return typename Matrix<T>::reverse_col_range_iterator(this->col_begin(col,range));
3122  }
3123 
3124  template<typename T>
3125  inline
3127  Matrix<T>::col_rend(const typename Matrix<T>::size_type col,
3128  const slip::Range<int>& range) const
3129  {
3130  return typename Matrix<T>::const_reverse_col_range_iterator(this->col_begin(col,range));
3131  }
3132 
3133  template<typename T>
3134  inline
3136  {
3137  return array_->upper_left();
3138  }
3139 
3140  template<typename T>
3141  inline
3143  {
3144  Array2d<T> const * tp(array_);
3145  return tp->upper_left();
3146  }
3147 
3148 
3149  template<typename T>
3150  inline
3152  {
3153  return array_->bottom_right();
3154  }
3155 
3156  template<typename T>
3157  inline
3159  {
3160  Array2d<T> const * tp(array_);
3161  return tp->bottom_right();
3162  }
3163 
3164  template<typename T>
3165  inline
3167  {
3168  return array_->upper_left(box);
3169  }
3170 
3171 
3172  template<typename T>
3173  inline
3175  {
3176  Array2d<T> const * tp(array_);
3177  return tp->upper_left(box);
3178  }
3179 
3180  template<typename T>
3181  inline
3183  {
3184  return array_->bottom_right(box);
3185  }
3186 
3187  template<typename T>
3188  inline
3190  {
3191  Array2d<T> const * tp(array_);
3192  return tp->bottom_right(box);
3193  }
3194 
3195 
3196  template<typename T>
3197  inline
3198  typename Matrix<T>::iterator2d_range
3200  const Range<int>& col_range)
3201  {
3202  return array_->upper_left(row_range,col_range);
3203  }
3204 
3205  template<typename T>
3206  inline
3209  const Range<int>& col_range) const
3210  {
3211  Array2d<T> const * tp(array_);
3212  return tp->upper_left(row_range,col_range);
3213  }
3214 
3215  template<typename T>
3216  inline
3217  typename Matrix<T>::iterator2d_range
3219  const Range<int>& col_range)
3220  {
3221  return array_->bottom_right(row_range,col_range);
3222  }
3223 
3224  template<typename T>
3225  inline
3228  const Range<int>& col_range) const
3229  {
3230  Array2d<T> const * tp(array_);
3231  return tp->bottom_right(row_range,col_range);
3232  }
3233 
3234  template<typename T>
3235  inline
3236  typename Matrix<T>::iterator2d_range
3238  {
3239  return array_->upper_left(range);
3240  }
3241 
3242  template<typename T>
3243  inline
3245  Matrix<T>::upper_left(const Range<int>& range) const
3246  {
3247  Array2d<T> const * tp(array_);
3248  return tp->upper_left(range);
3249  }
3250 
3251  template<typename T>
3252  inline
3253  typename Matrix<T>::iterator2d_range
3255  {
3256  return array_->bottom_right(range);
3257  }
3258 
3259  template<typename T>
3260  inline
3263  {
3264  Array2d<T> const * tp(array_);
3265  return tp->bottom_right(range);
3266  }
3267 
3268 
3269  template<typename T>
3270  inline
3273  {
3274  return array_->rbottom_right();
3275  }
3276 
3277  template<typename T>
3278  inline
3281  {
3282  Array2d<T> const * tp(array_);
3283  return tp->rbottom_right();
3284  }
3285 
3286  template<typename T>
3287  inline
3290  {
3291  return array_->rupper_left();
3292  }
3293 
3294  template<typename T>
3295  inline
3298  {
3299  Array2d<T> const * tp(array_);
3300  return tp->rupper_left();
3301  }
3302 
3303  template<typename T>
3304  inline
3307  {
3308  return array_->rbottom_right(box);
3309  }
3310 
3311  template<typename T>
3312  inline
3315  {
3316  Array2d<T> const * tp(array_);
3317  return tp->rbottom_right(box);
3318  }
3319 
3320  template<typename T>
3321  inline
3324  {
3325  return array_->rupper_left(box);
3326  }
3327 
3328  template<typename T>
3329  inline
3332  {
3333  Array2d<T> const * tp(array_);
3334  return tp->rupper_left(box);
3335  }
3336 
3337  template<typename T>
3338  inline
3341  const Range<int>& col_range)
3342  {
3343  return array_->rupper_left(row_range,col_range);
3344  }
3345 
3346  template<typename T>
3347  inline
3350  const Range<int>& col_range) const
3351  {
3352  Array2d<T> const * tp(array_);
3353  return tp->rupper_left(row_range,col_range);
3354  }
3355 
3356  template<typename T>
3357  inline
3360  const Range<int>& col_range)
3361  {
3362  return array_->rbottom_right(row_range,col_range);
3363  }
3364 
3365  template<typename T>
3366  inline
3369  const Range<int>& col_range) const
3370  {
3371  Array2d<T> const * tp(array_);
3372  return tp->rbottom_right(row_range,col_range);
3373  }
3374 
3375  template<typename T>
3376  inline
3379  {
3380  return this->rupper_left(range,range);
3381  }
3382 
3383  template<typename T>
3384  inline
3387  {
3388  return this->rupper_left(range,range);
3389  }
3390 
3391  template<typename T>
3392  inline
3395  {
3396  return this->rbottom_right(range,range);
3397  }
3398 
3399  template<typename T>
3400  inline
3403  {
3404  return this->rbottom_right(range,range);
3405  }
3406 
3407  template <typename T>
3408  inline
3409  std::ostream& operator<<(std::ostream & out, const Matrix<T>& a)
3410  {
3411  out<<*(a.array_);
3412  return out;
3413  }
3414 
3415 
3416 
3417  template<typename T>
3418  inline
3419  typename Matrix<T>::pointer
3421  {
3422  return (*array_)[i];
3423  }
3424 
3425  template<typename T>
3426  inline
3427  typename Matrix<T>::const_pointer
3428  Matrix<T>::operator[](const typename Matrix<T>::size_type i) const
3429  {
3430  return (*array_)[i];
3431  }
3432 
3433  template<typename T>
3434  inline
3435  typename Matrix<T>::reference
3437  const typename Matrix<T>::size_type j)
3438  {
3439  return (*array_)[i][j];
3440  }
3441 
3442  template<typename T>
3443  inline
3444  typename Matrix<T>::const_reference
3446  const typename Matrix<T>::size_type j) const
3447  {
3448  return (*array_)[i][j];
3449  }
3450 
3451  template<typename T>
3452  inline
3453  typename Matrix<T>::reference
3454  Matrix<T>::operator()(const Point2d<typename Matrix<T>::size_type>& point2d)
3455  {
3456  return (*array_)(point2d);
3457  }
3458 
3459  template<typename T>
3460  inline
3461  typename Matrix<T>::const_reference
3462  Matrix<T>::operator()(const Point2d<typename Matrix<T>::size_type>& point2d) const
3463  {
3464  return (*array_)(point2d);
3465  }
3466 
3467 
3468  template<typename T>
3469  inline
3470  Matrix<T>
3472  const Range<int>& col_range)
3473  {
3474  assert((*this)[0] != 0);
3475  assert(row_range.is_valid());
3476  assert(row_range.start() < int(this->dim2()));
3477  assert(row_range.stop() < int(this->dim2()));
3478  assert(col_range.is_valid());
3479  assert(col_range.start() < int(this->dim1()));
3480  assert(col_range.stop() < int(this->dim1()));
3481  std::size_t rows = row_range.iterations();
3482  std::size_t cols = col_range.iterations();
3483  return Matrix<T>(rows+1,cols+1,array_->upper_left(row_range,col_range),
3484  array_->bottom_right(row_range,col_range));
3485  }
3486 
3487  template<typename T>
3488  inline
3489  std::string
3490  Matrix<T>::name() const {return "Matrix";}
3491 
3492 
3493  template<typename T>
3494  inline
3495  typename Matrix<T>::size_type Matrix<T>::dim1() const {return array_->dim1();}
3496 
3497  template<typename T>
3498  inline
3499  typename Matrix<T>::size_type Matrix<T>::rows() const {return this->dim1();}
3500 
3501 
3502  template<typename T>
3503  inline
3504  typename Matrix<T>::size_type Matrix<T>::dim2() const {return array_->dim2();}
3505 
3506  template<typename T>
3507  inline
3508  typename Matrix<T>::size_type Matrix<T>::columns() const {return this->dim2();}
3509 
3510  template<typename T>
3511  inline
3512  typename Matrix<T>::size_type Matrix<T>::cols() const {return this->dim2();}
3513 
3514  template<typename T>
3515  inline
3516  typename Matrix<T>::size_type Matrix<T>::size() const {return array_->size();}
3517 
3518  template<typename T>
3519  inline
3520  typename Matrix<T>::size_type Matrix<T>::max_size() const {return array_->max_size();}
3521 
3522 
3523  template<typename T>
3524  inline
3525  bool Matrix<T>::empty()const {return array_->empty();}
3526 
3527  template<typename T>
3528  inline
3530  {
3531  array_->swap(*(M.array_));
3532  }
3533 
3534 
3535  template<typename T>
3536  inline
3538  {
3539  std::transform(array_->begin(),array_->end(),array_->begin(),std::bind2nd(std::plus<T>(),val));
3540  return *this;
3541  }
3542 
3543  template<typename T>
3544  inline
3546  {
3547  std::transform(array_->begin(),array_->end(),array_->begin(),std::bind2nd(std::minus<T>(),val));
3548  return *this;
3549  }
3550 
3551  template<typename T>
3552  inline
3554  {
3555  std::transform(array_->begin(),array_->end(),array_->begin(),std::bind2nd(std::multiplies<T>(),val));
3556  return *this;
3557  }
3558 
3559  template<typename T>
3560  inline
3562  {
3563  std::transform(array_->begin(),array_->end(),array_->begin(),std::bind2nd(std::divides<T>(),val));
3564  return *this;
3565  }
3566 
3567  template<typename T>
3568  inline
3570  {
3571  Matrix<T> tmp(*this);
3572  std::transform(array_->begin(),array_->end(),tmp.begin(),std::negate<T>());
3573  return tmp;
3574  }
3575 
3576  template<typename T>
3577  inline
3579  {
3580  assert(this->dim1() == rhs.dim1());
3581  assert(this->dim2() == rhs.dim2());
3582  std::transform(array_->begin(),array_->end(),(*(rhs.array_)).begin(),array_->begin(),std::plus<T>());
3583  return *this;
3584  }
3585 
3586  template<typename T>
3587  inline
3589  {
3590  assert(this->dim1() == rhs.dim1());
3591  assert(this->dim2() == rhs.dim2());
3592  std::transform(array_->begin(),array_->end(),(*(rhs.array_)).begin(),array_->begin(),std::minus<T>());
3593  return *this;
3594  }
3595 
3596  template<typename T>
3597  inline
3599  {
3600  assert(this->dim1() == rhs.dim1());
3601  assert(this->dim2() == rhs.dim2());
3602  std::transform(array_->begin(),array_->end(),(*(rhs.array_)).begin(),array_->begin(),std::multiplies<T>());
3603  return *this;
3604  }
3605 
3606  template<typename T>
3607  inline
3609  {
3610  assert(this->size() == rhs.size());
3611  std::transform(array_->begin(),array_->end(),(*(rhs.array_)).begin(),array_->begin(),std::divides<T>());
3612  return *this;
3613  }
3614 
3615 
3616 
3617  template<typename T>
3618  inline
3619  T& Matrix<T>::min() const
3620  {
3621  assert(array_->size() != 0);
3622  return *std::min_element(array_->begin(),array_->end(),std::less<T>());
3623  }
3624 
3625  template<typename T>
3626  inline
3627  T& Matrix<T>::max() const
3628  {
3629  assert(array_->size() != 0);
3630  return *std::max_element(array_->begin(),array_->end(),std::less<T>());
3631  }
3632 
3633  template<typename T>
3634  inline
3635  T Matrix<T>::sum() const
3636  {
3637  assert(array_->size() != 0);
3638  return std::accumulate(array_->begin(),array_->end(),T());
3639  }
3640 
3641  template<typename T>
3642  inline
3644  {
3645  assert(array_->size() != 0);
3646  assert(this->rows() == this->cols());
3647  T sum = (*this)[0][0];
3648  for(std::size_t i = 1; i < this->rows(); ++i)
3649  {
3650  sum += (*this)[i][i];
3651  }
3652  return sum;
3653  }
3654 
3655  template<typename T>
3656  inline
3657  T Matrix<T>::det() const
3658  {
3659  assert(array_->size() != 0);
3660  assert(this->rows() == this->cols());
3661  return T(slip::lu_det(*this));
3662  }
3663 
3664  template<typename T>
3665  inline
3667  {
3668  typename Matrix<T>::size_type r = typename Matrix<T>::size_type(0);
3669  //computes the SVD
3670  slip::Array2d<T> U(this->rows(),this->cols());
3671  slip::Array2d<T> V(this->cols(),this->cols());
3672  slip::Array<T> W(this->cols());
3673  slip::svd(*this,U,W.begin(),W.end(),V);
3674  norm_type max = std::abs(W[0]);
3675  norm_type tol = norm_type(std::max(this->rows(),this->cols())) * max * slip::epsilon<T>();
3676  for(std::size_t i = 0; i < W.size(); ++i)
3677  {
3678  norm_type tmp = std::abs(W[i]);
3679  if(tmp > tol)
3680  {
3681  r = (i + 1);
3682  }
3683  else
3684  {
3685  break;
3686  }
3687  }
3688  return r;
3689  }
3690 
3691  template<typename T>
3692  inline
3694  {
3695  assert(array_->size() != 0);
3696  assert(this->rows() == this->cols());
3697  slip::Array2d<T> U(this->rows(),this->cols());
3698  slip::Array2d<T> V(this->cols(),this->cols());
3699  slip::Array<T> W(this->cols());
3700  slip::svd(*this,U,W.begin(),W.end(),V);
3701  norm_type max = std::abs(W[0]);
3702  norm_type min = std::abs(W[0]);
3703  //norm_type cond = norm_type();
3704  norm_type tol = norm_type(std::max(this->rows(),this->cols())) * max * slip::epsilon<T>();
3705 
3706  for(std::size_t i = 1; i < W.size(); ++i)
3707  {
3708  norm_type tmp = std::abs(W[i]);
3709  if(tmp > tol)
3710  {
3711  min = tmp;
3712  }
3713  else
3714  {
3715  break;
3716  }
3717  }
3718 
3719  return max/min;
3720 
3721  }
3722 
3723  template<typename T>
3724  inline
3726  {
3727  assert(array_->size() != 0);
3728  assert(this->rows() == this->cols());
3729  slip::Matrix<T> tmp(this->rows(),this->cols());
3730  slip::lu_inv(*this,tmp);
3731  return tmp;
3732  }
3733 
3734  template<typename T>
3735  inline
3737  {
3738  slip::apply(this->begin(),this->end(),this->begin(),fun);
3739  return *this;
3740  }
3741 
3742  template<typename T>
3743  inline
3744  Matrix<T>& Matrix<T>::apply(T (*fun)(const T&))
3745  {
3746  slip::apply(this->begin(),this->end(),this->begin(),fun);
3747  return *this;
3748  }
3749 
3750 
3751 
3752  template<typename T>
3753  inline
3755  const Matrix<T>& M2)
3756  {
3757  assert(M1.dim1() == M2.dim1());
3758  assert(M1.dim2() == M2.dim2());
3759  Matrix<T> tmp(M1.dim1(),M1.dim2());
3760  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::plus<T>());
3761  return tmp;
3762  }
3763 
3764  template<typename T>
3765  inline
3767  const T& val)
3768  {
3769  Matrix<T> tmp(M1);
3770  tmp+=val;
3771  return tmp;
3772  }
3773 
3774  template<typename T>
3775  inline
3776  Matrix<T> operator+(const T& val,
3777  const Matrix<T>& M1)
3778  {
3779  return M1 + val;
3780  }
3781 
3782 
3783 template<typename T>
3784 inline
3786  const Matrix<T>& M2)
3787 {
3788  assert(M1.dim1() == M2.dim1());
3789  assert(M1.dim2() == M2.dim2());
3790  Matrix<T> tmp(M1.dim1(),M1.dim2());
3791  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::minus<T>());
3792  return tmp;
3793 }
3794 
3795 template<typename T>
3796 inline
3798  const T& val)
3799 {
3800  Matrix<T> tmp(M1);
3801  tmp-=val;
3802  return tmp;
3803 }
3804 
3805 template<typename T>
3806 inline
3807 Matrix<T> operator-(const T& val,
3808  const Matrix<T>& M1)
3809 {
3810  return -(M1 - val);
3811 }
3812 
3813 template<typename T>
3814 inline
3816  const Matrix<T>& M2)
3817 {
3818  assert(M1.dim1() == M2.dim1());
3819  assert(M1.dim2() == M2.dim2());
3820  Matrix<T> tmp(M1.dim1(),M1.dim2());
3821  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::multiplies<T>());
3822  return tmp;
3823 }
3824 
3825 template<typename T>
3826 inline
3828  const T& val)
3829 {
3830  Matrix<T> tmp(M1.dim1(),M1.dim2(),
3831  M1.begin(),M1.end());
3832  tmp*=val;
3833  return tmp;
3834 }
3835 
3836 template<typename T>
3837 inline
3838 Matrix<T> operator*(const T& val,
3839  const Matrix<T>& M1)
3840 {
3841  return M1 * val;
3842 }
3843 
3844 template<typename T>
3845 inline
3847  const Matrix<T>& M2)
3848 {
3849  assert(M1.dim1() == M2.dim1());
3850  assert(M1.dim2() == M2.dim2());
3851  Matrix<T> tmp(M1.dim1(),M1.dim2());
3852  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::divides<T>());
3853  return tmp;
3854 }
3855 
3856 template<typename T>
3857 inline
3859  const T& val)
3860 {
3861  Matrix<T> tmp(M1.dim1(),M1.dim2(),
3862  M1.begin(),M1.end());
3863  tmp/=val;
3864  return tmp;
3865 }
3866 
3867 // template<typename T>
3868 // inline
3869 // Matrix<T> operator/(const T& val,
3870 // const Matrix<T>& M1)
3871 // {
3872 // return M1 / val;
3873 // }
3874 
3875 
3876  template<typename T>
3877  inline
3878  T& min(const Matrix<T>& M1)
3879  {
3880  return M1.min();
3881  }
3882 
3883 template<typename T>
3884 inline
3885 T& max(const Matrix<T>& M1)
3886 {
3887  return M1.max();
3888 }
3889 
3890 template<typename T>
3891 inline
3893 {
3894 
3896  slip::apply(M.begin(),M.end(),tmp.begin(),std::abs);
3897  return tmp;
3898 }
3899 
3900 template<typename T>
3901 inline
3903 {
3904  Matrix<T> tmp(M.dim1(),M.dim2());
3905  slip::apply(M.begin(),M.end(),tmp.begin(),std::sqrt);
3906  return tmp;
3907 }
3908 
3909 template<typename T>
3910 inline
3912 {
3913  Matrix<T> tmp(M.dim1(),M.dim2());
3914  slip::apply(M.begin(),M.end(),tmp.begin(),std::cos);
3915  return tmp;
3916 }
3917 
3918 
3919 inline
3921 {
3922  Matrix<float> tmp(M.dim1(),M.dim2());
3923  slip::apply(M.begin(),M.end(),tmp.begin(),std::acos);
3924  return tmp;
3925 }
3926 
3927 inline
3929 {
3930  Matrix<double> tmp(M.dim1(),M.dim2());
3931  slip::apply(M.begin(),M.end(),tmp.begin(),std::acos);
3932  return tmp;
3933 }
3934 
3935 inline
3937 {
3938  Matrix<long double> tmp(M.dim1(),M.dim2());
3939  slip::apply(M.begin(),M.end(),tmp.begin(),std::acos);
3940  return tmp;
3941 }
3942 
3943 template<typename T>
3944 inline
3946 {
3947  Matrix<T> tmp(M.dim1(),M.dim2());
3948  slip::apply(M.begin(),M.end(),tmp.begin(),std::sin);
3949  return tmp;
3950 }
3951 
3952 
3953 inline
3955 {
3956  Matrix<float> tmp(M.dim1(),M.dim2());
3957  slip::apply(M.begin(),M.end(),tmp.begin(),std::asin);
3958  return tmp;
3959 }
3960 
3961 inline
3963 {
3964  Matrix<double> tmp(M.dim1(),M.dim2());
3965  slip::apply(M.begin(),M.end(),tmp.begin(),std::asin);
3966  return tmp;
3967 }
3968 
3969 inline
3971 {
3972  Matrix<long double> tmp(M.dim1(),M.dim2());
3973  slip::apply(M.begin(),M.end(),tmp.begin(),std::asin);
3974  return tmp;
3975 }
3976 
3977 template<typename T>
3978 inline
3980 {
3981  Matrix<T> tmp(M.dim1(),M.dim2());
3982  slip::apply(M.begin(),M.end(),tmp.begin(),std::tan);
3983  return tmp;
3984 }
3985 
3986 
3987 inline
3989 {
3990  Matrix<float> tmp(M.dim1(),M.dim2());
3991  slip::apply(M.begin(),M.end(),tmp.begin(),std::atan);
3992  return tmp;
3993 }
3994 
3995 inline
3997 {
3998  Matrix<double> tmp(M.dim1(),M.dim2());
3999  slip::apply(M.begin(),M.end(),tmp.begin(),std::atan);
4000  return tmp;
4001 }
4002 
4003 inline
4005 {
4006  Matrix<long double> tmp(M.dim1(),M.dim2());
4007  slip::apply(M.begin(),M.end(),tmp.begin(),std::atan);
4008  return tmp;
4009 }
4010 
4011 template<typename T>
4012 inline
4014 {
4015  Matrix<T> tmp(M.dim1(),M.dim2());
4016  slip::apply(M.begin(),M.end(),tmp.begin(),std::exp);
4017  return tmp;
4018 }
4019 
4020 template<typename T>
4021 inline
4023 {
4024  Matrix<T> tmp(M.dim1(),M.dim2());
4025  slip::apply(M.begin(),M.end(),tmp.begin(),std::log);
4026  return tmp;
4027 }
4028 
4029 template<typename T>
4030 inline
4032 {
4033  Matrix<T> tmp(M.dim1(),M.dim2());
4034  slip::apply(M.begin(),M.end(),tmp.begin(),std::cosh);
4035  return tmp;
4036 }
4037 
4038 template<typename T>
4039 inline
4041 {
4042  Matrix<T> tmp(M.dim1(),M.dim2());
4043  slip::apply(M.begin(),M.end(),tmp.begin(),std::sinh);
4044  return tmp;
4045 }
4046 
4047 template<typename T>
4048 inline
4050 {
4051  Matrix<T> tmp(M.dim1(),M.dim2());
4052  slip::apply(M.begin(),M.end(),tmp.begin(),std::tanh);
4053  return tmp;
4054 }
4055 
4056 template<typename T>
4057 inline
4059 {
4060  Matrix<T> tmp(M.dim1(),M.dim2());
4061  slip::apply(M.begin(),M.end(),tmp.begin(),std::log10);
4062  return tmp;
4063 }
4065  /* @{ */
4066 template<typename T>
4067 inline
4068 bool operator==(const Matrix<T>& x,
4069  const Matrix<T>& y)
4070 {
4071  return ( x.size() == y.size()
4072  && std::equal(x.begin(),x.end(),y.begin()));
4073 }
4074 
4075 template<typename T>
4076 inline
4077 bool operator!=(const Matrix<T>& x,
4078  const Matrix<T>& y)
4079 {
4080  return !(x == y);
4081 }
4082 
4083 /* @} */
4084 
4086  /* @{ */
4087 template<typename T>
4088 inline
4089 bool operator<(const Matrix<T>& x,
4090  const Matrix<T>& y)
4091 {
4092  return std::lexicographical_compare(x.begin(), x.end(),
4093  y.begin(), y.end());
4094 }
4095 
4096 template<typename T>
4097 inline
4098 bool operator>(const Matrix<T>& x,
4099  const Matrix<T>& y)
4100 {
4101  return (y < x);
4102 }
4103 
4104 template<typename T>
4105 inline
4106 bool operator<=(const Matrix<T>& x,
4107  const Matrix<T>& y)
4108 {
4109  return !(y < x);
4110 }
4111 
4112 template<typename T>
4113 inline
4114 bool operator>=(const Matrix<T>& x,
4115  const Matrix<T>& y)
4116 {
4117  return !(x < y);
4118 }
4119 /* @} */
4120 }//slip::
4121 
4122 #endif //SLIP_MATRIX_HPP
Provides a class to manipulate 2d dynamic and generic arrays.
pointer row_iterator
Definition: Matrix.hpp:212
HyperVolume< T > tanh(const HyperVolume< T > &M)
bool operator!=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1448
Matrix()
Constructs a Matrix.
Definition: Matrix.hpp:2718
std::size_t iterations() const
Rerturns the number of iterations of the range.
Definition: Range.hpp:305
slip::Matrix< int > Matrix_i
int alias
Definition: Matrix.hpp:2389
T & max(const GrayscaleImage< T > &M1)
Returns the max element of a GrayscaleImage.
self & operator/=(const T &val)
Definition: Matrix.hpp:3561
iterator2d upper_left()
Returns a read/write iterator2d that points to the first element of the Array2d. It points to the upp...
Definition: Array2d.hpp:2744
bool operator==(const slip::Matrix< T > &x, const slip::Matrix< T > &y)
Definition: Matrix.hpp:4068
Matrix(const size_type d1, const size_type d2, InputIterator first, InputIterator last)
Contructs a Matrix from a range.
Definition: Matrix.hpp:299
Matrix< T > sinh(const Matrix< T > &M)
Definition: Matrix.hpp:4040
Provides a class to modelize the difference of slip::Point2d.
Matrix< T > sqrt(const Matrix< T > &M)
Definition: Matrix.hpp:3902
slip::stride_iterator< const_col_iterator > const_col_range_iterator
Definition: Matrix.hpp:223
slip::Array2d< T >::const_iterator2d_range const_iterator2d_range
Definition: Matrix.hpp:225
iterator2d upper_left()
Returns a read/write iterator2d that points to the first element of the Matrix. It points to the uppe...
Definition: Matrix.hpp:3135
void fill(const T *value)
Fills the container range [begin(),begin()+size()) with a copy of the value array.
Definition: Matrix.hpp:1926
std::reverse_iterator< iterator2d > reverse_iterator2d
Definition: Matrix.hpp:232
~Matrix()
Destructor of the Matrix.
Definition: Matrix.hpp:2753
Matrix< T > tan(const Matrix< T > &M)
Definition: Matrix.hpp:3979
std::reverse_iterator< const_iterator > const_reverse_row_iterator
Definition: Matrix.hpp:229
reverse_row_iterator row_rbegin(const size_type row)
Returns a read/write reverse iterator that points to the last element of the row row in the Matrix...
reference operator()(const size_type i, const size_type j)
Subscript access to the data contained in the Matrix.
HyperVolume< T > abs(const HyperVolume< T > &V)
Returns the abs value of each element of the HyperVolume.
slip::Matrix< float > Matrix_f
float alias
Definition: Matrix.hpp:2379
value_type & reference
Definition: Matrix.hpp:200
size_type max_size() const
Returns the maximal size (number of elements) in the Matrix.
Definition: Matrix.hpp:3520
size_type dim1() const
Returns the number of rows (first dimension size) in the Matrix.
Definition: Matrix.hpp:3495
void lu_inv(const Matrix1 &M, Matrix2 &IM)
Computes the inverse of a matrix using LU decomposition.
std::size_t size_type
Definition: Matrix.hpp:204
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Matrix. Iteration is done in reverse element order.
Definition: Matrix.hpp:2820
slip::Matrix< double > Matrix_d
double alias
Definition: Matrix.hpp:2377
Matrix< long double > atan(const Matrix< long double > &M)
Definition: Matrix.hpp:4004
void fill(InputIterator first, InputIterator last)
Fills the container range [begin(),begin()+size()) with a copy of the range [first,last)
Definition: Matrix.hpp:1940
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
Definition: Array2d.hpp:119
T & max(const Matrix< T > &M1)
Definition: Matrix.hpp:3885
HyperVolume< T > cosh(const HyperVolume< T > &M)
iterator2d bottom_right()
Returns a read/write iterator2d that points to the past the end element of the Matrix. It points to past the end element of the bottom right element of the Matrix.
Definition: Matrix.hpp:3151
slip::stride_iterator< pointer > col_iterator
Definition: Matrix.hpp:214
value_type const & const_reference
Definition: Matrix.hpp:201
slip::lin_alg_traits< typename Matrix1::value_type >::value_type spectral_radius(const Matrix1 &A)
Spectral radius of a matrix .
slip::stride_iterator< const_pointer > const_row_range_iterator
Definition: Matrix.hpp:221
std::reverse_iterator< const_row_range_iterator > const_reverse_row_range_iterator
Definition: Matrix.hpp:235
T & min(const GrayscaleImage< T > &M1)
Returns the min element of a GrayscaleImage.
pointer operator[](const size_type i)
Subscript access to the row datas contained in the Matrix.
Color< T > operator+(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:602
norm_type frobenius_norm() const
Returns the Frobenius norm of the Matrix .
Definition: Matrix.hpp:2307
size_type rank() const
Returns the rank of the Matrix.
Definition: Matrix.hpp:3666
iterator begin()
Returns a read/write iterator that points to the first element in the Matrix. Iteration is done in or...
Definition: Matrix.hpp:2789
Provides a class to manipulate iterator2d within a slip::Box2d. It is used to iterate throw 2d contai...
iterator begin()
Returns a read/write iterator that points to the first element in the Array. Iteration is done in ord...
Definition: Array.hpp:1077
reverse_iterator2d rupper_left()
Returns a read/write reverse iterator2d. It points to the bottom right element of the Array2d...
Definition: Array2d.hpp:2900
iterator2d bottom_right()
Returns a read/write iterator2d that points to the past the end element of the Array2d. It points to past the end element of the bottom right element of the Array2d.
Definition: Array2d.hpp:2759
std::reverse_iterator< iterator > reverse_iterator
Definition: Matrix.hpp:209
size_type cols() const
Returns the number of columns (second dimension size) in the Matrix.
Definition: Matrix.hpp:3512
slip::Matrix< long > Matrix_l
long alias
Definition: Matrix.hpp:2381
HyperVolume< T > atan(const HyperVolume< T > &M)
HyperVolume< T > sin(const HyperVolume< T > &V)
Returns the sin value of each element of the HyperVolume.
size_type size() const
Returns the number of elements in the Matrix.
Definition: Matrix.hpp:3516
self inv() const
Returns the inverse of the Matrix.
Definition: Matrix.hpp:3725
size_type columns() const
Returns the number of columns (second dimension size) in the Matrix.
Definition: Matrix.hpp:3508
HyperVolume< T > exp(const HyperVolume< T > &M)
HyperVolume< T > sinh(const HyperVolume< T > &V)
Returns the sinh value of each element of the HyperVolume.
reverse_iterator2d rbottom_right()
Returns a read/write reverse iterator2d. It points to past the upper left element of the Array2d...
Definition: Array2d.hpp:2884
self & operator-=(const T &val)
Definition: Matrix.hpp:3545
Provides common linear algebra algorithms.
slip::Matrix< unsigned long > Matrix_ul
unsigned long alias
Definition: Matrix.hpp:2383
slip::stride_iterator< const_pointer > const_col_iterator
Definition: Matrix.hpp:215
col_iterator col_end(const size_type col)
Returns a read/write iterator that points one past the end element of the column column in the Matrix...
reverse_col_iterator col_rbegin(const size_type col)
Returns a read/write reverse iterator that points to the last element of the column column in the Mat...
HyperVolume< T > abs(const HyperVolume< T > &M)
bool operator>(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1469
T trace() const
Returns the trace of the elements of the Matrix.
Definition: Matrix.hpp:3643
self & operator*=(const T &val)
Definition: Matrix.hpp:3553
T det() const
Returns the determinant of the Matrix.
Definition: Matrix.hpp:3657
HyperVolume< T > sin(const HyperVolume< T > &M)
std::reverse_iterator< col_range_iterator > reverse_col_range_iterator
Definition: Matrix.hpp:236
std::reverse_iterator< const_col_iterator > const_reverse_col_iterator
Definition: Matrix.hpp:231
void swap(self &M)
Swaps data with another Matrix.
Definition: Matrix.hpp:3529
HyperVolume< T > tan(const HyperVolume< T > &V)
Returns the tan value of each element of the HyperVolume.
std::reverse_iterator< row_range_iterator > reverse_row_range_iterator
Definition: Matrix.hpp:234
slip::stride_iterator< col_iterator > col_range_iterator
Definition: Matrix.hpp:222
HyperVolume< T > cos(const HyperVolume< T > &M)
slip::Matrix< short > Matrix_s
short alias
Definition: Matrix.hpp:2385
This is a point2d class, a specialized version of Point<CoordType,DIM> with DIM = 2...
Definition: Array2d.hpp:132
value_type const * const_pointer
Definition: Matrix.hpp:199
slip::Matrix< unsigned int > Matrix_ui
unsigned int alias
Definition: Matrix.hpp:2391
iterator2d default_iterator
Definition: Matrix.hpp:245
bool empty() const
Returns true if the Matrix is empty. (Thus size() == 0)
Definition: Matrix.hpp:3525
Matrix & operator=(const self &rhs)
Assign a Matrix.
Definition: Matrix.hpp:2760
bool operator>=(const slip::Matrix< T > &x, const slip::Matrix< T > &y)
Definition: Matrix.hpp:4114
HyperVolume< T > log10(const HyperVolume< T > &V)
Returns the log10 value of each element of the HyperVolume.
bool operator!=(const slip::Matrix< T > &x, const slip::Matrix< T > &y)
Definition: Matrix.hpp:4077
self & operator+=(const T &val)
Add val to each element of the Matrix.
Definition: Matrix.hpp:3537
std::reverse_iterator< iterator2d_range > reverse_iterator2d_range
Definition: Matrix.hpp:238
slip::lin_alg_traits< value_type >::value_type norm_type
Definition: Matrix.hpp:241
reverse_row_iterator row_rend(const size_type row)
Returns a read/write reverse iterator that points one past the first element of the row row in the Ma...
This is some iterator to iterate a 2d container into a Box area defined by the indices of the 2d cont...
Definition: Array2d.hpp:122
slip::stride_iterator< pointer > row_range_iterator
Definition: Matrix.hpp:220
MultivariatePolynomial< T, DIM > operator*(const MultivariatePolynomial< T, DIM > &P1, const MultivariatePolynomial< T, DIM > &P2)
pointwise multiplication of two MultivariatePolynomial
std::reverse_iterator< iterator > reverse_row_iterator
Definition: Matrix.hpp:228
norm_type L1_norm() const
Returns the L1 norm ( ) of the elements of the Matrix.
Definition: Matrix.hpp:2274
HyperVolume< T > asin(const HyperVolume< T > &V)
Returns the sin value of each element of the HyperVolume.
Matrix< T > cos(const Matrix< T > &M)
Definition: Matrix.hpp:3911
iterator end()
Returns a read/write iterator that points one past the last element in the Array. Iteration is done i...
Definition: Array.hpp:1084
slip::lin_alg_traits< typename std::iterator_traits< RandomAccessIterator2d >::value_type >::value_type row_norm(RandomAccessIterator2d upper_left, RandomAccessIterator2d bottom_right)
Computes the row norm ( ) of a 2d range.
const_pointer const_iterator
Definition: Matrix.hpp:207
Matrix< T > operator-(const T &val, const Matrix< T > &M1)
substraction of a scalar to each element of a Matrix
Definition: Matrix.hpp:3807
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Matrix...
Definition: Matrix.hpp:2827
const Matrix< T > const_self
Definition: Matrix.hpp:196
slip::Array2d< T >::iterator2d_range iterator2d_range
Definition: Matrix.hpp:224
Provides some algorithms to computes eigenvalues and eigenvectors.
ptrdiff_t difference_type
Definition: Matrix.hpp:203
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
Definition: copy_ext.hpp:177
Provides some macros which are used for using complex as real.
norm_type cond() const
Returns the condition number of the Matrix where k is the rank of the matrix.
Definition: Matrix.hpp:3693
bool is_valid() const
Returns true if the range is valid :
Definition: Range.hpp:322
slip::Matrix< unsigned char > Matrix_uc
unsigned char alias
Definition: Matrix.hpp:2395
SubType start() const
Accessor of the start subscript of the Range.
Definition: Range.hpp:284
MultivariatePolynomial< T, DIM > operator-(const MultivariatePolynomial< T, DIM > &P1, const MultivariatePolynomial< T, DIM > &P2)
pointwise substraction of two MultivariatePolynomial
slip::lin_alg_traits< typename std::iterator_traits< RandomAccessIterator2d >::value_type >::value_type frobenius_norm(RandomAccessIterator2d upper_left, RandomAccessIterator2d bottom_right)
Computes the Frobenius norm ( ) of a 2d range.
T & min(const Matrix< T > &M1)
Definition: Matrix.hpp:3878
T & min(const GrayscaleImage< T > &M1)
Returns the min element of a GrayscaleImage.
iterator end()
Returns a read/write iterator that points one past the last element in the Array2d. Iteration is done in ordinary element order.
Definition: Array2d.hpp:2352
HyperVolume< T > sqrt(const HyperVolume< T > &M)
std::reverse_iterator< col_iterator > reverse_col_iterator
Definition: Matrix.hpp:230
HyperVolume< T > cos(const HyperVolume< T > &V)
Returns the cos value of each element of the HyperVolume.
HyperVolume< T > sinh(const HyperVolume< T > &M)
static const std::size_t DIM
Definition: Matrix.hpp:248
T sum() const
Returns the sum of the elements of the Matrix.
Definition: Matrix.hpp:3635
slip::Array2d< T >::const_iterator2d const_iterator2d
Definition: Matrix.hpp:219
MultivariatePolynomial< T, DIM > operator/(const MultivariatePolynomial< T, DIM > &P, const T &val)
division of a scalar to each element of a MultivariatePolynomial
This is some iterator to iterate a 2d container into a slip::Box2d area defined by the indices of the...
Definition: Array2d.hpp:116
row_iterator row_end(const size_type row)
Returns a read/write iterator that points one past the end element of the row row in the Matrix...
value_type * pointer
Definition: Matrix.hpp:198
std::reverse_iterator< const_col_range_iterator > const_reverse_col_range_iterator
Definition: Matrix.hpp:237
Matrix< T > sin(const Matrix< T > &M)
Definition: Matrix.hpp:3945
reverse_iterator2d rupper_left()
Returns a read/write reverse iterator2d. It points to the bottom right element of the Matrix...
Definition: Matrix.hpp:3289
std::string name() const
Returns the name of the class.
Definition: Matrix.hpp:3490
T & min() const
Returns the min element of the Matrix according to the operator <, if the T is complex, it returns the element with the minimal magnitude.
Definition: Matrix.hpp:3619
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: Matrix.hpp:210
HyperVolume< T > tanh(const HyperVolume< T > &V)
Returns the tanh value of each element of the HyperVolume.
HyperVolume< T > atan(const HyperVolume< T > &V)
Returns the atan value of each element of the HyperVolume.
Matrix1::value_type lu_det(const Matrix1 &M)
Computes the determinant of a matrix using LU decomposition.
slip::Matrix< char > Matrix_c
char alias
Definition: Matrix.hpp:2393
size_type rows() const
Returns the number of rows (first dimension size) in the Matrix.
Definition: Matrix.hpp:3499
col_iterator col_begin(const size_type col)
Returns a read/write iterator that points to the first element of the column column in the Matrix...
HyperVolume< T > log(const HyperVolume< T > &M)
HyperVolume< T > acos(const HyperVolume< T > &V)
Returns the acos value of each element of the HyperVolume.
Matrix< T > & apply(T(*fun)(T))
Applys the one-parameter C-function fun to each element of the Matrix.
Definition: Matrix.hpp:3736
self operator-() const
Definition: Matrix.hpp:3569
void svd(const Matrix1 &M, Matrix2 &U, RandomAccessIterator S_first, RandomAccessIterator S_last, Matrix3 &V, const int max_it=75)
(thin) Singular Value Decomposition Given a matrix M, this function computes its singular value decom...
norm_type infinite_norm() const
Returns the infinite norm ( ) of the elements of the Matrix.
Definition: Matrix.hpp:2298
HyperVolume< T > cosh(const HyperVolume< T > &V)
Returns the cosh value of each element of the HyperVolume.
slip::Array2d< T >::iterator2d iterator2d
Definition: Matrix.hpp:218
pointer iterator
Definition: Matrix.hpp:206
void fill(const T &value)
Fills the container range [begin(),begin()+size()) with copies of value.
Definition: Matrix.hpp:1915
Matrix< T > log(const Matrix< T > &M)
Definition: Matrix.hpp:4022
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
Definition: Array2d.hpp:125
void resize(const size_type d1, const size_type d2, const T &val=T())
Resizes a Matrix.
Definition: Matrix.hpp:2779
HyperVolume< T > acos(const HyperVolume< T > &M)
norm_type spectral_radius() const
Returns the spectral radius of the Matrix ( )
Definition: Matrix.hpp:2317
Matrix< long double > asin(const Matrix< long double > &M)
Definition: Matrix.hpp:3970
std::reverse_iterator< const_iterator2d > const_reverse_iterator2d
Definition: Matrix.hpp:233
Matrix< T > cosh(const Matrix< T > &M)
Definition: Matrix.hpp:4031
HyperVolume< T > log10(const HyperVolume< T > &M)
iterator end()
Returns a read/write iterator that points one past the last element in the Matrix. Iteration is done in ordinary element order.
Definition: Matrix.hpp:2796
HyperVolume< T > sqrt(const HyperVolume< T > &V)
Returns the sqrt value of each element of the HyperVolume.
size_type size() const
Returns the number of elements in the Array.
Definition: Array.hpp:1381
Provides some algorithms to apply C like functions to ranges.
Provides a class to modelize 2d points.
reverse_col_iterator col_rend(const size_type col)
Returns a read/write reverse iterator that points one past the first element of the column column in ...
Matrix< T > tanh(const Matrix< T > &M)
Definition: Matrix.hpp:4049
Provides a class to iterate a 1d range according to a step.
slip::lin_alg_traits< typename std::iterator_traits< RandomAccessIterator2d >::value_type >::value_type col_norm(RandomAccessIterator2d upper_left, RandomAccessIterator2d bottom_right)
Computes the column norm ( ) of a 2d range.
iterator begin()
Returns a read/write iterator that points to the first element in the Array2d. Iteration is done in o...
Definition: Array2d.hpp:2345
size_type dim2() const
Returns the number of columns (second dimension size) in the Matrix.
Definition: Matrix.hpp:3504
HyperVolume< T > tan(const HyperVolume< T > &M)
bool operator>(const slip::Matrix< T > &x, const slip::Matrix< T > &y)
Definition: Matrix.hpp:4098
bool operator==(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1439
HyperVolume< T > asin(const HyperVolume< T > &M)
This is a linear (one-dimensional) dynamic template container. This container statisfies the RandomAc...
Definition: Array.hpp:94
Matrix< long double > acos(const Matrix< long double > &M)
Definition: Matrix.hpp:3936
Matrix< T > log10(const Matrix< T > &M)
Definition: Matrix.hpp:4058
HyperVolume< T > log(const HyperVolume< T > &V)
Returns the log value of each element of the HyperVolume.
reverse_iterator2d rbottom_right()
Returns a read/write reverse iterator2d. It points to past the upper left element of the Matrix...
Definition: Matrix.hpp:3272
Matrix< T > exp(const Matrix< T > &M)
Definition: Matrix.hpp:4013
const_pointer const_row_iterator
Definition: Matrix.hpp:213
row_iterator row_begin(const size_type row)
Returns a read/write iterator that points to the first element of the row row in the Matrix...
MultivariatePolynomial< T, DIM > operator+(const MultivariatePolynomial< T, DIM > &P1, const MultivariatePolynomial< T, DIM > &P2)
pointwise addition of two MultivariatePolynomial
Color< T > operator*(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:658
Provides some Singular Value Decomposition (SVD) algorithms.
std::reverse_iterator< const_iterator2d_range > const_reverse_iterator2d_range
Definition: Matrix.hpp:239
Provides a class to manipulate Ranges.
Provides a class to manipulate iterator2d within a slip::Range. It is used to iterate throw 2d contai...
Matrix< typename slip::lin_alg_traits< T >::value_type > abs(const Matrix< T > &M)
Definition: Matrix.hpp:3892
void apply(InputIterator first, InputIterator last, OutputIterator result, typename std::iterator_traits< OutputIterator >::value_type(*function)(typename std::iterator_traits< InputIterator >::value_type))
Applies a C-function to each element of a range.
Definition: apply.hpp:128
This is a two-dimensional dynamic and generic container. This container statisfies the Bidirectionnal...
Definition: Array2d.hpp:135
T & max(const GrayscaleImage< T > &M1)
Returns the max element of a GrayscaleImage.
SubType stop() const
Accessor of the stop subscript of the Range.
Definition: Range.hpp:291
Color< T > operator/(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:686
bool operator>=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1485
const_iterator2d const_default_iterator
Definition: Matrix.hpp:246
norm_type L2_norm() const
Returns the L2 norm ( ) of the elements of the Matrix.
Definition: Matrix.hpp:2284
Color< T > operator-(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:630
slip::Matrix< unsigned short > Matrix_us
unsigned long alias
Definition: Matrix.hpp:2387
HyperVolume< T > exp(const HyperVolume< T > &V)
Returns the exp value of each element of the HyperVolume.
T & max() const
Returns the max element of the Matrix according to the operator >, , if the T is complex, it returns the element with the maximal magnitude.
Definition: Matrix.hpp:3627
Provides some algorithms to compute norms.