pygae / clifford

Geometric Algebra for Python
http://clifford.rtfd.io
BSD 3-Clause "New" or "Revised" License
754 stars 72 forks source link

domains of conformalize up()/down() algebra #34

Open arsenovic opened 6 years ago

arsenovic commented 6 years ago

i think the up and down methods of conformalize() should take/return vectors in the different algebras:

we could overload each method to work on vectors in either algebra. here is a quick way to do it,

from numpy import zeros
from clifford import Cl

ga,blades = Cl(2)
cga,blades,stuff = conformalize(ga)
def up(x):
    old_val = x.value
    new_val = zeros(cga.layout.gaDims)
    new_val[:len(old_val)] = old_val
    x_in_cga =  cga.MultiVector(value=new_val)
    #do normal up method on x_in_cga

and similar for down .what do you think? also, we need a consistent name for the algebra that is conformalized, like original, lower, whatever.

moble commented 6 years ago

I really like this idea, and your PR makes it look like an elegant approach, leaving room for helpful specializations and generally more descriptive code.

Now, to spitball some words that could be used to define the different methods and so on: In the literature, you'll frequently see discussion of the progression from Cartesian, to projective, and then conformal models of the same underlying Euclidean geometry. So I wonder if conformal and cartesian might be more descriptive and/or readily understood than up and down, respectively — and leave room for projective when people want to use that model. Maybe more generally, if you think of one space as a subspace of another, an element of the subspace is mapped into the superspace by "inclusion" or sometimes even "promotion", and mapped back to the subspace by "projection", "restriction", or "demotion". Also, when you have some structure over a space, you frequently call the original space the "base" space.

hugohadfield commented 6 years ago

I think in general we need to address the problems of mixing multivectors from multiple algebras. The most common form of this I run into is probably the cartesian/conformal pair but it is likely to appear in a variety of places in which we want to use code written for different algebras where one is a sub-algebra of another. I don't really know what the solution to this is and haven't touched it at all so far for fear opening a big can of worms that I don't have the time to get really stuck into... currently I find working entirely in (4,1) works well for all my (3,0) and (4,1) code and prevents any potential headaches caused by forgetting what layout is associated with what mv.

moble commented 6 years ago

For that purpose, I wonder to what extent the subalgebra should actually be a separate object. For example, e1, e2, e3 in the base space are really the same vectors in the conformal model of that space, so it makes sense that they should literally be the same objects in python. In particular, they behave identically under the various operations in each algebra — the only real difference being how we name things like the pseudoscalar and the dual.

From the viewpoint of universal geometric algebra, every particular GA is just a subalgebra of the universal GA, defined by its particular pseudoscalar. Where Alex does cga.down(C_.center), he could just as well write something like I3 = e1^e2^e3 and then C_.center.project(I3).

But I still think it makes sense to start with the base space and then conformalize it, as long as the basis vectors in the base space are really identified with the corresponding vectors of its conformal model. The conformal model could keep a copy of the base space's pseudoscalar to do all the projection, maybe via a method named something like cartesian — just for example. :)

arsenovic commented 6 years ago

agreed. . i kept both algebras mainly for clarity. it does allow objects to be constructed by either null vectors, or base vectors. This is useful in my opinion because original data likely comes from base space, while intermediate computations generate null vectors (or other cga objects). however, as suggested, to test for a MV x being in the base space could be made by simply testing x^I_base=0 (or perhaps <tol).

I_base is returned by conformalize() as a blade in cga, except its currently called I_ga ,

@moble , i think you meant I3.project(C_.center), but you need also the homo(); so it would be I3.project(cga.homo(C_.center)). the down() does the this , except uses a rejection from E0. homo could be done before hand, but its wasteful.

the method which puts a vector to/from base ga/cga by simply copying its components i am currently calling straight_up(), straight_down().

do we need the start with or keep the base space?

overall, i think an important aspects of clifford are to be clear, concise, and general. not a specialized CGA machine