82 void set(
const DT val);
154 this->v[0][0] = this->v[1][1] =
diagValue;
155 this->v[1][0] = this->v[0][1] = 0;
169 this->v[0] =
mat.
v[0];
170 this->v[1] =
mat.v[1];
188 this->v[0][0] =
in00;
189 this->v[0][1] =
in01;
190 this->v[1][0] =
in10;
191 this->v[1][1] =
in11;
197 this->v[0][0] =
static_cast<DT
>(
mat[0]);
198 this->v[0][1] =
static_cast<DT
>(
mat[1]);
199 this->v[1][0] =
static_cast<DT
>(
mat[2]);
200 this->v[1][1] =
static_cast<DT
>(
mat[3]);
206 this->v[0][0] =
static_cast<DT
>(
mat[0]);
207 this->v[0][1] =
static_cast<DT
>(
mat[1]);
208 this->v[1][0] =
static_cast<DT
>(
mat[2]);
209 this->v[1][1] =
static_cast<DT
>(
mat[3]);
217 mat[0] =
static_cast<float>(this->v[0][0]);
218 mat[1] =
static_cast<float>(this->v[0][1]);
219 mat[2] =
static_cast<float>(this->v[1][0]);
220 mat[3] =
static_cast<float>(this->v[1][1]);
228 mat[0] =
static_cast<double>(this->v[0][0]);
229 mat[1] =
static_cast<double>(this->v[0][1]);
230 mat[2] =
static_cast<double>(this->v[1][0]);
231 mat[3] =
static_cast<double>(this->v[1][1]);
237 return Tmat2(val, val, val, val);
243 this->v[0] = this->v[1] =
Tvec2<DT>(val);
255 this->v[0][0] = scale;
258 this->v[1][1] = scale;
270 return this->v[0][0] * this->v[1][1] - this->v[0][1] * this->v[1][0];
283 this->v[1].apply(
fct);
305 "Returning identity");
317 retMat[1][0] = this->v[1][0];
320 retMat[0][1] = this->v[0][1];
352 this->v[0] +=
m.
v[0];
353 this->v[1] +=
m.v[1];
360 this->v[0] -=
m.
v[0];
361 this->v[1] -=
m.v[1];
389#define _ML_MAT2_RC(i, j) a[i][0] * b[0][j] + a[i][1] * b[1][j]
401 return ((a[0] == b[0]) && (a[1] == b[1]));
419 return Tmat2<DT>(a) *=
static_cast<DT
>(-1.0);
459 return Tvec2<DT>(a[0][0] * v[0] + a[0][1] * v[1], a[1][0] * v[0] + a[1][1] * v[1]);
493 template <
class DT>
inline std::ostream&
operator<<(std::ostream&
os,
const ML_LA_NAMESPACE::Tmat2<DT>&
m)
495 return os <<
m[0] <<
'\n' <<
m[1];
499 template <
class DT>
inline std::istream&
operator>>(std::istream& is, ML_LA_NAMESPACE::Tmat2<DT>&
m)
501 ML_LA_NAMESPACE::Tmat2<DT>
m_tmp;
Base class of all matrix classes that holds the data buffer and provides some general access methods.
VectorT v[size]
The rows constituting the matrix.
Declaration of matrix type traits.
Tmat2(const float mat[4])
Constructor from four floating point values in an array given by mat, row by row.
void getValues(double mat[4]) const
Copies the contents of *this into mat, row by row.
Tmat2< DT > transpose() const
Returns the transposed matrix.
Tmat2(const DT in00, const DT in01, const DT in10, const DT in11)
Initializes all matrix elements explicitly with scalars, row by row.
const Tmat2< DT > & operator+=(const Tmat2< DT > &m)
Increments by a Tmat2.
const Tmat2< DT > & operator/=(const DT d)
Divides by a constant d. Division by zero is not handled and must be avoided by caller.
DT det() const
Returns the determinant of this matrix.
const Tmat2< DT > & operator-=(const Tmat2< DT > &m)
Decrements by a Tmat2.
Tmat2< DT > inverse(bool *isInvertible=nullptr) const
Tmat2()
Constructs the matrix from four zero elements.
void setScaleMatrix(const DT scale)
Sets a diagonal matrix with scale on the diagonal.
Tmat2(const Tmat2< DT > &mat)
Copy constructor from the Tmat2 mat.
bool operator<(const Tmat2< DT > &) const
Dummy 'lesser than operator' that always returns false.
const Tmat2< DT > & operator*=(const DT d)
Multiplies by a constant d.
DT ComponentType
A typedef to 'export' the type of components.
const Tmat2< DT > & operator=(const Tmat2< DT > &m)
Assigns from a Tmat2.
void setValues(const double mat[4])
Copies the contents of mat into *this, row by row.
void set(const DT val)
Sets all values to val.
static Tmat2< DT > getIdentity()
Returns the identity matrix.
Tmat2(const Tvec2< DT > &row0, const Tvec2< DT > &row1)
Composes a matrix from the two vectors row0 and row1.
Tmat2(const double mat[4])
Constructor from four double values in an array given by mat, row by row.
Tmat2(const DT diagValue)
Constructs the matrix that has the argument diagValue as the diagonal values, zero otherwise.
const Tmat2< DT > & apply(MLDblFuncPtr fct)
Applies the method fct to all vectors of *this and returns the matrix.
static Tmat2< DT > getMat(const DT val)
Returns a matrix filled with values val.
void getValues(float mat[4]) const
Copies the contents of *this into mat, row by row.
void setValues(const float mat[4])
Copies the contents of mat into *this, row by row.
Declaration of float vector type traits.
bool MLValueIs0WOM(MLint8 a)
Returns true if value is 0; otherwise, it returns false.
#define ML_BAD_PARAMETER
A bad/invalid parameter (or even an inappropriate image) has been passed to a module or an algorithm,...
#define _ML_MAT2_RC(i, j)
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
double(* MLDblFuncPtr)(double)
A function pointer type to a function that returns a double and takes a double as argument.
FloatingPointVector< T, size, DataContainer > operator/(FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs)
Component-wise division of lhs by specialized rhs of type MLdouble.
void ML_UTILS_EXPORT printTemplateError(const char *location, MLErrorCode reason, const std::string_view &handling)
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Returns true if yes.
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
bool operator!=(const Tmat2< DT > &a, const Tmat2< DT > &b)
a != b ? Returns true if yes.
FloatingPointVector< T, size, DataContainer > operator-(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component-wise subtraction of rhs from lhs.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.
istream & operator>>(istream &is, ml::FloatingPointVector< T, size, DataContainer > &v)
Reads a vector from std::istream.