Dag Sverre Seljebotn wrote: > Wayne Watson wrote: > >> I'm trying to compute the angle between two vectors in three dimensional >> space. For that, I need to use the "scalar (dot) product" , according to >> a calculus book (quoting the book) I'm holding in my hands right now. >> I've used dot() successfully to produce the necessary angle. My program >> works just fine. >> >> In the case of the dot(function), one must use np.dev(x.T,x), where x is >> 1x3. >> >> I'm not quite sure what your point is about dot()* unless you are >> thinking in some non-Euclidean fashion. One can form np.dot(a,b) with a >> and b arrays of 3x4 and 4x2 shape to arrive at a 3x2 array. That's >> definitely not a scalar. Is there a need for this sort of calculation in >> non-Euclidean geometry, which I have never dealt with? >> > > There's a difference between 1D and 2D arrays that's important here. For > a 1D array, np.dot(x.T, x) == np.dot(x, x), since there's only one > dimension. > A 4x1, 1x7, and 1x5 would be examples of a 1D array or matrix, right?
Are you saying that instead of using a rotational matrix like theta = 5.0 # degrees m1 = matrix([[2] ,[5]]) rotCW = matrix([ [cosD(theta), sinD(theta)], [-sinD(theta), cosD(theta)] ]) m2= rotCW*m1 m1=np.array(m1) m2=np.array(m2) that I should use a 2-D array for rotCW? So why does numpy have a matrix class? Is the class only used when working with matplotlib? To get the scalar value (sum of squares) I had to use a transpose, T, on one argument. > NumPy is all about arrays, not matrices and vectors. > > Dag Sverre > > >> *Maybe it's about something else related to it. >> >> >> David Goldsmith wrote: >> >>> np.dot(x.flat, x.flat) _is exactly_ "sum of squares"(x.flat). Your >>> math education appears to have drawn a distinction between "dot >>> product" and "scalar product," that, when one is talking about >>> Euclidean vectors, just isn't there: in that context, they are one and >>> the same thing. >>> >>> DG >>> >>> On Fri, Dec 18, 2009 at 9:29 PM, Wayne Watson >>> <sierra_mtnv...@sbcglobal.net> wrote: >>> >>> >>>> I'll amend that. I should have said, "Dot's all folks." -- Bugs Bunny >>>> >>>> -- >>>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>>> >>>> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >>>> Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet >>>> >>>> "... humans'innate skills with numbers isn't much >>>> better than that of rats and dolphins." >>>> -- Stanislas Dehaene, neurosurgeon >>>> >>>> Web Page: <www.speckledwithstars.net/> >>>> >>>> _______________________________________________ >>>> NumPy-Discussion mailing list >>>> NumPy-Discussion@scipy.org >>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion >>>> >>>> >>>> >>> _______________________________________________ >>> NumPy-Discussion mailing list >>> NumPy-Discussion@scipy.org >>> http://mail.scipy.org/mailman/listinfo/numpy-discussion >>> >>> >>> > > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet "... humans'innate skills with numbers isn't much better than that of rats and dolphins." -- Stanislas Dehaene, neurosurgeon Web Page: <www.speckledwithstars.net/> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion