SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Signal.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 
74 #ifndef SLIP_SIGNAL_HPP
75 #define SLIP_SIGNAL_HPP
76 
77 #include <iostream>
78 #include <iterator>
79 #include <cassert>
80 #include <numeric>
81 #include <algorithm>
82 #include <cmath>
83 #include <cstddef>
84 #include <complex>
85 #include <string>
86 #include "Vector.hpp"
87 #include "Box1d.hpp"
88 #include "stride_iterator.hpp"
89 #include "apply.hpp"
90 #include "norms.hpp"
92 #include "linear_algebra.hpp"
93 #include "complex_cast.hpp"
94 
95 #include <boost/serialization/access.hpp>
96 #include <boost/serialization/split_member.hpp>
97 #include <boost/serialization/string.hpp>
98 #include <boost/serialization/complex.hpp>
99 #include <boost/serialization/version.hpp>
100 
101 namespace slip
102 {
103 
104 template <typename T>
105 class Signal;
106 
107 template <typename T>
108 std::ostream& operator<<(std::ostream & out,
109  const Signal<T>& v);
110 
111 template<typename T>
112 bool operator==(const Signal<T>& x,
113  const Signal<T>& y);
114 
115 template<typename T>
116 bool operator!=(const Signal<T>& x,
117  const Signal<T>& y);
118 
119 template<typename T>
120 bool operator<(const Signal<T>& x,
121  const Signal<T>& y);
122 
123 template<typename T>
124 bool operator>(const Signal<T>& x,
125  const Signal<T>& y);
126 
127 template<typename T>
128 bool operator<=(const Signal<T>& x,
129  const Signal<T>& y);
130 
131 template<typename T>
132 bool operator>=(const Signal<T>& x,
133  const Signal<T>& y);
152 template <typename T>
153 class Signal
154 {
155 public :
156 
157  typedef T value_type;
158  typedef Signal<T> self;
159  typedef const Signal<T> const_self;
160 
161  typedef value_type* pointer;
162  typedef const value_type* const_pointer;
164  typedef const value_type& const_reference;
165 
166  typedef ptrdiff_t difference_type;
167  typedef std::size_t size_type;
168 
169  typedef pointer iterator;
171 
174 
175  typedef std::reverse_iterator<iterator> reverse_iterator;
176  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
177 
178  typedef std::reverse_iterator<iterator_range> reverse_iterator_range;
179  typedef std::reverse_iterator<const_iterator_range> const_reverse_iterator_range;
180 
182 
183  //default iterator of the container
186 
187 
188  static const std::size_t DIM = 1;
189 
190 public:
195 
199  Signal();
200 
205  Signal(const size_type n);
206 
212  Signal(const size_type n,
213  const T& val);
214 
220  Signal(const size_type n,
221  const T* val);
222 
231  template<typename InputIterator>
232  Signal(InputIterator first,
233  InputIterator last):
234  vector_(new slip::Vector<T>(first,last))
235  {}
236 
240  Signal(const self& rhs);
241 
245  ~Signal();
246 
247 
256  void resize(const size_type new_n,
257  const T& val = T());
258 
259 
264 
273  iterator begin();
274 
283  const_iterator begin() const;
284 
293  iterator end();
294 
303  const_iterator end() const;
304 
314 
324 
334 
345 
346 
365  iterator_range begin(const slip::Range<int>& range);
366 
385  const_iterator_range begin(const slip::Range<int>& range) const;
386 
404  iterator_range end(const slip::Range<int>& range);
405 
424  const_iterator_range end(const slip::Range<int>& range) const;
425 
426 
427 
445  iterator begin(const slip::Box1d<int>& box);
446 
464  const_iterator begin(const slip::Box1d<int>& box) const;
465 
483  iterator end(const slip::Box1d<int>& box);
484 
502  const_iterator end(const slip::Box1d<int>& box) const;
503 
504  //
524 
544 
563 
583 
584 
585 
604 
623 
642 
660  const_reverse_iterator rend(const slip::Box1d<int>& box) const;
672  friend std::ostream& operator<< <>(std::ostream & out,
673  const self& v);
674 
680  void write_ascii(const std::string& file_path_name) const
681  {
682  // slip::write_ascii_2d<self,value_type>(*this,file_path_name);
683  }
684 
690  void read_ascii(const std::string& file_path_name)
691  {
692  //slip::read_ascii_2d<self>(*this,file_path_name);
693  }
709  self& operator=(const self & rhs);
710 
716  self& operator=(const T& val);
717 
723  void fill(const T& value)
724  {
725  std::fill_n(this->begin(),this->size(),value);
726  }
727 
734  void fill(const T* value)
735  {
736  std::copy(value,value + this->size(), this->begin());
737  }
738 
747  template<typename InputIterator>
748  void fill(InputIterator first,
749  InputIterator last)
750  {
751  std::copy(first,last, this->begin());
752  }
766  friend bool operator== <>(const Signal<T>& x,
767  const Signal<T>& y);
768 
775  friend bool operator!= <>(const Signal<T>& x,
776  const Signal<T>& y);
777 
784  friend bool operator< <>(const Signal<T>& x,
785  const Signal<T>& y);
786 
793  friend bool operator> <>(const Signal<T>& x,
794  const Signal<T>& y);
795 
802  friend bool operator<= <>(const Signal<T>& x,
803  const Signal<T>& y);
804 
811  friend bool operator>= <>(const Signal<T>& x,
812  const Signal<T>& y);
813 
814 
832  reference operator[](const size_type i);
833 
844  const_reference operator[](const size_type i) const;
845 
856  reference operator()(const size_type i);
857 
868  const_reference operator()(const size_type i) const;
869 
882 
895 
907  self operator()(const slip::Range<int>& range);
908 
916 
922  self& operator+=(const T& val);
923  self& operator-=(const T& val);
924  self& operator*=(const T& val);
925  self& operator/=(const T& val);
926  // self& operator%=(const T& val);
927  // self& operator^=(const T& val);
928  // self& operator&=(const T& val);
929  // self& operator|=(const T& val);
930  // self& operator<<=(const T& val);
931  // self& operator>>=(const T& val);
932 
933  self operator-() const;
934  //self operator!() const;
935 
936  self& operator+=(const self& rhs);
937  self& operator-=(const self& rhs);
938  self& operator*=(const self& rhs);
939  self& operator/=(const self& rhs);
940 
941 
948  std::string name() const;
949 
953  size_type size() const;
954 
958  size_type max_size() const;
959 
963  bool empty()const;
964 
969  void swap(self& M);
970 
976  T& min() const;
977 
978 
984  T& max() const;
985 
990  T sum() const;
991 
997  {
998  return (this->vector_)->Euclidean_norm();
999  }
1000 
1006  {
1007  return (this->vector_)->L2_norm();
1008  }
1009 
1015  {
1016 
1017  return (this->vector_)->L1_norm();
1018  }
1019 
1025  {
1026  return (this->vector_)->L22_norm();
1027  }
1028 
1034  {
1035  return (this->vector_)->infinite_norm();
1036  }
1052  Signal<T>& apply(T (*fun)(T));
1053 
1069  Signal<T>& apply(T (*fun)(const T&));
1070 
1071  private:
1072  slip::Vector<T>* vector_;
1073 
1074  private:
1076  template<class Archive>
1077  void save(Archive & ar, const unsigned int version) const
1078  {
1079  ar & this->vector_;
1080  }
1081  template<class Archive>
1082  void load(Archive & ar, const unsigned int version)
1083  {
1084  ar & this->vector_;
1085  }
1086  BOOST_SERIALIZATION_SPLIT_MEMBER();
1087 }; // end of MathematicalContainer group
1089 
1110 
1118 template<typename T>
1119 Signal<T> operator+(const Signal<T>& V1,
1120  const Signal<T>& V2);
1121 
1128 template<typename T>
1129 Signal<T> operator+(const Signal<T>& V,
1130  const T& val);
1131 
1138 template<typename T>
1139 Signal<T> operator+(const T& val,
1140  const Signal<T>& V);
1141 
1142 
1150 template<typename T>
1151 Signal<T> operator-(const Signal<T>& V1,
1152  const Signal<T>& V2);
1153 
1160 template<typename T>
1161 Signal<T> operator-(const Signal<T>& V,
1162  const T& val);
1163 
1170 template<typename T>
1171 Signal<T> operator-(const T& val,
1172  const Signal<T>& V);
1173 
1181 template<typename T>
1182 Signal<T> operator*(const Signal<T>& V1,
1183  const Signal<T>& V2);
1184 
1191 template<typename T>
1192 Signal<T> operator*(const Signal<T>& V,
1193  const T& val);
1194 
1201 template<typename T>
1202 Signal<T> operator*(const T& val,
1203  const Signal<T>& V);
1204 
1212  template<typename T>
1213  Signal<T> operator/(const Signal<T>& V1,
1214  const Signal<T>& V2);
1215 
1222  template<typename T>
1223  Signal<T> operator/(const Signal<T>& V,
1224  const T& val);
1225 
1226 
1227 
1235  template<typename T>
1236  T& min(const Signal<T>& M1);
1237 
1245  template<typename T>
1246  T& max(const Signal<T>& M1);
1247 
1248 
1255  template<typename T>
1257 
1264  template<typename T>
1265  Signal<T> sqrt(const Signal<T>& V);
1266 
1273  template<typename T>
1274  Signal<T> cos(const Signal<T>& V);
1275 
1282  Signal<float> acos(const Signal<float>& V);
1297 
1304  template<typename T>
1305  Signal<T> sin(const Signal<T>& V);
1306 
1313  Signal<float> asin(const Signal<float>& V);
1328 
1335  template<typename T>
1336  Signal<T> tan(const Signal<T>& V);
1337 
1344  Signal<float> atan(const Signal<float>& V);
1359 
1360 
1367  template<typename T>
1368  Signal<T> exp(const Signal<T>& V);
1369 
1376  template<typename T>
1377  Signal<T> log(const Signal<T>& V);
1378 
1385  template<typename T>
1386  Signal<T> cosh(const Signal<T>& V);
1387 
1394  template<typename T>
1395  Signal<T> sinh(const Signal<T>& V);
1396 
1403  template<typename T>
1404  Signal<T> tanh(const Signal<T>& V);
1405 
1412  template<typename T>
1413  Signal<T> log10(const Signal<T>& V);
1414 
1415 }//slip::
1416 
1417 namespace slip
1418 {
1419  template<typename T>
1420  inline
1422  vector_(new slip::Vector<T>())
1423  {}
1424 
1425  template<typename T>
1426  inline
1428  vector_(new slip::Vector<T>(n))
1429  {}
1430 
1431  template<typename T>
1432  inline
1434  const T& val):
1435  vector_(new slip::Vector<T>(n,val))
1436  {}
1437 
1438  template<typename T>
1439  inline
1441  const T* val):
1442  vector_(new slip::Vector<T>(n,val))
1443  {}
1444 
1445  template<typename T>
1446  inline
1448  vector_(new slip::Vector<T>((*rhs.vector_)))
1449  {}
1450 
1451  template<typename T>
1452  inline
1454  {
1455  if(this != &rhs)
1456  {
1457  *(this->vector_) = *(rhs.vector_);
1458  }
1459  return *this;
1460  }
1461 
1462  template<typename T>
1463  inline
1465  {
1466  delete vector_;
1467  }
1468 
1469  template<typename T>
1470  inline
1472  {
1473  (this->vector_)->operator=(val);
1474  return *this;
1475  }
1476 
1477  template<typename T>
1478  inline
1479  void Signal<T>::resize(typename Signal<T>::size_type new_size,
1480  const T& val)
1481  {
1482  (this->vector_)->resize(new_size,val);
1483  }
1484 
1485 
1486  template<typename T>
1487  inline
1489  {
1490  return vector_->begin();
1491  }
1492 
1493  template<typename T>
1494  inline
1496  {
1497  return vector_->end();
1498  }
1499 
1500  template<typename T>
1501  inline
1503  {
1504  slip::Vector<T> const * tp(vector_);
1505  return tp->begin();
1506  }
1507 
1508  template<typename T>
1509  inline
1511  {
1512  slip::Vector<T> const * tp(vector_);
1513  return tp->end();
1514  }
1515 
1516 
1517  template<typename T>
1518  inline
1520  {
1521  return vector_->rbegin();
1522  }
1523 
1524  template<typename T>
1525  inline
1527  {
1528  return vector_->rend();
1529  }
1530 
1531  template<typename T>
1532  inline
1534  {
1535  slip::Vector<T> const * tp(vector_);
1536  return tp->rbegin();
1537  }
1538 
1539  template<typename T>
1540  inline
1542  {
1543  slip::Vector<T> const * tp(vector_);
1544  return tp->rend();
1545  }
1546 
1547  //
1548  template<typename T>
1549  inline
1550  typename Signal<T>::iterator_range
1552  {
1553  return vector_->begin(range);
1554  }
1555 
1556  template<typename T>
1557  inline
1558  typename Signal<T>::iterator_range
1560  {
1561  return vector_->end(range);
1562  }
1563 
1564  template<typename T>
1565  inline
1568  {
1569  slip::Vector<T> const * tp(vector_);
1570  return tp->begin(range);
1571  }
1572 
1573  template<typename T>
1574  inline
1576  Signal<T>::end(const slip::Range<int>& range) const
1577  {
1578  slip::Vector<T> const * tp(vector_);
1579  return tp->end(range);
1580  }
1581 
1582  //
1583  template<typename T>
1584  inline
1585  typename Signal<T>::iterator
1587  {
1588  return vector_->begin(box);
1589  }
1590 
1591  template<typename T>
1592  inline
1593  typename Signal<T>::iterator
1595  {
1596  return vector_->end(box);
1597  }
1598 
1599  template<typename T>
1600  inline
1601  typename Signal<T>::const_iterator
1603  {
1604  slip::Vector<T> const * tp(vector_);
1605  return tp->begin(box);
1606  }
1607 
1608  template<typename T>
1609  inline
1610  typename Signal<T>::const_iterator
1612  {
1613  slip::Vector<T> const * tp(vector_);
1614  return tp->end(box);
1615  }
1616 
1617  //
1618  template<typename T>
1619  inline
1621  {
1622  return vector_->rbegin(box);
1623  }
1624 
1625  template<typename T>
1626  inline
1627  typename Signal<T>::reverse_iterator
1629  {
1630  return vector_->rend(box);
1631  }
1632 
1633  template<typename T>
1634  inline
1637  {
1638  slip::Vector<T> const * tp(vector_);
1639  return tp->rbegin(box);
1640  }
1641 
1642  template<typename T>
1643  inline
1646  {
1647  slip::Vector<T> const * tp(vector_);
1648  return tp->rend(box);
1649  }
1650  //
1651  template<typename T>
1652  inline
1654  {
1655  return vector_->rbegin(range);
1656  }
1657 
1658  template<typename T>
1659  inline
1662  {
1663  return vector_->rend(range);
1664  }
1665 
1666  template<typename T>
1667  inline
1670  {
1671  slip::Vector<T> const * tp(vector_);
1672  return tp->rbegin(range);
1673  }
1674 
1675  template<typename T>
1676  inline
1678  Signal<T>::rend(const slip::Range<int>& range) const
1679  {
1680  slip::Vector<T> const * tp(vector_);
1681  return tp->rend(range);
1682  }
1683 
1684 
1685  template <typename T>
1686  inline
1687  std::ostream& operator<<(std::ostream & out,
1688  const Signal<T>& v)
1689  {
1690  out<<*(v.vector_);
1691  return out;
1692  }
1693 
1694  template<typename T>
1695  inline
1696  typename Signal<T>::reference Signal<T>::operator[](typename Signal<T>::size_type i)
1697  {
1698  return (*vector_)[i];
1699  }
1700 
1701  template<typename T>
1702  inline
1703  typename Signal<T>::const_reference Signal<T>::operator[](typename Signal<T>::size_type i) const
1704  {
1705  return (*vector_)[i];
1706  }
1707 
1708  template<typename T>
1709  inline
1710  typename Signal<T>::reference Signal<T>::operator()(typename Signal<T>::size_type i)
1711  {
1712  return (*vector_)(i);
1713  }
1714 
1715  template<typename T>
1716  inline
1717  typename Signal<T>::const_reference Signal<T>::operator()(typename Signal<T>::size_type i) const
1718  {
1719  return (*vector_)(i);
1720  }
1721 
1722  template <typename T>
1723  inline
1724  typename Signal<T>::reference
1725  Signal<T>::operator()(const slip::Point1d<typename Signal<T>::size_type>& p)
1726  {
1727  return (*vector_)(p);
1728  }
1729 
1730  template <typename T>
1731  inline
1732  typename Signal<T>::const_reference
1733  Signal<T>::operator()(const slip::Point1d<typename Signal<T>::size_type>& p) const
1734  {
1735  return (*vector_)(p);
1736  }
1737 
1738  template<typename T>
1739  inline
1741  {
1742  assert(this->vector_ != 0);
1743  assert(range.is_valid());
1744  assert(range.start() < (int)this->size());
1745  assert(range.stop() < (int)this->size());
1746  return Signal<T>(vector_->begin(range),vector_->end(range));
1747 
1748  }
1749 
1750  template<typename T>
1751  inline
1752  std::string
1753  Signal<T>::name() const {return "Signal";}
1754 
1755  template<typename T>
1756  inline
1758  {
1759  return (this->vector_)->size();
1760  }
1761 
1762  template<typename T>
1763  inline
1765  {
1766  return (this->vector_)->max_size();
1767  }
1768 
1769  template<typename T>
1770  inline
1771  bool Signal<T>::empty()const
1772  {
1773  return (this->vector_)->empty();
1774  }
1775 
1776  template<typename T>
1777  inline
1779  {
1780  (this->vector_)->swap(*(V.vector_));
1781  }
1782 
1783 
1784  template<typename T>
1785  inline
1787  {
1788  (this->vector_)->operator+=(val);
1789  return *this;
1790  }
1791 
1792  template<typename T>
1793  inline
1795  {
1796  (this->vector_)->operator-=(val);
1797  return *this;
1798  }
1799 
1800  template<typename T>
1801  inline
1803  {
1804  (this->vector_)->operator*=(val);
1805  return *this;
1806  }
1807 
1808  template<typename T>
1809  inline
1811  {
1812  (this->vector_)->operator/=(val);
1813  return *this;
1814  }
1815 
1816 
1817  template<typename T>
1818  inline
1820  {
1821  *(this->vector_) = (this->vector_)->operator-();
1822  return *this;
1823  }
1824 
1825  template<typename T>
1826  inline
1828  {
1829  (this->vector_)->operator+=(*(rhs.vector_));
1830  return *this;
1831  }
1832 
1833  template<typename T>
1834  inline
1836  {
1837  (this->vector_)->operator-=(*(rhs.vector_));
1838  return *this;
1839  }
1840 
1841  template<typename T>
1842  inline
1844  {
1845  (this->vector_)->operator*=(*(rhs.vector_));
1846  return *this;
1847  }
1848 
1849  template<typename T>
1850  inline
1852  {
1853  (this->vector_)->operator/=(*(rhs.vector_));
1854  return *this;
1855  }
1856 
1857  template<typename T>
1858  inline
1859  T& Signal<T>::min() const
1860  {
1861  return (this->vector_)->min();
1862  }
1863 
1864  template<typename T>
1865  inline
1866  T& Signal<T>::max() const
1867  {
1868  return (this->vector_)->max();
1869  }
1870 
1871  template<typename T>
1872  inline
1873  T Signal<T>::sum() const
1874  {
1875  return (this->vector_)->sum();
1876  }
1877 
1878  template<typename T>
1879  inline
1881  {
1882  (this->vector_)->apply(fun);
1883  return *this;
1884 
1885  }
1886 
1887  template<typename T>
1888  inline
1889  Signal<T>& Signal<T>::apply(T (*fun)(const T&))
1890  {
1891  (this->vector_)->apply(fun);
1892  return *this;
1893  }
1894 
1895 
1896 
1898  /* @{ */
1899 template<typename T>
1900 inline
1902  const Signal<T>& V2)
1903 {
1904  assert(V1.size() == V2.size());
1905  Signal<T> tmp(V1.size());
1906  std::transform(V1.begin(),V1.end(),V2.begin(),tmp.begin(),std::plus<T>());
1907 
1908  return tmp;
1909 }
1910 
1911 template<typename T>
1912 inline
1914  const T& val)
1915 {
1916  Signal<T> tmp(V1);
1917  tmp+=val;
1918  return tmp;
1919 }
1920 
1921 template<typename T>
1922 inline
1923 Signal<T> operator+(const T& val,
1924  const Signal<T>& V1)
1925 {
1926  return V1 + val;
1927 }
1928 
1929 template<typename T>
1930 inline
1932  const Signal<T>& V2)
1933 {
1934  assert(V1.size() == V2.size());
1935  Signal<T> tmp(V1.size());
1936  std::transform(V1.begin(),V1.end(),V2.begin(),tmp.begin(),std::minus<T>());
1937  return tmp;
1938 }
1939 
1940 template<typename T>
1941 inline
1943  const T& val)
1944 {
1945  Signal<T> tmp(V1);
1946  tmp-=val;
1947  return tmp;
1948 }
1949 
1950 template<typename T>
1951 inline
1952 Signal<T> operator-(const T& val,
1953  const Signal<T>& V1)
1954 {
1955  return -(V1 - val);
1956 }
1957 
1958 template<typename T>
1959 inline
1961  const Signal<T>& V2)
1962 {
1963  assert(V1.size() == V2.size());
1964  Signal<T> tmp(V1.size());
1965  std::transform(V1.begin(),V1.end(),V2.begin(),tmp.begin(),std::multiplies<T>());
1966  return tmp;
1967 }
1968 
1969 template<typename T>
1970 inline
1972  const T& val)
1973 {
1974  Signal<T> tmp(V1);
1975  tmp*=val;
1976  return tmp;
1977 }
1978 
1979 template<typename T>
1980 inline
1981 Signal<T> operator*(const T& val,
1982  const Signal<T>& V1)
1983 {
1984  return V1 * val;
1985 }
1986 
1987 template<typename T>
1988 inline
1990  const Signal<T>& V2)
1991 {
1992  assert(V1.size() == V2.size());
1993  Signal<T> tmp(V1.size());
1994  std::transform(V1.begin(),V1.end(),V2.begin(),tmp.begin(),std::divides<T>());
1995  return tmp;
1996 }
1997 
1998 template<typename T>
1999 inline
2001  const T& val)
2002 {
2003  Signal<T> tmp(V1);
2004  tmp/=val;
2005  return tmp;
2006 }
2007 
2008 /* @} */
2009 
2010 template<typename T>
2011 inline
2012 T& min(const Signal<T>& V1)
2013 {
2014  return V1.min();
2015 }
2016 
2017 template<typename T>
2018 inline
2019 T& max(const Signal<T>& V1)
2020 {
2021  return V1.max();
2022 }
2023 
2024 template<typename T>
2025 inline
2027 {
2028 
2030  slip::apply(V.begin(),V.end(),tmp.begin(),std::abs);
2031  return tmp;
2032 }
2033 
2034 template<typename T>
2035 inline
2037 {
2038  Signal<T> tmp(V.size());
2039  slip::apply(V.begin(),V.end(),tmp.begin(),std::sqrt);
2040  return tmp;
2041 }
2042 
2043 template<typename T>
2044 inline
2046 {
2047  Signal<T> tmp(V.size());
2048  slip::apply(V.begin(),V.end(),tmp.begin(),std::cos);
2049  return tmp;
2050 }
2051 
2052 
2053 inline
2055 {
2056  Signal<float> tmp(V.size());
2057  slip::apply(V.begin(),V.end(),tmp.begin(),std::acos);
2058  return tmp;
2059 }
2060 
2061 inline
2063 {
2064  Signal<double> tmp(V.size());
2065  slip::apply(V.begin(),V.end(),tmp.begin(),std::acos);
2066  return tmp;
2067 }
2068 
2069 inline
2071 {
2072  Signal<long double> tmp(V.size());
2073  slip::apply(V.begin(),V.end(),tmp.begin(),std::acos);
2074  return tmp;
2075 }
2076 
2077 template<typename T>
2078 inline
2080 {
2081  Signal<T> tmp(V.size());
2082  slip::apply(V.begin(),V.end(),tmp.begin(),std::sin);
2083  return tmp;
2084 }
2085 
2086 
2087 
2088 inline
2090 {
2091  Signal<float> tmp(V.size());
2092  slip::apply(V.begin(),V.end(),tmp.begin(),std::asin);
2093  return tmp;
2094 }
2095 
2096 inline
2098 {
2099  Signal<double> tmp(V.size());
2100  slip::apply(V.begin(),V.end(),tmp.begin(),std::asin);
2101  return tmp;
2102 }
2103 
2104 inline
2106 {
2107  Signal<long double> tmp(V.size());
2108  slip::apply(V.begin(),V.end(),tmp.begin(),std::asin);
2109  return tmp;
2110 }
2111 
2112 template<typename T>
2113 inline
2115 {
2116  Signal<T> tmp(V.size());
2117  slip::apply(V.begin(),V.end(),tmp.begin(),std::tan);
2118  return tmp;
2119 }
2120 
2121 inline
2123 {
2124  Signal<float> tmp(V.size());
2125  slip::apply(V.begin(),V.end(),tmp.begin(),std::atan);
2126  return tmp;
2127 }
2128 
2129 inline
2131 {
2132  Signal<double> tmp(V.size());
2133  slip::apply(V.begin(),V.end(),tmp.begin(),std::atan);
2134  return tmp;
2135 }
2136 
2137 inline
2139 {
2140  Signal<long double> tmp(V.size());
2141  slip::apply(V.begin(),V.end(),tmp.begin(),std::atan);
2142  return tmp;
2143 }
2144 
2145 template<typename T>
2146 inline
2148 {
2149  Signal<T> tmp(V.size());
2150  slip::apply(V.begin(),V.end(),tmp.begin(),std::exp);
2151  return tmp;
2152 }
2153 
2154 template<typename T>
2155 inline
2157 {
2158  Signal<T> tmp(V.size());
2159  slip::apply(V.begin(),V.end(),tmp.begin(),std::log);
2160  return tmp;
2161 }
2162 
2163 template<typename T>
2164 inline
2166 {
2167  Signal<T> tmp(V.size());
2168  slip::apply(V.begin(),V.end(),tmp.begin(),std::cosh);
2169  return tmp;
2170 }
2171 
2172 template<typename T>
2173 inline
2175 {
2176  Signal<T> tmp(V.size());
2177  slip::apply(V.begin(),V.end(),tmp.begin(),std::sinh);
2178  return tmp;
2179 }
2180 
2181 template<typename T>
2182 inline
2184 {
2185  Signal<T> tmp(V.size());
2186  slip::apply(V.begin(),V.end(),tmp.begin(),std::tanh);
2187  return tmp;
2188 }
2189 
2190 template<typename T>
2191 inline
2193 {
2194  Signal<T> tmp(V.size());
2195  slip::apply(V.begin(),V.end(),tmp.begin(),std::log10);
2196  return tmp;
2197 }
2198 
2200  /* @{ */
2201 template<typename T>
2202 inline
2203 bool operator==(const Signal<T>& x,
2204  const Signal<T>& y)
2205 {
2206  return *(x.vector_) == *(y.vector_);
2207 }
2208 
2209 template<typename T>
2210 inline
2211 bool operator!=(const Signal<T>& x,
2212  const Signal<T>& y)
2213 {
2214  return !(x == y);
2215 }
2216 /* @} */
2218  /* @{ */
2219 template<typename T>
2220 inline
2221 bool operator<(const Signal<T>& x,
2222  const Signal<T>& y)
2223 {
2224  return *(x.vector_) < *(y.vector_);
2225 }
2226 
2227 template<typename T>
2228 inline
2229 bool operator>(const Signal<T>& x,
2230  const Signal<T>& y)
2231 {
2232  return (y < x);
2233 }
2234 
2235 template<typename T>
2236 inline
2237 bool operator<=(const Signal<T>& x,
2238  const Signal<T>& y)
2239 {
2240  return !(y < x);
2241 }
2242 
2243 template<typename T>
2244 inline
2245 bool operator>=(const Signal<T>& x,
2246  const Signal<T>& y)
2247 {
2248  return !(x < y);
2249 }
2250 /* @} */
2251 }//slip::
2252 
2253 #endif //SLIP_SIGNAL_HPP
bool empty() const
Returns true if the Signal is empty. (Thus size() == 0)
Definition: Signal.hpp:1771
HyperVolume< T > tanh(const HyperVolume< T > &M)
bool operator!=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1448
const Signal< T > const_self
Definition: Signal.hpp:159
slip::stride_iterator< const_pointer > const_iterator_range
Definition: Signal.hpp:173
Signal< long double > asin(const Signal< long double > &V)
Definition: Signal.hpp:2105
Signal< T > cosh(const Signal< T > &V)
Definition: Signal.hpp:2165
Signal< T > sqrt(const Signal< T > &V)
Definition: Signal.hpp:2036
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Signal...
Definition: Signal.hpp:1526
norm_type Euclidean_norm() const
Returns the Euclidean norm of the elements of the Signal.
Definition: Signal.hpp:996
norm_type L1_norm() const
Returns the L1 norm ( ) of the elements of the Signal.
Definition: Signal.hpp:1014
slip::Signal< unsigned short > Signal_us
unsigned long alias
Definition: Signal.hpp:1101
slip::Signal< char > Signal_c
char alias
Definition: Signal.hpp:1107
void resize(const size_type new_n, const T &val=T())
Resizes a Signal.
Definition: Signal.hpp:1479
static const std::size_t DIM
Definition: Signal.hpp:188
slip::Signal< short > Signal_s
short alias
Definition: Signal.hpp:1099
const value_type * const_pointer
Definition: Signal.hpp:162
void swap(self &M)
Swaps data with another Signal.
Definition: Signal.hpp:1778
iterator end()
Returns a read/write iterator that points one past the last element in the Vector. Iteration is done in ordinary element order.
Definition: Vector.hpp:1481
norm_type L22_norm() const
Returns the L22 norm ( ) of the elements of the Signal.
Definition: Signal.hpp:1024
~Signal()
Destructor of the Signal.
Definition: Signal.hpp:1464
HyperVolume< T > cosh(const HyperVolume< T > &M)
reference operator()(const size_type i)
Subscript access to the data contained in the Signal.
T & min(const GrayscaleImage< T > &M1)
Returns the min element of a GrayscaleImage.
self & operator*=(const T &val)
Definition: Signal.hpp:1802
Signal< T > sinh(const Signal< T > &V)
Definition: Signal.hpp:2174
Color< T > operator+(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:602
std::string name() const
Returns the name of the class.
Definition: Signal.hpp:1753
Signal< T > log(const Signal< T > &V)
Definition: Signal.hpp:2156
norm_type infinite_norm() const
Returns the infinite norm ( ) of the elements of the Signal.
Definition: Signal.hpp:1033
HyperVolume< T > atan(const HyperVolume< T > &M)
std::reverse_iterator< iterator > reverse_iterator
Definition: Signal.hpp:175
void fill(const T *value)
Fills the container range [begin(),begin()+size()) with a copy of the value array.
Definition: Signal.hpp:734
void fill(const T &value)
Fills the container range [begin(),begin()+size()) with copies of value.
Definition: Signal.hpp:723
value_type & reference
Definition: Signal.hpp:163
HyperVolume< T > exp(const HyperVolume< T > &M)
self & operator/=(const T &val)
Definition: Signal.hpp:1810
Provides common linear algebra algorithms.
friend class boost::serialization::access
Definition: Signal.hpp:1075
norm_type L2_norm() const
Returns the Euclidean norm of the elements of the Signal.
Definition: Signal.hpp:1005
HyperVolume< T > abs(const HyperVolume< T > &M)
bool operator>(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1469
slip::stride_iterator< pointer > iterator_range
Definition: Signal.hpp:172
Signal< T > & apply(T(*fun)(T))
Applys the one-parameter C-function fun to each element of the Signal.
Definition: Signal.hpp:1880
void read_ascii(const std::string &file_path_name)
Read the Signal from an ASCII file.
Definition: Signal.hpp:690
HyperVolume< T > sin(const HyperVolume< T > &M)
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: Signal.hpp:176
const_pointer const_iterator
Definition: Signal.hpp:170
slip::Signal< unsigned int > Signal_ui
unsigned int alias
Definition: Signal.hpp:1105
Signal< typename slip::lin_alg_traits< T >::value_type > abs(const Signal< T > &V)
Definition: Signal.hpp:2026
HyperVolume< T > cos(const HyperVolume< T > &M)
size_type max_size() const
Returns the maximal size (number of elements) in the Signal.
Definition: Signal.hpp:1764
slip::Signal< double > Signal_d
double alias
Definition: Signal.hpp:1091
This is a point1d class, a specialized version of Point<CoordType,DIM> with DIM = 1...
Definition: Point1d.hpp:101
value_type * pointer
Definition: Signal.hpp:161
self & operator=(const self &rhs)
Assign a Signal.
Definition: Signal.hpp:1453
std::reverse_iterator< const_iterator_range > const_reverse_iterator_range
Definition: Signal.hpp:179
pointer iterator
Definition: Signal.hpp:169
This is a Box1d class, a specialized version of slip::Box<CoordType,DIM> with DIM = 1...
Definition: Box1d.hpp:110
slip::Signal< int > Signal_i
int alias
Definition: Signal.hpp:1103
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.
std::size_t size_type
Definition: Signal.hpp:167
bool is_valid() const
Returns true if the range is valid :
Definition: Range.hpp:322
SubType start() const
Accessor of the start subscript of the Range.
Definition: Range.hpp:284
slip::Signal< unsigned long > Signal_ul
unsigned long alias
Definition: Signal.hpp:1097
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Signal. Iteration is done in reverse element order.
Definition: Signal.hpp:1519
Numerical Vector class. This container statisfies the RandomAccessContainer concepts of the Standard ...
Definition: Vector.hpp:104
slip::Signal< float > Signal_f
float alias
Definition: Signal.hpp:1093
HyperVolume< T > sqrt(const HyperVolume< T > &M)
const value_type & const_reference
Definition: Signal.hpp:164
HyperVolume< T > sinh(const HyperVolume< T > &M)
self operator-() const
Definition: Signal.hpp:1819
size_type size() const
Returns the number of elements in the Signal.
Definition: Signal.hpp:1757
self & operator+=(const T &val)
Add val to each element of the Signal.
Definition: Signal.hpp:1786
std::reverse_iterator< iterator_range > reverse_iterator_range
Definition: Signal.hpp:178
Signal< T > cos(const Signal< T > &V)
Definition: Signal.hpp:2045
Signal< long double > atan(const Signal< long double > &V)
Definition: Signal.hpp:2138
iterator begin()
Returns a read/write iterator that points to the first element in the Signal. Iteration is done in or...
Definition: Signal.hpp:1488
void fill(InputIterator first, InputIterator last)
Fills the container range [begin(),begin()+size()) with a copy of the range [first,last)
Definition: Signal.hpp:748
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Vector. Iteration is done in reverse element order.
Definition: Vector.hpp:1505
Signal(InputIterator first, InputIterator last)
Contructs a Signal from a range.
Definition: Signal.hpp:232
std::ostream & operator<<(std::ostream &out, const Array< T > &a)
Definition: Array.hpp:1282
Signal< T > sin(const Signal< T > &V)
Definition: Signal.hpp:2079
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Vector...
Definition: Vector.hpp:1512
HyperVolume< T > log(const HyperVolume< T > &M)
Signal< T > exp(const Signal< T > &V)
Definition: Signal.hpp:2147
void write_ascii(const std::string &file_path_name) const
Write the Signal to an ASCII file.
Definition: Signal.hpp:680
self & operator-=(const T &val)
Definition: Signal.hpp:1794
HyperVolume< T > acos(const HyperVolume< T > &M)
HyperVolume< T > log10(const HyperVolume< T > &M)
Signal< T > tanh(const Signal< T > &V)
Definition: Signal.hpp:2183
iterator default_iterator
Definition: Signal.hpp:184
slip::lin_alg_traits< value_type >::value_type norm_type
Definition: Signal.hpp:181
const_iterator const_default_iterator
Definition: Signal.hpp:185
Provides some algorithms to apply C like functions to ranges.
ptrdiff_t difference_type
Definition: Signal.hpp:166
Provides a class to iterate a 1d range according to a step.
T & max() const
Returns the max element of the Signal according to the operator >, if T is std::complex, it returns the element of maximum magnitude.
Definition: Signal.hpp:1866
Numerical Signal class. This container statisfies the RandomAccessContainer concepts of the Standard ...
Definition: Signal.hpp:105
T & min() const
Returns the min element of the Signal according to the operator < if T is std::complex, it returns the element of minimum magnitude.
Definition: Signal.hpp:1859
HyperVolume< T > tan(const HyperVolume< T > &M)
bool operator==(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1439
Signal< long double > acos(const Signal< long double > &V)
Definition: Signal.hpp:2070
HyperVolume< T > asin(const HyperVolume< T > &M)
Signal< T > tan(const Signal< T > &V)
Definition: Signal.hpp:2114
slip::Signal< unsigned char > Signal_uc
unsigned char alias
Definition: Signal.hpp:1109
T sum() const
Returns the sum of the elements of the Signal.
Definition: Signal.hpp:1873
Color< T > operator*(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:658
Signal()
Constructs a Signal.
Definition: Signal.hpp:1421
Signal< T > log10(const Signal< T > &V)
Definition: Signal.hpp:2192
Provides a class to manipulate 1d box.
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
Provides a class to manipulate numerical vectors.
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
iterator begin()
Returns a read/write iterator that points to the first element in the Vector. Iteration is done in or...
Definition: Vector.hpp:1474
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
Color< T > operator-(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:630
iterator end()
Returns a read/write iterator that points one past the last element in the Signal. Iteration is done in ordinary element order.
Definition: Signal.hpp:1495
reference operator[](const size_type i)
Subscript access to the data contained in the Signal.
slip::Signal< long > Signal_l
long alias
Definition: Signal.hpp:1095
Provides some algorithms to compute norms.