DNA Calib 1.1
Project brief
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
tdm::mat< R, C, T > Struct Template Reference

#include <Mat.h>

Collaboration diagram for tdm::mat< R, C, T >:
Collaboration graph

Public Types

using value_type = T
 
using row_type = vec< C, value_type >
 
using column_type = vec< R, value_type >
 

Public Member Functions

 mat ()
 
 ~mat ()=default
 
 mat (const mat &)=default
 
matoperator= (const mat &)=default
 
 mat (mat &&)=default
 
matoperator= (mat &&)=default
 
template<typename U >
 mat (U scalar)
 
template<typename ... Us, typename std::enable_if< sizeof...(Us)==R *C >::type * = nullptr>
 mat (Us... scalars)
 
template<typename U >
 mat (const mat< R, C, U > &rhs)
 
template<typename U >
matoperator= (const mat< R, C, U > &rhs)
 
template<typename ... Us, typename std::enable_if< sizeof...(Us)==R >::type * = nullptr>
 mat (const vec< C, Us > &... vs)
 
row_typeoperator[] (dim_t index)
 
const row_typeoperator[] (dim_t index) const
 
T & operator() (dim_t rowIndex, dim_t colIndex)
 
const T & operator() (dim_t rowIndex, dim_t colIndex) const
 
template<typename F >
matapply (F func)
 
template<typename F >
const matapply (F func) const
 
matoperator++ ()
 
matoperator-- ()
 
template<typename U >
matoperator+= (U rhs)
 
template<typename U >
matoperator+= (const mat< R, C, U > &rhs)
 
matoperator+= (const mat &rhs)
 
template<typename U >
matoperator-= (U rhs)
 
template<typename U >
matoperator-= (const mat< R, C, U > &rhs)
 
matoperator-= (const mat &rhs)
 
template<typename U >
matoperator*= (U rhs)
 
template<typename U >
matoperator*= (const mat< R, C, U > &rhs)
 
matoperator*= (const mat &rhs)
 
template<typename U >
matoperator/= (U rhs)
 
template<typename U >
matoperator/= (const mat< R, C, U > &rhs)
 
matoperator/= (const mat &rhs)
 
template<typename ... , dim_t H = R, dim_t W = C>
std::enable_if< H==W, mat & >::type transpose ()
 
matnegate ()
 
row_type row (dim_t index) const
 
column_type column (dim_t index) const
 
template<dim_t H, dim_t W>
std::enable_if<(H >1 &&W >1 &&H<=R &&W<=C), mat< H, W, T > >::type submat (dim_t y, dim_t x) const
 

Static Public Member Functions

static constexpr dim_t rows ()
 
static constexpr dim_t columns ()
 
template<typename ... Us, typename std::enable_if< sizeof...(Us)==R >::type * = nullptr>
static mat fromRows (const vec< C, Us > &... vs)
 
template<typename ... Us, typename std::enable_if< sizeof...(Us)==C >::type * = nullptr>
static mat fromColumns (const vec< R, Us > &... vs)
 
template<typename U , typename ... , dim_t H = R, dim_t W = C>
static std::enable_if< H==W, mat >::type diagonal (U scalar)
 
template<typename U , typename ... , dim_t H = R, dim_t W = C>
static std::enable_if< H==W, mat >::type diagonal (const vec< W, U > &scalars)
 
template<typename ... Us, dim_t H = R, dim_t W = C>
static std::enable_if<(H==W)&&(sizeof...(Us)==H), mat >::type diagonal (Us... scalars)
 
template<typename ... , dim_t H = R, dim_t W = C>
static std::enable_if< H==W, mat >::type identity ()
 

Private Attributes

row_type values [R]
 

Member Typedef Documentation

◆ column_type

template<dim_t R, dim_t C, typename T >
using tdm::mat< R, C, T >::column_type = vec<R, value_type>

◆ row_type

template<dim_t R, dim_t C, typename T >
using tdm::mat< R, C, T >::row_type = vec<C, value_type>

◆ value_type

template<dim_t R, dim_t C, typename T >
using tdm::mat< R, C, T >::value_type = T

Constructor & Destructor Documentation

◆ mat() [1/7]

template<dim_t R, dim_t C, typename T >
tdm::mat< R, C, T >::mat ( )
inline
34 : values{} {
35 }
row_type values[R]
Definition: Mat.h:31

◆ ~mat()

template<dim_t R, dim_t C, typename T >
tdm::mat< R, C, T >::~mat ( )
default

◆ mat() [2/7]

template<dim_t R, dim_t C, typename T >
tdm::mat< R, C, T >::mat ( const mat< R, C, T > &  )
default

