I am looking for the Python `numpy`

equivalent of the IDL # operator. Here is what the # operator does:

Computes array elements by multiplying the columns of the first array by the rows of the second array. The second array must have the same number of columns as the first array has rows. The resulting array has the same number of columns as the first array and the same number of rows as the second array.

Here are the `numpy`

arrays I am dealing with:

```
A = [[ 0.9826128 0. 0.18566662]
[ 0. 1. 0. ]
[-0.18566662 0. 0.9826128 ]]
```

and

```
B = [[ 1. 0. 0. ]
[ 0.62692564 0.77418869 0.08715574]]
```

Also, `numpy.dot(A,B)`

results in `ValueError: matrices are not aligned`

.

If I'm correct you want matrix multiplication.

Reading the notes on IDL's definition of matrix multiplication, it seems they use the opposite notation to everyone else:

IDL’s convention is to consider the first dimension to be the column and the second dimension to be the row

So # can be achieved by the rather strange looking:

`numpy.dot(A.T, B.T).T`

from their example values:

```
import numpy as np
A = np.array([[0, 1, 2], [3, 4, 5]])
B = np.array([[0, 1], [2, 3], [4, 5]])
C = np.dot(A.T, B.T).T
print(C)
```

gives

```
[[ 3 4 5]
[ 9 14 19]
[15 24 33]]
```

Similar Questions

MATLAB has a nice silhouette function to help evaluate the number of clusters for k-means. Is there an equivalent for Python's Numpy/Scipy as well?

In javascript, we can use the || operator to set a variable since it stops at the first expression which results to a truthy value. What is the equivalent of the following in python? var myNumber = di

In Python you have the ability to view the compiled bytecode of a user-defined function using dis. Is there a builtin equivalent to this for Lua? It would really useful!

Possible Duplicate: C++/CLI-Question: Is there an equivalent to the C# “is” keyword or do I have to use reflection? C#'s is and as operators are not available in C++/CLI environment. What should I u

I am studying COM so there're some basic questions puzzling me... I know that IDL file is used to describe the method definitions (or the so called 'contract' between software modules), and the .H hea

What is the most pythonic equivalent for matlab's dummyvar function in order to deal with category variables nicely? Here is an example illustrating my problem, with a NxM matrix which denotes M diffe

it is clear to me how to extend Python with C++, but what if I want to write a function in Java to be used with numpy? Here is a simple scenario: I want to compute the average of a numpy array using

