I might do a poor job of explaining this, so I'll use an example somewhat similar to my problem, but here goes:
I need to compute a complex operation (repeatedly) that is a function of only a few scalars, say, x1, x2 and x3. Then a matrix whose elements are determined by a function of x1, x2, x3 (and the row and column location) is computed, called X.
Several very large matrix products are involved in intermediate steps, A, B and C. The values of the matrices involved in these products are constant.
Say we have matrices whose sizes are:
- A: k by n
- B: n by n
- C: n by k
- X: 3 by k
where n is very very large, and k is pretty large.
The function does (pseudocode):
func = function(x1, x2, x3)
X = make_X(x1, x2, x3)
return X * A * B * C * X^t
where * is the regular dot product. The output will only be a 3 by 3 matrix!
I (naively possibly) think that there must be some automatic way to efficiently compile this down into essentially 9 functions of x1, x2, x3 -- one for each element of the output matrix.
I use numpy/scipy fairly often, but have no experience with sympy or theano, though they seem to be in the ballpark. Any suggestions on how to solve this problem?
P.S., any code packages that address this would preferably be in python, but they don't have to be, so long as they are callable from python.