[Numpy-discussion] Matrix construction

Bill Baxter wbaxter at gmail.com
Thu Jun 22 15:11:11 EDT 2006


On 6/23/06, Keith Goodman <kwgoodman at gmail.com> wrote:
>
> On 6/22/06, Bill Baxter <wbaxter at gmail.com> wrote:
> > On 6/22/06, Ed Schofield <schofield at ftw.at> wrote:
> >
> > >
> > > On 22/06/2006, at 12:40 AM, Bill Baxter wrote:
> > >
> > > > Actually I think using mat() (just an alias for the matrix
> > > > constructor) is a bad way to do it.  That mat() (and most others on
> > > > that page) should probably be replaced with asmatrix() to avoid the
> > > > copy.
> > >
> > > Perhaps the 'mat' function should become an alias for 'asmatrix'.
> > > I've thought this for a while.
> >
> >
> > That makes sense to me.  As far as I know, asmatrix() defaults to
> calling
> > the constructor if it can't snarf the memory of the object being passed
> in.
> >
> > So, go on, shoot Ed and me down! :-)
>
> I can anticipate one problem: the Pirates will want their three-letter
> abbreviation for asarray.


arr() me maties!

Will functions like rand and eye always return arrays? Or will there
> be a day when you can tell numpy that you are working with matrices
> and then it will return matrices when you call rand, eye, etc?
>

I don't disagree there's a need, but you can always make your own:

def mrand(*vargs):
    return asmatrix(rand(*vargs))

def meye(N, **kwargs):
    return asmatrix(eye(N,**kwargs))

--bb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060623/f3a4fa62/attachment-0001.html>


More information about the NumPy-Discussion mailing list