I am working on moving some code from IDL into python. One IDL call is to INT_TABULATE which performs integration on a fixed range. The INT_TABULATED function integrates a tabulated set of data { xi

I am using python with numpy to read in data from a numerical model in a text file with a fairly complicated format. Numpy's genfromtxt and fromfile functions work well, but only if the data is struct

I am trying to restore a sav file with numpy readsav. The sav file contains an array of idl objects I have defined (with my own types). This type information is completely absent from the recarray I o

I am doing some research in physics, for which I need to analyze some data using a Markov Chain Monte Carlo (MCMC). I tried to just write one myself but I keep coming across bugs when python/numpy rou

In perl, the FindBin module is used to locate directory of original script. What's the best way to get this directory in python?

I have unfortunately no way to check this, because I have no IDL or Matlab licenses, that's why I'm asking here. The scenario is that I am saving HDF5 files with pandas and one of the columns is a Pyt

I would like to execute the equivalent of the following MATLAB code using NumPy: repmat([1; 1], [1 1 1]). How would I accomplish this?

I am trying to relate the python/numpy indices of two arrays with different sizes, but I cannot pass index one from the small array to the large array through a subroutine. For example, I have two nu

This question already has an answer here: Installing Numpy on 64bit Windows 7 with Python 2.7.3 3 answers I have been trying to get NumPy for Python 2.7 on Windows 64 bit, but the page http://w

I need to , well, dive into client side programming. Is there an equivalent to 'Dive into python' for jquery? I see that jquery 1.4 has been released. Does this change anything w.r.t answers?

What is the idiomatic Python equivalent of this C/C++ code? void foo() { static int counter = 0; counter++; printf(counter is %d\n, counter); } specifically, how does one implement the static membe

I'm just a newbie in python and am wondering if there is an equivalent function of find(A>9,1) from matlab for numpy/scipy. I know that there is the nonzero function in numpy but what i need is the

This question likely betrays a misconception, but I'm curious what the Tomcat of the Python world is. All of my web programming experience is in Java (or Groovy) so I think in Java terms. And when I

What's the equivalent of PHP's append to array ($my_array[] = abc;) in Python, which I have recently started learning? Let's say that I've a dictionary like this: my_dict = {'fruits':['orange', 'p

I just have started with python and I would translate this example from Matlab to python but I have not found the equivalent in Python. http://www.mathworks.es/es/help/matlab/ref/surface.html load cl

I am transporting my matlab code to python. There are alot of things that I am trying to find replacements for in python and numpy Matlab Code: [m,n]=size(Image); canvas=zeros(m,n); U_res_sel=squeeze

I'm trying 'translate' the sample code in here, but i can't find equivalent python function to cvCalcEigenObjects written in c language from cvaux.h.

I want to install numpy, pylab, scipy, and ipython on Mac OS X Lion. I installed the following: python-2.7.3-macosx10.6.dmg, numpy-1.6.1-py2.7-python.org-macosx10.6.dmg, matplotlib-1.1.1-py2.7-python

I am using python/numpy, and I have two arrays like the following: array1=[1 2 3] array2=[4 5 6] And I would like to create a new array: array3=[[1 2 3],[4 5 6]] and append items to it. So for examp

I would like to bind the operator() using Boost::Python but I don't really see how to do this. Consider the example: C++: class Queuer { public: void Queuer::operator()(const qfc::Queue & iq, cons

I am trying to port the following Python code to PHP, but I can't find the PHP equivalent to Python's struct. (and I specifically need an equivalent to struct.calcsize()) Is there any PHP equivalent t

I would like to do something like this in Fortran: program where real :: a(6) = (/ 4, 5, 6, 7, 8, 9 /) print *, a(a>7) end program In Python I would typically do this with NumPy like this: import

Simplified question Can I make Numpy agree with Matlab and Python's round? Matlab 2013a: >> round(-0.5) ans = -1 Python (using a Numpy array, or just a scalar, same result): >>> impor

I'm looking for a forgiving HTML parser for scraping HTML and extracting data in Ruby. I've had success using BeautifulSoup for this - what is the ruby equivalent?

Is there any equivalent to the PHP list() function in python? For example: PHP: list($first, $second, $third) = $myIndexArray; echo First: $first, Second: $second;

What's the priority ranking of numpy bitwise operators & and | ? if I do a & b | c what expression does it evaluate? a & (b | c) ? (a & b) | c ? How about a | b & c I also as

In C# there's a null-coalescing operator (written as ??) that allows for easy (short) null checking during assignment: string s = null; var other = s ?? some default value; Is there a python equiva

What is the equivalent of the .= operator in Excel VBA? I'm wanting to add strings to a variable. Below throws an error due to the .= query .= Job.Estimate Number#1 = ' & est & '

What is the python equivalent of: if (strpos($elem,text) !== false) { // do_something; }

i have a numpy array p like this: array([[ 0.92691702, 0.07308298], [ 0.65515095, 0.34484905], [ 0.32526151, 0.67473849], ..., [ 0.34171992, 0.65828008], [ 0.77521514, 0.22478486], [ 0.96430103, 0.035

Since there is no goto operator in Python, what technique can be used instead? Condition If it is true, go to thread 1, if is false, go to thread 2 In thread we do something small and after that we go

I wonder if anyone has an elegant solution to being able to pass a python list, a numpy vector (shape(n,)) or a numpy vector (shape(n,1)) to a function. The idea would be to generalize a function such

So I've got this numpy array of shape (31641600,2), which has some, if not many zero values in it. Let's call the array X. Doing: print len(X) >>> 31641600 But then doing: X = X[np.nonzero(X

i am quite new to prolog and i'd like an explanation about something if possible. What exactly does the --> prolog operator do? i can't seem to find an easy straight answer for that. and just

I have two arrays, for example: array1=numpy.array([1.1, 2.2, 3.3]) array2=numpy.array([1, 2, 3]) How can I find the difference between these two arrays in Python, to give: [0.1, 0.2, 0.3] As an arr

Should be a simple question, but I'm unable to find an answer anywhere. The ~ operator in python is a documented as a bitwise inversion operator. Fine. I have noticed seemingly schizophrenic behavior

I just want to quickly see the properties and values of an object in Python, how do I do that in the terminal on a mac (very basic stuff, never used python)? Specifically, I want to see what message.a

I am using Python 2.5, I just download numpy 1.9.0 from https://pypi.python.org/pypi/numpy. I am not so sure where should I put the module, hope you can help me.

I created a NumPy array, a = numpy.array([[1,2,3][4,5,6]]) I want to make the array look like this [[1,4],[2,5],[3,6]] and also after I make change I want to return to the original structure. Is ther

Basically, I am getting a memory error in python when trying to perform an algebraic operation on a numpy matrix. The variable u, is a large matrix of double (in the failing case its a 288x288x156 mat

For a project I'm working on, I need to have a lot of source code files generated from an interface description. That description is currently IDL (really, a pidgin IDL-like language), but I'm not mar

While trying to build my python by adding numpy to it I managed to have created problems somewhere. Now, even though I have numpy and other packages like BeautifulSoup installed, I'm unable to import

Can someone tell me what's the equivalent of Python's Fabric in Python itself, other languages or third party tools? I am still a bit fuzzy on what it is trying to accomplish and it's usage.