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 >
200 static const std::string classname();
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);
221 framed_multi(
const index_set_t
ist,
const Scalar_T& crd = Scalar_T(1));
223 framed_multi(
const index_set_t ist,
const Scalar_T& crd,
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 >
251 const framed_multi_t fast_framed_multi()
const;
256 unsigned long nbr_terms()
const;
259 static const framed_multi_t random(
const index_set_t frm, Scalar_T
fill = Scalar_T(1));
263 friend const framed_multi_t
264 operator* <>(
const framed_multi_t& lhs,
const framed_multi_t& rhs);
265 friend const framed_multi_t
266 operator^ <>(
const framed_multi_t& lhs,
const framed_multi_t& rhs);
267 friend const framed_multi_t
268 operator& <>(
const framed_multi_t& lhs,
const framed_multi_t& rhs);
269 friend const framed_multi_t
270 operator% <>(
const framed_multi_t& lhs,
const framed_multi_t& rhs);
272 star <>(
const framed_multi_t& lhs,
const framed_multi_t& rhs);
273 friend const framed_multi_t
274 operator/ <>(
const framed_multi_t& lhs,
const framed_multi_t& rhs);
275 friend const framed_multi_t
276 operator| <>(
const framed_multi_t& lhs,
const framed_multi_t& rhs);
279 operator>> <>(std::istream& s, multivector_t& val);
281 operator<< <>(std::ostream& os,
const multivector_t& val);
283 operator<< <>(std::ostream& os,
const term_t& term);
285 friend const framed_multi_t
286 exp <>(
const framed_multi_t& val);
289 multivector_t& operator+= (
const term_t& term);
293 multivector_t fold(
const index_set_t frm)
const;
295 multivector_t unfold(
const index_set_t frm)
const;
309 public std::pair<index_set<LO,HI>, Scalar_T>
316 {
return "var_term"; };
321 : var_pair_t(index_set_t(), Scalar_T(1))
324 var_term(
const index_set_t ist,
const Scalar_T& crd = Scalar_T(1))
325 : var_pair_t(ist, crd)
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 >
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 >
360 template<
typename Scalar_T, const index_t LO, const index_t HI >
365 template<
typename Scalar_T, const index_t LO, const index_t HI >
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 index_set< LO, HI > index_set_t
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.
static Multivector_T fast(const Matrix_T &X, index_t level)
Inverse generalized Fast Fourier Transform.
Scalar_T star(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Hestenes scalar product.
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.
map_t::const_iterator const_iterator
clifford_algebra<> declares the operations of a Clifford algebra
std::vector< Scalar_T > vector_t
const Multivector< Scalar_T, LO, HI > operator&(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Inner product.
size_t operator()(index_set_t val) const
const Multivector< Scalar_T, LO, HI > odd(const Multivector< Scalar_T, LO, HI > &val)
Odd part.
index_set< LO, HI > index_set_t
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.
size_t operator()() const
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.
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.
ublas::compressed_matrix< Scalar_T, orientation_t > matrix_t
Specific exception class.
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.
size_t hash_fn() const
Hash function.
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.
std::istream & operator>>(std::istream &s, framed_multi< Scalar_T, LO, HI > &val)
Read multivector from input.
multivector_t framed_multi_t
#define _GLUCAT_CLIFFORD_ALGEBRA_OPERATIONS
std::map< index_set_t, Scalar_T, std::less< const index_set_t > > sorted_map_t