Skip to content

Commit

Permalink
added x as commutator shorthand. other misc
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenovic committed Nov 16, 2016
1 parent 70ca56c commit 4b3e1c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
12 changes: 9 additions & 3 deletions clifford/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,13 @@ def randomRotor(self):
return R

@property
def basis_vectors(self, **kw):
return basis_vectors(self, **kw)
def basis_vectors(self):
return basis_vectors(self)

@property
def basis_vectors_lst(self):
d = self.basis_vectors
return [d[k] for k in sorted(d.keys())]

@property
def blades(self):
Expand Down Expand Up @@ -1436,7 +1441,8 @@ def commutator(self, other):
"""

return ((self * other) - (other * self)) / 2


x = commutator
def anticommutator(self, other):
"""Returns the anti-commutator product of two multivectors.
Expand Down
22 changes: 19 additions & 3 deletions clifford/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,19 @@ def mat2Frame(A, layout=None, is_complex=None):


return a, layout


def frame2Mat(B, A=None, is_complex=None):
if is_complex is not None:
raise NotImplementedError()
if A is None:
# assume we have orthonormal initial frame
A=B[0].layout.basis_vectors_lst


M = [float(b|a) for b in B for a in A] # you need float() due to bug in clifford
M = array(M).reshape(len(B),len(B))


def orthoFrames2Verser_dist(A,B, eps =None):
'''
Determines verser for two frames related by an orthogonal transform
Expand Down Expand Up @@ -148,7 +160,7 @@ def orthoFrames2Verser_dist(A,B, eps =None):

return R ,r_list

def orthoFrames2Verser(A,B, eps =None, delta=1e-3):
def orthoFrames2Verser(B,A=None, eps =None, delta=1e-3):
'''
Determines verser for two frames related by an orthogonal transform
Expand All @@ -163,6 +175,10 @@ def orthoFrames2Verser(A,B, eps =None, delta=1e-3):
'''

## Checking and Setup
if A is None:
# assume we have orthonormal initial frame
bv = B[0].layout.basis_vectors
A=[bv[k] for k in sorted(bv.keys())]

# make copy of original frames, so we can rotate A
A = Frame(A[:] )
Expand Down Expand Up @@ -257,7 +273,7 @@ def orthoMat2Verser(A, eps=None,layout=None,is_complex=None):
# warn('A doesnt appear to be a rotation. ')

A,layout = mat2Frame(eye(N),layout=layout,is_complex=False)
return orthoFrames2Verser(A,B, eps = eps)
return orthoFrames2Verser(A=A,B=B, eps = eps)



3 changes: 2 additions & 1 deletion docs/EulerAngles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "IPython (Python 2)",
"display_name": "Python [default]",
"language": "python",
"name": "python2"
},
Expand Down

0 comments on commit 4b3e1c3

Please sign in to comment.