Help me on function definition
sjmachin at lexicon.net
Sat Mar 29 04:09:50 CET 2008
On Mar 29, 12:47 pm, "aeneng" <aen... at yahoo.com> wrote:
> Hello everyone,
> I am just starting to use python in numerical cacluation.
> I need you to help me to see what's wrong with the following piece of
> codes, which computes the cross product of two vectors and returns
> the result. u and v are two 3x1 matrix.
> when I import the function, error message show like this>>> import cross
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "cross.py", line 8
> SyntaxError: invalid syntax
> WHAT IS WRONG WITH MY CODE?
> I appreciate your help.
> ##here is the function definition.
> def cross(u,v)
> """input two vectors u and v in 3-D space,
> output a cross product of vector w, in column or in row
> # store the result of the cross product in u
> return u #return the cross product of vector u x v.
And you are stuffing the result into the first argument as well as
returning the result ... not a good idea.
> if __name__=="__main__":
> from cvxopt.base import matrix
> print cross(u,v)
> print "file name is %s" %__name__
More information about the Python-list