An intelligent block matrix library for numpy, PyTorch, and beyond. Crafted by Brandon Amos with significant contributions by Eric Wong.
Let's try to construct the KKT matrix from Mattingley and Boyd's CVXGEN paper in numpy and PyTorch:
block, there is no way to infer the appropriate sizes of
the zero and identity matrix blocks.
It is an inconvenience to think about what size these
matrices should be.
Block acts a lot like
np.bmat and replaces:
'I'with an appropriately shaped identity matrix.
'-I'with an appropriately shaped negated identity matrix.
block is meant to be a quick prototyping tool and
there's probably a more efficient way to solve your system
if it has a lot of zeros or identity elements.
blockhandle numpy and PyTorch with the same interface?
I wrote the logic to handle matrix sizing to be agnostic of the matrix library being used. numpy and PyTorch are just backends. More backends can easily be added for your favorite Python matrix library.
```Python class Backend(metaclass=ABCMeta):
@abstractmethod def extract_shape(self, x): pass @abstractmethod def build_eye(self, n): pass @abstractmethod def build_full(self, shape, fill_val): pass @abstractmethod def build(self, rows): pass @abstractmethod def is_complete(self, rows): pass
pip install block
from block import block
I'd be happy to hear from you about any issues or features you add, please file an issue or send in a PR.
This repository is Apache-licensed.
This package pytorch_fft is very usefull and important to me. The fft of pytorch torch.fft ignore the batch dims, thus it run very slowly. While i need apply fft to many matrix, only this package can do this.
But when i install this package, it show that "torch.utils.ffi is deprecated. Please use cpp extensions instead". It can run in Pythorch 0.4, but it doesn't suppert the newest version of Pytorch, I hope you can fixed this problem, thus we can replace torch.fft with this package in the newest version of pytorch.
Supporting for the bmat of CVXPY (http://www.cvxpy.org/en/latest/tutorial/functions/index.html?highlight=bmat) would be very useful.
pytorch numpy deep-learning linear-algebra