91 #include <boost/serialization/access.hpp>
92 #include <boost/serialization/split_member.hpp>
93 #include <boost/serialization/complex.hpp>
94 #include <boost/serialization/version.hpp>
99 template <
class T, std::
size_t N>
102 template <
typename T, std::
size_t N>
106 template <
typename T, std::
size_t N>
110 template <
typename T, std::
size_t N>
114 template <
typename T, std::
size_t N>
115 bool operator<(const kvector<T,N>& x,
118 template <
typename T, std::
size_t N>
122 template <
typename T, std::
size_t N>
123 bool operator<=(const kvector<T,N>& x,
126 template <
typename T, std::
size_t N>
147 template <
class T, std::
size_t N>
180 static const std::size_t
SIZE = N;
181 static const std::size_t
DIM = 1;
251 assert(range.
start() >= 0);
252 assert(range.
stop() >= 0);
253 assert(range.
start() < int(this->
size()));
254 assert(range.
stop() < int(this->
size()));
279 assert(range.
start() >= 0);
280 assert(range.
stop() >= 0);
281 assert(range.
start() < int(this->
size()));
282 assert(range.
stop() < int(this->
size()));
478 friend std::ostream& operator<< <>(std::ostream & out,
523 std::fill_n(this->
begin(),N,value);
544 template<
typename InputIterator>
689 std::transform(this->
begin(),this->
end(),this->
begin(),std::bind2nd(std::plus<T>(),val));
695 std::transform(this->
begin(),this->
end(),this->
begin(),std::bind2nd(std::minus<T>(),val));
701 std::transform(this->
begin(),this->
end(),this->
begin(),std::bind2nd(std::multiplies<T>(),val));
707 std::transform(this->
begin(),this->
end(),this->
begin(),std::bind2nd(std::divides<T>(),val));
720 std::transform(this->
begin(),this->
end(),tmp.begin(),std::negate<T>());
727 assert(this->
size() == rhs.size());
728 std::transform(this->
begin(),this->
end(),rhs.begin(),this->
begin(),std::plus<T>());
734 assert(this->
size() == rhs.size());
735 std::transform(this->
begin(),this->
end(),rhs.begin(),this->
begin(),std::minus<T>());
741 assert(this->
size() == rhs.size());
742 std::transform(this->
begin(),this->
end(),rhs.begin(),this->
begin(),std::multiplies<T>());
748 assert(this->
size() == rhs.size());
749 std::transform(this->
begin(),this->
end(),rhs.begin(),this->
begin(),std::divides<T>());
760 std::string
name()
const {
return "kvector";}
802 assert(this->
size() != 0);
803 return *std::min_element(this->
begin(),this->
end(),std::less<T>());
814 assert(this->
size() != 0);
815 return *std::max_element(this->
begin(),this->
end(),std::less<T>());
824 assert(this->
size() != 0);
825 return std::accumulate(this->
begin(),this->
end(),T(0));
834 assert(this->
size() != 0);
844 assert(this->
size() != 0);
855 assert(this->
size() != 0);
856 return slip::L1_norm<norm_type>(this->
begin(),this->
end());
865 assert(this->
size() != 0);
875 assert(this->
size() != 0);
876 return slip::infinite_norm<norm_type>(this->
begin(),this->
end());
884 template<
typename Real>
885 Real
dot(
const self& other)
938 friend class boost::serialization::access;
939 template<
class Archive>
940 void save(Archive & ar,
const unsigned int version)
const
944 template<
class Archive>
945 void load(Archive & ar,
const unsigned int version)
949 BOOST_SERIALIZATION_SPLIT_MEMBER()
960 template<
typename T, std::
size_t N>
961 kvector<T,N>
operator+(
const kvector<T,N>& V1,
962 const kvector<T,N>& V2);
970 template<
typename T, std::
size_t N>
971 kvector<T,N>
operator+(
const kvector<T,N>& V,
980 template<
typename T, std::
size_t N>
982 const kvector<T,N>& V);
992 template<
typename T, std::
size_t N>
993 kvector<T,N>
operator-(
const kvector<T,N>& V1,
994 const kvector<T,N>& V2);
1002 template<
typename T, std::
size_t N>
1003 kvector<T,N>
operator-(
const kvector<T,N>& V,
1012 template<
typename T, std::
size_t N>
1014 const kvector<T,N>& V);
1023 template<
typename T, std::
size_t N>
1024 kvector<T,N>
operator*(
const kvector<T,N>& V1,
1025 const kvector<T,N>& V2);
1033 template<
typename T, std::
size_t N>
1034 kvector<T,N>
operator*(
const kvector<T,N>& V,
1043 template<
typename T, std::
size_t N>
1045 const kvector<T,N>& V);
1054 template<
typename T, std::
size_t N>
1055 kvector<T,N>
operator/(
const kvector<T,N>& V1,
1056 const kvector<T,N>& V2);
1064 template<
typename T, std::
size_t N>
1065 kvector<T,N>
operator/(
const kvector<T,N>& V,
1088 template<
typename T, std::
size_t N>
1089 T&
min(kvector<T,N>& M1);
1098 template<
typename T, std::
size_t N>
1099 T&
max(kvector<T,N>& M1);
1108 template<
typename T, std::
size_t N>
1109 kvector<typename slip::lin_alg_traits<T>::value_type,N>
abs(
const kvector<T,N>& V);
1117 template<
typename T, std::
size_t N>
1118 kvector<T,N>
sqrt(
const kvector<T,N>& V);
1126 template<
typename T, std::
size_t N>
1127 kvector<T,N>
cos(
const kvector<T,N>& V);
1136 template<std::
size_t N>
1137 kvector<float,N>
acos(
const kvector<float,N>& V);
1145 template<std::
size_t N>
1146 kvector<double,N>
acos(
const kvector<double,N>& V);
1154 template<std::
size_t N>
1155 kvector<long double,N>
acos(
const kvector<long double,N>& V);
1163 template<
typename T, std::
size_t N>
1164 kvector<T,N>
sin(
const kvector<T,N>& V);
1173 template<std::
size_t N>
1174 kvector<float,N>
asin(
const kvector<float,N>& V);
1182 template<std::
size_t N>
1183 kvector<double,N>
asin(
const kvector<double,N>& V);
1191 template<std::
size_t N>
1192 kvector<long double,N>
asin(
const kvector<long double,N>& V);
1201 template<
typename T, std::
size_t N>
1202 kvector<T,N>
tan(
const kvector<T,N>& V);
1211 template<std::
size_t N>
1212 kvector<float,N>
atan(
const kvector<float,N>& V);
1220 template<std::
size_t N>
1221 kvector<double,N>
atan(
const kvector<double,N>& V);
1229 template<std::
size_t N>
1230 kvector<long double,N>
atan(
const kvector<long double,N>& V);
1239 template<
typename T, std::
size_t N>
1240 kvector<T,N>
exp(
const kvector<T,N>& V);
1248 template<
typename T, std::
size_t N>
1249 kvector<T,N>
log(
const kvector<T,N>& V);
1257 template<
typename T, std::
size_t N>
1258 kvector<T,N>
cosh(
const kvector<T,N>& V);
1266 template<
typename T, std::
size_t N>
1267 kvector<T,N>
sinh(
const kvector<T,N>& V);
1275 template<
typename T, std::
size_t N>
1276 kvector<T,N>
tanh(
const kvector<T,N>& V);
1284 template<
typename T, std::
size_t N>
1285 kvector<T,N>
log10(
const kvector<T,N>& V);
1292 template <
typename T, std::
size_t N>
1297 for(std::size_t n = 0; n < N - 1; ++n)
1299 out<<b.
data[n]<<
",";
1306 template<
typename T, std::
size_t N>
1316 template<
typename T, std::
size_t N>
1326 template<
typename T, std::
size_t N>
1334 template<
typename T, std::
size_t N>
1344 template<
typename T, std::
size_t N>
1354 template<
typename T, std::
size_t N>
1362 template<
typename T, std::
size_t N>
1372 template<
typename T, std::
size_t N>
1382 template<
typename T, std::
size_t N>
1390 template<
typename T, std::
size_t N>
1400 template<
typename T, std::
size_t N>
1419 template<
typename T, std::
size_t N>
1426 template<
typename T, std::
size_t N>
1433 template<
typename T, std::
size_t N>
1443 template<
typename T, std::
size_t N>
1452 template<
typename T, std::
size_t N>
1462 template<std::
size_t N>
1471 template<std::
size_t N>
1480 template<std::
size_t N>
1489 template<
typename T, std::
size_t N>
1499 template<std::
size_t N>
1508 template<std::
size_t N>
1517 template<std::
size_t N>
1526 template<
typename T, std::
size_t N>
1537 template<std::
size_t N>
1546 template<std::
size_t N>
1555 template<std::
size_t N>
1564 template<
typename T, std::
size_t N>
1573 template<
typename T, std::
size_t N>
1582 template<
typename T, std::
size_t N>
1591 template<
typename T, std::
size_t N>
1600 template<
typename T, std::
size_t N>
1609 template<
typename T, std::
size_t N>
1619 template <
typename T, std::
size_t N>
1628 template <
typename T, std::
size_t N>
1637 template <
typename T, std::
size_t N>
1639 bool operator<(const kvector<T,N>& x,
1642 return std::lexicographical_compare(x.begin(), x.end(),
1643 y.begin(), y.end());
1646 template <
typename T, std::
size_t N>
1655 template <
typename T, std::
size_t N>
1657 bool operator<=(const kvector<T,N>& x,
1664 template <
typename T, std::
size_t N>
1673 #endif //KVECTOR_HPP
void fill(const T &value)
Fills the container range [begin(),begin()+N) with copies of value.
HyperVolume< T > tanh(const HyperVolume< T > &M)
bool operator!=(const Array< T > &x, const Array< T > &y)
self & operator-=(const self &rhs)
std::size_t iterations() const
Rerturns the number of iterations of the range.
kvector< T, N > exp(const kvector< T, N > &V)
const value_type * const_pointer
const_iterator_range end(const slip::Range< int > &range) const
Returns a read-only (constant) iterator_range that points one past the last element in the kvector...
const_reverse_iterator rbegin() const
Returns a read-only (constant) reverse iterator that points to the last element in the kvector...
std::reverse_iterator< const_iterator > const_reverse_iterator
const_reverse_iterator rend() const
Returns a read-only (constant) reverse iterator that points to one before the first element in the kv...
iterator_range end(const slip::Range< int > &range)
Returns a read/write iterator_range that points one past the last element in the kvector. Iteration is done in ordinary element order according to the Range.
kvector< T, N > sinh(const kvector< T, N > &V)
This is a linear (one-dimensional) static vector. This container statisfies the RandomAccessContainer...
kvector< T, N > & operator=(const kvector< T, N > &rhs)
Assigns all the element of the kvector by the kvector rhs.
norm_type infinite_norm() const
Returns the infinite norm ( ) of the elements of the kvector.
void load(Archive &ar, const unsigned int version)
norm_type L1_norm() const
Returns the L1 norm ( ) of the elements of the kvector.
kvector< long double, N > acos(const kvector< long double, N > &V)
slip::lin_alg_traits< typename std::iterator_traits< InputIterator >::value_type >::value_type L22_norm_cplx(InputIterator first, InputIterator last)
Computes the L22 norm of a complex container.
HyperVolume< T > cosh(const HyperVolume< T > &M)
norm_type Euclidean_norm() const
Returns the Euclidean norm of the elements of the kvector.
T & min(const GrayscaleImage< T > &M1)
Returns the min element of a GrayscaleImage.
kvector< T, N > log10(const kvector< T, N > &V)
kvector< T, N > cosh(const kvector< T, N > &V)
const_iterator const_default_iterator
self & operator+=(const self &rhs)
Color< T > operator+(const Color< T > &V1, const Color< T > &V2)
kvector< T, N > & operator=(const T &val)
Assigns all the element of the kvector by val.
norm_type L22_norm() const
Returns the L22 norm ( ) of the elements of the kvector.
kvector< T, N > sin(const kvector< T, N > &V)
HyperVolume< T > atan(const HyperVolume< T > &M)
T & min()
Returns the min element of the kvector according to the operator <, if T is std::complex, it returns the element of minimum magnitude.
kvector< T, N > tanh(const kvector< T, N > &V)
reference operator()(const size_type n)
Subscript access to the data contained in the kvector.
norm_type L2_norm() const
Returns the Euclidean norm of the elements of the kvector.
HyperVolume< T > exp(const HyperVolume< T > &M)
Provides common linear algebra algorithms.
size_type max_size() const
Returns the maximal size (number of elements) in the kvector.
iterator default_iterator
kvector< long double, N > atan(const kvector< long double, N > &V)
const value_type & const_reference
self & operator/=(const T &val)
const kvector< T, N > const_self
const_reference operator()(const size_type n) const
Subscript access to the data contained in the kvector.
HyperVolume< T > abs(const HyperVolume< T > &M)
bool operator>(const Array< T > &x, const Array< T > &y)
kvector< T, N > & apply(T(*fun)(T))
Applys the one-parameter C-function fun to each element of the kvector.
const_reference operator[](const size_type n) const
Subscript access to the data contained in the kvector.
HyperVolume< T > sin(const HyperVolume< T > &M)
Provides a class to manipulate 1d static and generic arrays.
HyperVolume< T > cos(const HyperVolume< T > &M)
reverse_iterator_range rend(const slip::Range< int > &range)
Returns a read/write reverse_iterator_range that points one previous the first element in the Range...
self & operator-=(const T &val)
reference operator[](const size_type n)
Subscript access to the data contained in the kvector.
slip::stride_iterator< pointer > iterator_range
Real dot(const self &other)
Computes the dot product with another kvector other.
self & operator+=(const T &val)
Add val to each element of the kvector.
iterator_range begin(const slip::Range< int > &range)
Returns a read/write iterator_range that points the first element within the Range. Iteration is done in ordinary element order according to the Range.
static const std::size_t DIM
iterator begin()
Returns a read/write iterator that points to the first element in the kvector. Iteration is done in o...
kvector< T, N > cos(const kvector< T, N > &V)
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
Provides some macros which are used for using complex as real.
bool is_valid() const
Returns true if the range is valid :
SubType start() const
Accessor of the start subscript of the Range.
void fill(InputIterator first, InputIterator last)
Fills the container range [begin(),begin()+N) with a copy of the range [first,last) ...
T sum() const
Returns the sum of the elements of the kvector.
const_pointer const_iterator
self & operator/=(const self &rhs)
void fill(const T *value)
Fills the container range [begin(),begin()+N) with a copy of the value array.
HyperVolume< T > sqrt(const HyperVolume< T > &M)
size_type size() const
Returns the number of elements in the kvector.
HyperVolume< T > sinh(const HyperVolume< T > &M)
kvector< typename slip::lin_alg_traits< T >::value_type, N > abs(const kvector< T, N > &V)
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the kvector...
slip::lin_alg_traits< value_type >::value_type norm_type
kvector< T, N > log(const kvector< T, N > &V)
self & operator*=(const T &val)
const_reverse_iterator_range rbegin(const slip::Range< int > &range) const
Returns a read-only (constant) reverse_iterator_range that points the end element within the Range...
std::reverse_iterator< iterator > reverse_iterator
std::string name() const
Returns the name of the class.
std::ostream & operator<<(std::ostream &out, const Array< T > &a)
iterator end()
Returns a read/write iterator that points one past the last element in the kvector. Iteration is done in ordinary element order.
HyperVolume< T > log(const HyperVolume< T > &M)
ptrdiff_t difference_type
reverse_iterator_range rbegin(const slip::Range< int > &range)
Returns a read/write reverse_iterator_range that points the end element within the Range...
std::iterator_traits< RandomAccessIterator1 >::value_type inner_product(RandomAccessIterator1 first1, RandomAccessIterator1 last1, RandomAccessIterator2 first2, typename std::iterator_traits< RandomAccessIterator1 >::value_type init=typename std::iterator_traits< RandomAccessIterator1 >::value_type())
Computes the inner_product of two ranges X and Y: .
HyperVolume< T > acos(const HyperVolume< T > &M)
std::reverse_iterator< iterator_range > reverse_iterator_range
HyperVolume< T > log10(const HyperVolume< T > &M)
int stride() const
Accessor of the stride of the Range.
slip::stride_iterator< const_pointer > const_iterator_range
Provides some algorithms to apply C like functions to ranges.
const_iterator begin() const
Returns a read-only (constant) iterator that points to the first element in the kvector. Iteration is done in ordinary element order.
kvector< T, N > & apply(T(*fun)(const T &))
Applys the one-parameter C-function fun to each element of the kvector.
kvector< long double, N > asin(const kvector< long double, N > &V)
std::reverse_iterator< const_iterator_range > const_reverse_iterator_range
Provides a class to iterate a 1d range according to a step.
bool empty() const
Returns true if the kvector is empty. (Thus size == 0)
const_iterator_range begin(const slip::Range< int > &range) const
Returns a read-only (constant) iterator_range that points the first element within the Range...
HyperVolume< T > tan(const HyperVolume< T > &M)
const_reverse_iterator_range rend(const slip::Range< int > &range) const
Returns a read-only (constant) reverse_iterator_range that points one previous the first element in t...
bool operator==(const Array< T > &x, const Array< T > &y)
kvector< T, N > tan(const kvector< T, N > &V)
const_iterator end() const
Returns a read-only (constant) iterator that points one past the last element in the kvector...
HyperVolume< T > asin(const HyperVolume< T > &M)
T & max()
Returns the max element of the kvector according to the operator >, if T is std::complex, it returns the element of maximum magnitude.
Color< T > operator*(const Color< T > &V1, const Color< T > &V2)
T data[N]
Data array storage of the kvector.
Provides a class to manipulate Ranges.
self & operator*=(const self &rhs)
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.
T & max(const GrayscaleImage< T > &M1)
Returns the max element of a GrayscaleImage.
SubType stop() const
Accessor of the stop subscript of the Range.
Color< T > operator/(const Color< T > &V1, const Color< T > &V2)
void swap(kvector &x)
Swaps data with another kvector.
bool operator>=(const Array< T > &x, const Array< T > &y)
Color< T > operator-(const Color< T > &V1, const Color< T > &V2)
void save(Archive &ar, const unsigned int version) const
Provides some algorithms to compute norms.
kvector< T, N > sqrt(const kvector< T, N > &V)
static const std::size_t SIZE
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the kvector. Iteration is done in reverse element order.