diff options
| author | Thomas Guillermo Albers Raviola <thomas@thomaslabs.org> | 2026-07-16 23:10:26 +0200 |
|---|---|---|
| committer | Thomas Guillermo Albers Raviola <thomas@thomaslabs.org> | 2026-07-16 23:10:26 +0200 |
| commit | 34b945681740c320c3a011326d493d7bd09019f3 (patch) | |
| tree | f9cb82e5ac59759fd46a6339bb3ab89f2b186c9c /tensors.mac | |
Initial commit
Diffstat (limited to 'tensors.mac')
| -rw-r--r-- | tensors.mac | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tensors.mac b/tensors.mac new file mode 100644 index 0000000..dea722a --- /dev/null +++ b/tensors.mac @@ -0,0 +1,21 @@ +/* Contract indices in expression */ + +/* NOTE: buildq works like splicing a list with quasiquote in lisp; escaped +items are defined at start of quote */ +contr(expr, var) ::= ( + if listp(var) and length(var) > 1 then + block([head, tail], + head : first(var), + tail : rest(var), + buildq([expr, head, tail], sum(contr(expr, tail), head, 1, 4))) + elseif listp(var) and length(var) = 1 then + block([head], + head : first(var), + buildq([expr, head], sum(expr, head, 1, 4))) + elseif listp(var) then + expr + else + buildq([expr, var], sum(expr, var, 1, 4)))$ + +/* Differentiate with respect to nth coordinate */ +cdiff(func, coord) := diff(func, ct_coords[coord])$ |
