IDS peak ICV v1.2.0
Loading...
Searching...
No Matches
peak_icv_matrix.hpp
Go to the documentation of this file.
1
11#pragma once
12
14
15namespace peak
16{
17namespace icv
18{
19
33template <typename Type, std::size_t rows, std::size_t columns>
34class Matrix : public Array2D<Type, rows, columns>
35{
36public:
37 using Array2D<Type, rows, columns>::Array2D; // NOLINT
38
45 {
46 return Matrix::Diagonal(static_cast<Type>(1));
47 }
48
58 static Matrix Diagonal(const Type& value)
59 {
60 static_assert(rows == columns, "Matrix must be symmetrical!");
61
62 Matrix result;
63
64 for (size_t i = 0; i < rows; ++i)
65 {
66 result.At(i, i) = static_cast<Type>(value);
67 }
68
69 return result;
70 }
71};
72
73} /* namespace icv */
74} /* namespace peak */
A class template for a two-dimensional array.
constexpr Array2D()
Default constructor that initializes the array with default values.
constexpr Type & At(std::size_t row, std::size_t col)
Accesses the element at the specified row and column.
A class template for a two-dimensional matrix.
static Matrix Identity()
Creates and returns an identity matrix.
static Matrix Diagonal(const Type &value)
Constructs a uniform diagonal matrix.