## Re: [Matplotlib-users] Vector magnitude?

 Re: [Matplotlib-users] Vector magnitude? From: Steve Schmerler - 2007-09-05 20:51:36 ```Robert Dailey wrote: > Hi, > > I have two questions: > > 1) Is there any way to represent vectors? Currently I'm using 'array' for > vectors. > I suppose you mean vectors in the Matlab way? Then you should have a look at http://scipy.org/NumPy_for_Matlab_Users#head-e9a492daa18afcd86e84e07cd2824a9b1b651935 In short: of course you can do all linalg with numpy.array. With numpy.matrix, some operations (like dot products) can be written more conveniently. > 2) Is there a way to calculate the magnitude (length) of a vector? > a = array([3,1,4]) len(a) a.size # only for a rank-1 array a.shape[0] For some basics on numpy, you may also check out: http://scipy.org/Documentation HTH -- cheers, steve I love deadlines. I like the whooshing sound they make as they fly by. -- Douglas Adams ```

 [Matplotlib-users] Vector magnitude? From: Robert Dailey - 2007-09-05 17:02:08 Attachments: Message as HTML ```Hi, I have two questions: 1) Is there any way to represent vectors? Currently I'm using 'array' for vectors. 2) Is there a way to calculate the magnitude (length) of a vector? Thanks. ```
 Re: [Matplotlib-users] Vector magnitude? From: Steve Schmerler - 2007-09-05 20:51:36 ```Robert Dailey wrote: > Hi, > > I have two questions: > > 1) Is there any way to represent vectors? Currently I'm using 'array' for > vectors. > I suppose you mean vectors in the Matlab way? Then you should have a look at http://scipy.org/NumPy_for_Matlab_Users#head-e9a492daa18afcd86e84e07cd2824a9b1b651935 In short: of course you can do all linalg with numpy.array. With numpy.matrix, some operations (like dot products) can be written more conveniently. > 2) Is there a way to calculate the magnitude (length) of a vector? > a = array([3,1,4]) len(a) a.size # only for a rank-1 array a.shape[0] For some basics on numpy, you may also check out: http://scipy.org/Documentation HTH -- cheers, steve I love deadlines. I like the whooshing sound they make as they fly by. -- Douglas Adams ```
 Re: [Matplotlib-users] Vector magnitude? From: Norbert Nemec - 2007-09-06 19:09:25 ```Robert Dailey wrote: > 1) Is there any way to represent vectors? Currently I'm using 'array' > for vectors. There is no explicit 'vector' representation. You may view vectors as either column or row vectors and represent them as 1xN or Nx1 matrices. In that case, the linear algebra like matrix products etc. can be used rather elegantly. Otherwise, you just use 1D-arrays and take care of the vector semantics yourself. > 2) Is there a way to calculate the magnitude (length) of a vector? numpy.linalg.norm(X) (works for vectors as well as matrices) ```
 Re: [Matplotlib-users] Vector magnitude? From: Steve Schmerler - 2007-09-07 06:47:09 ```Norbert Nemec wrote: > >> 2) Is there a way to calculate the magnitude (length) of a vector? > numpy.linalg.norm(X) > This makes more sense than len(). I've got confused by "length" :) -- cheers, steve I love deadlines. I like the whooshing sound they make as they fly by. -- Douglas Adams ```