simit-lang / simit

A language for computing on sparse systems
http://simit-lang.org
Other
454 stars 52 forks source link

Bulk assignment #11

Open fredrikbk opened 8 years ago

fredrikbk commented 8 years ago

Let's add bulk assignment to tensors using square bracket tensor literal syntax:

var A : matrix[2,2](float) = [expr0, expr1; expr2, expr3];

, where the expri is any expression.

This was needed by @mike323zyf in the following code:

var X_g = [0.0, 0.0; 0.0, 0.0];

X_g(0, 0) = ver(1).u(0) - ver(0).u(0);
X_g(1, 0) = ver(1).u(1) - ver(0).u(1);
X_g(0, 1) = ver(2).u(0) - ver(0).u(0);
X_g(1, 1) = ver(2).u(1) - ver(0).u(1);

denominator = X_g(0, 0) * X_g(1, 1) - X_g(0, 1) * X_g(1, 0);

tri.B = [       X_g(1, 1) / denominator,  -1.0 * X_g(0, 1) / denominator;
         -1.0 * X_g(1, 0) / denominator,  X_g(0, 0)        / denominator];
fredrikbk commented 8 years ago

@stephenchouca any chance you could add this? It is not urgent since it is easy to work around (as with assignment to X_g in the code above).

stephenchouca commented 8 years ago

I can take a look at it at some point. There are a couple of bug fixes and other enhancements that I should probably work on first though.