Solve linear system with Variable matrix

Hello!
I have to solve linear system with Variable matrix and then to compute gradients with respect to it.
Is there any way to perform this operation?

1 Like

I think you’re looking for torch.gesv

Thanks a lot, it was rather hard to find this function!

1 Like

gesv can only support the matrix A being square. Is it possible to solve linear system for non-square A in PyTorch?

Linear system for non-square is an overparametrized linar system which is solved by minimization, typically svd. Im not sure if it’s differentiable

1 Like

For non-square A, you should look at gels, not gesv. https://pytorch.org/docs/stable/torch.html#torch.gels