[GiNaC-list] Vector algebra from Clifford units

Vladimir Kisil kisilv at maths.leeds.ac.uk
Fri Jun 24 18:04:28 CEST 2005


		Hi,

		In response to the previous request on vector algebra in
  different bases I include a simple illustration how to achieve
  principal vector operations from the Clifford algebra functionality in
  GiNaC. This is working with current CVS but will not work yet with the
  current release 1.3.1.

  Hope this can be useful,
  Vladimir
-- 
Vladimir V. Kisil     email: kisilv at maths.leeds.ac.uk
--                      www: http://maths.leeds.ac.uk/~kisilv/

#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;

ex vector3D(const ex & list, const ex & basis, const ex & mu) {
	varidx nu((new symbol)->setflag(status_flags::dynallocated), 3);
	return indexed(matrix(1, 3, ex_to<lst>(list)), nu.toggle_variance())*basis.subs(mu == nu);
}

ex scalar_product(const ex & v1, const ex & v2) {
	return remove_dirac_ONE(canonicalize_clifford(expand_dummy_sum((v1*v2 + v2*v1)/2)));
}

ex vector_product(const ex & v1, const ex & v2, const ex & e_prod) {
	return canonicalize_clifford(expand_dummy_sum((v1*v2 - v2*v1)*e_prod/2));
}


int main(){
	
	realsymbol a1("a1"), b1("b1"), c1("c1"), a2("a2"), b2("b2"), c2("c2"), 
		a3("a3"), b3("b3"), c3("c3"), t("t");
	
	varidx nu(symbol("nu", "\\nu"), 3), mu(symbol("mu", "\\mu"), 3);
	
	ex M = diag_matrix(lst(1, 1, 1)),  // Metrics of point spaces
		T = matrix (3, 3, lst(0, 0, 1,
							  0, 1, 0,
							  -1, 0, 0)),// Transformation matrix
	 	basis1 =  clifford_unit(mu, M, 0), // Main basis defined by Clifford units
	 	basis2 = basis1 * indexed(T, nu, mu.toggle_variance()), // Transformed basis
	 	e1_prod = basis1.subs(mu == 0)*basis1.subs(mu == 1)*basis1.subs(mu == 2),  // Maps bivecors to vectors
	 	vect1 = vector3D(lst(a1, b1, c1), basis1, mu), // vector in the main basis
		vect2 = vector3D(lst(a2, b2, c2), basis2, nu), // vector in the transformed basis
		vect3 = vector3D(lst(a3, b3, c3), basis1, mu); // second vector in the main basis
	
	cout << canonicalize_clifford(expand_dummy_sum(2*vect1+t*vect2)) << endl;
	//-> -e~0*c2*t+a2*t*e~2+2*a1*e~0+2*c1*e~2+e~1*b2*t+2*b1*e~1

	cout << clifford_to_lst(2*vect1+t*vect2, basis1) << endl;
	//-> {-c2*t+2*a1,b2*t+2*b1,2*c1+a2*t}

	cout << scalar_product(vect1, vect3) << endl;
	//-> b3*b1+c1*c3+a3*a1

	cout << scalar_product(vect1, vect2) << endl;
	//-> a2*c1+b1*b2-a1*c2

	cout << vector_product(vect1, vect3, e1_prod) << endl;
	//-> a3*b1*e~2-c1*a3*e~1+c1*b3*e~0-b1*e~0*c3+a1*e~1*c3-b3*a1*e~2

	cout << clifford_to_lst(vector_product(vect1, vect3, e1_prod), basis1) << endl;
	//-> {-b1*c3+c1*b3,a1*c3-c1*a3,-b3*a1+a3*b1}

	cout << vector_product(vect1, vect2, e1_prod) << endl;
	//-> c1*e~1*c2+a2*a1*e~1-a1*b2*e~2-a2*b1*e~0+c1*e~0*b2-b1*c2*e~2

	cout << clifford_to_lst(vector_product(vect1, vect2, e1_prod), basis1) << endl;
	//-> {c1*b2-a2*b1,c1*c2+a2*a1,-b1*c2-a1*b2}
}




More information about the GiNaC-list mailing list