Skip to content

Commit

Permalink
ENH: Add grade ranges.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Endres committed Aug 16, 2018
1 parent 8793d3e commit 81c78c3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions clifford/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ def _checkList(self):
if self.bladeTupList.count(blade) != 1:
raise ValueError("blades not unique")

# check for right dimensionality
if len(self.bladeTupList) != 2**self.dims:
raise ValueError("incorrect number of blades")
# check for right dimensionality #TODO: Find replacement
#if len(self.bladeTupList) != 2**self.dims:
# raise ValueError("incorrect number of blades")

# check for valid ranges of indices
valid = list(range(self.firstIdx, self.firstIdx + self.dims))
Expand Down Expand Up @@ -2116,7 +2116,7 @@ def fact(n):
return int(fact(n)/(fact(k)*fact(n - k)))


def elements(dims, firstIdx=0):
def elements(dims, firstIdx=0, kr=None):
"""Return a list of tuples representing all 2**dims of blades
in a dims-dimensional GA.
Expand All @@ -2126,8 +2126,10 @@ def elements(dims, firstIdx=0):
indcs = list(range(firstIdx, firstIdx + dims))

blades = [()]
if kr is None:
kr = range(1, dims+1)

for k in range(1, dims+1):
for k in kr:
# k = grade

if k == 1:
Expand Down Expand Up @@ -2167,19 +2169,22 @@ def elements(dims, firstIdx=0):
return blades


def Cl(p=0, q=0, sig=None, names=None, firstIdx=1, mvClass=MultiVector):
def Cl(p=0, q=0, sig=None, names=None, firstIdx=1, mvClass=MultiVector,
kr=None):
"""Returns a Layout and basis blades for the geometric algebra Cl_p,q.
The notation Cl_p,q means that the algebra is p+q dimensional, with
the first p vectors with positive signature and the final q vectors
negative.
Cl(p, q=0, names=None, firstIdx=0) --> Layout, {'name': basisElement, ...}
Use kr to define subspace of blades
"""
if sig is None:
sig = [+1]*p + [-1]*q
bladeTupList = elements(len(sig), firstIdx)

bladeTupList = elements(len(sig), firstIdx, kr)
layout = Layout(sig, bladeTupList, firstIdx=firstIdx, names=names)
blades = bases(layout, mvClass)

Expand Down

0 comments on commit 81c78c3

Please sign in to comment.