Joe Hays wrote:
I'm a newbie to python. Can anyone tell me why the following little
program complains about incorrect dimensions?
<snip>
import pylab
from pylab import *
n = 10; m = 2*n;
A = randn(m,n);
b = A*rand(n,1) + 2*rand(m,1);
</snip>
The actual error I receive is,
<snip>
b = A*rand(n,1) + 2*rand(m,1);
ValueError: shape mismatch: objects cannot be broadcast to a single
shape
</snip>
This is supposed to be doing a matrix multply of an (m,n)(n,1). This
results in an (m,1). This should then be able to be added to the
2*rand(m,1), but, its not for some reason.
Ideas?
You will want to ask numpy questions on the numpy mailing list (preferably with
a subject line a bit more informative with respect to the actual problem). http://www.scipy.org/Mailing_Lists
In this case, the problem is that * does not do matrix multiplication; it does
element-wise multiplication. Use dot(A, randn(n,1)) instead.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco 0 1207 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Elger |
last post by:
Dear Members,
A newbie question
How do I convert this XML example into HTML (using XSLT)?
<DOCUMENT>
<PARA>
This <BOLD>is</BOLD> a <BOLD>test</BOLD>
</PARA>
</DOCUMENT>
|
by: DragonLord |
last post by:
I have a custom user control that i am trying to understand and it has numbers before the line items. So here it comes the real newbie question What the heck are the numbers for??
205: For lngCount = 0 To lstIncluded.Items.Count - 1
206: If lstIncluded.GetSelected(lngCount) Then
207: strMembers = strMembers & VB6.GetItemData(lstIncluded, lngCount) & ","
End If
209: Next
211: If Len(strMembers) > 0 Then
212: strMembers =...
|
by: kamikaze04 |
last post by:
Hello.
I have a very newbie question about Streams. The situation is that i have a function (that i cannot modify it's definition/call):
public void F1(istream & in){
while( ...) {
in >> value
do stuff with value;
}
|
by: Banibrata Dutta |
last post by:
Hi,
I've gone through the list of "language differences" between 2.3 / 2.4
& 2.5 of CPython. I've spend around 2 weeks now, learning v2.5 of
CPython, and I consider myself still very very newbie. So, unable to
take a call as to how-important or desirable the newer language
features are -- so whether to write my app for v2.5 of Python, versus,
as few others on this list have recommended, i.e. to stick to v2.3 ??
Are the preformance...
|
by: Raxit |
last post by:
Hi,
i was reading/learning some hello world program in python.
I think its very simillar to Java/C++/C#. What's different (except
syntax) ?
what can i do easily with python which is not easy in c++/java !?
Tnx,
Raxit
| |
by: idiolect |
last post by:
Hi all - Sorry to plague you with another newbie question from a
lurker. Hopefully, this will be simple.
I have a list full of RGB pixel values read from an image. I want to
test each RGB band value per pixel, and set it to something else if it
meets or falls below a certain threshold - i.e., a Red value of 0
would be changed to 50.
I've built my list by using a Python Image Library statement akin to
the following:
|
by: Randall |
last post by:
I am a newbie trying to learn the DOM. Can someone tell me why the
first alert statement returns null, and the second returns the value
33px (which was set using the style="top:33px;" in the DIV tag).
Why doesn't the first alert statement pick up the style.left attribute
from the CSS?
<html>
<head>
<style type="text/css">
|
by: Philipp.Weissenbacher |
last post by:
Hi all!
This is most certainly a total newbie question, but why doesn't the
following code cause a segfault?
void insertion_sort(int a, int length)
{
int i;
for (i=0; i < length; i++)
{
int j, v = a;
|
by: Lokean |
last post by:
Sorry for this newbie question, this is not my realm of expertese.
I have searched google, tried several applications that claim they can do this, such as Mapforce, which I found confusing, to Oxygen, to HTML kit, et cetera.
I am more confused than ever.
here's my quandry.
I was sent a file and told that we need to get the data into a more readable form.
I've tried using apps to pull it in, but it's not displaying properly.
|
by: Dave |
last post by:
I am new to Visual Web Developer 2005 Expres.
I am using absolute positioning and every time I add a button control to my
web form its width extends all the way to the edge of the page. IOW I get a
long skinny button that extends to the right side of the browser.
This does not appear to happen with other controls. Any idea why it happens
to the button?
Here is how the button looks in source code:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |