[Numpy-discussion] dot function or dot notation, matrices, arrays?
Dag Sverre Seljebotn
Sat Dec 19 07:19:50 CST 2009
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
> 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
NumPy is all about arrays, not matrices and vectors.
> *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.
>> On Fri, Dec 18, 2009 at 9:29 PM, Wayne Watson
>> <firstname.lastname@example.org> 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 mailing list
More information about the NumPy-Discussion