Skip to content

Commit

Permalink
Merge pull request sympy#1098 from cbuehler/3103
Browse files Browse the repository at this point in the history
remove broadcasting from galgebra
  • Loading branch information
smichr committed Mar 3, 2012
2 parents f05e39c + fe723d4 commit c6542db
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 568 deletions.
2 changes: 1 addition & 1 deletion doc/src/modules/galgebra/GA/BasicGAtest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MV.setup('a b c d e')
a,b,c,d,e = MV.setup('a b c d e')
MV.set_str_format(1)

print 'e|(a^b) =',e|(a^b)
Expand Down
6 changes: 3 additions & 3 deletions doc/src/modules/galgebra/GA/Dirac.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
'0 0 -1 0,'+\
'0 0 0 -1'

vars = make_symbols('t x y z')
MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)
vars = symbols('t x y z')
gamma_t,gamma_x,gamma_y,gamma_z = MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)

parms = make_symbols('m e')
m,e = symbols('m e')
Format('1 1 1 1')
I = MV(ONE,'pseudo')
nvars = len(vars)
Expand Down
20 changes: 3 additions & 17 deletions doc/src/modules/galgebra/GA/GAsympy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,8 @@ curvilinear coordinates using:
is::

metric = '1 0 0,0 1 0,0 0 1'
MV.setup('gamma_x gamma_y gamma_z',metric,True)
coords = make_symbols('r theta phi')
gamma_x,gamma_y,gamma_z = MV.setup('gamma_x gamma_y gamma_z',metric,True)
coords = r,theta,phi = sympy.symbols('r theta phi')
x = r*(sympy.cos(theta)*gamma_z+sympy.sin(theta)*\
(sympy.cos(phi)*gamma_x+sympy.sin(phi)*gamma_y))
x.set_name('x')
Expand Down Expand Up @@ -1165,8 +1165,7 @@ Instantiating a Multivector

Now that grades and bases have been described we can show all the ways that a
multivector can be instantiated. As an example assume that the multivector space
is initialized with ``MV.setup('e1 e2 e3')``. Then the vectors ``e1``, ``e2``,
and ``e3`` are made available (broadcast) for use in the program .
is initialized with ``e1,e2,e3 = MV.setup('e1 e2 e3')``.

So that multivectors
could be instantiated with statements such as (``a1``, ``a2``, and ``a3`` are
Expand Down Expand Up @@ -1350,19 +1349,6 @@ These are functions in :mod:`GA`, but not in the multivector (:class:`MV`)
class.


.. function:: make_symbols(symnamelst)

:func:`make_symbols` creates a list of :mod:`sympy` symbols with names defined
by the space delimited string *symnamelst*. In addition to returning the symbol
list the function broadcasts the named symbols to the main program. For example
if you make the call::

syms = make_symbols('x y ab')

Not only will *syms* contain the symbols, but you can also directly use *x*,
*y*, and *ab* as symbols in your program.


.. function:: set_names(var_lst,var_str)

:func:`set_names` allows one to name a list, *var_lst*, of multivectors enmass.
Expand Down
4 changes: 2 additions & 2 deletions doc/src/modules/galgebra/GA/Maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
'0 0 -1 0,'+\
'0 0 0 -1'

vars = make_symbols('t x y z')
MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)
vars = symbols('t x y z')
gamma_t,gamma_x,gamma_y,gamma_z = MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)
LatexPrinter.format(1,1,1,1)
I = MV(1,'pseudo')
print '$I$ Pseudo-Scalar'
Expand Down
13 changes: 7 additions & 6 deletions doc/src/modules/galgebra/GA/conformalgeometryGAtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

metric = '1 0 0 0 0,0 1 0 0 0,0 0 1 0 0,0 0 0 0 2,0 0 0 2 0'

MV.setup('e0 e1 e2 n nbar',metric,debug=0)
e0,e1,e2,n,nbar = MV.setup('e0 e1 e2 n nbar',metric,debug=0)
MV.set_str_format(1)
e = n+nbar
#conformal representation of points

A = make_vector(e0) # point a = (1,0,0) A = F(a)
B = make_vector(e1) # point b = (0,1,0) B = F(b)
C = make_vector(-1*e0) # point c = (-1,0,0) C = F(c)
D = make_vector(e2) # point d = (0,0,1) D = F(d)
X = make_vector('x',3)
A = F(e0,n,nbar) # point a = (1,0,0) A = F(a)
B = F(e1,n,nbar) # point b = (0,1,0) B = F(b)
C = F(-1*e0,n,nbar) # point c = (-1,0,0) C = F(c)
D = F(e2,n,nbar) # point d = (0,0,1) D = F(d)
x0,x1,x2 = sympy.symbols('x0 x1 x2')
X = F(MV([x0,x1,x2],'vector'),n,nbar)

print 'a = e0, b = e1, c = -e0, and d = e2'
print 'A = F(a) = 1/2*(a*a*n+2*a-nbar), etc.'
Expand Down
4 changes: 2 additions & 2 deletions doc/src/modules/galgebra/GA/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
'0 1 0,'+\
'0 0 1'

MV.setup('gamma_x gamma_y gamma_z',metric,True)
gamma_x,gamma_y,gamma_z = MV.setup('gamma_x gamma_y gamma_z',metric,True)
Format('1 1 1 1')

