-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Milestone
Description
One can iterate over a multivector to get all values in it (e.g. all points in a point cloud), but this only seems to work if the input are already arrays:
import numpy as np
ALGEBRA = Algebra.fromname("3DPGA")
N = 500
x = np.random.random_sample(N)
y = np.random.random_sample(N)
z = np.random.random_sample(N)
pnt = MultiVector(ALGEBRA, e032=x, e013=y, e021=z, e123=np.ones(N))
for p in pnt:
print(p) # works fine
For scalar input, I assumed the iteration would just return the scalar input. Instead, a TypeError is raised.
pnt = MultiVector(ALGEBRA, e032=1.5, e013=6.0, e021=-4.0, e123=1.0)
for p in pnt: # TypeError
print(p)
The above example does work if all are converted to np.ndarray first.
x = np.array([1.5])
y = np.array([6.0])
z = np.array([-4.0])
pnt = MultiVector(ALGEBRA, e032=x, e013=y, e021=z, e123=np.array([1.0]))
for p in pnt:
print(p) # works fine
For empty input, I would assume the for loop does not iterate at all (like iterating over an empty list). However, this seems to return an infinite loop.
pnt = MultiVector(ALGEBRA)
for p in pnt:
print(p) # infinite sequence of 0's.
Metadata
Metadata
Assignees
Labels
No labels