# Source code for sympy.galgebra.ga

# sympy/galgebra/ga.py

"""
ga.py implements the symbolic geometric algebra of an n-dimensional
vector space with constant metric (future versions will allow for a
metric that is a function of coordinates) with an arbitrary set of
basis vectors (whether they are orthogonal or not depends on the
metric the use inputs).

All the products of geometric algebra -

geometric
outer (wedge)
inner (dots)
left contraction
right contaction

at the documentation for the module.
"""

from __future__ import print_function

from functools import reduce
from itertools import combinations

import copy
import operator

from sympy import Symbol, Expr, expand, Mul, Add, S, collect, \
Function, simplify, diff, trigsimp, sqrt, Number, \
factor_terms, sin, cos, sinh, cosh
from sympy import N as Nsympy

from sympy.galgebra.printing import GA_Printer, GA_LatexPrinter, enhance_print, latex
from sympy.galgebra.vector import Vector
from sympy.galgebra.debug import oprint
from sympy.galgebra.stringarrays import fct_sym_array, str_combinations
from sympy.galgebra.ncutil import linear_expand, bilinear_product, nc_substitue, \
get_commutative_coef, ONE_NC

[docs]def diagpq(p, q=0): """ Returns string equivalent metric tensor for signature (p, q). """ n = p + q D = [] for i in range(p): D.append((i*'0 ' +'1 '+ (n-i-1)*'0 ')[:-1]) for i in range(p,n): D.append((i*'0 ' +'-1 '+ (n-i-1)*'0 ')[:-1]) return ','.join(D)
[docs]def arbitrary_metric(n): """ Returns string equivalent metric tensor for arbitrary signature. """ return ','.join(n*[(n*'# ')[:-1]])
[docs]def arbitrary_metric_conformal(n): """ Returns string equivalent metric tensor for arbitrary signature (n+1,1). """ str1 = ','.join(n*[n*'# '+'0 0']) return ','.join([str1, n*'0 '+'1 0', n*'0 '+'0 -1'])