1 #ifndef _GLUCAT_FRAMED_MULTI_H 2 #define _GLUCAT_FRAMED_MULTI_H 38 #if defined(_GLUCAT_USE_BOOST_POOL_ALLOC) 40 #include <boost/pool/poolfwd.hpp> 50 #if defined(_GLUCAT_USE_STD_UNORDERED_MAP) 51 # include <unordered_map> 54 #if defined(_GLUCAT_USE_STD_UNORDERED_MAP) 55 # define _GLUCAT_MAP_IS_HASH 57 # define _GLUCAT_MAP_IS_ORDERED 64 template<
typename Scalar_T, const index_t LO, const index_t HI >
67 template<
typename Scalar_T, const index_t LO, const index_t HI >
71 template<
typename Scalar_T, const index_t LO, const index_t HI >
76 template<
typename Scalar_T, const index_t LO, const index_t HI >
81 template<
typename Scalar_T, const index_t LO, const index_t HI >
86 template<
typename Scalar_T, const index_t LO, const index_t HI >
91 template<
typename Scalar_T, const index_t LO, const index_t HI >
96 template<
typename Scalar_T, const index_t LO, const index_t HI >
101 template<
typename Scalar_T, const index_t LO, const index_t HI >
106 template<
typename Scalar_T, const index_t LO, const index_t HI >
111 template<
typename Scalar_T, const index_t LO, const index_t HI >
113 operator<< (std::ostream& os, const framed_multi<Scalar_T,LO,HI>& val);
116 template<
typename Scalar_T, const index_t LO, const index_t HI >
118 operator<< (std::ostream& os, const std::pair< const index_set<LO,HI>, Scalar_T >& term);
121 template<
typename Scalar_T, const index_t LO, const index_t HI >
125 template< const index_t LO, const index_t HI>
134 template<
typename Scalar_T =
double, const index_t LO = DEFAULT_LO, const index_t HI = DEFAULT_HI >
136 public clifford_algebra< Scalar_T, index_set<LO,HI>, framed_multi<Scalar_T,LO,HI> >,
137 #if defined(_GLUCAT_USE_STD_UNORDERED_MAP) 138 private std::unordered_map< index_set<LO,HI>, Scalar_T, index_set_hash<LO,HI> >
140 private std::map< index_set<LO,HI>, Scalar_T,
141 std::less< const index_set<LO,HI> >
142 #if defined(_GLUCAT_USE_BOOST_POOL_ALLOC)
143 , boost::fast_pool_allocator< std::pair<const index_set<LO,HI>, Scalar_T> >
153 typedef std::pair<const index_set_t, Scalar_T>
term_t;
157 template<
typename Other_Scalar_T, const index_t Other_LO, const index_t Other_HI >
159 template<
typename Other_Scalar_T, const index_t Other_LO, const index_t Other_HI >
167 std::less<const index_set_t>
168 #if defined(_GLUCAT_USE_BOOST_POOL_ALLOC) 169 , boost::fast_pool_allocator<term_t>
173 #if defined(_GLUCAT_USE_STD_UNORDERED_MAP) 174 typedef std::unordered_map< index_set_t, Scalar_T, index_set_hash<LO,HI> >
192 typedef std::pair< const multivector_t, const multivector_t >
211 template<
typename Other_Scalar_T >
214 template<
typename Other_Scalar_T >
216 const index_set_t frm,
const bool prechecked =
false);
219 const index_set_t frm,
const bool prechecked =
false);
224 const index_set_t frm,
const bool prechecked =
false);
231 const index_set_t frm,
const bool prechecked =
false);
236 const index_set_t frm,
const bool prechecked =
false);
242 const index_set_t frm,
const bool prechecked =
false)
243 { *
this =
framed_multi(std::string(str), frm, prechecked); };
245 template<
typename Other_Scalar_T >
248 template<
typename Other_Scalar_T >
283 operator<< <>(std::ostream& os,
const term_t& term);
309 public std::pair<index_set<LO,HI>, Scalar_T>
316 {
return "var_term"; };
330 this->second *= rhs.second * this->first.sign_of_mult(rhs.first);
331 this->first ^= rhs.first;
340 template<
typename Scalar_T, const index_t LO, const index_t HI >
344 crd_of_mult(
const std::pair<
const index_set<LO,HI>, Scalar_T>& lhs,
345 const std::pair<
const index_set<LO,HI>, Scalar_T>& rhs);
348 template<
typename Scalar_T, const index_t LO, const index_t HI >
349 const std::pair<const index_set<LO,HI>, Scalar_T>
351 (
const std::pair<const index_set<LO,HI>, Scalar_T>& lhs,
352 const std::pair<const index_set<LO,HI>, Scalar_T>& rhs);
355 template<
typename Scalar_T, const index_t LO, const index_t HI >
356 const framed_multi<Scalar_T,LO,HI>
357 sqrt(
const framed_multi<Scalar_T,LO,HI>& val,
const framed_multi<Scalar_T,LO,HI>&
i,
bool prechecked);
360 template<
typename Scalar_T, const index_t LO, const index_t HI >
361 const framed_multi<Scalar_T,LO,HI>
362 exp(
const framed_multi<Scalar_T,LO,HI>& val);
365 template<
typename Scalar_T, const index_t LO, const index_t HI >
366 const framed_multi<Scalar_T,LO,HI>
367 log(
const framed_multi<Scalar_T,LO,HI>& val,
const framed_multi<Scalar_T,LO,HI>&
i,
bool prechecked);
373 template <
typename Scalar_T, const glucat::index_t LO, const glucat::index_t HI>
374 struct numeric_limits<
glucat::framed_multi<Scalar_T,LO,HI> > :
375 public numeric_limits<Scalar_T>
378 #endif // _GLUCAT_FRAMED_MULTI_H multivector_t & centre_pm4_qp4(index_t &p, index_t &q)
Subalgebra isomorphism: R_{p,q} to R_{p-4,q+4}.
index_set< LO, HI > index_set_t
const framed_pair_t divide(const index_set_t ist) const
Divide multivector into part divisible by index_set and remainder.
static Scalar_T 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)
Coordinate of product of terms.
multivector_t & centre_qp1_pm1(index_t &p, index_t &q)
Subalgebra isomorphism: R_{p,q} to R_{q+1,p-1}.
Scalar_T star(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Hestenes scalar product.
size_t operator()() const
class var_term var_term_t
const Multivector< Scalar_T, LO, HI > sqrt(const Multivector< Scalar_T, LO, HI > &val, const Multivector< Scalar_T, LO, HI > &i, const bool prechecked=false)
Square root of multivector with specified complexifier.
matrix_multi_t::matrix_t matrix_t
map_t::size_type size_type
const Multivector< Scalar_T, LO, HI > operator/(const Multivector< Scalar_T, LO, HI > &lhs, const Scalar_T &scr)
Quotient of multivector and scalar.
~framed_multi()
Destructor.
const Multivector< Scalar_T, LO, HI > operator*(const Multivector< Scalar_T, LO, HI > &lhs, const Scalar_T &scr)
Product of multivector and scalar.
A framed_multi<Scalar_T,LO,HI> is a framed approximation to a multivector.
framed_multi multivector_t
const Multivector< Scalar_T, LO, HI > log(const Multivector< Scalar_T, LO, HI > &val, const Multivector< Scalar_T, LO, HI > &i, const bool prechecked=false)
Natural logarithm of multivector with specified complexifier.
static const std::string classname()
Class name used in messages.
map_t::const_iterator const_iterator
size_t hash_fn() const
Hash function.
virtual const multivector_t odd() const=0
Odd part of multivector, sum of odd grade terms.
std::vector< Scalar_T > vector_t
index_set< LO, HI > index_set_t
var_term_t & operator*=(const term_t &rhs)
Product of variable term and term.
var_term()
Default constructor.
std::pair< const multivector_t, const multivector_t > framed_pair_t
A matrix_multi<Scalar_T,LO,HI> is a matrix approximation to a multivector.
const Multivector< Scalar_T, LO, HI > operator^(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Outer product.
const framed_multi< Scalar_T, LO, HI > exp(const framed_multi< Scalar_T, LO, HI > &val)
Exponential of multivector.
size_t operator()(index_set_t val) const
multivector_t fold(const index_set_t frm) const
Subalgebra isomorphism: fold each term within the given frame.
std::unordered_map< index_set_t, Scalar_T, index_set_hash< LO, HI > > map_t
static const std::string classname()
Class name used in messages.
std::pair< const index_set_t, Scalar_T > term_t
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.
const Multivector< Scalar_T, LO, HI > operator%(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Left contraction.
multivector_t & centre_pp4_qm4(index_t &p, index_t &q)
Subalgebra isomorphism: R_{p,q} to R_{p+4,q-4}.
ublas::compressed_matrix< Scalar_T, orientation_t > matrix_t
Specific exception class.
const framed_multi_t fast_framed_multi() const
Use inverse generalized FFT to construct a framed_multi_t.
multivector_t unfold(const index_set_t frm) const
Subalgebra isomorphism: unfold each term within the given frame.
const matrix_multi< Other_Scalar_T, LO, HI > fast_matrix_multi(const index_set_t frm) const
Use generalized FFT to construct a matrix_multi_t.
hash_size_t(size_t hash_size)
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,3}".
error< multivector_t > error_t
Index set class based on std::bitset<> in Gnu standard C++ library.
_GLUCAT_CLIFFORD_ALGEBRA_OPERATIONS unsigned long nbr_terms() const
Number of terms.
const Multivector< Scalar_T, LO, HI > operator|(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Transformation via twisted adjoint action.
std::pair< index_set< LO, HI >, Scalar_T > var_pair_t
framed_multi(const char *str)
Construct a multivector from a char*: eg: "3+2{1,2}-6.1e-2{2,3}".
matrix_multi< Scalar_T, LO, HI > matrix_multi_t
int index_t
Size of index_t should be enough to represent LO, HI.
const Multivector< Scalar_T, LO, HI > operator &(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Inner product.
framed_multi()
Default constructor.
std::istream & operator>>(std::istream &s, framed_multi< Scalar_T, LO, HI > &val)
Read multivector from input.
static const framed_multi_t random(const index_set_t frm, Scalar_T fill=Scalar_T(1))
Random multivector within a frame.
multivector_t framed_multi_t
multivector_t & operator+=(const term_t &term)
Add a term, if non-zero.
#define _GLUCAT_CLIFFORD_ALGEBRA_OPERATIONS
const matrix_t fast(const index_t level, const bool odd) const
Generalized FFT from framed_multi_t to matrix_t.
std::map< index_set_t, Scalar_T, std::less< const index_set_t > > sorted_map_t