So I think we've decided to make a new Vector class, to replace the
previous UnitVector and Vector classes, and it will not extend any
other sympy classes. It will use sympy's matrix class. The current
plan is for each vector to have a list of lists; the inner list will
be the coefficients of each basis vector and the frame they belong to,
and the outer list will store the inner list for each frame. It will
be something like:
[[(1,2,1),B],[(4,2,1),N]]
As for operations, we're currently leaning towards writing operators
for Vector, and then wrapping them with Dot, Cross, etc.
So if A & B are Vectors, and t a scalar:
A*t would call Vector.__mul__
Dot(A,B) would call Vector.__and__ , maybe? We're still deciding on
which operators to use for dot and cross products.
Does this seem like an good solution? Allowing one user interface
that is unambiguous but longer and a shorter, rougher option?
I think this will all work out nicely, as once you have the basis
vectors instantiated, you'll control what is returned by every
operation. This leads to the final thing we're trying to decide; how
to use the three basis vectors.
It's between calling something like:
b1,b2,b3,B = ReferenceFrame('B'), where b1 is a Vector with contents
[[(1,0,0),B]], etc
or
B = ReferenceFrame('B')
and then access the basis vectors as B[1], B[2], B[3] or B.x,B.y,B.z
or B.i, B.j, B.k
What are people's opinions here? Should the basis vectors be linked
with the frame they are created with? Or should they be independent
in the namespace?
-Gilbert
On May 11, 1:18 pm, Ronan Lamy <[email protected]> wrote:
> Le mardi 10 mai 2011 à 11:37 -0700, Luke a écrit :
>
> > The dot and cross products are implemented at the lowest level in
> > UnitVector, and the Vector class simply calls these methods on all of
> > the UnitVector objects that comprise it when these methods are called
> > on a Vector class.
>
> > dot and cross functions are provided as convenience wrapper functions
> > around the class methods, so the user can choose to use whichever
> > approach is more natural to them.
>
> Not making a choice between the two options might seem easiest in the
> short term but it's actually the worst decision in the long term. And
> this is Alex Martelli's opinion[1], not mine, so it must be true!
>
> The function interface suggests that the operation is something that
> depends equally on the two operands. The method interface suggests that
> it's something that the first operand does to the second, or that it's a
> characteristic of the first operand influenced by the second. I think
> the first interpretation makes more sense. In any case, the current
> implementation shouldn't dictate what the interface looks like, because
> implementations can always be changed, but modifying an interface is
> much more painful.
>
> [1]: See his Pycon 2011 talk
> [http://python.mirocommunity.org/video/4230/pycon-2011-api-design-anti...]
> from 26:38 and, more specifically, from 29:08. Slides for the talk:
> [http://www.aleax.it/pycon11_adap.pdf]
>
>
>
>
>
>
>
> > ~Luke
>
> > On Tue, May 10, 2011 at 11:02 AM, Vinzent Steinberg
> > <[email protected]> wrote:
> > > On 10 Mai, 03:30, Ronan Lamy <[email protected]> wrote:
> > >> Please, try to make the interface dot(v1, v2), and not v1.dot(v2).
>
> > > While I agree that it looks cleaner for the simple case, I would
> > > prefer
>
> > > v1.dot(v2).dot(v3)
>
> > > over
>
> > > dot(dot(v1, v2), v3)
>
> > > For the dot product it does of course not make sense to multiply three
> > > vectors in a row, but I think we should keep this in mind in general
> > > for user defined operations.
>
> > > Vinzent
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "sympy" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group
> > > athttp://groups.google.com/group/sympy?hl=en.
>
> > --
> > "Those who would give up essential liberty to purchase a little
> > temporary safety deserve neither liberty nor safety."
>
> > -- Benjamin Franklin, Historical Review of Pennsylvania, 1759
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.