◆ mat() [3/7]

template<dim_t R, dim_t C, typename T >
tdm::mat< R, C, T >::mat ( mat< R, C, T > &&  )
default

◆ mat() [4/7]

template<dim_t R, dim_t C, typename T >
template<typename U >
tdm::mat< R, C, T >::mat ( scalar)
inlineexplicit
46 {
47 apply([scalar](row_type& row, dim_t /*unused*/) {
48 row = row_type{scalar};
49 });
50 }
std::size_t dim_t
Definition: Types.h:22
row_type row(dim_t index) const
Definition: Mat.h:247
mat & apply(F func)
Definition: Mat.h:140
vec< C, value_type > row_type
Definition: Mat.h:19

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ mat() [5/7]

template<dim_t R, dim_t C, typename T >
template<typename ... Us, typename std::enable_if< sizeof...(Us)==R *C >::type * = nullptr>
tdm::mat< R, C, T >::mat ( Us...  scalars)
inline
53 {
54 T tmp[sizeof...(Us)] = {static_cast<T>(scalars)...};
55 apply([&tmp](row_type& row, dim_t ri) {
56 row.apply([&tmp, ri](value_type& value, dim_t ci) {
57 value = tmp[ri * columns() + ci];
58 });
59 });
60 }
static constexpr dim_t columns()
Definition: Mat.h:26
T value_type
Definition: Mat.h:18
vec & apply(F func)
Definition: Vec.h:68

References tdm::mat< R, C, T >::apply(), tdm::vec< L, T >::apply(), tdm::mat< R, C, T >::columns(), and tdm::mat< R, C, T >::row().

◆ mat() [6/7]

