Infrastructure de base
This commit is contained in:
parent
d901e17fa8
commit
491addb201
7 changed files with 296 additions and 0 deletions
82
src/matrix_impl64.cpp
Normal file
82
src/matrix_impl64.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include <rotgen/matrix.hpp>
|
||||
#include <Eigen/Dense>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
struct matrix_impl64::payload
|
||||
{
|
||||
Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> data;
|
||||
payload(std::size_t r=0, std::size_t c=0) : data(r, c) {}
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os,matrix_impl64 const& m)
|
||||
{
|
||||
return os << m.storage_->data;
|
||||
}
|
||||
|
||||
matrix_impl64::matrix_impl64(std::size_t r, std::size_t c)
|
||||
: storage_(std::make_unique<payload>(r,c))
|
||||
{}
|
||||
|
||||
matrix_impl64::matrix_impl64(matrix_impl64 const& o)
|
||||
: matrix_impl64(o.storage_->data.rows(),o.storage_->data.cols())
|
||||
{
|
||||
storage_->data = o.storage_->data;
|
||||
}
|
||||
|
||||
matrix_impl64& matrix_impl64::operator=(matrix_impl64 const& o)
|
||||
{
|
||||
if (this != &o) storage_->data = o.storage_->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
matrix_impl64::matrix_impl64(matrix_impl64&&) noexcept = default;
|
||||
matrix_impl64& matrix_impl64::operator=(matrix_impl64&&) noexcept = default;
|
||||
|
||||
matrix_impl64::~matrix_impl64() = default;
|
||||
|
||||
std::size_t matrix_impl64::rows() const
|
||||
{
|
||||
return static_cast<std::size_t>(storage_->data.rows());
|
||||
}
|
||||
|
||||
std::size_t matrix_impl64::cols() const
|
||||
{
|
||||
return static_cast<std::size_t>(storage_->data.cols());
|
||||
}
|
||||
|
||||
double& matrix_impl64::operator()(std::size_t i, std::size_t j)
|
||||
{
|
||||
return storage_->data(i,j);
|
||||
}
|
||||
|
||||
double const& matrix_impl64::operator()(std::size_t i, std::size_t j) const
|
||||
{
|
||||
return storage_->data(i,j);
|
||||
}
|
||||
|
||||
matrix_impl64& matrix_impl64::operator+=(matrix_impl64 const& rhs)
|
||||
{
|
||||
storage_->data += rhs.storage_->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
matrix_impl64& matrix_impl64::operator*=(matrix_impl64 const& rhs)
|
||||
{
|
||||
storage_->data *= rhs.storage_->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
matrix_impl64& matrix_impl64::operator*=(double s)
|
||||
{
|
||||
storage_->data *= s;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue