Vu Nguyen
Vu Nguyen

Reputation: 1007

Symbolic array expression

I'm wondering if there's a way to treat array variables symbolically (something like sympy but for array instead of numerical variables). So that I can have array expressions such as

f1 = 3*A[i] + 4*B[i][j] - 7 == 0

or something even more advanced such as nested array relations

f2= 3 * A[C[i][j]] == B[i] + 3

By treating A, B symbolically, I can change the contents of A, B by using substitution , e.g.:

f1.subs(A=[1,2,3,4],B=[[1,2],[3,4]])

I can then add f1 and f2, etc.

Upvotes: 2

Views: 1102

Answers (1)

MRocklin
MRocklin

Reputation: 57301

Judging from your tags I'll assume that you're interested mainly in Python solutions.

There are a few projects that build up array expressions symbolically. I recommend that you look at

  • Theano - builds array expressions for code generation. Primarily used for machine learning applications but a fairly general project.
  • SymPy Matrix Expressions - restricted to matrices but handles some of the special knowledge we have for linear algebra.
  • SymPy Indexed
  • Blaze - a new project growing out of the folks at Continuum.

If you're willing to go out of Python you could look at the xAct in Mathematica.

There are many other projects that I haven't listed here that might be relevant depending on your application. Symbolic linear algebra is a very active field. Each project tends to be designed with a specific application in mind though.

Upvotes: 2

Related Questions