[ADVANCED INITIALISATION] implemented and tested the static methods

Co-authored-by: kallore <kkaspar@codereckons.com>

See merge request oss/rotgen!4
This commit is contained in:
Karen Kaspar 2025-05-20 20:56:39 +02:00 committed by Joel Falcou
parent 03591ac323
commit ab8336bd5b
4 changed files with 191 additions and 3 deletions

View file

@ -70,7 +70,12 @@ namespace rotgen
const double* data() const;
private:
static matrix_impl64 Zero(std::size_t rows, std::size_t cols);
static matrix_impl64 Constant(std::size_t rows, std::size_t cols, double value);
static matrix_impl64 Random(std::size_t rows, std::size_t cols);
static matrix_impl64 Identity(std::size_t rows, std::size_t cols);
private:
struct payload;
std::unique_ptr<payload> storage_;
};

View file

@ -118,6 +118,58 @@ namespace rotgen
static_cast<parent&>(*this) /= rhs;
return *this;
}
static matrix Zero()
requires (Rows != -1 && Cols != -1)
{
return parent::Zero(Rows, Cols);
}
static matrix Zero(int rows, int cols)
{
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
return parent::Zero(rows, cols);
}
static matrix Constant(Scalar value)
requires (Rows != -1 && Cols != -1)
{
return parent::Constant(Rows, Cols, static_cast<double>(value));
}
static matrix Constant(int rows, int cols, Scalar value)
{
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
return parent::Constant(rows, cols, static_cast<double>(value));
}
static matrix Random()
requires (Rows != -1 && Cols != -1)
{
return parent::Random(Rows, Cols);
}
static matrix Random(int rows, int cols)
{
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
return parent::Random(rows, cols);
}
static matrix Identity()
requires (Rows != -1 && Cols != -1)
{
return parent::Identity(Rows, Cols);
}
static matrix Identity(int rows, int cols)
{
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
return parent::Identity(rows, cols);
}
};
template<typename S, int R, int C, int O, int MR, int MC>