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

What is the perl's equivalent of repr in python/ruby's inspect method? (I'm asking so I can use it for doing print debugging)

I am trying to embed python 2.7.3 in C++ and use Numpy library and I obtain runtime error while importing Numpy for the second time. Here is a simple code example (as smallest as possible) : #include

What are the differences in performance and behavior between using Python's native sum function and NumPy's numpy.sum? sum works on NumPy's arrays and numpy.sum works on Python lists and they both ret

What does empty operator warning (translated from russian) mean in netbeans? for(int v = 1; v <= n; v++) { int parent = in.nextInt(); if(parent == 0); root = v; }

I am implementing a python script to do fuse mount programatically. I have written an equivalent in C, by making use of socketpair and recvmsg api's. But in python recvmsg is not implemented, so I am

I am working on c code conversion to python using numpy . What is numpy equivalent of following matlab functions? 1. mxGetNumberOfDimensions 2. mxIsDouble 3. mxGetM 4. mxCreateDoubleMatrix 5. mxGetPr

What is the equivalent of the |= operator in Visual Basic? For example (C#): flags |= MyEnum.SomeFlag

What is the Python equivalent to DatabaseMetaData

With linq i have to check if a value of a row is present in a array. The equivalent of the sql query: WHERE ID IN (2,3,4,5) How can i do? thanks

I would like to install Python Pandas library (0.8.1) on Mac OS X 10.6.8. This library needs Numpy>=1.6. I tried this $ sudo easy_install pandas Searching for pandas Reading http://pypi.python.org/

I am writing a script using python Spyder 2.2.5 with Windows 7, python 2.7 At the very beginning I have tried all the import ways: from numpy import * or import numpy and also import numpy as np An

Is there an equivalent to dir in python for java, or a library which provides similar functionality (i.e. properties of objects and classes output as informative strings)? This question is similar t

For python 3.2 I used sudo apt-get install python3.2-numpy.It worked. What to do for python3.3? Nothing I could think of works. Same goes for scipy, etc. Thanks. Edit: this is how it looks like radu@s

Can someone indicate what I am doing wrong here? import numpy as np a = np.array([1,2,3,4,5],dtype=int) b = np.array(['a','b','c','d','e'],dtype='|S1') np.savetxt('test.txt',zip(a,b),fmt=%i %s) The

Okay so I'm fairly new to Python, I ran the commands sudo easy_install pip sudo pip install numpy Afterwards, I typed python followed by import numpy and got the error ImportError: No module named n

I am relatively new to python. I have a numpy array that has 3 dimensions. I know we can display only few elements using :. It seems to work just fine while I'm doing it starting from a small value,

If I am creating my own class in Python, what function should I define so as to allow the use of the 'in' operator, e.g. class MyClass(object): ... m = MyClass() if 54 in m: ...

What is the closest equivalent to an R Factor variable in Python pandas?

I've raked through a lot of make for Python projects, but I can't find any with the simplicity of a cake file. What I'm looking for is a Python equivalent that will let me: Keep the build commands

From the Naive Bayes tutorial in sklearn there's example on iris dataset but it looks too cryptic, can someone help to enlighten me? What does the iris.data mean? why is there 4 columns? What does th

I'm trying to define the operator type add when it comes to my class Point. Point is exactly what it seems, (x, y). I can't seem to get the operator to work though because the code keeps printing the

I am a strong Python programmer, but not quite there when it comes to PHP. I need to try something, and if that doesn't work out, do something else. This is what it would look like in Python: try: pr

I'm looking for list-comprehension method or similar in Numpy to eliminate use of a for-loop eg. index_values is a Python dictionary list of lists (each list containing a different number of index val

I'am using numpy and have an array (ndarray type) which contain some values. Shape of this array 1000x1500. I reshaped it brr = np.reshape(arr, arr.shape[0]*arr.shape[1]) when I trying brr.reverse(

A default ATL Simple Object has the following at the top of its IDL file: import oaidl.idl; import ocidl.idl; What are these files for, and how do I know when I need to import them? Is there any

I need to determine what is the equivalent for SQLite of the <=> operator in MySQL. Any idea?

I know I can live without it, but the question's been bugging me. Is there a Ruby idiom that's equivalent to Groovy's Elvis operator (?:)? Essentially, I want to be able to shorten this PARAM = ARGV[0

Im working with two arrays, trying to work with them like a 2 dimensional array. I'm using a lot of vectorized calculations with NumPy. Any idea how I would populate an array like this: X = [1, 2, 3,

I'm speaking of this module: http://docs.python.org/library/operator.html From the article: The operator module exports a set of functions implemented in C corresponding to the intrinsic operators of

I have a GUI driven image analysis package in IDL that needs some serious rewriting. Python has been suggested to be as an alternative to IDL (with benefits of cost and some nice libraries among other

Possible Duplicate: Does python have a package/module management system? In ruby I can do something like gem install my-cool-gem How do I do this in python?

I googled, but didn't find a clear answer. Example: class Foo { public: operator void* () { return ptr; } private: void *ptr; }; I understand what void* operator() is. Is the above operator the same

Is there a VB.NET equivalent for C#'s ?? operator?

I'm an R user and I cannot figure out the pandas equivalent of match(). I need use this function to iterate over a bunch of files, grab a key piece of info, and merge it back into the current data str

I am trying to take the following R statement and convert it to Python using NumPy: 1 + apply(tmp,1,function(x) length(which(x[1:k] < x[k+1]))) Is there a Python equivalent to which()? Here, x is

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 am coming to python from ruby. What is the equivalent statement of require (Ruby) in Python?

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've seen the % operator being used in some Python code related to strings, such as: String = Value: % variable What does that mean? How is it different from using: String = Value: + variable

I am trying to understand what is machine epsilon. According to the Wikipedia, it can be calculated as follows: def machineEpsilon(func=float): machine_epsilon = func(1) while func(1)+func(machine_eps

Is there a python equivalent to echo -e? In other words, is there a built-in function to convert r\x50\x79\x74\x68\x6f\x6e to Python in Python? Edit I added the 'r' prefix, to make sure everyone u

What is the difference between an iterable and an array_like object in Python programs which use Numpy? Both iterable and array_like are often seen in Python documentation and they share some similar

This question already has an answer here: Converting numpy dtypes to native python types 5 answers I have a numpy array with a single value (scalar) which I would like to convert to correspodin

I use pylab (more specifically numpy) in all of my python programs. The exceptions are very rare, if any. So far, I have taken the habit of importing numpy in the following way: from numpy import *

I was wondering if anyone could help me with one problem that I have when using the python + numpy function 'savetxt'. The problem is: (1) I have a subroutine in which I save a matrix (numerical data

Possible Duplicates: Python: defining my own operators? Rules of thumb for when to use operator overloading in python Is it possible to overload operators in Python? If so, can one define new operat

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

What does the following error: Warning: overflow encountered in exp in scipy/numpy using Python generally mean? I'm computing a ratio in log form, i.e. log(a) + log(b) and then taking the exponent of

I need to modify the HTTP header of a file within Python, and I know this is possible using the Django 'File' object (https://docs.djangoproject.com/en/dev/topics/files/) as documented in the example

I have alias defined in my .zshrc as alias python=/usr/local/bin/python3.4. Problem is when I try to install numpy(v1.8.1) it get installed with python2.7. I would like to install it with python3.4 An