Skip to content

Commit

Permalink
added static algebras as modules
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenovic committed Oct 4, 2016
1 parent b08f611 commit 8c5db72
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 16 deletions.
31 changes: 15 additions & 16 deletions clifford/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,10 @@
import numpy as np
from numpy import linalg

_eps = 1e-15 # float epsilon for float comparisons
_pretty = True # pretty-print global
_print_precision = 5 # pretty printing precision on floats

class NoMorePermutations(StandardError):
""" No more permutations can be generated.
"""


_eps = 1e-15 # float epsilon for float comparisons
_pretty = True # pretty-print global
_print_precision = 5 # pretty printing precision on floats
def _myDot(a, b):
"""Returns the inner product as *I* learned it.
Expand All @@ -200,7 +195,11 @@ def _myDot(a, b):

# innerproduct sums over the *last* axes of *both* arguments
return np.inner(a, newB)


class NoMorePermutations(StandardError):
""" No more permutations can be generated.
"""


class Layout(object):
""" Layout stores information regarding the geometric algebra itself and the
Expand Down Expand Up @@ -558,9 +557,6 @@ def bases(self,*args, **kw):
'''
return bases(layout=self, *args,**kw)




class MultiVector(object):
"""An element of the algebra
Expand Down Expand Up @@ -606,6 +602,12 @@ def __init__(self, layout, value=None):


def __array_wrap__(self,out_arr, context=None):
'''
This is a work-around needed to prevent numpy arrays from
operating on MultiVectors using their operators. This happens
because Multivectors act enough like an array, that duck
typing thinks they are an array.
'''
uf, objs, huh = context
if uf.__name__ =='multiply':
return objs[1]*objs[0]
Expand All @@ -619,7 +621,7 @@ def __array_wrap__(self,out_arr, context=None):
return math.e**(objs[0])

else:
raise ValueError('i dont know what to do')
raise ValueError('i dont know how to %s yet'%uf.__name__)


def _checkOther(self, other, coerce=1):
Expand Down Expand Up @@ -1709,7 +1711,6 @@ def Cl(p, q=0, names=None, firstIdx=1, mvClass=MultiVector):

return layout, blades


def bases(layout, mvClass=MultiVector,grades=None):
"""Returns a dictionary mapping basis element names to their MultiVector
instances, optionally for specific grades
Expand All @@ -1733,8 +1734,6 @@ def bases(layout, mvClass=MultiVector,grades=None):
dict[layout.names[i]] = mvClass(layout, v)
return dict



def basis_vectors(layout):
'''
dictionary of basis vectors
Expand Down
4 changes: 4 additions & 0 deletions clifford/g2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

from . import Cl
layout, blades = Cl(2)
locals().update(blades)
6 changes: 6 additions & 0 deletions clifford/g2c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from . import Cl
layout, blades = Cl(2)
layout, blades, stuff = conformalize(layout)

locals().update(blades)
locals().update(stuff)
3 changes: 3 additions & 0 deletions clifford/g3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import Cl
layout, blades = Cl(3)
locals().update(blades)
3 changes: 3 additions & 0 deletions clifford/g3_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import Cl
layout, blades = Cl(3,1)
locals().update(blades)
6 changes: 6 additions & 0 deletions clifford/g3c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from . import Cl
layout, blades = Cl(3)
layout, blades, stuff = conformalize(layout)

locals().update(blades)
locals().update(stuff)
3 changes: 3 additions & 0 deletions clifford/g4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import Cl
layout, blades = Cl(4)
locals().update(blades)

0 comments on commit 8c5db72

Please sign in to comment.