simit
simit copied to clipboard
Bulk assignment
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];
@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).
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.