Reputation: 832
I'm trying to solve a rectangular system for sparse features using cupy. I know the built-in function sparse.linalg.lsqr(A, b)
do it for square matrix A
. However I like to solve a rectangular sparse system. This is the way we can solve a squared system:
Import cupy as cp
A = cp.sparse.rand(200, 100, density=0.1)
b = cp.random.random(100)
x = cp.sparse.linalg.lsqr (A, b)
print(x)
It gives an error of dimension mismatch for rectangular systems and I can't find a built-in sparse method equivalent to e.g. cupy.tensorsolve()
.
By the way, is there a way to do it with Tensorflow? Thank you for help. I'm using google a Colaboratory notebook.
Upvotes: 2
Views: 575
Reputation: 1073
It might be too late for questioner, but for posterity I answer this question.
This can be implemented by wrapping lsqr
in MAGMA as shown in this example.
Upvotes: 2
Reputation: 1624
You can refer https://docs-cupy.chainer.org/en/stable/reference/linalg.html for the current cupy's supporting functions for linear algebra. I can find cupy.linalg.tensorsolve
, but I could not find cupy.linalg.lsqr
so far.
Also I think it is nice to tag this question as "cupy" or "numpy".
Upvotes: -1