[Numpy-discussion] PyMatrix: Announcement
Sebastian Haase
haase at msg.ucsf.edu
Thu Dec 11 10:46:02 CST 2003
Thanks for the reply.
PEP 225 is from Sept-2000 and http://matpy.sourceforge.net and dated from Mar-2002 (Python 2.0)
That is about the results I got from my first google-groups search. What is the current thinking about this ?
Looks to me like the "new operator" idea is dead. Or ??
I actually like (read: could live with) alternative 4 in PEP 225: which is, to provide operator overloading for what I call
"different views" of the same matrix / image. How difficult is this to implement ?
(What is the real difference to alternative 3 ? They both have m1.E * m2.E . )
Regards,
Sebastian
----- Original Message -----
From: Colin J. Williams
To: Sebastian Haase
Sent: Wednesday, December 10, 2003 5:27 AM
Subject: Re: [Numpy-discussion] PyMatrix: Announcement
Sebastian Haase wrote:
Hi Colin,
We are interested in using your PyMatrix packages (It' numarray not Numeric,
right?).That is correct. Testing so far is with numarray 0.7. Please remember to also install the version 0.7 addons. When version 0.8 arrives, all will be included in one package.
The package is intended for comment and review. There is at least one problem in numarray, which we hope will be resolved in version 0.8. For example, for some functions, upon the first call, the function returns an instance of the M class (matrix), on the second call, it returns an instance of the NumArray class.
First though, someone in my lab had the following concern:
What if I actually need the element-wise multiplication ?
(In other words: The Matlab .* operator) [1]
I understand that python does not allow to invent new operator symbols.Yes. This issue was discussed in PEP 225.
How about multiplying a Matrix with a Numarray ?Please see [2].
Is it possible to have a 'numarray view' of a Matrix object ? (I'm thinking
of two differently typed objects sharing one "value-memory space", so that
essentially the type determines which multiplication is being used ...)There is a need to think through the copy/view approach in PyMatrix. Currently, most cases are copies.
I'm inclined to deprecate the dual view approach, but I would appreciate comments.
Let me know if you have any questions or comments.
Colin W.
Thanks,
Sebastian Haase
----- Original Message -----
From: "Colin J. Williams" <cjw at sympatico.ca>
Newsgroups: comp.lang.python,comp.lang.python.announce
To: "numpy-discussion" <numpy-discussion at lists.sourceforge.net>; "SciPy
Discussion List" <scipy-user at scipy.net>
Cc: "Huaiyu Zhu" <hzhu at users.sourceforge.net>
Sent: Monday, November 24, 2003 5:17 AM
Subject: [Numpy-discussion] PyMatrix: Announcement
PyMatrix is available for test and review.
http://www3.sympatico.ca/cjw
PyMatrix provides access to basic matrix arithmetic, using Python and
numarray.
Examples:
A * B => the product of
matrices A and B
A.I => the inverse of matrix
A
A.EVectors => the eigenvectors of A
A.var(0) => the variances of the
columns of A
(a.T*a).I * a.T*b => the solution (x) for a *
x = b,
where a is a
matrix and b a column vector
This package was developed on a Windows XP. I would appreciate
comments, particularly with respect to usage on other systems.
Colin W.
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Notes:
[1] Elementwise Multiplication
The thinking here is that, for most matrix usage, the elementwise multiplication is less frequently required.
Thus, a more complex expression can be tolerated. See the example below:
a= mRange(9, shape=(3, 3))
b= mRange((9, 18), shape= (3, 3))
print 'Matrixwise multiplation:'
print 'a * b (prettyprinted):', pp(a * b)
print 'Elementwise multiplation:'
print 'a * b (prettyprinted):', pp(M(a.A * b.A)))
In the last case, we use the array mechanism.
The output is:
Matrixwise multiplation:
a * b (prettyprinted):matrix([[ 42, 45, 48],
[150, 162, 174],
[258, 279, 300]])
None
Elementwise multiplation:
a * b (prettyprinted):matrix([[ 0, 10, 22],
[ 36, 52, 70],
[ 90, 112, 136]])
None
[2] Multiplication of a matrix by an array or nested list
When an compatible array or list is juxtapositioned with a matrix, it is in effect coerced to the higher class.
a= mRange(9, shape=(3, 3)
c= N.arange(9, shape=(3, 3))
print 'A matrix multiplied by an array:'
print 'a * c (prettyprinted):', pp(a * c)
print 'A matrix multiplied by a list:'
lst= [[0, 1, 2],
[3, 4, 5],
[6, 7, 8]]
print 'a * lst (prettyprinted):', pp(a * lst)
The output is:
A matrix multiplied by an array:
a * c (prettyprinted):matrix([[ 15, 18, 21],
[ 42, 54, 66],
[ 69, 90, 111]])
None
A matrix multiplied by a list:
a * lst (prettyprinted):matrix([[ 15, 18, 21],
[ 42, 54, 66],
[ 69, 90, 111]])
None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20031211/01bb2e3f/attachment-0001.html
More information about the Numpy-discussion
mailing list