coords = make_symbols('r theta phi')
coords = r,theta,phi = symbols('r theta phi')
x = r*(sympy.cos(theta)*gamma_z+sympy.sin(theta)*\
(sympy.cos(phi)*gamma_x+sympy.sin(phi)*gamma_y))
x.set_name('x')
Expand Down
17 changes: 3 additions & 14 deletions doc/src/modules/galgebra/GA/headerGAtest.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import os,sys,sympy
from sympy.galgebra.GA import make_symbols, types, MV, ZERO, ONE, HALF
from sympy import collect
from sympy.galgebra.GA import MV, ZERO, ONE, HALF
from sympy import collect, symbols

def F(x):
def F(x, n, nbar):
"""
Conformal Mapping Function
"""
Fx = HALF*((x*x)*n+2*x-nbar)
return(Fx)

def make_vector(a,n = 3):
if type(a) == types.StringType:
sym_str = ''
for i in range(n):
sym_str += a+str(i)+' '
sym_lst = make_symbols(sym_str)
sym_lst.append(ZERO)
sym_lst.append(ZERO)
a = MV(sym_lst,'vector')
return(F(a))

if __name__ == '__main__':
7 changes: 5 additions & 2 deletions doc/src/modules/galgebra/GA/hyperbolicGAtest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
print 'Example: non-euclidian distance calculation'

metric = '0 # #,# 0 #,# # 1'
MV.setup('X Y e',metric)
X,Y,e = MV.setup('X Y e',metric)
XdotY = sympy.Symbol('(X.Y)')
Xdote = sympy.Symbol('(X.e)')
Ydote = sympy.Symbol('(Y.e)')
MV.set_str_format(1)
L = X^Y^e
B = L*e
Expand All @@ -12,7 +15,7 @@
print 'B*e*B.rev() =',BeBr
print 'B^2 =',Bsq
print 'L^2 =',(L*L)()
make_symbols('s c Binv M S C alpha')
s,c,Binv,M,S,C,alpha = symbols('s c Binv M S C alpha')
Bhat = Binv*B # Normalize translation generator
R = c+s*Bhat # Rotor R = exp(alpha*Bhat/2)
print 's = sinh(alpha/2) and c = cosh(alpha/2)'
Expand Down
2 changes: 1 addition & 1 deletion doc/src/modules/galgebra/GA/reciprocalframeGAtest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MV.setup('e1 e2 e3',metric)
e1,e2,e3 = MV.setup('e1 e2 e3')

print 'Example: Reciprocal Frames e1, e2, and e3 unit vectors.\n\n'

Expand Down
6 changes: 3 additions & 3 deletions doc/src/modules/galgebra/latex_ex/Maxwell.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys
import sys, sympy
import sympy.galgebra.GAsympy as GA
import sympy.galgebra.latex_ex as tex

Expand All @@ -9,8 +9,8 @@
'0 0 -1 0,'+\
'0 0 0 -1'

vars = GA.make_symbols('t x y z')
GA.MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)
vars = sympy.symbols('t x y z')
gamma_t,gamma_x,gamma_y,gamma_z = GA.MV.setup('gamma_t gamma_x gamma_y gamma_z',metric,True,vars)
tex.Format()
I = GA.MV(1,'pseudo')
I.convert_to_blades()
Expand Down
11 changes: 4 additions & 7 deletions doc/src/modules/galgebra/latex_ex/latex_ex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ One of the main extensions in :mod:`latex_ex` is the ability to encode complex
symbols (multiple greek letters with accents and superscripts and subscripts) is
ascii strings containing only letters, numbers, and underscores. These
restrictions allow :mod:`sympy` variable names to represent complex symbols. For
example if we use the :mod:`GA` module function :func:`make_symbols` as
example if we use the function :func:`symbols` as
follows::

make_symbols('xalpha Gammavec__1_rho delta__j_k')
xalpha,Gammavec__1_rho,delta__j_k = symbols('xalpha Gammavec__1_rho delta__j_k')

``make_symbols`` creates the three :mod:`sympy` symbols *xalpha*,
``symbols`` creates the three :mod:`sympy` symbols *xalpha*,
*Gammavec__1_rho*, and *delta__j_k*. If these symbols are printed with the
:mod:`latex_ex` modules the results are

Expand Down Expand Up @@ -284,10 +284,7 @@ the string ``'x = '+str(x)`` to the output processor (:func:`xdvi`). Because
the string contains an :math:`=` sign the processor treats the string as an
LaTeX equation (unnumbered). If ``'x ='`` was not in the print statment a
LaTeX error would be generated. In the case of a :class:`GA` multivector one
does not need the ``'x ='`` if the multivector has been given a name. In the
example the :class:`GA` function :func:`make_symbols` has been used to create
the :class:`sympy` symbols for convenience. The :class:`sympy` function
:func:`Symbol` could have also been used.
does not need the ``'x ='`` if the multivector has been given a name.


:program:`Maxwell.py` a multivector example
Expand Down
5 changes: 2 additions & 3 deletions doc/src/modules/galgebra/latex_ex/latexdemo.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import sys
import sympy.galgebra.GA as GA
import sys, sympy
import sympy.galgebra.latex_ex as tex

if __name__ == '__main__':

tex.Format()
GA.make_symbols('xbm alpha_1 delta__nugamma_r')
xbm,alpha_1,delta__nugamma_r = sympy.symbols('xbm alpha_1 delta__nugamma_r')

x = alpha_1*xbm/delta__nugamma_r

Expand Down
Loading

0 comments on commit c6542db

Please sign in to comment.