Medusa  1.1
Coordinate Free Mehless Method implementation
MatrixBaseAddons.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_TYPES_MATRIXBASEADDONS_HPP_
2 #define MEDUSA_BITS_TYPES_MATRIXBASEADDONS_HPP_
3 
13 enum {
14  dim = RowsAtCompileTime * ColsAtCompileTime };
15 
16 typedef Scalar scalar_t;
17 
19 template<typename OtherDerived>
20 bool operator<(const MatrixBase<OtherDerived>& arg) const {
21  for (int i = 0; i < this->size(); ++i) {
22  if (this->operator[](i) == arg[i]) continue;
23  return this->operator[](i) < arg[i];
24  }
25  return false;
26 }
27 
29 template<typename OtherDerived>
30 bool operator>(const MatrixBase<OtherDerived>& arg) const { return arg < *this; }
31 
33 template<typename OtherDerived>
34 bool operator<=(const MatrixBase<OtherDerived>& arg) const { return !(arg < *this); }
35 
37 template<typename OtherDerived>
38 bool operator>=(const MatrixBase<OtherDerived>& arg) const { return !(*this < arg); }
39 
45 template<class Pred>
46 mm::indexes_t filter(const Pred& pred) const {
47  mm::indexes_t ret;
48  for (int i = 0; i < size(); ++i)
49  if (pred(this->operator[](i))) ret.push_back(i);
50  return ret;
51 }
52 
54 mm::indexes_t operator<(const Scalar& v) const {
55  mm::indexes_t ret;
56  for (int i = 0; i < size(); ++i)
57  if (this->operator[](i) < v) ret.push_back(i);
58  return ret;
59 }
60 
62 mm::indexes_t operator>(const Scalar& v) const {
63  mm::indexes_t ret;
64  for (int i = 0; i < size(); ++i)
65  if (this->operator[](i) > v) ret.push_back(i);
66  return ret;
67 }
68 
70 mm::indexes_t operator<=(const Scalar& v) const {
71  mm::indexes_t ret;
72  for (int i = 0; i < size(); ++i)
73  if (this->operator[](i) <= v) ret.push_back(i);
74  return ret;
75 }
76 
78 mm::indexes_t operator>=(const Scalar& v) const {
79  mm::indexes_t ret;
80  for (int i = 0; i < size(); ++i)
81  if (this->operator[](i) >= v) ret.push_back(i);
82  return ret;
83 }
84 
86 mm::indexes_t operator==(const Scalar& v) const {
87  mm::indexes_t ret;
88  for (int i = 0; i < size(); ++i)
89  if (this->operator[](i) == v) ret.push_back(i);
90  return ret;
91 }
92 
94 mm::indexes_t operator!=(const Scalar& v) const {
95  mm::indexes_t ret;
96  for (int i = 0; i < size(); ++i)
97  if (this->operator[](i) != v) ret.push_back(i);
98  return ret;
99 }
100 
101 #endif // MEDUSA_BITS_TYPES_MATRIXBASEADDONS_HPP_
scalar_t
Scalar scalar_t
Type of the elements, alias of Scalar.
Definition: MatrixBaseAddons.hpp:16
operator>
bool operator>(const MatrixBase< OtherDerived > &arg) const
Lexicographical compare of vectors.
Definition: MatrixBaseAddons.hpp:30
dim
@ dim
Number of elements of this matrix.
Definition: MatrixBaseAddons.hpp:14
operator<
bool operator<(const MatrixBase< OtherDerived > &arg) const
Lexicographical compare of vectors.
Definition: MatrixBaseAddons.hpp:20
operator>=
bool operator>=(const MatrixBase< OtherDerived > &arg) const
Lexicographical compare of vectors.
Definition: MatrixBaseAddons.hpp:38
filter
mm::indexes_t filter(const Pred &pred) const
Returns list of indexes for which predicate returns true.
Definition: MatrixBaseAddons.hpp:46
operator!=
mm::indexes_t operator!=(const Scalar &v) const
Returns list of indexes for which their elements compare not equal to a.
Definition: MatrixBaseAddons.hpp:94
mm::indexes_t
std::vector< int > indexes_t
Class representing a collection of indices.
Definition: Config.hpp:36
operator==
mm::indexes_t operator==(const Scalar &v) const
Returns list of indexes for which their elements compare equal to a.
Definition: MatrixBaseAddons.hpp:86
operator<=
bool operator<=(const MatrixBase< OtherDerived > &arg) const
Lexicographical compare of vectors.
Definition: MatrixBaseAddons.hpp:34