54 template<
typename algebra_type,
typename basis_type>
60 static const int Num = basis::Num;
68 using Dual =
typename algebra::template make_gp< typename blade<algebra::dim,algebra::dim>::type,
basis>;
87 template<
typename...Args>
89 val{
static_cast<value_t>(v)...} {}
96 template<
class alg,
typename B>
100 template<bits::type IDX>
value_t get()
const;
102 template<bits::type IDX>
value_t&
get();
104 template<bits::type IDX> Multivector&
set(
value_t v);
108 std::fill( &(val[0]), &(val[0]) + basis::Num, v);
122 template<
class B> B
cast()
const;
124 template<
class B> B
copy()
const;
128 for (
int i = 0; i <
Num; ++i) {
129 if (val[i] != mv[i])
return false;
137 VPrint::Call( *
this );
147 return algebra::gp(*
this, b);
160 return algebra::op(*
this, b);
166 auto operator <= ( const MultivectorB<B>& b) const-> decltype( algebra::ip(*
this,b)) {
167 return algebra::ip(*
this, b);
173 return ( (*
this * b) - (b * (*
this) ) ) * .5;
183 template<
typename B> Multivector sp(
const MultivectorB<B>& b)
const {
return spin(b); }
184 template<
typename B> Multivector re(
const MultivectorB<B>& b)
const {
return reflect(b); }
188 return Reverse< basis >::Type::template Make(*
this) ;
193 Multivector tmp = ~(*this);
194 value_t v = ((*this) * tmp)[0];
195 return (v==0) ? tmp : tmp / v;
200 auto operator / (
const MultivectorB<B>& b)
const RETURNS(
211 Multivector<
algebra, typename algebra::vector_basis >
null() const;
224 Multivector translate ( const
MultivectorB<B>& b ) const;
227 template<class ... Ts>
228 Multivector trs ( Ts ... v ) const;
229 template<class ... Ts>
230 Multivector translate ( Ts ... v ) const;
235 Multivector transverse ( const
MultivectorB<B>& b ) const;
237 template<class ... Ts>
238 Multivector trv ( Ts ... v ) const;
239 template<class ... Ts>
240 Multivector transverse ( Ts ... v ) const;
255 Multivector dil ( const
MultivectorB<B>& b, VSR_PRECISION t ) const;
257 Multivector dilate ( const
MultivectorB<B>& b, VSR_PRECISION t ) const;
263 auto dual() const ->
Dual {
264 return algebra::gp( *
this ,
typename space::Pss(-1) );
267 auto undual() const -> Dual {
268 return algebra::gp( *
this ,
typename space::Pss(1) );
271 auto duale() const ->
DualE{
272 return algebra::gp( *
this ,
typename space::Euc(-1) );
275 auto unduale() const ->
DualE{
276 return algebra::gp( *
this ,
typename space::Euc(1) );
283 value_t wt()
const{
return (*
this <= *
this)[0]; }
284 value_t rwt()
const{
return (*
this <= ~(*
this))[0]; }
285 value_t norm()
const {
value_t a = rwt();
if(a<0)
return 0;
return sqrt( a ); }
286 value_t rnorm()
const{
value_t a = rwt();
if(a<0)
return -sqrt( -a );
return sqrt( a ); }
288 Multivector unit()
const {
value_t t = sqrt( fabs( (*
this <= *
this)[0] ) );
if (t == 0)
return Multivector();
return *
this / t; }
289 Multivector runit()
const {
value_t t = rnorm();
if (t == 0)
return Multivector();
return *
this / t; }
290 Multivector tunit()
const {
value_t t = norm();
if (t == 0)
return Multivector();
return *
this / t; }
297 auto operator + (
const MultivectorB<B>& b) -> decltype(
algebra::sum(*
this, b) ) {
302 Multivector operator + (
const Multivector& a)
const {
304 for (
int i = 0; i <
Num; ++i) tmp[i] = (*
this)[i] + a[i];
308 Multivector operator - (
const Multivector& a)
const {
310 for (
int i = 0; i <
Num; ++i) tmp[i] = (*
this)[i] - a[i];
314 Multivector operator -()
const{
315 Multivector tmp = *
this;
316 for (
int i = 0; i <
Num; ++i){ tmp[i] = -tmp[i]; }
320 Multivector& operator -=(
const Multivector& b){
321 for (
int i = 0; i <
Num; ++i) (*
this)[i] -= b[i];
324 Multivector& operator +=(
const Multivector& b){
325 for (
int i = 0; i <
Num; ++i) (*
this)[i] += b[i];
329 Multivector operator / (VSR_PRECISION f)
const{
330 Multivector tmp = *
this;
331 for (
int i = 0; i <
Num; ++i){ tmp[i] /= f; }
335 Multivector& operator /= (VSR_PRECISION f){
336 for (
int i = 0; i <
Num; ++i){ (*this)[i] /= f; }
340 Multivector
operator * (VSR_PRECISION f)
const {
341 Multivector tmp = *
this;
342 for (
int i = 0; i <
Num; ++i){ tmp[i] *= f; }
346 for (
int i = 0; i <
Num; ++i){ (*this)[i] *= f; }
350 auto operator + (VSR_PRECISION a)
const -> decltype(
algebra::sumv( a, *
this) ) {
354 static Multivector x,y,z,xy,xz,yz;
356 friend ostream& operator << (ostream& os,
const Multivector& m){
357 for (
int i=0; i <
Num; ++i){
369 template<
typename Algebra,
typename B>
template<
class A>
371 return Cast< typename A::basis, B >::Type::template doCast<A>( *this );
374 template<
typename Algebra,
typename B>
template<
class A>
377 for (
int i = 0; i < A::basis::Num; ++i) tmp[i] = (*
this)[i];
385 template<
typename Algebra,
typename B>
template<bits::type IDX>
387 return val[ find(IDX, B()) ];
389 template<
typename Algebra,
typename B>
template<bits::type IDX>
391 return val[ find(IDX, B()) ];
393 template<
typename Algebra,
typename B>
template<bits::type IDX>
399 template<
typename Algebra,
typename B>
400 Multivector<Algebra,B> Multivector<Algebra,B>::x = Multivector<Algebra,B>().
template set<1>(1);
402 template<
typename Algebra,
typename B>
403 Multivector<Algebra,B> Multivector<Algebra,B>::y = Multivector<Algebra,B>().
template set<2>(1);
405 template<
typename Algebra,
typename B>
406 Multivector<Algebra,B> Multivector<Algebra,B>::z = Multivector<Algebra,B>().
template set<4>(1);
408 template<
typename Algebra,
typename B>
409 Multivector<Algebra,B> Multivector<Algebra,B>::xy = Multivector<Algebra,B>().
template set<3>(1);
411 template<
typename Algebra,
typename B>
412 Multivector<Algebra,B> Multivector<Algebra,B>::xz = Multivector<Algebra,B>().
template set<5>(1);
414 template<
typename Algebra,
typename B>
415 Multivector<Algebra,B> Multivector<Algebra,B>::yz = Multivector<Algebra,B>().
template set<6>(1);
423 template<
typename Algebra,
typename B>
425 return Conjugate<B>::Type::template Make(*
this);
427 template<
typename Algebra,
typename B>
429 return Involute<B>::Type::template Make(*
this);
468 template<
typename algebra>
470 template <bits::type ... NN>
using e =
typename algebra::types::template e<NN...>;
474 template<bits::type N,
typename T=VSR_PRECISION>
using conformal = algebra< metric<N-1,1,
true>,T>;
491 template<
typename T=VSR_PRECISION>
493 template <bits::type ... NN>
using e =
typename GAE<
euclidean<bits::dimOf( bits::blade((1<<(NN-1))...) ), T >>::template e<NN...>;
B cast() const
Casting to type B.
Multivector involution() const
Involution Unary Operation.
Definition: vsr_multivector.h:428
Multivector & operator*=(const MultivectorB< B > &b)
Geometric Product in place Transformation.
Definition: vsr_multivector.h:152
auto operator%(const MultivectorB< B > &b) const -> decltype(algebra::gp(*this, b))
Commutator Product \(a \times b\)
Definition: vsr_multivector.h:172
constexpr value_t operator[](int idx) const
Get value at idx
Definition: vsr_multivector.h:78
static const int dim
– Dimension of Algebra (2,3,4,5,etc)
Definition: vsr_algebra.h:102
Multivector spin(const MultivectorB< B > &b) const
Rotor (even) transformation \(RA\tilde{R}\)
Definition: vsr_multivector.h:178
static const int Num
number of bases
Definition: vsr_multivector.h:60
An algebra instance is templated on:
Definition: vsr_algebra.h:96
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
static mv_t< typename ICat< typename NotType< Basis< 0 >, B >::Type, Basis< 0 > >::Type > sumv(VSR_PRECISION a, const mv_t< B > &b)
Sum some scalar value.
Definition: vsr_algebra.h:165
Multivector< algebra, B > MultivectorB
another Type within same algebra
Definition: vsr_multivector.h:65
Multivector< algebra, typename algebra::vector_basis > null() const
Conformal Mapping \(\boldsymbol(x)\to n_o + \boldsymbol{x} + \boldsymbol{x}^2n_\infty \) ...
Definition: vsr_generic_op.h:1118
basis_type basis
basis is an algebraic data type created with compile-time list processing
Definition: vsr_multivector.h:58
Multivector operator~() const
Reversion \(\tilde{A}\)
Definition: vsr_multivector.h:187
typename algebra::template make_gp< typename blade< algebra::dim, algebra::dim >::type, basis > Dual
the Dual Type (product of this and algebra::types::pseudoscalar)
Definition: vsr_multivector.h:68
named_types< impl > types
certain prenamed types in euclidean and conformal
Definition: vsr_algebra.h:230
void print()
Printing.
Definition: vsr_multivector.h:135
Definition: vsr_multivector.h:469
Multivector operator!() const
Inversion \(\tilde{A}/A\tilde{A}\)
Definition: vsr_multivector.h:192
typename algebra::types space
<>::::<>
Definition: vsr_multivector.h:63
auto operator*(const MultivectorB< B > &b) const -> decltype(algebra::gp(*this, b))
Geometric Product \(a*b\)
Definition: vsr_multivector.h:146
NPss< 5 > Pss
Pseudoscalar
Definition: vsr_cga3D_types.h:70
static constexpr A reflect(const A &a, const B &b)
Reflect a by b, return type a.
Definition: vsr_algebra.h:203
constexpr Multivector(Args...v)
Construct from list of args (cannot be longer than Num)
Definition: vsr_multivector.h:88
Multivector inv() const
Involution Unary Operation Shorthand.
Definition: vsr_multivector.h:119
N+1 algebra
algebra (a metric and field)
Definition: vsr_multivector.h:57
implementations of algebras (Euclidean, PQ-metric, and conformal)
constexpr Multivector(const Multivector< algebra, B > &b)
Construct from different Basis within same Algebra.
Definition: vsr_multivector.h:93
Multivector & set(value_t v)
Set value of blade type IDX
auto operator^(const MultivectorB< B > &b) const -> decltype(algebra::op(*this, b))
Outer Product \(a \wedge b\)
Definition: vsr_multivector.h:159
Multivector conjugation() const
Conjugation Unary Operation.
Definition: vsr_multivector.h:424
Definition: vsr_multivector.h:492
the versor library namespace
Definition: vsr_algebra.h:29
Multivector rot(const MultivectorB< B > &b) const
B copy() const
Copying to type B.
static constexpr A spin(const A &a, const B &b)
Spin a by b, return type a.
Definition: vsr_algebra.h:194
Multivector conj() const
Conjugation Unary Operation Shorthand.
Definition: vsr_multivector.h:115
typename algebra::value_t value_t
the field over which the algebra is defined (e.g. float or double)
Definition: vsr_multivector.h:62
bool operator==(const Multivector &mv) const
Comparison.
Definition: vsr_multivector.h:127
constexpr Multivector(const Multivector< alg, B > &b)
Construct from different algebra signature and different basis.
Definition: vsr_multivector.h:97
const value_t array_type[Num]
Data Array Type
Definition: vsr_multivector.h:73
typename algebra::template make_gp< Basis< bits::pss(algebra::dim-2)>, basis > DualE
the Euclidan subspace Dual Type (product of this and algebra::types::euclidean_pseudoscalar) ...
Definition: vsr_multivector.h:70
Multivector & reset(value_t v=value_t())
Reset.
Definition: vsr_multivector.h:107
array_type & begin() const
Pointer to first data.
Definition: vsr_multivector.h:75
Multivector rotate(const MultivectorB< B > &b) const
value_t val[Num]
Data Array
Definition: vsr_multivector.h:72
Multivector reflect(const MultivectorB< B > &b) const
Versor (Odd) Transformation \(R\hat{A}\tilde{R}\)
Definition: vsr_multivector.h:181
value_t get() const
Immutable get value of blade type IDX (.
static mv_t< B > sum(const mv_t< B > &a, const mv_t< B > &b)
Sum of Similar types.
Definition: vsr_algebra.h:133
value_type value_t
– Field over which Algebra is Defined (e.g. float, double, complex)
Definition: vsr_algebra.h:100