From: Satya U. <sat...@ya...> - 2006-08-14 19:44:12
|
Dear All, Just a few queries regarding matrices. On my python shell i typed: >>> from Numeric import * >>> from LinearAlgebra import * >>> A = [1,2,3,4,5,6,7,8,9] >>> B = reshape(A,(3,3)) >>> B array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> X = identity(3) >>> X array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> D = power(B,0) >>> D array([[1, 1, 1], [1, 1, 1], [1, 1, 1]]) the power function is giving a resultant matrix in which each element of matrix B is raised to the power of 0 so as to make it 1. But, taken as a whole i.e. matrix B to the power of 0 should have given the identity matrix. Also, what is the procedure for taking the log of an entire matrix (log(A) where A is a matrix takes the log of every individual element in A, but thats not the same as taking the log of the entire matrix) Thanking you, Satya --------------------------------- Here's a new way to find what you're looking for - Yahoo! Answers Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW |
From: Sven S. <sve...@gm...> - 2006-08-14 19:59:04
|
Hi, Satya Upadhya schrieb: >>>> from Numeric import * Well this list is about the numpy package, but anyway... > the power function is giving a resultant matrix in which each element of > matrix B is raised to the power of 0 so as to make it 1. But, taken as a > whole i.e. matrix B to the power of 0 should have given the identity > matrix. afaik, in numpy terms if you are dealing with a numpy array, such functions are elementwise by design. In contrast, if you have a numpy matrix (a special subclass of the array class) --constructed e.g. as mat(eye(3))-- then power is redefined to be the matrix power; at least that's the rule for the ** operator, not 100% sure if for the explicit power() function as well, but I suppose so. > > Also, what is the procedure for taking the log of an entire matrix > (log(A) where A is a matrix takes the log of every individual element in > A, but thats not the same as taking the log of the entire matrix) I don't understand what you want, how do you take the log of a matrix mathematically? -Sven |
From: Torgil S. <tor...@gm...> - 2006-08-14 21:03:07
|
>>> import numpy >>> numpy.__version__ '1.0b1' >>> from numpy import * >>> A = [1,2,3,4,5,6,7,8,9] >>> B = asmatrix(reshape(A,(3,3))) >>> B matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> B**0 matrix([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]) >>> power(B,0) matrix([[1, 1, 1], [1, 1, 1], [1, 1, 1]]) Shouldn't power() and the ** operator return the same result for matrixes? //Torgil |
From: Travis O. <oli...@ie...> - 2006-08-14 21:13:54
|
Torgil Svensson wrote: >>>> import numpy >>>> numpy.__version__ >>>> > '1.0b1' > >>>> from numpy import * >>>> A = [1,2,3,4,5,6,7,8,9] >>>> B = asmatrix(reshape(A,(3,3))) >>>> B >>>> > matrix([[1, 2, 3], > [4, 5, 6], > [7, 8, 9]]) > >>>> B**0 >>>> > matrix([[ 1., 0., 0.], > [ 0., 1., 0.], > [ 0., 0., 1.]]) > >>>> power(B,0) >>>> > matrix([[1, 1, 1], > [1, 1, 1], > [1, 1, 1]]) > > Shouldn't power() and the ** operator return the same result for matrixes? > No. power is always the ufunc which does element-by-element raising to a power. This is actually a feature in that you can use the function call to do raising to a power without caring what kind of array subclass is used. In the same manner, multiply is *always* the ufunc. -Travis |
From: Christopher B. <Chr...@no...> - 2006-08-14 23:36:42
|
Torgil Svensson wrote: > Shouldn't power() and the ** operator return the same result for matrixes? no, but the built-in pow() should -- does it? -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
From: Alan G I. <ai...@am...> - 2006-08-15 14:48:28
|
> Torgil Svensson wrote:=20 >> Shouldn't power() and the ** operator return the same result for matrixe= s?=20 On Mon, 14 Aug 2006, Christopher Barker apparently wrote:=20 > no, but the built-in pow() should -- does it?=20 The "try it and see" approach says that it does. Cheers, Alan Isaac |
From: Andrew S. <str...@as...> - 2006-08-15 05:37:24
|
Sven Schreiber wrote: > Hi, > > Satya Upadhya schrieb: > > >>>>> from Numeric import * >>>>> > > Well this list is about the numpy package, but anyway... > This list is for numpy, numarray, and Numeric. There's just a lot more numpy talk going on these days, but "numpy-discussion" comes from the bad old days where no one realized that allowing your software package to be called multiple things (Numeric, Numeric Python, numpy) might result in confusion years later. Cheers! Andrew |
From: Nils W. <nw...@ia...> - 2006-08-14 20:24:29
|
On Mon, 14 Aug 2006 21:58:50 +0200 Sven Schreiber <sve...@gm...> wrote: > Hi, >=20 > Satya Upadhya schrieb: >=20 >>>>> from Numeric import * >=20 > Well this list is about the numpy package, but anyway... >=20 >> the power function is giving a resultant matrix in which=20 >>each element of >> matrix B is raised to the power of 0 so as to make it 1.=20 >>But, taken as a >> whole i.e. matrix B to the power of 0 should have given=20 >>the identity >> matrix. >=20 > afaik, in numpy terms if you are dealing with a numpy=20 >array, such > functions are elementwise by design. > In contrast, if you have a numpy matrix (a special=20 >subclass of the array > class) --constructed e.g. as mat(eye(3))-- then power is=20 >redefined to be > the matrix power; at least that's the rule for the **=20 >operator, not 100% > sure if for the explicit power() function as well, but I=20 >suppose so. >=20 >> =20 >> Also, what is the procedure for taking the log of an=20 >>entire matrix >> (log(A) where A is a matrix takes the log of every=20 >>individual element in >> A, but thats not the same as taking the log of the=20 >>entire matrix) >=20 > I don't understand what you want, how do you take the=20 >log of a matrix > mathematically? >=20 > -Sven >=20 > -----------------------------------------------------------------------= -- > Using Tomcat but need to do more? Need to support web=20 >services, security? > Get stuff done quickly with pre-integrated technology to=20 >make your job easier > Download IBM WebSphere Application Server v.1.0.1 based=20 >on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion Help on function logm in module scipy.linalg.matfuncs: logm(A, disp=3D1) Matrix logarithm, inverse of expm. Nils |