Every variable in Tsunami is a multi-dimensional array. the dimensions are specified by a "dimension list", which looks like this: < a, b, c>. thus, for instance, a matrix multiply is written x<a,c> = y<a,b> * z<b,c>.
i've gotten to the point now where i really have to concern myself with the logic of how these dimensions are handled. so after some consideration, i've broken it down to a small set of concrete rules. i added them to the readme file, and i'm posting them here as well:
=========Handling dimension lists ("< , , >") in expressions:=====
the dimension list < , > in an expression defines what output dimensions of that identifier (the source) are connected to the input dimensions of the connecting identifier (the sink).
*if the source's output contains dimensions not in the dimension list, those dimensions are "reduced".
*if the dimension list contains dimensions not in the source's output, the data is "repeated" to extend in those dimensions.
*if the sink's input contains dimensions not in the dimension list, the source data is "repeated" to extend in those dimensions
*if the dimension list contains dimensions not in the sink's input, the sink is "repeated" to extend in those dimensions.
*however, if the dimension list contains dimensions in neither the source nor the sink, they are forwarded to the output of the sink, delaying the repetition until then.
(repetition amounts to adding the dimension, but with a stride of zero.)
For example, the infix expression:
x<a,c> = y<a> * z<c>.
causes y to repeat across the c dimension, and z to repeat across the a dimension, before their elements are multiplied together. this results in an outer product.
Likewise, the infix expression:
x<a,c> = y<a,b> * z<b,c>.
causes an outer product on a,b,c, which is then reduced along b, resulting in a matrix product.
note, however, that "x" and "x<a,b,c>" refer to the non-reduced product.
that is, unless x is explicitly defined:
channel x<a,c>.
in which case the expression can be written as:
x = y<a,b> * z<b,c>.
and "x" refers to x<a,c>, while x<a,b,c> refers to x<a,c> repeated along b.
oh, and operators input dimensions are always the union of all the dimensions of their sources.