20 #ifndef EXTERIOR_OBJECT_HPP
21 #define EXTERIOR_OBJECT_HPP
26 #include <unsupported/Eigen/KroneckerProduct>
51 template<
size_t l,
size_t d>
58 return _transforms.at(i);
62 static void init() noexcept {
63 static_assert(0 < l && l <= d,
"Error: Tried to generate Koszul basis outside the range [1,d]");
64 if (initialized == 1)
return;
68 for (
size_t i = 0; i < d; ++i) {
69 _transforms[i].setZero();
72 for (
size_t i = 0; i < d; ++i) {
73 _transforms[i](0,i) = 1;
81 std::array<size_t,l> basis_cp;
82 std::copy(cbasis.cbegin(),cbasis.cend(),basis_cp.begin()+1);
84 for (
size_t j = 0; j < d; ++j) {
85 if (try_pos == l-1 || j < cbasis[try_pos]) {
86 basis_cp[try_pos] = j;
89 basis_cp[try_pos] = basis_cp[try_pos+1];
99 static inline int initialized = 0;
100 static inline std::array<ExtAlgMatType,d> _transforms;
104 template<
size_t l,
size_t d>
111 return _transforms.at(i);
116 static_assert(l < d,
"Error: Tried to generate diff basis outside the range [0,d-1]");
117 if (initialized == 1)
return;
120 for (
size_t i = 0; i < d; ++i) {
125 static inline int initialized = 0;
126 static inline std::array<ExtAlgMatType,d> _transforms;
134 template<
size_t d,
size_t index>
136 static Eigen::MatrixXd
get (
const int r) {
137 static_assert(index < d,
"Error: Tried to take the koszul operator on a direction outside the dimension");
141 current.at(index) += 1;
152 template<
size_t d,
size_t index>
154 static Eigen::MatrixXd
get (
const int r) {
155 static_assert(index < d,
"Error: Tried to take the differential operator on a direction outside the dimension");
156 assert(r > 0 &&
"Error: Cannot generate a matrix for the differential on P_0");
160 size_t cval = current.at(index);
161 if (cval == 0)
continue;
162 current.at(index) -= 1;
182 template<
size_t l,
size_t d>
185 static Eigen::MatrixXd
get (
const int r ) {
186 if constexpr (l==0 || l > d) {
187 return Eigen::MatrixXd(0,0);
193 init_loop_for<0>(r,scalar_part,M);
199 template<
size_t i,
typename T>
static void init_loop_for(
int r, T & scalar_part,T & M) {
200 if constexpr(i < d) {
201 scalar_part.setZero();
204 for (
int s = 0; s <= r; ++s) {
212 init_loop_for<i+1>(r,scalar_part,M);
218 template<
size_t l,
size_t d>
221 static Eigen::MatrixXd
get (
const int r ) {
223 return Eigen::MatrixXd(0,0);
229 init_loop_for<0>(r,scalar_part,M);
242 template<
size_t i,
typename T>
static void init_loop_for(
int r,T &scalar_part,T &M) {
243 if constexpr (i < d) {
244 scalar_part.setZero();
247 for (
int s = 0; s < r; ++s) {
255 init_loop_for<i+1>(r,scalar_part,M);
266 init_loop_for<0,1>(r+1);
270 template<
size_t l,
size_t k>
static void init_loop_for(
int r) {
271 if constexpr(k <= d) {
272 if constexpr(l < k) {
274 init_loop_for<l+1,k>(r);
277 init_loop_for<0,k+1>(r);
Diff operator on the exterior algebra.
Definition: exterior_objects.hpp:105
Eigen::Matrix< double, Dimension::ExtDim(l+1, d), Dimension::ExtDim(l, d)> ExtAlgMatType
Definition: exterior_objects.hpp:107
static const ExtAlgMatType & get_transform(size_t i)
Return the action of the Diff operator on the i-th basis of the exterior algebra.
Definition: exterior_objects.hpp:110
static void init() noexcept
Initialize the Diff operator.
Definition: exterior_objects.hpp:115
static const size_t index_from_tuple(const std::array< size_t, l > &tuple)
Search the index corresponding to the given tuple. Throw if not found.
Definition: exterior_algebra.hpp:90
static const std::array< size_t, l > & expand_basis(size_t i)
Return the coefficient of the basis at the given index.
Definition: exterior_algebra.hpp:83
static void init() noexcept
Initialize the exterior algebra basis. Must be called at least once before use.
Definition: exterior_algebra.hpp:66
Koszul operator on the exterior algebra.
Definition: exterior_objects.hpp:52
static const ExtAlgMatType & get_transform(size_t i)
Return the action of the Koszul operator on the i-th basis of the exterior algebra.
Definition: exterior_objects.hpp:57
static void init() noexcept
Initialize the Koszul operator.
Definition: exterior_objects.hpp:62
Eigen::Matrix< double, Dimension::ExtDim(l-1, d), Dimension::ExtDim(l, d)> ExtAlgMatType
Definition: exterior_objects.hpp:54
The methods in this file are meant to compute the action of everything that is independent of the atl...
constexpr size_t ExtDim(size_t l, size_t d)
Dimension of the exterior algebra .
Definition: exterior_dimension.hpp:37
constexpr size_t PLDim(int r, size_t l, size_t d)
Dimension of .
Definition: exterior_dimension.hpp:55
constexpr size_t PolyDim(int r, size_t d)
Dimension of .
Definition: exterior_dimension.hpp:43
constexpr size_t HDim(int r, size_t d)
Dimension of homogeneous polynomials .
Definition: exterior_dimension.hpp:49
Definition: maxwell.hpp:23
Differential operator from to .
Definition: exterior_objects.hpp:219
static Eigen::MatrixXd get_as_degr(const int r)
Differential operator from to .
Definition: exterior_objects.hpp:235
static Eigen::MatrixXd get(const int r)
Differential operator from to .
Definition: exterior_objects.hpp:221
Generate the matrices for the Differential operator on homogeneous monomial.
Definition: exterior_objects.hpp:153
static Eigen::MatrixXd get(const int r)
Definition: exterior_objects.hpp:154
Initialize every class related to the polynomial degree r.
Definition: exterior_objects.hpp:262
static void init(int r)
Initialize up to degree r.
Definition: exterior_objects.hpp:264
Koszul operator from to .
Definition: exterior_objects.hpp:183
static Eigen::MatrixXd get(const int r)
Koszul operator from to .
Definition: exterior_objects.hpp:185
Generate the matrices for the Koszul operator on homogeneous monomial.
Definition: exterior_objects.hpp:135
static Eigen::MatrixXd get(const int r)
Definition: exterior_objects.hpp:136
Generate a basis of monomial powers of degree r.
Definition: exterior_algebra.hpp:304
static std::vector< std::array< size_t, d > > const & homogeneous(const int r)
Basis of homogeneous polynomial of degree r.
Definition: exterior_algebra.hpp:306
static void init(const int r)
Initialise the basis for degree up to r. Must be called at least once before use.
Definition: exterior_algebra.hpp:318