From 0fb1bae4879c13e63af52d99977b3e453d20942a Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 30 Nov 2017 13:51:37 -0500 Subject: [PATCH] Add c:sum/@dim This allows the result of a rate block to be a matrix; there was previously no way for a named value to be assigned a matrix unless it was a parameter. This is a bit of a kluge---the compiler won't discover the proper type information and won't perform the proper safeguards. * src/current/calc.xsd (sum)[@dim]: Add attribute. * src/current/compiler/js-calc.xsl: Add xs namespace. (compile-calc): Do not perform casting when @dim > 1. * src/current/include/preproc/expand.xsl (lv:rate-each): Include @dim in c:sum expansion. * src/current/include/preproc/macros.xsl: (c:*/@generates): Use @dim to determine symbol dimensions. * src/current/include/preproc/expand.xsl: Parse @dim aliases (e.g. "vector", "matrix"). --- src/current/calc.xsd | 10 ++++++ src/current/compiler/js-calc.xsl | 24 +++++++++++--- src/current/include/preproc/expand.xsl | 40 ++++++++++++++++++++++++ src/current/include/preproc/macros.xsl | 2 +- src/current/include/preproc/symtable.xsl | 5 ++- 5 files changed, 75 insertions(+), 6 deletions(-) diff --git a/src/current/calc.xsd b/src/current/calc.xsd index 9ff9f67a..c5b95723 100644 --- a/src/current/calc.xsd +++ b/src/current/calc.xsd @@ -235,6 +235,16 @@ + + + + + Specify the dimension of each index of the generator result. + Disables casting and truncating with @precision if greater + than 0 or 'scaler'. This expands into c:sum/@dim. + + + diff --git a/src/current/compiler/js-calc.xsl b/src/current/compiler/js-calc.xsl index f760fbcb..219c8a40 100644 --- a/src/current/compiler/js-calc.xsl +++ b/src/current/compiler/js-calc.xsl @@ -36,6 +36,7 @@ --> + + ( function() { @@ -245,7 +249,12 @@ ) { - var result = +(+( + var result = + + @@ -260,9 +269,16 @@ ] - )).toFixed( - - ); + )) + + + + .toFixed( + + ) + + + ; diff --git a/src/current/include/preproc/expand.xsl b/src/current/include/preproc/expand.xsl index f023df15..c43fcc2d 100644 --- a/src/current/include/preproc/expand.xsl +++ b/src/current/include/preproc/expand.xsl @@ -122,6 +122,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/current/include/preproc/macros.xsl b/src/current/include/preproc/macros.xsl index e58f247c..234632f5 100644 --- a/src/current/include/preproc/macros.xsl +++ b/src/current/include/preproc/macros.xsl @@ -402,7 +402,7 @@ - + diff --git a/src/current/include/preproc/symtable.xsl b/src/current/include/preproc/symtable.xsl index 432c3abd..7635c9a3 100644 --- a/src/current/include/preproc/symtable.xsl +++ b/src/current/include/preproc/symtable.xsl @@ -688,9 +688,12 @@ + + + type="gen" dtype="float" dim="{$dim}" desc="{@desc}" tex="{@sym}" />