Add geom::matrix::diagonal
This commit is contained in:
parent
64b3e876ad
commit
cae538d7a5
1 changed files with 10 additions and 0 deletions
|
|
@ -48,6 +48,7 @@ namespace psemek::geom
|
||||||
static matrix zero();
|
static matrix zero();
|
||||||
static matrix identity();
|
static matrix identity();
|
||||||
static matrix scalar(T const & s);
|
static matrix scalar(T const & s);
|
||||||
|
static matrix diagonal(vector<T, std::min(R, C)> const & d);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, std::size_t R, std::size_t C>
|
template <typename T, std::size_t R, std::size_t C>
|
||||||
|
|
@ -74,6 +75,15 @@ namespace psemek::geom
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, std::size_t R, std::size_t C>
|
||||||
|
matrix<T, R, C> matrix<T, R, C>::diagonal(vector<T, std::min(R, C)> const & d)
|
||||||
|
{
|
||||||
|
matrix<T, R, C> m = zero();
|
||||||
|
for (std::size_t i = 0; i < std::min(R, C); ++i)
|
||||||
|
m[i][i] = d[i];
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t R, std::size_t C>
|
template <typename T, std::size_t R, std::size_t C>
|
||||||
bool operator == (matrix<T, R, C> const & m1, matrix<T, R, C> const & m2)
|
bool operator == (matrix<T, R, C> const & m1, matrix<T, R, C> const & m2)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue