It appears that matrixmultiply( A,B) has a side-effect of transposing the
second argument (B).
Is this supposed to happen?
Is there anyway to prevent it from transposing?
This shows what happens:
#! /usr/bin/env python
from numarray import *
A=array([[350],
[370],
[510],
[490],
[500]])
B=array([[35,37,51,49,50]])
print "A and B before matmul:"
print A
print B
AB=matrixmultip ly(A,B)
print "AxB, A, B, after matmul:"
print AB
print A
print B
print"Apparantl y, the second argument of matrixmultiply( A,B) is always
transposed."
------------ And now a word from our sponsor ----------------------
For a quality mail server, try SurgeMail, easy to install,
fast, efficient and reliable. Run a million users on a standard
PC running NT or Unix without running out of power, use the best!
---- See http://netwinsite.com/sponsor/sponsor_surgemail.htm ---- 6 1990
On Mon, 19 Jul 2004, Raoul wrote: A=array([[350], [370], [510], [490], [500]])
B=array([[35,37,51,49,50]])
print "A and B before matmul:" print A print B
AB=matrixmultip ly(A,B)
print "AxB, A, B, after matmul:" print AB print A print B
This works for me (B before == B after). Which version of numarray are
you using? This works for me (B before == B after). Which version of numarray are you using?
It's version 1.0, on Python 2.3+.
I do have one lengthy example where the second argument was not changed
(on one matmul, all the others in that example did transpose), but was
not able to reproduce that in a small example; so it seems not to be
consistent.
For completeness, here's my output, as you can see the row-vector B has
changed into a column-vector.
A and B before matmul:
[[350]
[370]
[510]
[490]
[500]]
[[35 37 51 49 50]]
AxB, A, B, after matmul:
[[12250 12950 17850 17150 17500]
[12950 13690 18870 18130 18500]
[17850 18870 26010 24990 25500]
[17150 18130 24990 24010 24500]
[17500 18500 25500 24500 25000]]
[[350]
[370]
[510]
[490]
[500]]
[[35]
[37]
[51]
[49]
[50]]
Apparantly, the second argument of matrixmultiply( A,B) is always transposed.
Raoul wrote: It appears that matrixmultiply( A,B) has a side-effect of transposing the second argument (B).
I can verify this on Mac OSX with the latest CVS of numarray. Please
post a bug report to the tracker. http://sourceforge.net/tracker/?atid...69&func=browse
--
Robert Kern rk***@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
On Mon, 19 Jul 2004, Raoul Meuldijk wrote: This works for me (B before == B after). Which version of numarray are you using?
It's version 1.0, on Python 2.3+. I do have one lengthy example where the second argument was not changed (on one matmul, all the others in that example did transpose), but was not able to reproduce that in a small example; so it seems not to be consistent.
Okay, I was using 0.9. Upgrading to 1.0 confirms the error. This is a
bug in numarray, but it has already been fixed in CVS. As a temporary
fix, use the original Python definition (ripped from numarraycore.py ):
def dot(array1, array2):
return ufunc.innerprod uct(array1, swapaxes(array2 , -1, -2))
matrixmultiply = dot
This will fix both matrixmultiply and dot, as they are both affected by
the bug.
Robert Kern wrote: Raoul wrote:
It appears that matrixmultiply( A,B) has a side-effect of transposing the second argument (B).
I can verify this on Mac OSX with the latest CVS of numarray. Please post a bug report to the tracker.
http://sourceforge.net/tracker/?atid...69&func=browse
I have reported it, thanks. Okay, I was using 0.9. Upgrading to 1.0 confirms the error. This is a bug in numarray, but it has already been fixed in CVS. As a temporary fix, use the original Python definition (ripped from numarraycore.py ):
def dot(array1, array2): return ufunc.innerprod uct(array1, swapaxes(array2 , -1, -2))
matrixmultiply = dot
This will fix both matrixmultiply and dot, as they are both affected by the bug.
Your fix works perfectly! Thanks!
Raoul This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eugene Druker |
last post by:
Hi all,
I need eigen values and vectors for symmetric matrices (like VCV).
Solving with numarray and testing the results, I've got
strange results - input and output matrices of some sizes are
very different. That's an example of differencies:
Size MaxDif(E.Val) MaxDif(E.Vect)
2 0 1.110223e-016
3 1.776357e-015 2.053913e-015
10 1.221245e-015 7.255307e-014
|
by: Marc Schellens |
last post by:
Following the NumPy documentation, I took over some C code,
but run into an error.
Does anybody have a suggestion?
Thanks,
marc
gdlpython.cpp:225: `PyArray_Type' undeclared (first use this function)
#include <python2.3/Python.h>
|
by: Christian Seberino |
last post by:
How add a column to a 2d array/matrix in numarray???
The unelegant way I found was to:
1. Create a new array with an extra column (e.g. using 'zeros' function).
2. Copy original array into new array.
3. Copy new column into last column.
Is there a slicker way to do this?
|
by: grv |
last post by:
So it is supposed to be very fast to have an array of say 5 million
integers stored in a binary file and do
a = numarray.fromfile('filename', (2, 2, 2))
numarray.add(a, 9, a)
but how is that faster than reading the entire file into memory and then
having a for loop in C:
(loop over range) {
*p++ += 9 }
|
by: Michael Drumheller |
last post by:
(If you're not interested in NumArray, please skip this message.)
I am new to NumArray and I wonder if someone can help me with
array-indexing. Here's the basic situation: Given a rank-2 array
(i.e., a matrix) it seems to be trivial, with array indexing,
to extract a subset of its *columns*. But it does not seem
to be trivial to extract a subset of its *rows*. The code
snippet below describes the problem (if it really is a problem)...
| |
by: Peter Dobcsanyi |
last post by:
Calling the following function with a large enough 'n' causes memory leak.
import numarray as N
def loop(n, m=100):
for i in xrange(n):
a = N.zeros((m,m))
N.matrixmultiply(a, a)
If the matrixmultiply line is commented out, there is no leak, the
|
by: George Sakkis |
last post by:
What's the fastest and most elegant equivalent of zip() in
Numeric/Numarray between two equally sized 1D arrays ? That is, how to
combine two (N,)-shaped arrays to one (N,2) (or (2,N)) shaped ? I
expect the fastest and the most elegant idiom to be identical, as it is
usually the case in this excellent library, but if not, both would be
useful to know. Thanks,
George
|
by: Colin J. Williams |
last post by:
Python advertises some basic service:
C:\Python24>python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
With numarray, help gives unhelpful responses:
|
by: andrewfelch |
last post by:
Below is the code to/from Boolean arrays and Unsigned integers. On my
Pentium 4, functions such as "bitwise_and" are 32 times faster when run
on 32-bit integers instead of the entire-byte-consuming-Boolean.
Good luck all:-)
uint32Mask =
numarray.array(, numarray.UInt32)
uint32MaskInner = numarray.copy.deepcopy(uint32Mask)
uint32MaskInner.shape =
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |