parent
5d8a084070
commit
b6fcd4b341
34 changed files with 972 additions and 139 deletions
|
|
@ -11,8 +11,6 @@
|
|||
This file is a X-File to generate various block_impl_* definitions variant
|
||||
*/
|
||||
//==================================================================================================
|
||||
#define STR(text) STR_I(text)
|
||||
#define STR_I(...) #__VA_ARGS__
|
||||
|
||||
//==================================================================================================
|
||||
// Internal payload
|
||||
|
|
@ -107,7 +105,11 @@ struct CLASSNAME::payload
|
|||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator=(CLASSNAME&&) noexcept = default;
|
||||
CLASSNAME& CLASSNAME::operator=(CLASSNAME&& o) noexcept
|
||||
{
|
||||
if (this != &o) { storage_->data = std::move(o.storage_->data); }
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <rotgen/impl/map.hpp>
|
||||
#include <rotgen/impl/payload.hpp>
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/LU>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,19 +2,23 @@
|
|||
#define TYPE double
|
||||
#define STORAGE_ORDER Eigen::ColMajor
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include "map_model.cpp"
|
||||
#undef CLASSNAME
|
||||
#undef CLASSCONSTNAME
|
||||
#undef SOURCENAME
|
||||
#undef STORAGE_ORDER
|
||||
|
||||
#define STORAGE_ORDER Eigen::RowMajor
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include "map_model.cpp"
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
#undef STORAGE_ORDER
|
||||
|
||||
#undef SIZE
|
||||
|
|
@ -24,18 +28,22 @@
|
|||
#define TYPE float
|
||||
#define STORAGE_ORDER Eigen::ColMajor
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include "map_model.cpp"
|
||||
#undef CLASSNAME
|
||||
#undef CLASSCONSTNAME
|
||||
#undef SOURCENAME
|
||||
#undef STORAGE_ORDER
|
||||
|
||||
#define STORAGE_ORDER Eigen::RowMajor
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include "map_model.cpp"
|
||||
#undef CLASSNAME
|
||||
#undef CLASSCONSTNAME
|
||||
#undef SOURCENAME
|
||||
#undef STORAGE_ORDER
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,15 @@
|
|||
if (this != &o) storage_->data = o.storage_->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator=(CLASSNAME&& o)
|
||||
{
|
||||
if (this != &o) storage_->data = std::move(o.storage_->data);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
CLASSNAME::CLASSNAME(CLASSNAME&&) noexcept = default;
|
||||
CLASSNAME& CLASSNAME::operator=(CLASSNAME&&) noexcept = default;
|
||||
|
||||
CLASSNAME::~CLASSNAME() = default;
|
||||
|
||||
|
|
@ -160,6 +165,13 @@
|
|||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::inverse() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.inverse().eval());
|
||||
return result;
|
||||
}
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
void CLASSNAME::normalize()
|
||||
{
|
||||
|
|
@ -267,18 +279,36 @@
|
|||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator+=(CLASSCONSTNAME const& rhs)
|
||||
{
|
||||
storage_->data += rhs.storage()->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator-=(CLASSNAME const& rhs)
|
||||
{
|
||||
storage_->data -= rhs.storage_->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator-=(CLASSCONSTNAME const& rhs)
|
||||
{
|
||||
storage_->data -= rhs.storage()->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator*=(CLASSNAME const& rhs)
|
||||
{
|
||||
storage_->data *= rhs.storage_->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator*=(CLASSCONSTNAME const& rhs)
|
||||
{
|
||||
storage_->data *= rhs.storage()->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator*=(TYPE s)
|
||||
{
|
||||
storage_->data *= s;
|
||||
|
|
|
|||
61
src/svd.cpp
Normal file
61
src/svd.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include <rotgen/detail/generators.hpp>
|
||||
#include <rotgen/impl/matrix.hpp>
|
||||
#include <rotgen/impl/payload.hpp>
|
||||
#include <rotgen/impl/svd.hpp>
|
||||
#include <rotgen/config.hpp>
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/SVD>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
#define SIZE 64
|
||||
#define TYPE double
|
||||
#define STORAGE_ORDER Eigen::ColMajor
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include "svd_model.cpp"
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#undef STORAGE_ORDER
|
||||
|
||||
#define STORAGE_ORDER Eigen::RowMajor
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include "svd_model.cpp"
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#undef STORAGE_ORDER
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
#define STORAGE_ORDER Eigen::ColMajor
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include "svd_model.cpp"
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#undef STORAGE_ORDER
|
||||
|
||||
#define STORAGE_ORDER Eigen::RowMajor
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include "svd_model.cpp"
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#undef STORAGE_ORDER
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
}
|
||||
111
src/svd_model.cpp
Normal file
111
src/svd_model.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
|
||||
//==================================================================================================
|
||||
/*
|
||||
This file is a X-File to generate various svd_impl_* definitions variant
|
||||
*/
|
||||
//==================================================================================================
|
||||
|
||||
//==================================================================================================
|
||||
// Internal payload
|
||||
//==================================================================================================
|
||||
struct CLASSNAME::payload
|
||||
{
|
||||
using matrix_type = Eigen::Matrix<TYPE,Eigen::Dynamic,Eigen::Dynamic,STORAGE_ORDER>;
|
||||
Eigen::JacobiSVD<matrix_type> data;
|
||||
|
||||
payload(SOURCENAME const& src, int options) : data(src.storage()->data,options) {}
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
// Constructors & Special Members
|
||||
//==================================================================================================
|
||||
CLASSNAME::CLASSNAME(SOURCENAME const& m, int options)
|
||||
: storage_(std::make_unique<payload>(m,options))
|
||||
{}
|
||||
|
||||
|
||||
CLASSNAME::CLASSNAME(CLASSNAME const& o)
|
||||
: storage_(std::make_unique<payload>(*o.storage_))
|
||||
{
|
||||
}
|
||||
|
||||
CLASSNAME::CLASSNAME(CLASSNAME&&) noexcept = default;
|
||||
|
||||
CLASSNAME& CLASSNAME::operator=(CLASSNAME const& o)
|
||||
{
|
||||
if (this != &o) storage_->data = o.storage_->data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME& CLASSNAME::operator=(CLASSNAME&& o) noexcept
|
||||
{
|
||||
if (this != &o) storage_->data = std::move(o.storage_->data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLASSNAME::~CLASSNAME() = default;
|
||||
|
||||
int CLASSNAME::rank() const { return storage_->data.rank(); }
|
||||
|
||||
SOURCENAME CLASSNAME::U() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.matrixU());
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::U(int r) const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign( storage_->data.matrixU().leftCols(r) );
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::singular_values() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.singularValues());
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::singular_values(int r) const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.singularValues().head(r));
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::D() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.singularValues().asDiagonal());
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::D(int r) const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.singularValues().head(r).asDiagonal());
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::V() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.matrixV());
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::V(int r) const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign( storage_->data.matrixV().leftCols(r) );
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue