Infrastructure de base

This commit is contained in:
Joel Falcou 2025-05-07 17:01:58 +02:00
parent d901e17fa8
commit 491addb201
7 changed files with 296 additions and 0 deletions

View file

@ -0,0 +1,43 @@
//==================================================================================================
/*
ROTGEN - Runtime Overlay for Eigen
Copyright : CODE RECKONS
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#pragma once
#include <memory>
#include <cstddef>
namespace rotgen
{
class matrix_impl64
{
public:
matrix_impl64(std::size_t rows = 0, std::size_t cols = 0);
matrix_impl64(matrix_impl64 const& other);
matrix_impl64& operator=(matrix_impl64 const& other);
matrix_impl64(matrix_impl64&&) noexcept;
matrix_impl64& operator=(matrix_impl64&&) noexcept;
~matrix_impl64();
std::size_t rows() const;
std::size_t cols() const;
double& operator()(std::size_t i, std::size_t j);
double const& operator()(std::size_t i, std::size_t j) const;
matrix_impl64& operator+=(matrix_impl64 const& rhs);
matrix_impl64& operator*=(matrix_impl64 const& rhs);
matrix_impl64& operator*=(double d);
friend std::ostream& operator<<(std::ostream&,matrix_impl64 const&);
private:
struct payload;
std::unique_ptr<payload> storage_;
};
}

49
include/rotgen/matrix.hpp Normal file
View file

@ -0,0 +1,49 @@
//==================================================================================================
/*
ROTGEN - Runtime Overlay for Eigen
Copyright : CODE RECKONS
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#pragma once
#include <rotgen/impl/matrix_impl64.hpp>
namespace rotgen
{
template<typename Scalar, int Rows = -1, int Cols = -1>
class matrix : public matrix_impl64
{
using parent = matrix_impl64;
public:
matrix() : parent(Rows==-1?0:Rows,Cols==-1?0:Cols) {}
matrix(std::size_t r, std::size_t c) : parent(r,c) {}
matrix& operator+=(matrix const& rhs)
{
static_cast<parent&>(*this) += static_cast<parent const&>(rhs);
return *this;
}
matrix& operator*=(matrix const& rhs)
{
static_cast<parent&>(*this) *= static_cast<parent const&>(rhs);
return *this;
}
};
template<typename S, int R, int C>
matrix<S,R,C> operator+(matrix<S,R,C> const& lhs, matrix<S,R,C> const& rhs)
{
matrix<S,R,C> that(lhs);
return that += rhs;
}
template<typename S, int R, int C>
matrix<S,R,C> operator*(matrix<S,R,C> const& lhs, matrix<S,R,C> const& rhs)
{
matrix<S,R,C> that(lhs);
return that *= rhs;
}
}