template<dim_t R, dim_t C, typename T >
template<typename U >
tdm::mat< R, C, T >::mat ( const mat< R, C, U > &  rhs)
inline
63 {
64 apply([&rhs](row_type& row, dim_t ri) {
65 row = rhs[ri];
66 });
67 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ mat() [7/7]

template<dim_t R, dim_t C, typename T >
template<typename ... Us, typename std::enable_if< sizeof...(Us)==R >::type * = nullptr>
tdm::mat< R, C, T >::mat ( const vec< C, Us > &...  vs)
inline
75 : values{row_type{vs} ...} {
76 }

Member Function Documentation

◆ apply() [1/2]

template<dim_t R, dim_t C, typename T >
template<typename F >
mat & tdm::mat< R, C, T >::apply ( func)
inline

◆ apply() [2/2]

template<dim_t R, dim_t C, typename T >
template<typename F >
const mat & tdm::mat< R, C, T >::apply ( func) const
inline
148 {
149 for (dim_t ri{}; ri != rows(); ++ri) {
150 func(values[ri], ri);
151 }
152 return *this;
153 }

References tdm::mat< R, C, T >::rows(), and tdm::mat< R, C, T >::values.

◆ column()

template<dim_t R, dim_t C, typename T >
column_type tdm::mat< R, C, T >::column ( dim_t  index) const
inline
251 {
252 column_type col;
253 apply([&col, index](const row_type& row, dim_t ri) {
254 col[ri] = row[index];
255 });
256 return col;
257 }
vec< R, value_type > column_type
Definition: Mat.h:20

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

Referenced by tdm::operator*().

◆ columns()

template<dim_t R, dim_t C, typename T >
static constexpr dim_t tdm::mat< R, C, T >::columns ( )
inlinestaticconstexpr
26 {
27 return row_type::dimensions();
28 }
static constexpr dim_t dimensions()
Definition: Vec.h:13

References tdm::vec< C, value_type >::dimensions().

Referenced by tdm::mat< R, C, T >::mat(), and tdm::mat< R, C, T >::submat().

◆ diagonal() [1/3]

template<dim_t R, dim_t C, typename T >
template<typename U , typename ... , dim_t H = R, dim_t W = C>
static std::enable_if< H==W, mat >::type tdm::mat< R, C, T >::diagonal ( const vec< W, U > &  scalars)
inlinestatic
99 {
100 mat ret;
101 ret.apply([&scalars](row_type& row, dim_t ri) {
102 row[ri] = scalars[ri];
103 });
104 return ret;
105 }
mat()
Definition: Mat.h:34

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ diagonal() [2/3]

template<dim_t R, dim_t C, typename T >
template<typename U , typename ... , dim_t H = R, dim_t W = C>
static std::enable_if< H==W, mat >::type tdm::mat< R, C, T >::diagonal ( scalar)
inlinestatic
90 {
91 mat ret;
92 ret.apply([scalar](row_type& row, dim_t ri) {
93 row[ri] = scalar;
94 });
95 return ret;
96 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

Referenced by tdm::mat< R, C, T >::diagonal(), tdm::mat< R, C, T >::identity(), and tdm::affine::scale().

◆ diagonal() [3/3]

template<dim_t R, dim_t C, typename T >
template<typename ... Us, dim_t H = R, dim_t W = C>
static std::enable_if<(H==W)&&(sizeof...(Us)==H), mat >::type tdm::mat< R, C, T >::diagonal ( Us...  scalars)
inlinestatic
108 {
109 return diagonal(vec<R, T>{scalars ...});
110 }
static std::enable_if< H==W, mat >::type diagonal(U scalar)
Definition: Mat.h:90

References tdm::mat< R, C, T >::diagonal().

◆ fromColumns()

template<dim_t R, dim_t C, typename T >
template<typename ... Us, typename std::enable_if< sizeof...(Us)==C >::type * = nullptr>
static mat tdm::mat< R, C, T >::fromColumns ( const vec< R, Us > &...  vs)
inlinestatic
84 {
85 mat<sizeof...(vs), R, T> tmp{vs ...};
86 return tdm::transpose(tmp);
87 }
mat< C, R, T > transpose(const mat< R, C, T > &m)
Definition: Computations.h:57

References tdm::transpose().

◆ fromRows()

template<dim_t R, dim_t C, typename T >
template<typename ... Us, typename std::enable_if< sizeof...(Us)==R >::type * = nullptr>
static mat tdm::mat< R, C, T >::fromRows ( const vec< C, Us > &...  vs)
inlinestatic
79 {
80 return mat{vs ...};
81 }

◆ identity()

template<dim_t R, dim_t C, typename T >
template<typename ... , dim_t H = R, dim_t W = C>
static std::enable_if< H==W, mat >::type tdm::mat< R, C, T >::identity ( )
inlinestatic
113 {
114 return diagonal(static_cast<T>(1));
115 }

References tdm::mat< R, C, T >::diagonal().

Referenced by dnac::extractTranslationMatrix().

◆ negate()

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::negate ( )
inline
240 {
241 apply([](row_type& row, dim_t /*unused*/) {
242 row.negate();
243 });
244 return *this;
245 }
vec & negate()
Definition: Vec.h:178

References tdm::mat< R, C, T >::apply(), tdm::vec< L, T >::negate(), and tdm::mat< R, C, T >::row().

◆ operator()() [1/2]

template<dim_t R, dim_t C, typename T >
T & tdm::mat< R, C, T >::operator() ( dim_t  rowIndex,
dim_t  colIndex 
)
inline
131 {
132 return operator[](rowIndex)[colIndex];
133 }
row_type & operator[](dim_t index)
Definition: Mat.h:117

References tdm::mat< R, C, T >::operator[]().

◆ operator()() [2/2]

template<dim_t R, dim_t C, typename T >
const T & tdm::mat< R, C, T >::operator() ( dim_t  rowIndex,
dim_t  colIndex 
) const
inline
135 {
136 return operator[](rowIndex)[colIndex];
137 }

References tdm::mat< R, C, T >::operator[]().

◆ operator*=() [1/3]

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::operator*= ( const mat< R, C, T > &  rhs)
inline
215 {
216 return operator*=<T>(rhs);
217 }

◆ operator*=() [2/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator*= ( const mat< R, C, U > &  rhs)
inline
211 {
212 return (*this = *this * rhs);
213 }

◆ operator*=() [3/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator*= ( rhs)
inline
204 {
205 return apply([rhs](row_type& row, dim_t /*unused*/) {
206 row *= rhs;
207 });
208 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

Referenced by tdm::mat< R, C, T >::operator/=().

◆ operator++()

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::operator++ ( )
inline
155 {
156 return apply([](row_type& row, dim_t /*unused*/) {
157 ++row;
158 });
159 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ operator+=() [1/3]

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::operator+= ( const mat< R, C, T > &  rhs)
inline
181 {
182 return operator+=<T>(rhs);
183 }

◆ operator+=() [2/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator+= ( const mat< R, C, U > &  rhs)
inline
175 {
176 return apply([&rhs](row_type& row, dim_t ri) {
177 row += rhs[ri];
178 });
179 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ operator+=() [3/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator+= ( rhs)
inline
168 {
169 return apply([rhs](row_type& row, dim_t /*unused*/) {
170 row += rhs;
171 });
172 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ operator--()

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::operator-- ( )
inline
161 {
162 return apply([](row_type& row, dim_t /*unused*/) {
163 --row;
164 });
165 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ operator-=() [1/3]

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::operator-= ( const mat< R, C, T > &  rhs)
inline
199 {
200 return operator-=<T>(rhs);
201 }

◆ operator-=() [2/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator-= ( const mat< R, C, U > &  rhs)
inline
193 {
194 return apply([&rhs](row_type& row, dim_t ri) {
195 row -= rhs[ri];
196 });
197 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ operator-=() [3/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator-= ( rhs)
inline
186 {
187 return apply([rhs](row_type& row, dim_t /*unused*/) {
188 row -= rhs;
189 });
190 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ operator/=() [1/3]

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::operator/= ( const mat< R, C, T > &  rhs)
inline
231 {
232 return operator/=<T>(rhs);
233 }

◆ operator/=() [2/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator/= ( const mat< R, C, U > &  rhs)
inline
227 {
228 return operator*=(inverse(rhs));
229 }
mat< N, N, T > inverse(const mat< N, N, T > &m)
Definition: Computations.h:134
mat & operator*=(U rhs)
Definition: Mat.h:204

References tdm::inverse(), and tdm::mat< R, C, T >::operator*=().

◆ operator/=() [3/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator/= ( rhs)
inline
220 {
221 return apply([rhs](row_type& row, dim_t /*unused*/) {
222 row /= rhs;
223 });
224 }

References tdm::mat< R, C, T >::apply(), and tdm::mat< R, C, T >::row().

◆ operator=() [1/3]

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::operator= ( const mat< R, C, T > &  )
default

◆ operator=() [2/3]

template<dim_t R, dim_t C, typename T >
template<typename U >
mat & tdm::mat< R, C, T >::operator= ( const mat< R, C, U > &  rhs)
inline
70 {
71 return operator=(mat<R, C, T>{rhs});
72 }
mat & operator=(const mat &)=default

References tdm::mat< R, C, T >::operator=().

◆ operator=() [3/3]

template<dim_t R, dim_t C, typename T >
mat & tdm::mat< R, C, T >::operator= ( mat< R, C, T > &&  )
default

◆ operator[]() [1/2]

template<dim_t R, dim_t C, typename T >
row_type & tdm::mat< R, C, T >::operator[] ( dim_t  index)
inline
117 {
118 // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay)
119 assert(index < rows());
120 // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index)
121 return values[index];
122 }

References tdm::mat< R, C, T >::rows(), and tdm::mat< R, C, T >::values.

Referenced by tdm::mat< R, C, T >::operator()(), and tdm::mat< R, C, T >::row().

◆ operator[]() [2/2]

template<dim_t R, dim_t C, typename T >
const row_type & tdm::mat< R, C, T >::operator[] ( dim_t  index) const
inline
124 {
125 // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay)
126 assert(index < rows());
127 // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index)
128 return values[index];
129 }

References tdm::mat< R, C, T >::rows(), and tdm::mat< R, C, T >::values.

◆ row()

template<dim_t R, dim_t C, typename T >
row_type tdm::mat< R, C, T >::row ( dim_t  index) const
inline

◆ rows()

template<dim_t R, dim_t C, typename T >
static constexpr dim_t tdm::mat< R, C, T >::rows ( )
inlinestaticconstexpr

◆ submat()

template<dim_t R, dim_t C, typename T >
template<dim_t H, dim_t W>
std::enable_if<(H >1 &&W >1 &&H<=R &&W<=C), mat< H, W, T > >::type tdm::mat< R, C, T >::submat ( dim_t  y,
dim_t  x 
) const
inline
260 {
261 assert(H + y <= rows());
262 assert(W + x <= columns());
263 mat<H, W, T> ret;
264 ret.apply([this, y, x](typename mat<H, W, T>::row_type& row, dim_t ri) {
265 row.apply([this, y, x, ri](value_type& value, dim_t ci) {
266 value = values[y + ri][x + ci];
267 });
268 });
269 return ret;
270 }

References tdm::mat< R, C, T >::apply(), tdm::vec< L, T >::apply(), tdm::mat< R, C, T >::columns(), tdm::mat< R, C, T >::row(), tdm::mat< R, C, T >::rows(), and tdm::mat< R, C, T >::values.

◆ transpose()

template<dim_t R, dim_t C, typename T >
template<typename ... , dim_t H = R, dim_t W = C>
std::enable_if< H==W, mat & >::type tdm::mat< R, C, T >::transpose ( )
inline
236 {
237 return (*this = tdm::transpose(*this));
238 }

References tdm::transpose().

Member Data Documentation

◆ values

template<dim_t R, dim_t C, typename T >
row_type tdm::mat< R, C, T >::values[R]
private

The documentation for this struct was generated from the following file: