[Numpy-discussion] dot function or dot notation, matrices, arrays?
Sat Dec 19 10:45:16 CST 2009
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
>> 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
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([ ,])
rotCW = matrix([ [cosD(theta), sinD(theta)], [-sinD(theta),
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
> 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.
>>> 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
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/>
More information about the NumPy-Discussion