1#ifndef _GLUCAT_FRAMED_MULTI_H
2#define _GLUCAT_FRAMED_MULTI_H
40#if defined(_GLUCAT_USE_BOOST_POOL_ALLOC)
42#include <boost/pool/poolfwd.hpp>
48#include <unordered_map>
55 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
58 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
62 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
64 operator* (
const framed_multi<Scalar_T,LO,HI,Tune_P>& lhs,
const framed_multi<Scalar_T,LO,HI,Tune_P>& rhs) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
67 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
69 operator^ (
const framed_multi<Scalar_T,LO,HI,Tune_P>& lhs,
const framed_multi<Scalar_T,LO,HI,Tune_P>& rhs) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
72 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
74 operator& (
const framed_multi<Scalar_T,LO,HI,Tune_P>& lhs,
const framed_multi<Scalar_T,LO,HI,Tune_P>& rhs) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
77 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
79 operator% (
const framed_multi<Scalar_T,LO,HI,Tune_P>& lhs,
const framed_multi<Scalar_T,LO,HI,Tune_P>& rhs) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
82 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
84 star(
const framed_multi<Scalar_T,LO,HI,Tune_P>& lhs,
const framed_multi<Scalar_T,LO,HI,Tune_P>& rhs) -> Scalar_T;
87 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
89 operator/ (
const framed_multi<Scalar_T,LO,HI,Tune_P>& lhs,
const framed_multi<Scalar_T,LO,HI,Tune_P>& rhs) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
92 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
94 operator| (
const framed_multi<Scalar_T,LO,HI,Tune_P>& lhs,
const framed_multi<Scalar_T,LO,HI,Tune_P>& rhs) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
97 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
99 operator>> (std::istream& s, framed_multi<Scalar_T,LO,HI,Tune_P>& val) -> std::istream&;
102 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
104 operator<< (std::ostream& os,
const framed_multi<Scalar_T,LO,HI,Tune_P>& val) -> std::ostream&;
107 template<
typename Scalar_T, const index_t LO, const index_t HI >
109 operator<< (std::ostream& os,
const std::pair<
const index_set<LO,HI>, Scalar_T >& term) -> std::ostream&;
112 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
114 exp(
const framed_multi<Scalar_T,LO,HI,Tune_P>& val) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
116 template< const index_t LO, const index_t HI>
125 template<
typename Scalar_T =
double, const index_t LO = DEFAULT_LO, const index_t HI = DEFAULT_HI,
typename Tune_P = tuning<> >
127 public clifford_algebra< Scalar_T, index_set<LO,HI>, framed_multi<Scalar_T,LO,HI,Tune_P> >,
128 private std::unordered_map< index_set<LO,HI>, Scalar_T, index_set_hash<LO,HI> >
136 using term_t = std::pair<const index_set_t, Scalar_T>;
140 template<
typename Other_Scalar_T, const index_t Other_LO, const index_t Other_HI,
typename Other_Tune_P >
142 template<
typename Other_Scalar_T, const index_t Other_LO, const index_t Other_HI,
typename Other_Tune_P >
149 using sorted_map_t = std::map< index_set_t, Scalar_T, std::less<const index_set_t> >;
150 using map_t = std::unordered_map<index_set_t, Scalar_T, index_set_hash<LO, HI>>;
171 static auto classname() ->
const std::string;
182 template<
typename Other_Scalar_T >
185 template<
typename Other_Scalar_T >
187 const index_set_t frm,
const bool prechecked =
false);
190 const index_set_t frm,
const bool prechecked =
false);
195 const index_set_t frm,
const bool prechecked =
false);
202 const index_set_t frm,
const bool prechecked =
false);
207 const index_set_t frm,
const bool prechecked =
false);
213 const index_set_t frm,
const bool prechecked =
false)
214 { *
this =
framed_multi(std::string(str), frm, prechecked); };
216 template<
typename Other_Scalar_T >
219 template<
typename Other_Scalar_T >
254 operator<< <>(
std::ostream& os, const
term_t& term) ->
std::ostream&;
287 {
return "var_term"; };
301 this->second *= rhs.second * this->first.sign_of_mult(rhs.first);
302 this->first ^= rhs.first;
311 template<
typename Scalar_T, const index_t LO, const index_t HI >
319 template<
typename Scalar_T, const index_t LO, const index_t HI >
322 (
const std::pair<const index_set<LO,HI>, Scalar_T>& lhs,
323 const std::pair<const index_set<LO,HI>, Scalar_T>& rhs) ->
const std::pair<
const index_set<LO,HI>, Scalar_T>;
326 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
328 sqrt(
const framed_multi<Scalar_T,LO,HI,Tune_P>& val,
const framed_multi<Scalar_T,LO,HI,Tune_P>& i,
bool prechecked) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
331 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
336 template<
typename Scalar_T, const index_t LO, const index_t HI,
typename Tune_P >
338 log(
const framed_multi<Scalar_T,LO,HI,Tune_P>& val,
const framed_multi<Scalar_T,LO,HI,Tune_P>& i,
bool prechecked) ->
const framed_multi<Scalar_T,LO,HI,Tune_P>;
344 template <
typename Scalar_T, const glucat::index_t LO, const glucat::index_t HI,
typename Tune_P >
345 struct numeric_limits<
glucat::framed_multi<Scalar_T,LO,HI,Tune_P> > :
346 public numeric_limits<Scalar_T>
clifford_algebra<> declares the operations of a Clifford algebra
virtual auto odd() const -> const multivector_t=0
Odd part of multivector, sum of odd grade terms.
virtual auto operator*=(const Scalar_T &scr) -> multivector_t &=0
Product of multivector and scalar.
Specific exception class.
auto operator()() const -> size_t
hash_size_t(size_t hash_size)
static auto classname() -> const std::string
Class name used in messages.
var_term(const index_set_t ist, const Scalar_T &crd=Scalar_T(1))
Construct a variable term from an index set and a scalar coordinate.
std::pair< index_set< LO, HI >, Scalar_T > var_pair_t
var_term()
Default constructor.
~var_term()=default
Destructor.
A framed_multi<Scalar_T,LO,HI,Tune_P> is a framed approximation to a multivector.
auto divide(const index_set_t ist) const -> const framed_pair_t
Divide multivector into part divisible by index_set and remainder.
auto fast(const index_t level, const bool odd) const -> const matrix_t
Generalized FFT from multivector_t to matrix_t.
friend class framed_multi
typename map_t::const_iterator const_iterator
framed_multi multivector_t
std::vector< Scalar_T > vector_t
auto fast_matrix_multi(const index_set_t frm) const -> const matrix_multi< Other_Scalar_T, LO, HI, Tune_P >
Use generalized FFT to construct a matrix_multi_t.
index_set< LO, HI > index_set_t
std::pair< const multivector_t, const multivector_t > framed_pair_t
auto centre_pm4_qp4(index_t &p, index_t &q) -> multivector_t &
Subalgebra isomorphism: R_{p,q} to R_{p-4,q+4}.
std::unordered_map< index_set_t, Scalar_T, index_set_hash< LO, HI > > map_t
typename matrix_multi_t::matrix_t matrix_t
framed_multi(const char *str, const index_set_t frm, const bool prechecked=false)
Construct a multivector, within a given frame, from a char*: eg: "3+2{1,2}-6.1e-2{2,...
auto fold(const index_set_t frm) const -> multivector_t
Subalgebra isomorphism: fold each term within the given frame.
friend auto star(const multivector_t &lhs, const multivector_t &rhs) -> Scalar_T
~framed_multi() override=default
Destructor.
static auto random(const index_set_t frm, Scalar_T fill=Scalar_T(1)) -> const multivector_t
Random multivector within a frame.
multivector_t framed_multi_t
auto centre_qp1_pm1(index_t &p, index_t &q) -> multivector_t &
Subalgebra isomorphism: R_{p,q} to R_{q+1,p-1}.
framed_multi(const char *str)
Construct a multivector from a char*: eg: "3+2{1,2}-6.1e-2{2,3}".
auto fast_framed_multi() const -> const framed_multi_t
Use inverse generalized FFT to construct a framed_multi_t.
friend auto exp(const multivector_t &val) -> const multivector_t
auto unfold(const index_set_t frm) const -> multivector_t
Subalgebra isomorphism: unfold each term within the given frame.
static auto classname() -> const std::string
Class name used in messages.
typename map_t::size_type size_type
typename map_t::iterator iterator
std::map< index_set_t, Scalar_T, std::less< const index_set_t > > sorted_map_t
auto centre_pp4_qm4(index_t &p, index_t &q) -> multivector_t &
Subalgebra isomorphism: R_{p,q} to R_{p+4,q-4}.
std::pair< const index_set_t, Scalar_T > term_t
_GLUCAT_CLIFFORD_ALGEBRA_OPERATIONS auto nbr_terms() const -> unsigned long
Number of terms.
auto operator()(index_set_t val) const -> size_t
Index set class based on std::bitset<> in Gnu standard C++ library.
A matrix_multi<Scalar_T,LO,HI,Tune_P> is a matrix approximation to a multivector.
ublas::matrix< Scalar_T, orientation_t > matrix_t
#define _GLUCAT_CLIFFORD_ALGEBRA_OPERATIONS
auto operator<<(std::ostream &os, const framed_multi< Scalar_T, LO, HI, Tune_P > &val) -> std::ostream &
Write multivector to output.
auto operator|(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const RHS< Scalar_T, LO, HI, Tune_P > &rhs) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Transformation via twisted adjoint action.
auto operator*(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const Scalar_T &scr) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Product of multivector and scalar.
auto operator&(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const RHS< Scalar_T, LO, HI, Tune_P > &rhs) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Inner product.
auto exp(const framed_multi< Scalar_T, LO, HI, Tune_P > &val) -> const framed_multi< Scalar_T, LO, HI, Tune_P >
Exponential of multivector.
int index_t
Size of index_t should be enough to represent LO, HI.
static auto crd_of_mult(const std::pair< const index_set< LO, HI >, Scalar_T > &lhs, const std::pair< const index_set< LO, HI >, Scalar_T > &rhs) -> Scalar_T
Coordinate of product of terms.
auto operator%(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const RHS< Scalar_T, LO, HI, Tune_P > &rhs) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Left contraction.
auto operator>>(std::istream &s, framed_multi< Scalar_T, LO, HI, Tune_P > &val) -> std::istream &
Read multivector from input.
auto operator/(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const Scalar_T &scr) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Quotient of multivector and scalar.
auto log(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Natural logarithm of multivector with specified complexifier.
auto star(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const RHS< Scalar_T, LO, HI, Tune_P > &rhs) -> Scalar_T
Hestenes scalar product.
auto operator^(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const RHS< Scalar_T, LO, HI, Tune_P > &rhs) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Outer product.
auto sqrt(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Square root of multivector with specified complexifier.