23 #ifndef vsr_algebra_INC
24 #define vsr_algebra_INC
26 #include "vsr_xlists.h"
27 #include "vsr_products.h"
40 template<bits::type dim, bits::type grade>
42 using vec =
typename vsr::Blade1<dim>::VEC;
43 using sub =
typename blade<dim, grade-1>::type;
44 using type =
typename EOProd<vec,sub>::basis;
49 template<bits::type dim>
51 using type = Basis<0>;
55 template<bits::type dim, bits::type grade=dim>
57 using sub =
typename all_blades<dim, grade-1>::type;
58 using one =
typename blade<dim, grade>::type;
59 using type =
typename ICat< one, sub >::Type;
63 template<bits::type dim>
65 using type = Basis<0>;
95 template<
class metric_type,
class value_type >
102 static const int dim = metric::type::Num;
110 template <
class A,
class B>
using sum_basis_t =
typename ICat< typename NotType< A, B >::Type, A >::Type;
111 template <
class A,
class B>
using gp_basis_t =
typename impl::template gp_arrow_t<A,B>::basis;
112 template <
class A,
class B>
using op_basis_t =
typename impl::template op_arrow_t<A,B>::basis;
113 template <
class A,
class B>
using ip_basis_t =
typename impl::template ip_arrow_t<A,B>::basis;
135 for (
int i = 0; i < B::Num; ++i) c[i] = a[i] + b[i];
143 for (
int i = 0; i < B::Num; ++i) c[i] = a[i] - b[i];
148 template<
class B1,
class B2>
149 static mv_t<typename ICat< typename NotType< B1, B2 >::Type, B1 >::Type>
152 return sum( a.template cast<Ret>() , b.template cast<Ret>() );
155 template<
class B1,
class B2>
156 static mv_t<typename ICat< typename NotType< B1, B2 >::Type, B1 >::Type>
159 return diff( a.template cast<Ret>() , b.template cast<Ret>() );
164 static mv_t<typename ICat< typename NotType< Basis<0>, B >::Type, Basis<0> >::Type>
167 return sum( Ret(a) , b.template cast<Ret>() );
173 template<
class A,
class B>
174 static constexpr
auto gp(
const A& a,
const B& b) -> gp_t<A,B> {
175 typedef typename impl::template gp_arrow_t<typename A::basis, typename B::basis> x;
176 typedef mv_t<typename x::basis> type;
177 return x::Arrow::template Make<type>(a,b);
179 template<
class A,
class B>
180 static constexpr
auto op(
const A& a,
const B& b) -> op_t<A,B> {
181 typedef typename impl::template op_arrow_t<typename A::basis, typename B::basis> x;
182 typedef mv_t<typename x::basis> type;
183 return x::Arrow::template Make<type>(a,b);
185 template<
class A,
class B>
186 static constexpr
auto ip(
const A& a,
const B& b) -> ip_t<A,B> {
187 typedef typename impl::template ip_arrow_t<typename A::basis, typename B::basis> x;
188 typedef mv_t<typename x::basis> type;
189 return x::Arrow::template Make<type>(a,b);
193 template<
class A,
class B>
194 static constexpr A
spin(
const A& a,
const B& b) {
195 typedef gp_basis_t<typename B::basis, typename A::basis > tmp_basis;
197 using x =
typename impl::template rot_arrow_t<tmp_basis, typename B::basis, typename A::basis>;
198 return x::Arrow::template Make<A>( gp(b, a), Reverse<typename B::basis>::Type::template Make(b) );
202 template<
class A,
class B>
203 static constexpr A
reflect(
const A& a,
const B& b) {
204 typedef gp_basis_t<typename B::basis, typename A::basis > tmp_basis;
205 using x =
typename impl::template rot_arrow_t<tmp_basis, typename B::basis, typename A::basis>;
206 return x::Arrow::template Make<A>( gp(b, a.involution() ), Reverse<typename B::basis>::Type::template Make(b) );
210 template<
typename B1,
typename B2>
214 template<
typename B1,
typename B2>
218 template<
typename B1,
typename B2>
222 template<
typename B1,
typename B2>
226 template<bits::type grade>
248 template<
typename Algebra,
bool Eucl
idean,
bool Conformal>
256 template<
typename Algebra>
261 template <
class A,
class B>
using gp_arrow_t = EGProd<A,B>;
262 template <
class A,
class B>
using op_arrow_t = EOProd<A,B>;
263 template <
class A,
class B>
using ip_arrow_t = EIProd<A,B>;
265 template<
class R,
class A,
class B>
using rot_arrow_t = REGProd< R, A, B>;
274 template<
typename Algebra>
276 using algebra = Algebra;
277 using metric_type =
typename Algebra::metric::type;
280 template <
class A,
class B>
using gp_arrow_t = MGProd<A, B, metric_type>;
281 template <
class A,
class B>
using op_arrow_t = MOProd<A, B, metric_type>;
282 template <
class A,
class B>
using ip_arrow_t = MIProd<A, B, metric_type>;
284 template<
class R,
class A,
class B>
using rot_arrow_t = RMGProd< R, A, B, metric_type>;
291 template<
typename Algebra>
294 using metric_type =
typename Algebra::metric::type;
297 template <
class A,
class B>
using gp_arrow_t = CGProd<A, B, metric_type>;
298 template <
class A,
class B>
using op_arrow_t = COProd<A, B, metric_type>;
299 template <
class A,
class B>
using ip_arrow_t = CIProd<A, B, metric_type>;
301 template<
class R,
class A,
class B>
using rot_arrow_t = RCGProd< R, A, B, metric_type>;
313 using alg =
typename A::algebra;
315 template<bits::type ... N>
using e_basis = Basis< bits::blade((1<<(N-1))...)>;
316 template<bits::type ... N>
using e =
Multivector<alg, e_basis<N...>>;
318 using sca = Basis<0>;
319 using pss = Basis<bits::pss(alg::dim)>;
320 using vec =
typename Blade1<alg::dim>::VEC;
321 using biv =
typename alg::template op_basis_t<vec,vec>;
322 using tri =
typename alg::template op_basis_t<vec,biv>;
323 using rot =
typename alg::template sum_basis_t<biv,sca>;
331 template<
typename alg>
337 template<bits::type ... N>
using e_basis = Basis< bits::blade((1<<(N-1))...)>;
338 template<bits::type ... N>
using e =
Multivector<alg, e_basis<N...>>;
340 using sca = Basis<0>;
341 using pss = Basis<bits::pss(alg::dim)>;
342 using vec =
typename Blade1<alg::dim>::VEC;
343 using biv =
typename algebra::template op_basis_t<vec,vec>;
344 using tri =
typename algebra::template op_basis_t<vec,biv>;
345 using rot =
typename algebra::template sum_basis_t<biv,sca>;
356 using scalar_basis = Basis<0>;
357 using pseudoscalar_basis = Basis<bits::pss(alg::dim)>;
358 using vector_basis =
typename blade<alg::dim,1>::type;
359 using bivector_basis =
typename blade<alg::dim,2>::type;
360 using trivector_basis =
typename blade<alg::dim,3>::type;
361 using rotor_basis =
typename algebra::template sum_basis_t<bivector_basis, scalar_basis>;
362 using euclidean_pseudoscalar_basis = pseudoscalar_basis;
378 template<
typename alg>
383 template<bits::type ... N>
using e = Basis< bits::blade((1<<(N-1))...)>;
386 using sca = Basis<0>;
387 using pss = Basis<bits::pss(algebra::dim)>;
390 using pnt =
typename Blade1<algebra::dim>::VEC ;
391 using ori =
typename basis_t::origin<algebra::dim> ;
392 using inf =
typename basis_t::infinity<algebra::dim> ;
393 using mnk =
typename basis_t::eplane<algebra::dim> ;
395 using biv =
typename algebra::template op_basis_t<vec,vec>;
396 using tri =
typename algebra::template op_basis_t<vec,biv>;
397 using rot =
typename algebra::template sum_basis_t<biv,sca>;
398 using tnv =
typename algebra::template op_basis_t<vec,ori>;
399 using drv =
typename algebra::template op_basis_t<vec,inf>;
400 using tnb =
typename algebra::template op_basis_t<biv,ori>;
401 using drb =
typename algebra::template op_basis_t<biv,inf>;
402 using tnt =
typename algebra::template op_basis_t<tri,ori>;
403 using drt =
typename algebra::template op_basis_t<tri,inf>;
404 using par =
typename algebra::template op_basis_t<pnt,pnt>;
405 using cir =
typename algebra::template op_basis_t<par,pnt>;
406 using sph =
typename algebra::template op_basis_t<cir,pnt>;
407 using flp =
typename algebra::template op_basis_t<pnt,inf>;
409 using lin =
typename algebra::template op_basis_t<pnt,flp>;
410 using dll =
typename algebra::template gp_basis_t<lin,pss>;
411 using dlp =
typename algebra::template sum_basis_t<vec,inf>;
412 using pln =
typename algebra::template op_basis_t<cir,inf>;
413 using trs =
typename algebra::template sum_basis_t<drv, sca>;
414 using trv =
typename algebra::template sum_basis_t<tnv, sca>;
415 using dil =
typename algebra::template sum_basis_t<mnk, sca>;
416 using tsd =
typename algebra::template sum_basis_t<flp, sca>;
417 using mot =
typename algebra::template gp_basis_t<rot, trs>;
418 using bst =
typename algebra::template sum_basis_t<par,sca>;
419 using con =
typename algebra::template gp_basis_t<par, par>;
static mv_t< typename ICat< typename NotType< B1, B2 >::Type, B1 >::Type > sum(const mv_t< B1 > &a, const mv_t< B2 > &b)
Sum of Different types.
Definition: vsr_algebra.h:150
static const int dim
– Dimension of Algebra (2,3,4,5,etc)
Definition: vsr_algebra.h:102
static mv_t< B > diff(const mv_t< B > &a, const mv_t< B > &b)
Difference of Similar types.
Definition: vsr_algebra.h:141
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
Definition: vsr_algebra.h:73
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
all blades within a spatial dim upto and including maxgrade
Definition: vsr_algebra.h:56
typename blade< dim, 1 >::type vector_basis
– 1-blade vector basis (no data)
Definition: vsr_algebra.h:236
Definition: vsr_algebra.h:71
static mv_t< typename ICat< typename NotType< B1, B2 >::Type, B1 >::Type > diff(const mv_t< B1 > &a, const mv_t< B2 > &b)
Difference of Different types.
Definition: vsr_algebra.h:157
static constexpr A reflect(const A &a, const B &b)
Reflect a by b, return type a.
Definition: vsr_algebra.h:203
the versor library namespace
Definition: vsr_algebra.h:29
static constexpr A spin(const A &a, const B &b)
Spin a by b, return type a.
Definition: vsr_algebra.h:194
metafunction to construct a basis blade type from spatial dimension and subspace grade ...
Definition: vsr_algebra.h:41
metric_type metric
– Metric, with signature, whether Euclidean, Projective, Conformal, etc
Definition: vsr_algebra.h:98
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