Enter code here...Enter code here...
I am trying to perform a dot multiplication between a numpy array (64,1000) and a sympy matrix (1000, 100) containing only variables, but the computation never ends. How to do that?
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/402c5bd3-b503-4a45-9ea4-6754a4e49a23%40googlegroups.com.
That calculation is going to create matrix with 6,400 elements, each of which will be a summation of 1000 terms (at least before any possible simplification, and assuming you mean variables without a numeric value). Bearing in mind that symbolic expressions take quite a lot of memory, that lot is going to take up a fair bit of memory but I'd guess it would be OK in 64 bits (you don't say if your Python installation is 64bits as opposed to 32 bits).
However, calculating something that size is certainly going to be challenging, and may need to run over night. In addition there is the problem that the program may be choking trying to print the result.
My advice would be to start with a much scaled down example, and then gradually scale it up to see what breaks.
If you want to do something immediately to use the matrix without printing the 64 x 100 matrix of algebraic expressions (!!) that might be best.
Good luck!
David
On 30/05/2020 15:02, Giuseppe G. A. Celano wrote:
--Enter code here...
I am trying to perform a dot multiplication between a numpy array (64,1000) and a sympy matrix (1000, 100) containing only variables, but the computation never ends. How to do that?
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/402c5bd3-b503-4a45-9ea4-6754a4e49a23%40googlegroups.com.
import numpy as npfrom sympy import *
n, d, n2, d2 = 5, 7, 4, 3
x = MatrixSymbol('x', n, d)y = MatrixSymbol('y', n, d2)
w1 = MatrixSymbol("l", 7, 4)w2 = MatrixSymbol("p", 4, 3)
h2 = x * w1predicted = h2 * w2HadamardPower(predicted - y, 2).diff(x[0, 0])