Multiplying Block Matrices in Numpy

Posted by Ada Xu on Stack Overflow See other posts from Stack Overflow or by Ada Xu
Published on 2013-11-02T09:15:23Z Indexed on 2013/11/02 9:54 UTC
Read the original article Hit count: 183

Hi Everyone I am python newbie I have to implement lasso L1 regression for a class assignment. This involves solving a quadratic equation involving block matrices.

minimize x^t * H * x + f^t * x

where x > 0

Where H is a 2 X 2 block matrix with each element being a k dimensional matrix and x and f being a 2 X 1 vectors each element being a k dimension vector.

I was thinking of using nd arrays.

such that

  np.shape(H) = (2, 2, k, k)
  np.shape(x) = (2, k)

But I figured out that np.dot(X, H) doesn't work here. Is there an easy way to solve this problem? Thanks in advance.

© Stack Overflow or respective owner

Related posts about python

Related posts about numpy