Package namespace/imports/decl cleanup

master
Mike Gerwitz 2015-03-18 11:31:47 -04:00 committed by Mike Gerwitz
parent 4ddda94a4c
commit fb1416837b
22 changed files with 948 additions and 1059 deletions

View File

@ -1,123 +1,117 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../rater.xsd"
core="true" core="true"
name="core/base"
desc="Base features"> desc="Base features">
<!-- magic variable that will contain the result of a classification (this <!-- magic variable that will contain the result of a classification (this
definition exists to simplify validations (its symbol is Xi because it definition exists to simplify validations (its symbol is Xi because it
looks like a sideways array) --> looks like a sideways array) -->
<lv:const name="_CMATCH_" type="boolean" desc="Set indicating indexes of classification matches" sym="\Xi"> <const name="_CMATCH_" type="boolean" desc="Set indicating indexes of classification matches" sym="\Xi">
<lv:item value="0" desc="Dummy value; this set is populated upon entering each rate block" /> <item value="0" desc="Dummy value; this set is populated upon entering each rate block" />
</lv:const> </const>
<lv:const name="NEGATE" value="-1" type="float" desc="Negate a value" sym="-" /> <const name="NEGATE" value="-1" type="float" desc="Negate a value" sym="-" />
<!-- useful where constants are required --> <!-- useful where constants are required -->
<lv:const name="ZERO" value="0.00" type="float" desc="Zero value" /> <const name="ZERO" value="0.00" type="float" desc="Zero value" />
<!-- the runtime is responsible for automatically populating these fields with meaningful values --> <!-- the runtime is responsible for automatically populating these fields with meaningful values -->
<lv:const name="__DATE_YEAR__" value="0" type="integer" desc="Current year" sym="\widehat{D^\gamma}" magic="true" /> <const name="__DATE_YEAR__" value="0" type="integer" desc="Current year" sym="\widehat{D^\gamma}" magic="true" />
<lv:typedef name="integer" desc="Any value in the set of integers" sym="\mathbb{I}"> <typedef name="integer" desc="Any value in the set of integers" sym="\mathbb{I}">
<lv:base-type /> <base-type />
</lv:typedef> </typedef>
<!-- real number --> <!-- real number -->
<lv:typedef name="float" desc="Any real number (represented as a float)" sym="\mathbb{R}"> <typedef name="float" desc="Any real number (represented as a float)" sym="\mathbb{R}">
<lv:base-type /> <base-type />
</lv:typedef> </typedef>
<lv:typedef name="boolean" desc="Boolean values"> <typedef name="boolean" desc="Boolean values">
<lv:enum type="integer"> <enum type="integer">
<lv:item name="TRUE" value="1" desc="True" /> <item name="TRUE" value="1" desc="True" />
<lv:item name="FALSE" value="0" desc="False" /> <item name="FALSE" value="0" desc="False" />
</lv:enum> </enum>
</lv:typedef> </typedef>
<!-- does not have much practical use outside of the core --> <!-- does not have much practical use outside of the core -->
<lv:typedef name="empty" desc="Empty set" sym="\emptyset"> <typedef name="empty" desc="Empty set" sym="\emptyset">
<lv:base-type /> <base-type />
</lv:typedef> </typedef>
<!-- <!--
Useful in certain circumstances. Don't judge. Useful in certain circumstances. Don't judge.
--> -->
<lv:classify as="always" keep="true" yields="alwaysTrue" desc="Always true" /> <classify as="always" keep="true" yields="alwaysTrue" desc="Always true" />
<lv:template name="_todo_" desc="A simple TODO :)"> <template name="_todo_" desc="A simple TODO :)">
<lv:param name="@desc@" desc="TODO desc"> <param name="@desc@" desc="TODO desc">
<lv:text>TODO</lv:text> <text>TODO</text>
</lv:param> </param>
<lv:param name="@hide@" desc="Whether to hide content by stripping <param name="@hide@" desc="Whether to hide content by stripping
it entriely from the output" /> it entriely from the output" />
<lv:unless name="@hide@"> <unless name="@hide@">
<c:const value="0" type="integer" desc="@desc@" /> <c:const value="0" type="integer" desc="@desc@" />
</lv:unless> </unless>
</lv:template> </template>
<lv:template name="_ignore_" desc="Simply removes all child nodes (as if it was commented out)"> <template name="_ignore_" desc="Simply removes all child nodes (as if it was commented out)">
<lv:param name="@values@" desc="Nodes to comment out" /> <param name="@values@" desc="Nodes to comment out" />
<lv:param name="@desc@" desc="Description" /> <param name="@desc@" desc="Description" />
<!-- nothing --> <!-- nothing -->
</lv:template> </template>
<lv:template name="_fail-on-empty_" desc="Fail on rate lookup failure"> <template name="_fail-on-empty_" desc="Fail on rate lookup failure">
<lv:param name="@values@" desc="Optional conditions to include in match" /> <param name="@values@" desc="Optional conditions to include in match" />
<lv:param name="@name@" desc="Data to check (scalar, vector or otherwise)" /> <param name="@name@" desc="Data to check (scalar, vector or otherwise)" />
<lv:param name="@when@" desc="Conditional check (optional)" /> <param name="@when@" desc="Conditional check (optional)" />
<lv:param name="@class@" desc="Conditional class check" /> <param name="@class@" desc="Conditional class check" />
<lv:param name="@as@" desc="Classifier name"> <param name="@as@" desc="Classifier name">
<lv:text>-err-empty-</lv:text> <text>-err-empty-</text>
<lv:param-value name="@name@" lower="true" /> <param-value name="@name@" lower="true" />
</lv:param> </param>
<lv:param name="@desc@" desc="Description"> <param name="@desc@" desc="Description">
<lv:param-value name="@name@" /> <param-value name="@name@" />
<lv:text> is empty</lv:text> <text> is empty</text>
</lv:param> </param>
<lv:param name="@classyields@" desc="Classification yield to match on"> <param name="@classyields@" desc="Classification yield to match on">
<lv:param-class-to-yields name="@class@" /> <param-class-to-yields name="@class@" />
</lv:param> </param>
<!-- default to external to ensure that calculations do not wind up in the <!-- default to external to ensure that calculations do not wind up in the
classifier --> classifier -->
<lv:param name="@external@" desc="External classification"> <param name="@external@" desc="External classification">
<lv:text>true</lv:text> <text>true</text>
</lv:param> </param>
<lv:classify as="@as@" desc="@desc@" external="@external@" terminate="true"> <classify as="@as@" desc="@desc@" external="@external@" terminate="true">
<!-- include any option conditions --> <!-- include any option conditions -->
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
<lv:if name="@when@"> <if name="@when@">
<lv:match on="@when@" value="TRUE" /> <match on="@when@" value="TRUE" />
</lv:if> </if>
<lv:if name="@class@"> <if name="@class@">
<lv:match on="@classyields@" value="TRUE" /> <match on="@classyields@" value="TRUE" />
</lv:if> </if>
<lv:match on="@name@" value="ZERO" /> <match on="@name@" value="ZERO" />
</lv:classify> </classify>
</lv:template> </template>
</lv:package> </package>

View File

@ -1,22 +1,16 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../rater.xsd"
core="true" core="true"
name="core/cond"
desc="Generic conditionals"> desc="Generic conditionals">
<lv:import package="base" /> <import package="base" />
<!-- TODO: use reduce once we have support for function passing --> <!-- TODO: use reduce once we have support for function passing -->
<lv:function name="or" desc="Return value A if non-zero, otherwise B"> <function name="or" desc="Return value A if non-zero, otherwise B">
<lv:param name="or_a" type="float" desc="Value to return if non-zero" /> <param name="or_a" type="float" desc="Value to return if non-zero" />
<lv:param name="or_b" type="float" desc="Value to return if A is zero" /> <param name="or_b" type="float" desc="Value to return if A is zero" />
<c:cases> <c:cases>
<!-- return B if A is zero --> <!-- return B if A is zero -->
@ -35,23 +29,23 @@
<c:value-of name="or_a" /> <c:value-of name="or_a" />
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:function> </function>
<lv:template name="_cond_" desc="Conditional shorthand"> <template name="_cond_" desc="Conditional shorthand">
<lv:param name="@name@" desc="Value to check" /> <param name="@name@" desc="Value to check" />
<lv:param name="@index@" desc="Index of boolean value" /> <param name="@index@" desc="Index of boolean value" />
<lv:param name="@value@" desc="Constant value" /> <param name="@value@" desc="Constant value" />
<lv:param name="@type@" desc="Value type" /> <param name="@type@" desc="Value type" />
<lv:param name="@cond@" desc="Value to compare against (default boolean true)"> <param name="@cond@" desc="Value to compare against (default boolean true)">
<lv:text>TRUE</lv:text> <text>TRUE</text>
</lv:param> </param>
<lv:param name="@desc@" desc="Value description"> <param name="@desc@" desc="Value description">
<lv:text>Value when </lv:text> <text>Value when </text>
<lv:param-value name="@name@" /> <param-value name="@name@" />
</lv:param> </param>
<c:const value="@value@" type="@type@" desc="@desc@"> <c:const value="@value@" type="@type@" desc="@desc@">
<!-- TODO: non-index option --> <!-- TODO: non-index option -->
@ -61,50 +55,50 @@
</c:eq> </c:eq>
</c:when> </c:when>
</c:const> </c:const>
</lv:template> </template>
<lv:template name="_yield-unless_" desc="Yield a value unless another value is set"> <template name="_yield-unless_" desc="Yield a value unless another value is set">
<lv:param name="@name@" desc="Overriding value" /> <param name="@name@" desc="Overriding value" />
<lv:param name="@index@" desc="Index" /> <param name="@index@" desc="Index" />
<lv:param name="@values@" desc="Value to use otherwise" /> <param name="@values@" desc="Value to use otherwise" />
<c:cases> <c:cases>
<c:case> <c:case>
<lv:if name="@index@"> <if name="@index@">
<c:when name="@name@" index="@index@"> <c:when name="@name@" index="@index@">
<c:gt> <c:gt>
<c:const value="0" type="integer" desc="Use override if greater than 0" /> <c:const value="0" type="integer" desc="Use override if greater than 0" />
</c:gt> </c:gt>
</c:when> </c:when>
</lv:if> </if>
<lv:unless name="@index@"> <unless name="@index@">
<c:when name="@name@"> <c:when name="@name@">
<c:gt> <c:gt>
<c:const value="0" type="integer" desc="Use override if greater than 0" /> <c:const value="0" type="integer" desc="Use override if greater than 0" />
</c:gt> </c:gt>
</c:when> </c:when>
</lv:unless> </unless>
<lv:if name="@index@"> <if name="@index@">
<c:value-of name="@name@" index="@index@" /> <c:value-of name="@name@" index="@index@" />
</lv:if> </if>
<lv:unless name="@index@"> <unless name="@index@">
<c:value-of name="@name@" /> <c:value-of name="@name@" />
</lv:unless> </unless>
</c:case> </c:case>
<c:otherwise> <c:otherwise>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:template> </template>
<lv:template name="_default_" desc="Set a default value if a value is not set"> <template name="_default_" desc="Set a default value if a value is not set">
<lv:param name="@name@" desc="Param name" /> <param name="@name@" desc="Param name" />
<lv:param name="@index@" desc="Index" /> <param name="@index@" desc="Index" />
<lv:param name="@default@" desc="Default value to use if empty" /> <param name="@default@" desc="Default value to use if empty" />
<c:cases> <c:cases>
<c:case> <c:case>
@ -121,36 +115,37 @@
<c:value-of name="@name@" index="@index@" /> <c:value-of name="@name@" index="@index@" />
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:template> </template>
<lv:template name="_cond-value-each_" desc="Conditional value"> <template name="_cond-value-each_" desc="Conditional value">
<lv:param name="@class@" desc="Class match" /> <param name="@class@" desc="Class match" />
<lv:param name="@generates@" desc="Variable to generate into" /> <param name="@generates@" desc="Variable to generate into" />
<lv:param name="@value@" desc="Value to yield (use either this or const)" /> <param name="@value@" desc="Value to yield (use either this or const)" />
<lv:param name="@const@" desc="Constant to yield (use either this or value)" /> <param name="@const@" desc="Constant to yield (use either this or value)" />
<lv:param name="@count@" desc="Optional number of times to apply const/value (as a variable)" /> <param name="@count@" desc="Optional number of times to apply const/value (as a variable)" />
<lv:param name="@desc@" desc="Optional constant description"> <param name="@desc@" desc="Optional constant description">
<lv:text>Constant value</lv:text> <text>Constant value</text>
</lv:param> </param>
<!-- simply returns a constant value for the class match --> <!-- simply returns a constant value for the class match -->
<lv:rate-each class="@class@" accumulate="none" generates="@generates@" index="k"> <rate-each class="@class@" accumulate="none" generates="@generates@" index="k">
<c:product> <c:product>
<lv:if name="@value@"> <if name="@value@">
<c:value-of name="@value@" /> <c:value-of name="@value@" />
</lv:if> </if>
<lv:unless name="@value@"> <unless name="@value@">
<c:const value="@const@" type="float" desc="@desc@" /> <c:const value="@const@" type="float" desc="@desc@" />
</lv:unless> </unless>
<!-- if this is not provided, then the c:product will be optimized away --> <!-- if this is not provided, then the c:product will be optimized away -->
<lv:if name="@count@"> <if name="@count@">
<c:value-of name="@count@" index="k" /> <c:value-of name="@count@" index="k" />
</lv:if> </if>
</c:product> </c:product>
</lv:rate-each> </rate-each>
</lv:template> </template>
</lv:package> </package>

View File

@ -1,16 +1,10 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../rater.xsd"
core="true" core="true"
name="core/datetime"
desc="Date and time"> desc="Date and time">
<lv:import package="base" /> <import package="base" />
<!-- <!--
@ -19,23 +13,23 @@
Note that a positive number will be returned if the given date is in the past, Note that a positive number will be returned if the given date is in the past,
negative if in the future. negative if in the future.
--> -->
<lv:template name="_ageYears_" desc="Age in years of the given date relative to the current"> <template name="_ageYears_" desc="Age in years of the given date relative to the current">
<lv:param name="@generates@" desc="Generator variable, per index" /> <param name="@generates@" desc="Generator variable, per index" />
<lv:param name="@yearset@" desc="Set of years to iterate on" /> <param name="@yearset@" desc="Set of years to iterate on" />
<lv:param name="@sym@" desc="Generator symbol" /> <param name="@sym@" desc="Generator symbol" />
<lv:param name="@when@" desc="Only when this boolean value is true" /> <param name="@when@" desc="Only when this boolean value is true" />
<lv:param name="@default@" desc="Default age when yearset values are empty" /> <param name="@default@" desc="Default age when yearset values are empty" />
<lv:param name="@yields@" desc="Variable to yield into"> <param name="@yields@" desc="Variable to yield into">
<lv:text>_</lv:text> <text>_</text>
<lv:param-value name="@generates@" /> <param-value name="@generates@" />
</lv:param> </param>
<lv:rate yields="@yields@"> <rate yields="@yields@">
<c:sum of="@yearset@" index="k" generates="@generates@" desc="Relative age" sym="@sym@"> <c:sum of="@yearset@" index="k" generates="@generates@" desc="Relative age" sym="@sym@">
<c:cases> <c:cases>
<lv:if name="@when@"> <if name="@when@">
<c:case> <c:case>
<c:when name="@when@" index="k"> <c:when name="@when@" index="k">
<c:eq> <c:eq>
@ -44,14 +38,14 @@
</c:when> </c:when>
<!-- return a default, or 0 if no default is provided --> <!-- return a default, or 0 if no default is provided -->
<lv:if name="@default@"> <if name="@default@">
<c:value-of name="@default@" index="k" /> <c:value-of name="@default@" index="k" />
</lv:if> </if>
<lv:unless name="@default@"> <unless name="@default@">
<c:const value="0" type="integer" desc="Condition not met, but no default" /> <c:const value="0" type="integer" desc="Condition not met, but no default" />
</lv:unless> </unless>
</c:case> </c:case>
</lv:if> </if>
<!-- if no @when@, then we'll always do this --> <!-- if no @when@, then we'll always do this -->
<c:otherwise> <c:otherwise>
@ -74,15 +68,16 @@
</c:case> </c:case>
<!-- we don't have a value; just use the default age we were given --> <!-- we don't have a value; just use the default age we were given -->
<lv:if name="@default@"> <if name="@default@">
<c:otherwise> <c:otherwise>
<c:value-of name="@default@" index="k" /> <c:value-of name="@default@" index="k" />
</c:otherwise> </c:otherwise>
</lv:if> </if>
</c:cases> </c:cases>
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</c:sum> </c:sum>
</lv:rate> </rate>
</lv:template> </template>
</lv:package> </package>

View File

@ -1,113 +1,108 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
Brings c:case statements to life Brings c:case statements to life
The problem with cases is that they are so verbose for simple cases. This The problem with cases is that they are so verbose for simple cases. This
makes simple cases simple. makes simple cases simple.
--> -->
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../rater.xsd"
core="true" core="true"
name="map"
desc="Mapping templates/functions"> desc="Mapping templates/functions">
<lv:template name="_map-set_" desc="Map a set of values"> <template name="_map-set_" desc="Map a set of values">
<lv:param name="@name@" desc="Param name" /> <param name="@name@" desc="Param name" />
<lv:param name="@index@" desc="Index" /> <param name="@index@" desc="Index" />
<lv:param name="@values@" desc="Criteria (map nodes)" /> <param name="@values@" desc="Criteria (map nodes)" />
<lv:param name="@label@" desc="Case statement label"> <param name="@label@" desc="Case statement label">
<!-- default empty --> <!-- default empty -->
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:param name="@default@" desc="Default value" /> <param name="@default@" desc="Default value" />
<c:cases label="@label@"> <c:cases label="@label@">
<lv:param-copy name="@values@"> <param-copy name="@values@">
<lv:param-meta name="map_param" value="@name@" /> <param-meta name="map_param" value="@name@" />
<lv:param-meta name="map_index" value="@index@" /> <param-meta name="map_index" value="@index@" />
</lv:param-copy> </param-copy>
<!-- TODO: allow setting default via @default or t:default or something <!-- TODO: allow setting default via @default or t:default or something
(or both) --> (or both) -->
<lv:if name="@default@"> <if name="@default@">
<c:otherwise> <c:otherwise>
<c:const value="@default@" type="integer" desc="No mapping" /> <c:const value="@default@" type="integer" desc="No mapping" />
</c:otherwise> </c:otherwise>
</lv:if> </if>
</c:cases> </c:cases>
</lv:template> </template>
<lv:template name="_map_" desc="Map criteria"> <template name="_map_" desc="Map criteria">
<lv:param name="@from@" desc="Value to map from" /> <param name="@from@" desc="Value to map from" />
<lv:param name="@value@" desc="Constant to map to" /> <param name="@value@" desc="Constant to map to" />
<lv:param name="@to@" desc="Named value (use instead of @value@)" /> <param name="@to@" desc="Named value (use instead of @value@)" />
<lv:param name="@type@" desc="Constant value type"> <param name="@type@" desc="Constant value type">
<lv:text>float</lv:text> <text>float</text>
</lv:param> </param>
<lv:param name="@desc@" desc="Map description"> <param name="@desc@" desc="Map description">
<lv:text>Destination mapping</lv:text> <text>Destination mapping</text>
</lv:param> </param>
<!-- set by parent map-set --> <!-- set by parent map-set -->
<lv:param name="@name@" desc="Param name"> <param name="@name@" desc="Param name">
<lv:param-inherit meta="map_param" /> <param-inherit meta="map_param" />
</lv:param> </param>
<lv:param name="@index@" desc="Index"> <param name="@index@" desc="Index">
<lv:param-inherit meta="map_index" /> <param-inherit meta="map_index" />
</lv:param> </param>
<c:case> <c:case>
<!-- index provided --> <!-- index provided -->
<lv:if name="@index@"> <if name="@index@">
<c:when name="@name@" index="@index@"> <c:when name="@name@" index="@index@">
<c:eq> <c:eq>
<c:value-of name="@from@" /> <c:value-of name="@from@" />
</c:eq> </c:eq>
</c:when> </c:when>
</lv:if> </if>
<!-- no index provided --> <!-- no index provided -->
<lv:unless name="@index@"> <unless name="@index@">
<c:when name="@name@"> <c:when name="@name@">
<c:eq> <c:eq>
<c:value-of name="@from@" /> <c:value-of name="@from@" />
</c:eq> </c:eq>
</c:when> </c:when>
</lv:unless> </unless>
<lv:if name="@value@"> <if name="@value@">
<c:const value="@value@" type="@type@" desc="@desc@" /> <c:const value="@value@" type="@type@" desc="@desc@" />
</lv:if> </if>
<lv:unless name="@value@"> <unless name="@value@">
<!-- TODO: index support --> <!-- TODO: index support -->
<c:value-of name="@to@" /> <c:value-of name="@to@" />
</lv:unless> </unless>
</c:case> </c:case>
</lv:template> </template>
<lv:template name="_map-else_" desc="Non-matching map criteria"> <template name="_map-else_" desc="Non-matching map criteria">
<lv:param name="@value@" desc="Constant to map to" /> <param name="@value@" desc="Constant to map to" />
<lv:param name="@to@" desc="Named value (use instead of @value@)" /> <param name="@to@" desc="Named value (use instead of @value@)" />
<c:otherwise> <c:otherwise>
<lv:if name="@value@"> <if name="@value@">
<c:const value="@value@" type="float" desc="@desc@" /> <c:const value="@value@" type="float" desc="@desc@" />
</lv:if> </if>
<lv:unless name="@value@"> <unless name="@value@">
<!-- TODO: index support --> <!-- TODO: index support -->
<c:value-of name="@to@" /> <c:value-of name="@to@" />
</lv:unless> </unless>
</c:otherwise> </c:otherwise>
</lv:template> </template>
</lv:package> </package>

View File

@ -1,21 +1,15 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../rater.xsd"
core="true" core="true"
name="core/numeric"
desc="Numeric computations"> desc="Numeric computations">
<!-- we are a meta-package --> <!-- we are a meta-package -->
<lv:import package="numeric/boolean" export="true" /> <import package="numeric/boolean" export="true" />
<lv:import package="numeric/convert" export="true" /> <import package="numeric/convert" export="true" />
<lv:import package="numeric/minmax" export="true" /> <import package="numeric/minmax" export="true" />
<lv:import package="numeric/round" export="true" /> <import package="numeric/round" export="true" />
<import package="numeric/common" export="true" />
</package>
<lv:import package="numeric/common" export="true" />
</lv:package>

View File

@ -1,20 +1,14 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/numeric/boolean"
desc="Numeric computations dealing with boolean algebra"> desc="Numeric computations dealing with boolean algebra">
<lv:import package="../base" /> <import package="../base" />
<lv:function name="not" desc="Negates a boolean value" sym="\lnot"> <function name="not" desc="Negates a boolean value" sym="\lnot">
<lv:param name="not_value" type="boolean" desc="Boolean value to negate" /> <param name="not_value" type="boolean" desc="Boolean value to negate" />
<c:const value="1" type="boolean" desc="Value of 1 if given value is zero"> <c:const value="1" type="boolean" desc="Value of 1 if given value is zero">
<c:when name="not_value"> <c:when name="not_value">
@ -23,5 +17,5 @@
</c:eq> </c:eq>
</c:when> </c:when>
</c:const> </c:const>
</lv:function> </function>
</lv:package> </package>

View File

@ -1,83 +1,77 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/numeric/common"
desc="General numeric opreations"> desc="General numeric opreations">
<lv:import package="../base" /> <import package="../base" />
<lv:template name="_inc_" desc="Increment value [by 1]"> <template name="_inc_" desc="Increment value [by 1]">
<lv:param name="@values@" desc="Value to increment (nodes)" /> <param name="@values@" desc="Value to increment (nodes)" />
<lv:param name="@value@" desc="Value to decrement by (default 1)"> <param name="@value@" desc="Value to decrement by (default 1)">
<lv:text>1</lv:text> <text>1</text>
</lv:param> </param>
<c:sum> <c:sum>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
<c:const value="@value@" type="integer" desc="Increment by 1" /> <c:const value="@value@" type="integer" desc="Increment by 1" />
</c:sum> </c:sum>
</lv:template> </template>
<lv:template name="_dec_" desc="Decrement value [by 1]"> <template name="_dec_" desc="Decrement value [by 1]">
<lv:param name="@values@" desc="Value to decrement (nodes)" /> <param name="@values@" desc="Value to decrement (nodes)" />
<lv:param name="@value@" desc="Value to decrement by (default 1)"> <param name="@value@" desc="Value to decrement by (default 1)">
<lv:text>1</lv:text> <text>1</text>
</lv:param> </param>
<c:sum> <c:sum>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
<c:product> <c:product>
<c:value-of name="NEGATE" /> <c:value-of name="NEGATE" />
<c:const value="@value@" type="integer" desc="Decrement by 1" /> <c:const value="@value@" type="integer" desc="Decrement by 1" />
</c:product> </c:product>
</c:sum> </c:sum>
</lv:template> </template>
<lv:template name="_negate_" desc="Negate a value"> <template name="_negate_" desc="Negate a value">
<lv:param name="@values@" desc="Value to decrement (nodes)" /> <param name="@values@" desc="Value to decrement (nodes)" />
<lv:param name="@label@" desc="Application label"> <param name="@label@" desc="Application label">
<!-- default empty --> <!-- default empty -->
<lv:text></lv:text> <text></text>
</lv:param> </param>
<c:product label="@label@"> <c:product label="@label@">
<c:value-of name="NEGATE" /> <c:value-of name="NEGATE" />
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:product> </c:product>
</lv:template> </template>
<lv:template name="_percent-of_" desc="Take percentage of a value"> <template name="_percent-of_" desc="Take percentage of a value">
<lv:param name="@value@" desc="Value to take percentage of" /> <param name="@value@" desc="Value to take percentage of" />
<lv:param name="@index@" desc="Index" /> <param name="@index@" desc="Index" />
<lv:param name="@percent@" desc="Percent (as a whole number)" /> <param name="@percent@" desc="Percent (as a whole number)" />
<lv:param name="@desc@" desc="Optional description"> <param name="@desc@" desc="Optional description">
<lv:text>Percent to reduce</lv:text> <text>Percent to reduce</text>
</lv:param> </param>
<c:product> <c:product>
<c:value-of name="@value@" index="@index@" /> <c:value-of name="@value@" index="@index@" />
<t:ptor value="@percent@" desc="@desc@" /> <t:ptor value="@percent@" desc="@desc@" />
</c:product> </c:product>
</lv:template> </template>
@ -85,11 +79,11 @@
Calculates a value based on the given multiplier if the given value falls Calculates a value based on the given multiplier if the given value falls
within the given range within the given range
--> -->
<lv:function name="rangeadd" desc="Add a value multiplier for a given range"> <function name="rangeadd" desc="Add a value multiplier for a given range">
<lv:param name="low" type="float" desc="Lower bound, inclusive" /> <param name="low" type="float" desc="Lower bound, inclusive" />
<lv:param name="high" type="float" desc="Upper bound, inclusive" /> <param name="high" type="float" desc="Upper bound, inclusive" />
<lv:param name="val" type="float" desc="Value to compare" /> <param name="val" type="float" desc="Value to compare" />
<lv:param name="mult" type="float" desc="Range multiplier" /> <param name="mult" type="float" desc="Range multiplier" />
<c:product> <c:product>
<c:when name="val"> <c:when name="val">
@ -114,5 +108,6 @@
</c:product> </c:product>
</c:sum> </c:sum>
</c:product> </c:product>
</lv:function> </function>
</lv:package> </package>

View File

@ -1,13 +1,8 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<package xmlns="http://www.lovullo.com/rater" <package xmlns="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/numeric/convert"
desc="Converts scalars to another type"> desc="Converts scalars to another type">
<import package="../base" /> <import package="../base" />
@ -383,3 +378,4 @@
</c:case> </c:case>
</template> </template>
</package> </package>

View File

@ -1,22 +1,16 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/numeric/minmax"
desc="Numeric computations dealing with minimums and maximums"> desc="Numeric computations dealing with minimums and maximums">
<lv:import package="../base" /> <import package="../base" />
<lv:function name="max" desc="Return the greater value"> <function name="max" desc="Return the greater value">
<lv:param name="max1" type="float" desc="First value to compare" /> <param name="max1" type="float" desc="First value to compare" />
<lv:param name="max2" type="float" desc="Second value to compare" /> <param name="max2" type="float" desc="Second value to compare" />
<c:cases> <c:cases>
<c:case> <c:case>
@ -33,12 +27,12 @@
<c:value-of name="max2" /> <c:value-of name="max2" />
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:function> </function>
<lv:function name="min" desc="Return the lesser value"> <function name="min" desc="Return the lesser value">
<lv:param name="min1" type="float" desc="First value to compare" /> <param name="min1" type="float" desc="First value to compare" />
<lv:param name="min2" type="float" desc="Second value to compare" /> <param name="min2" type="float" desc="Second value to compare" />
<c:cases> <c:cases>
<c:case> <c:case>
@ -55,15 +49,15 @@
<c:value-of name="min2" /> <c:value-of name="min2" />
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:function> </function>
<lv:template name="_min-zero_" desc="Does not allow a value below 0 to be yielded"> <template name="_min-zero_" desc="Does not allow a value below 0 to be yielded">
<lv:param name="@values@" desc="Calculation to apply restriction to" /> <param name="@values@" desc="Calculation to apply restriction to" />
<lv:param name="@label@" desc="Application label"> <param name="@label@" desc="Application label">
<!-- default empty --> <!-- default empty -->
<lv:text></lv:text> <text></text>
</lv:param> </param>
<c:apply name="max" label="@label@"> <c:apply name="max" label="@label@">
<c:arg name="max1"> <c:arg name="max1">
@ -71,26 +65,26 @@
</c:arg> </c:arg>
<c:arg name="max2"> <c:arg name="max2">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:template> </template>
<!-- trivial, but cuts turns a verbose rate-each and function application <!-- trivial, but cuts turns a verbose rate-each and function application
into potentially a one-line template application --> into potentially a one-line template application -->
<lv:template name="_quickMaxEach_" desc="Quick max application"> <template name="_quickMaxEach_" desc="Quick max application">
<lv:param name="@class@" desc="Class to match on" /> <param name="@class@" desc="Class to match on" />
<lv:param name="@generates@" desc="Value to generate into" /> <param name="@generates@" desc="Value to generate into" />
<lv:param name="@a@" desc="Value a" /> <param name="@a@" desc="Value a" />
<lv:param name="@b@" desc="Value b" /> <param name="@b@" desc="Value b" />
<lv:param name="@yields@" desc="Yield variable"> <param name="@yields@" desc="Yield variable">
<lv:text>_</lv:text> <text>_</text>
<lv:param-value name="@generates@" /> <param-value name="@generates@" />
</lv:param> </param>
<lv:rate-each class="@class@" accumulate="none" yields="@yields@" generates="@generates@" index="k"> <rate-each class="@class@" accumulate="none" yields="@yields@" generates="@generates@" index="k">
<c:apply name="max"> <c:apply name="max">
<c:arg name="max1"> <c:arg name="max1">
<c:value-of name="@a@" index="k" /> <c:value-of name="@a@" index="k" />
@ -99,54 +93,54 @@
<c:value-of name="@b@" index="k" /> <c:value-of name="@b@" index="k" />
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:rate-each> </rate-each>
</lv:template> </template>
<lv:template name="_cap_" <template name="_cap_"
desc="Cap a value at a given maximum"> desc="Cap a value at a given maximum">
<lv:param name="@values@" desc="Value expression" /> <param name="@values@" desc="Value expression" />
<lv:param name="@name@" desc="Value to cap at" /> <param name="@name@" desc="Value to cap at" />
<lv:param name="@index@" desc="Index of value to cap at"> <param name="@index@" desc="Index of value to cap at">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:param name="@value@" <param name="@value@"
desc="Constant value to cap at (deprecated)" /> desc="Constant value to cap at (deprecated)" />
<lv:param name="@desc@" desc="Value description"> <param name="@desc@" desc="Value description">
<lv:text>Maximum value</lv:text> <text>Maximum value</text>
</lv:param> </param>
<c:apply name="min"> <c:apply name="min">
<c:arg name="min1"> <c:arg name="min1">
<!-- deprecated --> <!-- deprecated -->
<lv:if name="@value@"> <if name="@value@">
<c:const value="@value@" type="float" desc="@desc@" /> <c:const value="@value@" type="float" desc="@desc@" />
</lv:if> </if>
<lv:unless name="@value@"> <unless name="@value@">
<c:value-of name="@name@" <c:value-of name="@name@"
index="@index@" index="@index@"
type="float" type="float"
label="@desc@" /> label="@desc@" />
</lv:unless> </unless>
</c:arg> </c:arg>
<c:arg name="min2"> <c:arg name="min2">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:template> </template>
<!-- useful in products --> <!-- useful in products -->
<lv:template name="_min-value-of_" desc="Return a value or a minimum"> <template name="_min-value-of_" desc="Return a value or a minimum">
<lv:param name="@name@" desc="Name of value" /> <param name="@name@" desc="Name of value" />
<lv:param name="@index@" desc="Value index" /> <param name="@index@" desc="Value index" />
<lv:param name="@label@" desc="Optional label" /> <param name="@label@" desc="Optional label" />
<lv:param name="@min@" desc="Minimum value" /> <param name="@min@" desc="Minimum value" />
<c:apply name="max" label="{@label@}, minimum of 1"> <c:apply name="max" label="{@label@}, minimum of 1">
<c:arg name="max1"> <c:arg name="max1">
@ -157,14 +151,14 @@
<c:value-of name="@name@" index="@index@" label="@label@" /> <c:value-of name="@name@" index="@index@" label="@label@" />
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:template> </template>
<lv:template name="_between_" desc="Assert that a value is within the given range, inclusive"> <template name="_between_" desc="Assert that a value is within the given range, inclusive">
<lv:param name="@min@" desc="Minimum value, inclusive" /> <param name="@min@" desc="Minimum value, inclusive" />
<lv:param name="@max@" desc="Maximum value, inclusive" /> <param name="@max@" desc="Maximum value, inclusive" />
<lv:param name="@desc@" desc="Description" /> <param name="@desc@" desc="Description" />
<c:gte> <c:gte>
<c:const value="@min@" type="float" desc="{@desc@}; minimum" /> <c:const value="@min@" type="float" desc="{@desc@}; minimum" />
@ -172,7 +166,7 @@
<c:lte> <c:lte>
<c:const value="@max@" type="float" desc="{@desc@}; maximum" /> <c:const value="@max@" type="float" desc="{@desc@}; maximum" />
</c:lte> </c:lte>
</lv:template> </template>
@ -181,29 +175,29 @@
TODO: max is incomplete (should have all the options of min) TODO: max is incomplete (should have all the options of min)
--> -->
<lv:template name="_bump_" desc="Bump a value if it does not reach a minimum"> <template name="_bump_" desc="Bump a value if it does not reach a minimum">
<!-- if a minimum percentage --> <!-- if a minimum percentage -->
<lv:param name="@percent@" desc="Percent, as a whole value" /> <param name="@percent@" desc="Percent, as a whole value" />
<lv:param name="@value@" desc="Value to take percentage of, or take whole value of if no percent" /> <param name="@value@" desc="Value to take percentage of, or take whole value of if no percent" />
<lv:param name="@vindex@" desc="Optional index for base" /> <param name="@vindex@" desc="Optional index for base" />
<lv:param name="@name@" desc="Provided value" /> <param name="@name@" desc="Provided value" />
<lv:param name="@generates@" desc="Variable to generate into" /> <param name="@generates@" desc="Variable to generate into" />
<lv:param name="@when@" desc="Conditional bump" /> <param name="@when@" desc="Conditional bump" />
<lv:param name="@class@" desc="Class to match on" /> <param name="@class@" desc="Class to match on" />
<lv:param name="@keep@" desc="Value of keep flag" /> <param name="@keep@" desc="Value of keep flag" />
<!-- alternative to @name@ --> <!-- alternative to @name@ -->
<lv:param name="@const@" desc="Constant value, instead of named" /> <param name="@const@" desc="Constant value, instead of named" />
<!-- max values for bumping down --> <!-- max values for bumping down -->
<lv:param name="@maxpercent@" desc="Maximum percent" /> <param name="@maxpercent@" desc="Maximum percent" />
<lv:rate yields="_{@generates@}" keep="@keep@"> <rate yields="_{@generates@}" keep="@keep@">
<c:sum of="@name@" index="k" generates="@generates@" desc="Bumped value"> <c:sum of="@name@" index="k" generates="@generates@" desc="Bumped value">
<c:cases> <c:cases>
<!-- if a condition was provided, check it first --> <!-- if a condition was provided, check it first -->
<lv:if name="@when@"> <if name="@when@">
<c:case> <c:case>
<c:when name="@when@" index="k"> <c:when name="@when@" index="k">
<c:eq> <c:eq>
@ -214,10 +208,10 @@
<!-- just return the value provided --> <!-- just return the value provided -->
<c:value-of name="@name@" index="k" /> <c:value-of name="@name@" index="k" />
</c:case> </c:case>
</lv:if> </if>
<!-- if a condition was provided, check it first --> <!-- if a condition was provided, check it first -->
<lv:if name="@class@"> <if name="@class@">
<c:case> <c:case>
<c:when name="@class@" index="k"> <c:when name="@class@" index="k">
<c:eq> <c:eq>
@ -228,7 +222,7 @@
<!-- just return the value provided --> <!-- just return the value provided -->
<c:const value="0" type="float" desc="Zero value" /> <c:const value="0" type="float" desc="Zero value" />
</c:case> </c:case>
</lv:if> </if>
<!-- condition was not provided or did not match (we check for the <!-- condition was not provided or did not match (we check for the
negative of the condition above so that this template will still negative of the condition above so that this template will still
@ -238,37 +232,37 @@
<c:let> <c:let>
<c:values> <c:values>
<c:value name="min" type="float" desc="Minimum"> <c:value name="min" type="float" desc="Minimum">
<lv:unless name="@const@"> <unless name="@const@">
<!-- this will produce a percentage of the provided value, unless no <!-- this will produce a percentage of the provided value, unless no
percent was given, in which case the entire value will be used percent was given, in which case the entire value will be used
--> -->
<c:product> <c:product>
<!-- if a percent was provided, then take a certain percentage of the value --> <!-- if a percent was provided, then take a certain percentage of the value -->
<lv:if name="@percent@"> <if name="@percent@">
<!-- given index or default index? --> <!-- given index or default index? -->
<lv:if name="@vindex@"> <if name="@vindex@">
<c:value-of name="@value@" index="@vindex@" /> <c:value-of name="@value@" index="@vindex@" />
</lv:if> </if>
<lv:unless name="@vindex@"> <unless name="@vindex@">
<c:value-of name="@value@" index="k" /> <c:value-of name="@value@" index="k" />
</lv:unless> </unless>
<c:quotient label="Percent as real number"> <c:quotient label="Percent as real number">
<c:const value="@percent@" type="integer" desc="Whole percent" /> <c:const value="@percent@" type="integer" desc="Whole percent" />
<c:const value="100" type="integer" desc="Divisor to convert percent to real number" /> <c:const value="100" type="integer" desc="Divisor to convert percent to real number" />
</c:quotient> </c:quotient>
</lv:if> </if>
<!-- otherwise, use the given value --> <!-- otherwise, use the given value -->
<lv:unless name="@percent@"> <unless name="@percent@">
<c:value-of name="@name@" index="k" /> <c:value-of name="@name@" index="k" />
</lv:unless> </unless>
</c:product> </c:product>
</lv:unless> </unless>
<lv:if name="@const@"> <if name="@const@">
<c:const value="@const@" type="float" desc="Constant minimum value" /> <c:const value="@const@" type="float" desc="Constant minimum value" />
</lv:if> </if>
</c:value> </c:value>
</c:values> </c:values>
@ -281,16 +275,16 @@
</t:maxreduce> </t:maxreduce>
</c:value> </c:value>
<lv:if name="@maxpercent@"> <if name="@maxpercent@">
<c:value name="max" type="float" desc="Maximum"> <c:value name="max" type="float" desc="Maximum">
<c:product> <c:product>
<!-- given index or default index? --> <!-- given index or default index? -->
<lv:if name="@vindex@"> <if name="@vindex@">
<c:value-of name="@value@" index="@vindex@" /> <c:value-of name="@value@" index="@vindex@" />
</lv:if> </if>
<lv:unless name="@vindex@"> <unless name="@vindex@">
<c:value-of name="@value@" index="k" /> <c:value-of name="@value@" index="k" />
</lv:unless> </unless>
<c:quotient label="Max percent as real number"> <c:quotient label="Max percent as real number">
<c:const value="@maxpercent@" type="integer" desc="Whole max percent" /> <c:const value="@maxpercent@" type="integer" desc="Whole max percent" />
@ -298,13 +292,13 @@
</c:quotient> </c:quotient>
</c:product> </c:product>
</c:value> </c:value>
</lv:if> </if>
</c:values> </c:values>
<c:cases> <c:cases>
<!-- if a max percent was provided, then check to ensure it <!-- if a max percent was provided, then check to ensure it
was not exceeded --> was not exceeded -->
<lv:if name="@maxpercent@"> <if name="@maxpercent@">
<c:case> <c:case>
<c:when name="@name@" index="k"> <c:when name="@name@" index="k">
<c:gt> <c:gt>
@ -314,7 +308,7 @@
<c:value-of name="max" /> <c:value-of name="max" />
</c:case> </c:case>
</lv:if> </if>
<!-- if no max, just yield the bumped value according to the minimum --> <!-- if no max, just yield the bumped value according to the minimum -->
<c:otherwise> <c:otherwise>
@ -326,6 +320,7 @@
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</c:sum> </c:sum>
</lv:rate> </rate>
</lv:template> </template>
</lv:package> </package>

View File

@ -1,30 +1,24 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/numeric/round"
desc="Numeric computations dealing with rounding"> desc="Numeric computations dealing with rounding">
<lv:import package="../base" /> <import package="../base" />
<!-- template version of round function, supporting arbitrary nodes --> <!-- template version of round function, supporting arbitrary nodes -->
<lv:template name="_round_" desc="Round to the nearest integer"> <template name="_round_" desc="Round to the nearest integer">
<lv:param name="@values@" desc="Calculation to round (single node)" /> <param name="@values@" desc="Calculation to round (single node)" />
<lv:param name="@precision@" desc="Level of precision after decimal point"> <param name="@precision@" desc="Level of precision after decimal point">
<lv:text>0</lv:text> <text>0</text>
</lv:param> </param>
<c:apply name="round_real" label="Rounded value"> <c:apply name="round_real" label="Rounded value">
<c:arg name="round_real_val"> <c:arg name="round_real_val">
<c:sum> <c:sum>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:sum> </c:sum>
</c:arg> </c:arg>
@ -35,7 +29,7 @@
</c:expt> </c:expt>
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:template> </template>
<!-- <!--
@ -57,38 +51,38 @@
with @exp@, in which case the step will apply to @name@ after its value with @exp@, in which case the step will apply to @name@ after its value
has been exponentiated. has been exponentiated.
--> -->
<lv:template name="_let-round_" <template name="_let-round_"
desc="Produce floor and ceiling values"> desc="Produce floor and ceiling values">
<lv:param name="@values@" <param name="@values@"
desc="Calculation subject to let expression" /> desc="Calculation subject to let expression" />
<lv:param name="@name@" <param name="@name@"
desc="Value to round" /> desc="Value to round" />
<lv:param name="@index@" <param name="@index@"
desc="Optional value index"> desc="Optional value index">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:param name="@high@" <param name="@high@"
desc="Name to yield ceil'd value into" /> desc="Name to yield ceil'd value into" />
<lv:param name="@low@" <param name="@low@"
desc="Name to yield floor'd value into" /> desc="Name to yield floor'd value into" />
<lv:param name="@nearest@" <param name="@nearest@"
desc="Name to yield nearest integer to value into" /> desc="Name to yield nearest integer to value into" />
<lv:param name="@exp@" <param name="@exp@"
desc="Offset digits before rounding"> desc="Offset digits before rounding">
<lv:text>#0</lv:text> <text>#0</text>
</lv:param> </param>
<lv:param name="@step@" <param name="@step@"
desc="Arbitrary step"> desc="Arbitrary step">
<lv:text>#1</lv:text> <text>#1</text>
</lv:param> </param>
@ -123,7 +117,7 @@
<c:let> <c:let>
<c:values> <c:values>
<lv:if name="@high@"> <if name="@high@">
<c:value name="@high@" type="float" <c:value name="@high@" type="float"
desc="Ceiling of adjusted {@name@}"> desc="Ceiling of adjusted {@name@}">
<c:product> <c:product>
@ -134,9 +128,9 @@
<c:value-of name="__div" /> <c:value-of name="__div" />
</c:product> </c:product>
</c:value> </c:value>
</lv:if> </if>
<lv:if name="@low@"> <if name="@low@">
<c:value name="@low@" type="float" <c:value name="@low@" type="float"
desc="floor of adjusted {@name@}"> desc="floor of adjusted {@name@}">
<c:product> <c:product>
@ -147,9 +141,9 @@
<c:value-of name="__div" /> <c:value-of name="__div" />
</c:product> </c:product>
</c:value> </c:value>
</lv:if> </if>
<lv:if name="@nearest@"> <if name="@nearest@">
<c:value name="@nearest@" type="float" <c:value name="@nearest@" type="float"
desc="nearest integer to adjusted {@name@}"> desc="nearest integer to adjusted {@name@}">
<c:product> <c:product>
@ -160,21 +154,21 @@
<c:value-of name="__div" /> <c:value-of name="__div" />
</c:product> </c:product>
</c:value> </c:value>
</lv:if> </if>
</c:values> </c:values>
<!-- body subject to let expression --> <!-- body subject to let expression -->
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:let> </c:let>
</c:let> </c:let>
</c:let> </c:let>
</lv:template> </template>
<!-- ceil if > 0.5, otherwise floor; round() in most languages --> <!-- ceil if > 0.5, otherwise floor; round() in most languages -->
<!-- TODO: support left and right delimiters; do \floor \ceil --> <!-- TODO: support left and right delimiters; do \floor \ceil -->
<lv:function name="round" desc="Round to the nearest integer"> <function name="round" desc="Round to the nearest integer">
<lv:param name="roundval" type="float" desc="Value to round to nearest integer" /> <param name="roundval" type="float" desc="Value to round to nearest integer" />
<!-- By raising by 0.5 and taking the floor() of the resulting value, we <!-- By raising by 0.5 and taking the floor() of the resulting value, we
can produce values consistent with common round() implementations. It can produce values consistent with common round() implementations. It
@ -187,12 +181,12 @@
<c:const value="0.5" type="float" desc="Raises value in a manner that it can be properly rounded by a floor" /> <c:const value="0.5" type="float" desc="Raises value in a manner that it can be properly rounded by a floor" />
</c:sum> </c:sum>
</c:floor> </c:floor>
</lv:function> </function>
<lv:function name="round_real" desc="Round to the nearest 1/n"> <function name="round_real" desc="Round to the nearest 1/n">
<lv:param name="round_real_val" type="float" desc="Value to round" /> <param name="round_real_val" type="float" desc="Value to round" />
<lv:param name="round_real_n" type="integer" desc="Round to 1/n" /> <param name="round_real_n" type="integer" desc="Round to 1/n" />
<!-- we can achieve this by multiplying by N, rounding, and then dividing <!-- we can achieve this by multiplying by N, rounding, and then dividing
by the same N --> by the same N -->
@ -208,12 +202,12 @@
<c:value-of name="round_real_n" /> <c:value-of name="round_real_n" />
</c:quotient> </c:quotient>
</lv:function> </function>
<!-- this is simply a shorthand for round_real --> <!-- this is simply a shorthand for round_real -->
<lv:function name="round_cents" desc="Round to the nearest penny"> <function name="round_cents" desc="Round to the nearest penny">
<lv:param name="round_cents_val" type="float" desc="Monetary value" /> <param name="round_cents_val" type="float" desc="Monetary value" />
<c:apply name="round_real"> <c:apply name="round_real">
<c:arg name="round_real_n"> <c:arg name="round_real_n">
@ -224,17 +218,17 @@
<c:value-of name="round_cents_val" /> <c:value-of name="round_cents_val" />
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:function> </function>
<lv:template name="_ceil-n_" desc="Ceiling on the last n digits"> <template name="_ceil-n_" desc="Ceiling on the last n digits">
<lv:param name="@values@" desc="Calculation to use (single node)" /> <param name="@values@" desc="Calculation to use (single node)" />
<lv:param name="@digits@" desc="Level of precision after decimal point" /> <param name="@digits@" desc="Level of precision after decimal point" />
<c:product> <c:product>
<c:ceil> <c:ceil>
<c:quotient> <c:quotient>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
<c:expt> <c:expt>
<c:const value="10" type="integer" desc="Decimal base" /> <c:const value="10" type="integer" desc="Decimal base" />
<c:const value="@digits@" type="integer" desc="Number of digits" /> <c:const value="@digits@" type="integer" desc="Number of digits" />
@ -247,6 +241,6 @@
<c:const value="@digits@" type="integer" desc="Number of digits" /> <c:const value="@digits@" type="integer" desc="Number of digits" />
</c:expt> </c:expt>
</c:product> </c:product>
</lv:template> </template>
</package>
</lv:package>

View File

@ -1,31 +1,26 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../rater.xsd"
core="true" core="true"
name="core/tdat"
desc="Territory data support (used in conjunction with tdat script)"> desc="Territory data support (used in conjunction with tdat script)">
<lv:import package="base" export="true" /> <import package="base" export="true" />
<lv:template name="_terr-code_" desc="Defines a territory code for a given classification"> <template name="_terr-code_" desc="Defines a territory code for a given classification">
<lv:param name="@class@" desc="Classification" /> <param name="@class@" desc="Classification" />
<lv:param name="@code@" desc="Territory code" /> <param name="@code@" desc="Territory code" />
<lv:param name="@generates@" desc="Generator" /> <param name="@generates@" desc="Generator" />
<lv:param name="@yields@" desc="Yield var"> <param name="@yields@" desc="Yield var">
<lv:text>_</lv:text> <text>_</text>
<lv:param-value name="@generates@" /> <param-value name="@generates@" />
</lv:param> </param>
<lv:rate-each class="@class@" accumulate="none" yields="@yields@" generates="@generates@" index="k"> <rate-each class="@class@" accumulate="none" yields="@yields@" generates="@generates@" index="k">
<c:const value="@code@" type="integer" desc="Territory code" /> <c:const value="@code@" type="integer" desc="Territory code" />
</lv:rate-each> </rate-each>
</lv:template> </template>
</lv:package> </package>

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <!--
BDD specification framework BDD specification framework
@ -39,7 +39,7 @@
name="core/test/spec" name="core/test/spec"
desc="Behavior-driven development specification system"> desc="Behavior-driven development specification system">
<import package="../../core" /> <import package="../base" />
<!-- <!--

View File

@ -1,24 +1,19 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../rater.xsd"
core="true" core="true"
name="core/vector"
desc="Vector operations"> desc="Vector operations">
<!-- we are a meta-package --> <!-- we are a meta-package -->
<lv:import package="vector/arithmetic" export="true" /> <import package="vector/arithmetic" export="true" />
<lv:import package="vector/cmatch" export="true" /> <import package="vector/cmatch" export="true" />
<lv:import package="vector/convert" export="true" /> <import package="vector/convert" export="true" />
<lv:import package="vector/count" export="true" /> <import package="vector/count" export="true" />
<lv:import package="vector/list" export="true" /> <import package="vector/list" export="true" />
<lv:import package="vector/matrix" export="true" /> <import package="vector/matrix" export="true" />
<lv:import package="vector/table" export="true" /> <import package="vector/table" export="true" />
<import package="vector/common" export="true" />
</package>
<lv:import package="vector/common" export="true" />
</lv:package>

View File

@ -1,87 +1,81 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/arithmetic"
desc="Vector arithmetic"> desc="Vector arithmetic">
<lv:import package="../base" /> <import package="../base" />
<lv:import package="../numeric/common" /> <import package="../numeric/common" />
<lv:import package="../numeric/minmax" /> <import package="../numeric/minmax" />
<!-- for the time being, the vectors must be of the same length, or the first <!-- for the time being, the vectors must be of the same length, or the first
vector must be the longer (otherwise the values will not properly add) vector must be the longer (otherwise the values will not properly add)
--> -->
<lv:template name="_vadd_" desc="Produce a vector resulting from the addition of two vectors"> <template name="_vadd_" desc="Produce a vector resulting from the addition of two vectors">
<lv:param name="@a@" desc="First vector to add" /> <param name="@a@" desc="First vector to add" />
<lv:param name="@b@" desc="Second vector to add" /> <param name="@b@" desc="Second vector to add" />
<lv:param name="@into@" desc="Variable to yield vector into" /> <param name="@into@" desc="Variable to yield vector into" />
<lv:param name="@yields@" desc="Value to yield (useless)"> <param name="@yields@" desc="Value to yield (useless)">
<lv:text>__</lv:text> <text>__</text>
<lv:param-value name="@into@" /> <param-value name="@into@" />
</lv:param> </param>
<lv:param name="@gendesc@" desc="Generator description (for @into@)"> <param name="@gendesc@" desc="Generator description (for @into@)">
<lv:text>Sum of vectors </lv:text> <text>Sum of vectors </text>
<lv:param-value name="@a@" /> <param-value name="@a@" />
<lv:text> and </lv:text> <text> and </text>
<lv:param-value name="@b@" /> <param-value name="@b@" />
</lv:param> </param>
<lv:param name="@sym@" desc="Generator symbol"> <param name="@sym@" desc="Generator symbol">
<!-- empty by default --> <!-- empty by default -->
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:rate accumulate="none" yields="@yields@"> <rate accumulate="none" yields="@yields@">
<c:sum of="@a@" index="k" generates="@into@" desc="@gendesc@" sym="@sym@"> <c:sum of="@a@" index="k" generates="@into@" desc="@gendesc@" sym="@sym@">
<c:value-of name="@a@" index="k" /> <c:value-of name="@a@" index="k" />
<c:value-of name="@b@" index="k" /> <c:value-of name="@b@" index="k" />
</c:sum> </c:sum>
</lv:rate> </rate>
</lv:template> </template>
<!-- the template version of the function --> <!-- the template version of the function -->
<lv:template name="_maxreduce_" desc="Reduce a set to its maximum"> <template name="_maxreduce_" desc="Reduce a set to its maximum">
<lv:param name="@values@" desc="Values to reduce" /> <param name="@values@" desc="Values to reduce" />
<lv:param name="@isvector@" desc="Set to 'true' if the nodes should not be wrapped in c:set" /> <param name="@isvector@" desc="Set to 'true' if the nodes should not be wrapped in c:set" />
<lv:param name="@label@" desc="Application label"> <param name="@label@" desc="Application label">
<!-- default empty --> <!-- default empty -->
<lv:text></lv:text> <text></text>
</lv:param> </param>
<c:apply name="maxreduce" label="@label@"> <c:apply name="maxreduce" label="@label@">
<c:arg name="maxreduce_set"> <c:arg name="maxreduce_set">
<!-- if we were not provided with a vector (default), create one out of <!-- if we were not provided with a vector (default), create one out of
the given nodes --> the given nodes -->
<lv:unless name="@isvector@" eq="true"> <unless name="@isvector@" eq="true">
<c:set> <c:set>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:set> </c:set>
</lv:unless> </unless>
<!-- if they told us that they have provided a vector, then do not <!-- if they told us that they have provided a vector, then do not
create one --> create one -->
<lv:if name="@isvector@" eq="true"> <if name="@isvector@" eq="true">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</lv:if> </if>
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:template> </template>
<lv:function name="maxreduce" desc="Reduce a set to its maximum"> <function name="maxreduce" desc="Reduce a set to its maximum">
<lv:param name="maxreduce_set" type="float" set="vector" desc="Set to find max of" /> <param name="maxreduce_set" type="float" set="vector" desc="Set to find max of" />
<c:let> <c:let>
<c:values> <c:values>
@ -123,7 +117,7 @@
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</c:let> </c:let>
</lv:function> </function>
<!-- <!--
@ -142,9 +136,9 @@
TODO: If we can support variable applications, then this simply be a TODO: If we can support variable applications, then this simply be a
generic reduce function that accepts max/min/etc. generic reduce function that accepts max/min/etc.
--> -->
<lv:function name="_maxreduce" desc="Recursively reduce a set to its maximum (called by maxreduce)"> <function name="_maxreduce" desc="Recursively reduce a set to its maximum (called by maxreduce)">
<lv:param name="_maxreduce_set" type="float" set="vector" desc="Set to find max of" /> <param name="_maxreduce_set" type="float" set="vector" desc="Set to find max of" />
<lv:param name="_maxreduce_i" type="integer" desc="Index" /> <param name="_maxreduce_i" type="integer" desc="Index" />
<c:cases> <c:cases>
<!-- base case: if we're on the last index, do not recurse --> <!-- base case: if we're on the last index, do not recurse -->
@ -194,39 +188,40 @@
</c:apply> </c:apply>
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:function> </function>
<!-- simplifies retrieving the max of a set of values --> <!-- simplifies retrieving the max of a set of values -->
<lv:template name="_maxOfEach_" desc="Take the max of the given set of values"> <template name="_maxOfEach_" desc="Take the max of the given set of values">
<lv:param name="@class@" desc="Class to match on" /> <param name="@class@" desc="Class to match on" />
<lv:param name="@values@" desc="Individual values without lv:set" /> <param name="@values@" desc="Individual values without set" />
<lv:param name="@generates@" desc="Value to generate into" /> <param name="@generates@" desc="Value to generate into" />
<lv:param name="@index@" desc="Index to use for rate-each" /> <param name="@index@" desc="Index to use for rate-each" />
<lv:param name="@yields@" desc="Yield variable"> <param name="@yields@" desc="Yield variable">
<lv:text>_</lv:text> <text>_</text>
<lv:param-value name="@generates@" /> <param-value name="@generates@" />
</lv:param> </param>
<lv:rate-each class="@class@" accumulate="none" yields="@yields@" generates="@generates@" index="@index@"> <rate-each class="@class@" accumulate="none" yields="@yields@" generates="@generates@" index="@index@">
<c:apply name="maxreduce"> <c:apply name="maxreduce">
<c:arg name="maxreduce_set"> <c:arg name="maxreduce_set">
<c:set> <c:set>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:set> </c:set>
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:rate-each> </rate-each>
</lv:template> </template>
<lv:template name="_vsum_" desc="Yield sum of all elements of a vector as a scalar"> <template name="_vsum_" desc="Yield sum of all elements of a vector as a scalar">
<lv:param name="@of@" desc="Vector to sum" /> <param name="@of@" desc="Vector to sum" />
<lv:param name="@yields@" desc="Name of scalar to yield" /> <param name="@yields@" desc="Name of scalar to yield" />
<lv:rate yields="@yields@"> <rate yields="@yields@">
<c:sum of="@of@" /> <c:sum of="@of@" />
</lv:rate> </rate>
</lv:template> </template>
</lv:package> </package>

View File

@ -1,17 +1,11 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/cmatch"
desc="Vector operations on classification matches"> desc="Vector operations on classification matches">
<lv:import package="../base" /> <import package="../base" />
<lv:import package="arithmetic" export="true" /> <import package="arithmetic" export="true" />
<!-- <!--
@ -35,125 +29,126 @@
This is an excellent example of building a feature atop of the DSL without This is an excellent example of building a feature atop of the DSL without
having to add a new language feature. having to add a new language feature.
--> -->
<lv:template name="_cmatch-to-vector_" desc="Vectorizes a classification match"> <template name="_cmatch-to-vector_" desc="Vectorizes a classification match">
<lv:param name="@class@" desc="Classification match string" /> <param name="@class@" desc="Classification match string" />
<lv:param name="@generates@" desc="Variable to yield generates (will yield a vector)" /> <param name="@generates@" desc="Variable to yield generates (will yield a vector)" />
<lv:param name="@keep@" desc="Rate block @keep"> <param name="@keep@" desc="Rate block @keep">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:param name="@yields@" desc="Dummy variable to yield generates (useless, but required)"> <param name="@yields@" desc="Dummy variable to yield generates (useless, but required)">
<lv:text>__</lv:text> <text>__</text>
<lv:param-value name="@generates@" /> <param-value name="@generates@" />
</lv:param> </param>
<lv:param name="@gendesc@" desc="Generator description"> <param name="@gendesc@" desc="Generator description">
<lv:text>Vector containing boolean </lv:text> <text>Vector containing boolean </text>
<lv:param-value name="@class@" /> <param-value name="@class@" />
<lv:text> classification matches</lv:text> <text> classification matches</text>
</lv:param> </param>
<lv:param name="@sym@" desc="Generator symbol (corresponds to @generates@)"> <param name="@sym@" desc="Generator symbol (corresponds to @generates@)">
<!-- defaults to nothing --> <!-- defaults to nothing -->
<lv:text></lv:text> <text></text>
</lv:param> </param>
<!-- this conversion is as simple as using a generator to yield the value <!-- this conversion is as simple as using a generator to yield the value
of _CMATCH_ for each index --> of _CMATCH_ for each index -->
<lv:rate class="@class@" accumulate="none" yields="@yields@" always="true" keep="@keep@"> <rate class="@class@" accumulate="none" yields="@yields@" always="true" keep="@keep@">
<c:sum of="_CMATCH_" index="k" generates="@generates@" desc="@gendesc@" sym="@sym@"> <c:sum of="_CMATCH_" index="k" generates="@generates@" desc="@gendesc@" sym="@sym@">
<c:value-of name="_CMATCH_" index="k" /> <c:value-of name="_CMATCH_" index="k" />
</c:sum> </c:sum>
</lv:rate> </rate>
</lv:template> </template>
<lv:template name="_cmatch-to-scalar_" desc="Reduces a classification match into a scalar"> <template name="_cmatch-to-scalar_" desc="Reduces a classification match into a scalar">
<lv:param name="@class@" desc="Classification match string" /> <param name="@class@" desc="Classification match string" />
<lv:param name="@yields@" desc="Variable to yield into" /> <param name="@yields@" desc="Variable to yield into" />
<lv:param name="@sym@" desc="Yield symbol (defaults to nothing)"> <param name="@sym@" desc="Yield symbol (defaults to nothing)">
<!-- defaults to nothing --> <!-- defaults to nothing -->
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:param name="@keep@" desc="Rate block @keep"> <param name="@keep@" desc="Rate block @keep">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:rate class="@class@" accumulate="none" yields="@yields@" sym="@sym@" keep="@keep@"> <rate class="@class@" accumulate="none" yields="@yields@" sym="@sym@" keep="@keep@">
<!-- if any single one matches, then we want to yield a 1 --> <!-- if any single one matches, then we want to yield a 1 -->
<c:apply name="maxreduce" maxreduce_set="_CMATCH_" /> <c:apply name="maxreduce" maxreduce_set="_CMATCH_" />
</lv:rate> </rate>
</lv:template> </template>
<!-- <!--
Counts one for each classification vector match Counts one for each classification vector match
--> -->
<lv:template name="_cmatch-count_" desc="Counts the number of classification matches of a vector"> <template name="_cmatch-count_" desc="Counts the number of classification matches of a vector">
<lv:param name="@class@" desc="Classification match" /> <param name="@class@" desc="Classification match" />
<lv:param name="@yields@" desc="Value to yield" /> <param name="@yields@" desc="Value to yield" />
<!-- nothing by default --> <!-- nothing by default -->
<lv:param name="@no@" desc="Non-match"> <param name="@no@" desc="Non-match">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:rate class="@class@" no="@no@" yields="@yields@"> <rate class="@class@" no="@no@" yields="@yields@">
<c:sum of="_CMATCH_" /> <c:sum of="_CMATCH_" />
</lv:rate> </rate>
</lv:template> </template>
<!-- because verbose repition is an evil --> <!-- because verbose repition is an evil -->
<lv:inline-template> <inline-template>
<lv:for-each> <for-each>
<lv:set cmp="eq" /> <set cmp="eq" />
<lv:set cmp="ne" /> <set cmp="ne" />
<lv:set cmp="gt" /> <set cmp="gt" />
<lv:set cmp="gte" /> <set cmp="gte" />
<lv:set cmp="lt" /> <set cmp="lt" />
<lv:set cmp="lte" /> <set cmp="lte" />
</lv:for-each> </for-each>
<lv:template name="_match-{@cmp@}_" desc="Match value {@cmp@}"> <template name="_match-{@cmp@}_" desc="Match value {@cmp@}">
<lv:param name="@on@" desc="Value to assert" /> <param name="@on@" desc="Value to assert" />
<!-- pick one --> <!-- pick one -->
<lv:param name="@const@" desc="Match against constant value" /> <param name="@const@" desc="Match against constant value" />
<lv:param name="@value@" desc="Match against variable" /> <param name="@value@" desc="Match against variable" />
<lv:match on="@on@"> <match on="@on@">
<lv:dyn-node name="c:{@cmp@}"> <dyn-node name="c:{@cmp@}">
<lv:if name="@const@"> <if name="@const@">
<c:const value="@const@" type="float" desc="Comparison" /> <c:const value="@const@" type="float" desc="Comparison" />
</lv:if> </if>
<lv:unless name="@const@"> <unless name="@const@">
<c:value-of name="@value@" /> <c:value-of name="@value@" />
</lv:unless> </unless>
</lv:dyn-node> </dyn-node>
</lv:match> </match>
</lv:template> </template>
</lv:inline-template> </inline-template>
<lv:template name="_match-class_" <template name="_match-class_"
desc="Match on a class name (rather than @yields)"> desc="Match on a class name (rather than @yields)">
<lv:param name="@name@" desc="Classification name" /> <param name="@name@" desc="Classification name" />
<lv:param name="@__yields@" desc="Classification yield to match on"> <param name="@__yields@" desc="Classification yield to match on">
<lv:param-class-to-yields name="@name@" /> <param-class-to-yields name="@name@" />
</lv:param> </param>
<lv:param name="@value@" desc="Value to match on"> <param name="@value@" desc="Value to match on">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<match on="@__yields@" value="@value@" />
</template>
</package>
<lv:match on="@__yields@" value="@value@" />
</lv:template>
</lv:package>

View File

@ -1,38 +1,32 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/common"
desc="General vector operations"> desc="General vector operations">
<lv:import package="../base" /> <import package="../base" />
<lv:import package="../numeric/common" /> <import package="../numeric/common" />
<!-- useful because you can pass a conditional expression as an argument and <!-- useful because you can pass a conditional expression as an argument and
select the index of the result --> select the index of the result -->
<lv:function name="vival" desc="Select index value from some vector"> <function name="vival" desc="Select index value from some vector">
<lv:param name="vector" type="float" set="vector" desc="Vector" /> <param name="vector" type="float" set="vector" desc="Vector" />
<lv:param name="index" type="integer" desc="Index" /> <param name="index" type="integer" desc="Index" />
<c:value-of name="vector"> <c:value-of name="vector">
<c:index> <c:index>
<c:value-of name="index" /> <c:value-of name="index" />
</c:index> </c:index>
</c:value-of> </c:value-of>
</lv:function> </function>
<lv:function name="mival" desc="Select index value from some matrix"> <function name="mival" desc="Select index value from some matrix">
<lv:param name="matrix" type="float" set="matrix" desc="Matrix" /> <param name="matrix" type="float" set="matrix" desc="Matrix" />
<lv:param name="row" type="integer" desc="Row index" /> <param name="row" type="integer" desc="Row index" />
<lv:param name="col" type="integer" desc="Column index" /> <param name="col" type="integer" desc="Column index" />
<c:value-of name="matrix"> <c:value-of name="matrix">
<c:index> <c:index>
@ -42,13 +36,13 @@
<c:value-of name="col" /> <c:value-of name="col" />
</c:index> </c:index>
</c:value-of> </c:value-of>
</lv:function> </function>
<lv:template name="_map-value_" desc="Map from a value to another using a vector map"> <template name="_map-value_" desc="Map from a value to another using a vector map">
<lv:param name="@from@" desc="Name of value to map" /> <param name="@from@" desc="Name of value to map" />
<lv:param name="@index@" desc="Index" /> <param name="@index@" desc="Index" />
<lv:param name="@using@" desc="Vector to use for mapping" /> <param name="@using@" desc="Vector to use for mapping" />
<c:apply name="vival"> <c:apply name="vival">
<c:arg name="vector"> <c:arg name="vector">
@ -59,7 +53,7 @@
<c:value-of name="@from@" index="@index@" /> <c:value-of name="@from@" index="@index@" />
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:template> </template>
@ -70,13 +64,13 @@
will be used to map a value to an index within the matrix for either a row will be used to map a value to an index within the matrix for either a row
or column. or column.
--> -->
<lv:function name="mlookup" desc="Matrix value lookup based on two index maps"> <function name="mlookup" desc="Matrix value lookup based on two index maps">
<lv:param name="matrix" type="float" set="matrix" desc="Rate matrix indexed by CT and PC" /> <param name="matrix" type="float" set="matrix" desc="Rate matrix indexed by CT and PC" />
<lv:param name="rmap" type="integer" set="vector" desc="Row index map" /> <param name="rmap" type="integer" set="vector" desc="Row index map" />
<lv:param name="cmap" type="integer" set="vector" desc="Column index map" /> <param name="cmap" type="integer" set="vector" desc="Column index map" />
<lv:param name="rval" type="integer" desc="Row value (to be fed to map for index lookup)" /> <param name="rval" type="integer" desc="Row value (to be fed to map for index lookup)" />
<lv:param name="cval" type="integer" desc="Column value (to be fed to map for index lookup)" /> <param name="cval" type="integer" desc="Column value (to be fed to map for index lookup)" />
<c:value-of name="matrix"> <c:value-of name="matrix">
<!-- row --> <!-- row -->
@ -97,13 +91,13 @@
</c:value-of> </c:value-of>
</c:index> </c:index>
</c:value-of> </c:value-of>
</lv:function> </function>
<lv:function name="first_index" desc="Determine the matching index of a vector; -1 if no match"> <function name="first_index" desc="Determine the matching index of a vector; -1 if no match">
<lv:param name="vector" type="float" set="vector" desc="Source vector to search" /> <param name="vector" type="float" set="vector" desc="Source vector to search" />
<lv:param name="value" type="integer" desc="Value to match" /> <param name="value" type="integer" desc="Value to match" />
<lv:param name="offset" type="integer" desc="Vector offset" /> <param name="offset" type="integer" desc="Vector offset" />
<c:let> <c:let>
<c:values> <c:values>
@ -151,12 +145,13 @@
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</c:let> </c:let>
</lv:function> </function>
<!-- generates a variable that can be recognized as an empty set (useful for <!-- generates a variable that can be recognized as an empty set (useful for
defaults to params that require sets) --> defaults to params that require sets) -->
<lv:rate-each class="always" yields="__empty" generates="__emptySet" index="k"> <rate-each class="always" yields="__empty" generates="__emptySet" index="k">
<c:const value="0" type="integer" desc="Nothing" /> <c:const value="0" type="integer" desc="Nothing" />
</lv:rate-each> </rate-each>
</lv:package> </package>

View File

@ -1,16 +1,8 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/convert"
desc="Convert vectors into other types"> desc="Convert vectors into other types">
<lv:import package="../base" /> <import package="../base" />
</package>
</lv:package>

View File

@ -1,31 +1,25 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/count"
desc="Vector element counting"> desc="Vector element counting">
<lv:import package="../base" /> <import package="../base" />
<!-- TODO: deprecate in favor of the new c:length-of --> <!-- TODO: deprecate in favor of the new c:length-of -->
<lv:function name="length" desc="Counts the number of items in a vector (regardless of value)"> <function name="length" desc="Counts the number of items in a vector (regardless of value)">
<lv:param name="count_set" type="integer" set="vector" desc="Vector to count" /> <param name="count_set" type="integer" set="vector" desc="Vector to count" />
<c:sum of="count_set" index="k"> <c:sum of="count_set" index="k">
<c:const value="1" type="integer" desc="Add 1 for each value in the set" /> <c:const value="1" type="integer" desc="Add 1 for each value in the set" />
</c:sum> </c:sum>
</lv:function> </function>
<!-- similar to a logical "exists" --> <!-- similar to a logical "exists" -->
<lv:function name="hasany" desc="Returns 1 or 0 based on whether any values in a boolean vector are set" sym="\exists"> <function name="hasany" desc="Returns 1 or 0 based on whether any values in a boolean vector are set" sym="\exists">
<lv:param name="any_set" type="boolean" set="vector" desc="Boolean set to check" /> <param name="any_set" type="boolean" set="vector" desc="Boolean set to check" />
<c:ceil> <c:ceil>
<c:quotient label="Create a fraction > 0 if any value in the given set is 1"> <c:quotient label="Create a fraction > 0 if any value in the given set is 1">
@ -43,5 +37,6 @@
</c:sum> </c:sum>
</c:quotient> </c:quotient>
</c:ceil> </c:ceil>
</lv:function> </function>
</lv:package> </package>

View File

@ -1,32 +1,26 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/interp"
desc="Interpolation"> desc="Interpolation">
<lv:import package="../base" /> <import package="../base" />
<lv:import package="../numeric/common" /> <import package="../numeric/common" />
<lv:template name="_interpolate_" desc="Interpolate the first two values in a vector"> <template name="_interpolate_" desc="Interpolate the first two values in a vector">
<lv:param name="@values@" desc="Set" /> <param name="@values@" desc="Set" />
<lv:param name="@low@" desc="Lower value" /> <param name="@low@" desc="Lower value" />
<lv:param name="@high@" desc="Upper value" /> <param name="@high@" desc="Upper value" />
<lv:param name="@actual@" desc="Actual value" /> <param name="@actual@" desc="Actual value" />
<c:let> <c:let>
<c:values> <c:values>
<!-- allows us to reference the set values --> <!-- allows us to reference the set values -->
<c:value name="orig_set" type="float" set="vector" desc="The given set"> <c:value name="orig_set" type="float" set="vector" desc="The given set">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:value> </c:value>
</c:values> </c:values>
@ -118,7 +112,7 @@
</c:cases> </c:cases>
</c:let> </c:let>
</c:let> </c:let>
</lv:template> </template>
<!-- <!--
@ -129,31 +123,31 @@
results in a great deal of boilerplate code. This makes you not want to results in a great deal of boilerplate code. This makes you not want to
kill yourself. At least not because of this interpolation query kill yourself. At least not because of this interpolation query
--> -->
<lv:template name="_interpolate-query-field_" <template name="_interpolate-query-field_"
desc="Interpolate table data"> desc="Interpolate table data">
<lv:param name="@table@" desc="Table to query" /> <param name="@table@" desc="Table to query" />
<lv:param name="@field@" desc="Table field to query" /> <param name="@field@" desc="Table field to query" />
<lv:param name="@key@" desc="Predicate subject column" /> <param name="@key@" desc="Predicate subject column" />
<lv:param name="@step@" desc="Key step" /> <param name="@step@" desc="Key step" />
<lv:param name="@values@" desc="Query predicates" /> <param name="@values@" desc="Query predicates" />
<lv:param name="@actual@" <param name="@actual@"
desc="Actual value" /> desc="Actual value" />
<lv:param name="@index@" desc="Actual value index"> <param name="@index@" desc="Actual value index">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:param name="@table_max@" <param name="@table_max@"
desc="Maximum value in table (should be a multiple of @step)" /> desc="Maximum value in table (should be a multiple of @step)" />
<!-- TODO: accept a function to calculate factor --> <!-- TODO: accept a function to calculate factor -->
<lv:param name="@step_factor@" <param name="@step_factor@"
desc="Factor to use per step after maximum to infer value" /> desc="Factor to use per step after maximum to infer value" />
<lv:param name="@step_factor_index@" <param name="@step_factor_index@"
desc="Index of step factor value"> desc="Index of step factor value">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<c:let> <c:let>
@ -163,16 +157,16 @@
<c:value name="lookup" type="float" <c:value name="lookup" type="float"
desc="Value to retrieve and interpolate"> desc="Value to retrieve and interpolate">
<!-- maximum provided --> <!-- maximum provided -->
<lv:if name="@table_max@"> <if name="@table_max@">
<t:cap name="@table_max@"> <t:cap name="@table_max@">
<c:value-of name="@actual@" /> <c:value-of name="@actual@" />
</t:cap> </t:cap>
</lv:if> </if>
<!-- no maximum --> <!-- no maximum -->
<lv:unless name="@table_max@"> <unless name="@table_max@">
<c:value-of name="@actual@" index="@index@" /> <c:value-of name="@actual@" index="@index@" />
</lv:unless> </unless>
</c:value> </c:value>
</c:values> </c:values>
@ -195,13 +189,13 @@
<c:value-of name="high" /> <c:value-of name="high" />
</t:when> </t:when>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</t:query-field> </t:query-field>
</t:interpolate> </t:interpolate>
</t:let-round> </t:let-round>
<!-- step factor --> <!-- step factor -->
<lv:if name="@step_factor@"> <if name="@step_factor@">
<c:let> <c:let>
<c:values> <c:values>
<!-- additional value (of key) that needs to be infered --> <!-- additional value (of key) that needs to be infered -->
@ -226,10 +220,10 @@
</c:quotient> </c:quotient>
</c:product> </c:product>
</c:let> </c:let>
</lv:if> </if>
</c:sum> </c:sum>
</c:let> </c:let>
</lv:template> </template>
<!-- <!--
@ -262,10 +256,10 @@
7.5 / 5 = 1.5, Q.E.D. 7.5 / 5 = 1.5, Q.E.D.
--> -->
<lv:function name="vecpos" desc="Calculate the position of a value within a vector of a given step"> <function name="vecpos" desc="Calculate the position of a value within a vector of a given step">
<lv:param name="step" type="float" desc="Step between each of the values" /> <param name="step" type="float" desc="Step between each of the values" />
<lv:param name="skip" type="float" desc="Amount skipped before first element of vector" /> <param name="skip" type="float" desc="Amount skipped before first element of vector" />
<lv:param name="value" type="float" desc="Arbitrary value" /> <param name="value" type="float" desc="Arbitrary value" />
<c:quotient> <c:quotient>
<c:sum> <c:sum>
@ -277,7 +271,7 @@
<c:value-of name="step" /> <c:value-of name="step" />
</c:quotient> </c:quotient>
</lv:function> </function>
<!-- <!--
@ -295,11 +289,11 @@
step and skip amounts, since they were only needed to determine the value's step and skip amounts, since they were only needed to determine the value's
position. position.
--> -->
<lv:function name="vecstep" desc="Calculate a value that falls between a vector of values at a given step"> <function name="vecstep" desc="Calculate a value that falls between a vector of values at a given step">
<lv:param name="set" type="float" set="vector" desc="Vector of values" /> <param name="set" type="float" set="vector" desc="Vector of values" />
<lv:param name="step" type="float" desc="Step between each of the values" /> <param name="step" type="float" desc="Step between each of the values" />
<lv:param name="skip" type="float" desc="Amount skipped before first element of vector" /> <param name="skip" type="float" desc="Amount skipped before first element of vector" />
<lv:param name="value" type="float" desc="Arbitrary value" /> <param name="value" type="float" desc="Arbitrary value" />
<!-- call the function that will do the actual work --> <!-- call the function that will do the actual work -->
<c:apply name="vecstepi" set="set"> <c:apply name="vecstepi" set="set">
@ -311,7 +305,7 @@
<c:apply name="vecpos" step="step" skip="skip" value="value" /> <c:apply name="vecpos" step="step" skip="skip" value="value" />
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:function> </function>
<!-- <!--
@ -339,9 +333,9 @@
position from the position itself: 2.5 - 2 = 0.5. position from the position itself: 2.5 - 2 = 0.5.
- So, we have: 5 + ( 15-10 * 2.5-2 ) = 5 + ( 5 * 0.5 ) = 5 + 2.5 = 7.5. - So, we have: 5 + ( 15-10 * 2.5-2 ) = 5 + ( 5 * 0.5 ) = 5 + 2.5 = 7.5.
--> -->
<lv:function name="vecstepi" desc="Calculate a value that falls between a vector of values at an arbitrary index"> <function name="vecstepi" desc="Calculate a value that falls between a vector of values at an arbitrary index">
<lv:param name="set" type="float" set="vector" desc="Vector of values" /> <param name="set" type="float" set="vector" desc="Vector of values" />
<lv:param name="pos" type="float" desc="Position of value within the vector (may be between values)" /> <param name="pos" type="float" desc="Position of value within the vector (may be between values)" />
<c:sum> <c:sum>
<!-- add the closest lower value... --> <!-- add the closest lower value... -->
@ -385,5 +379,6 @@
</c:sum> </c:sum>
</c:product> </c:product>
</c:sum> </c:sum>
</lv:function> </function>
</lv:package> </package>

View File

@ -1,17 +1,11 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/list"
desc="Treating vectors as lists"> desc="Treating vectors as lists">
<lv:import package="../base" /> <import package="../base" />
@ -21,23 +15,23 @@
This template recurses and, as such, should only be used within functions. This template recurses and, as such, should only be used within functions.
--> -->
<lv:template name="_cons-until-empty_" desc="Generate empty base case for functions that recurse on cdrs of sets"> <template name="_cons-until-empty_" desc="Generate empty base case for functions that recurse on cdrs of sets">
<lv:param name="@values@" desc="Body" /> <param name="@values@" desc="Body" />
<lv:param name="@set@" desc="Set to operate on" /> <param name="@set@" desc="Set to operate on" />
<lv:param name="@car@" desc="Variable in which to store car of the set"> <param name="@car@" desc="Variable in which to store car of the set">
<lv:text>__car</lv:text> <text>__car</text>
</lv:param> </param>
<lv:param name="@cdr@" desc="Variable in which to store the cdr of the set"> <param name="@cdr@" desc="Variable in which to store the cdr of the set">
<lv:text>__cdr</lv:text> <text>__cdr</text>
</lv:param> </param>
<lv:param name="@base@" desc="Base set to return (otherwise an empty set)" /> <param name="@base@" desc="Base set to return (otherwise an empty set)" />
<lv:param name="@glance@" desc="Glance at (but do nothing with) this value; recurse without action" /> <param name="@glance@" desc="Glance at (but do nothing with) this value; recurse without action" />
<!-- intended for use by merge-until-empty to reduce duplicate code; not to <!-- intended for use by merge-until-empty to reduce duplicate code; not to
be set via direct template applications --> be set via direct template applications -->
<lv:param name="@merge@" desc="Perform merge instead of cons; system-use only" /> <param name="@merge@" desc="Perform merge instead of cons; system-use only" />
<c:let> <c:let>
@ -61,13 +55,13 @@
</c:when> </c:when>
<!-- if a base set was provided, return that; otherwise, return an empty set --> <!-- if a base set was provided, return that; otherwise, return an empty set -->
<lv:if name="@base@"> <if name="@base@">
<c:value-of name="@base@" /> <c:value-of name="@base@" />
</lv:if> </if>
<lv:unless name="@base@"> <unless name="@base@">
<!-- return an empty set --> <!-- return an empty set -->
<c:set /> <c:set />
</lv:unless> </unless>
</c:case> </c:case>
<c:otherwise> <c:otherwise>
@ -91,7 +85,7 @@
<c:cases> <c:cases>
<!-- if we have a glancing value, then immediately recurse <!-- if we have a glancing value, then immediately recurse
without processing if we have a match --> without processing if we have a match -->
<lv:if name="@glance@"> <if name="@glance@">
<c:case> <c:case>
<c:when name="@car@"> <c:when name="@car@">
<c:eq> <c:eq>
@ -105,17 +99,17 @@
</c:arg> </c:arg>
</c:recurse> </c:recurse>
</c:case> </c:case>
</lv:if> </if>
<!-- otherwise, process as normal --> <!-- otherwise, process as normal -->
<c:otherwise> <c:otherwise>
<lv:unless name="@merge@"> <unless name="@merge@">
<!-- here's our recursive operation: cons the result of processing <!-- here's our recursive operation: cons the result of processing
this car with the result of recursively processing the cdr this car with the result of recursively processing the cdr
(note that c:recurse will recurse on the function that applied (note that c:recurse will recurse on the function that applied
this template, _not_ on the template itself)--> this template, _not_ on the template itself)-->
<c:cons> <c:cons>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
<c:recurse> <c:recurse>
<c:arg name="@set@"> <c:arg name="@set@">
@ -123,9 +117,9 @@
</c:arg> </c:arg>
</c:recurse> </c:recurse>
</c:cons> </c:cons>
</lv:unless> </unless>
<lv:if name="@merge@"> <if name="@merge@">
<!-- the order is different from the cons above to maintain <!-- the order is different from the cons above to maintain
consistency in the returned set --> consistency in the returned set -->
<c:apply name="vmerge"> <c:apply name="vmerge">
@ -138,17 +132,17 @@
</c:arg> </c:arg>
<c:arg name="onto"> <c:arg name="onto">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:if> </if>
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</c:let> </c:let>
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</c:let> </c:let>
</lv:template> </template>
@ -157,31 +151,31 @@
This template recurses and, as such, should only be used within functions. This template recurses and, as such, should only be used within functions.
--> -->
<lv:template name="_merge-until-empty_" desc="Generate empty base case for functions that recursively merge on cdrs of sets"> <template name="_merge-until-empty_" desc="Generate empty base case for functions that recursively merge on cdrs of sets">
<lv:param name="@values@" desc="Body" /> <param name="@values@" desc="Body" />
<lv:param name="@set@" desc="Set to operate on" /> <param name="@set@" desc="Set to operate on" />
<lv:param name="@car@" desc="Variable in which to store car of the set" /> <param name="@car@" desc="Variable in which to store car of the set" />
<lv:param name="@cdr@" desc="Variable in which to store the cdr of the set"> <param name="@cdr@" desc="Variable in which to store the cdr of the set">
<lv:text>__cdr</lv:text> <text>__cdr</text>
</lv:param> </param>
<lv:param name="@glance@" desc="Glance at (but do nothing with) this value; recurse without action" /> <param name="@glance@" desc="Glance at (but do nothing with) this value; recurse without action" />
<!-- to reduce duplicate template code, we simply set a merge flag on cons-until-empty --> <!-- to reduce duplicate template code, we simply set a merge flag on cons-until-empty -->
<t:cons-until-empty set="@set@" car="@car@" cdr="@cdr@" glance="@glance@" merge="true"> <t:cons-until-empty set="@set@" car="@car@" cdr="@cdr@" glance="@glance@" merge="true">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</t:cons-until-empty> </t:cons-until-empty>
</lv:template> </template>
<!-- <!--
Merges two vectors Merges two vectors
--> -->
<lv:function name="vmerge" desc="Merge two vectors (does not remove duplicates)"> <function name="vmerge" desc="Merge two vectors (does not remove duplicates)">
<lv:param name="vector" type="float" set="vector" desc="Vector to merge" /> <param name="vector" type="float" set="vector" desc="Vector to merge" />
<lv:param name="onto" type="float" set="vector" desc="Vector to append to" /> <param name="onto" type="float" set="vector" desc="Vector to append to" />
<!-- the template handles much of this for us: just keep cons'ing the car <!-- the template handles much of this for us: just keep cons'ing the car
until we have nothing more to cons, then that gets cons'd onto the until we have nothing more to cons, then that gets cons'd onto the
@ -189,5 +183,6 @@
<t:cons-until-empty set="vector" car="car" base="onto"> <t:cons-until-empty set="vector" car="car" base="onto">
<c:value-of name="car" /> <c:value-of name="car" />
</t:cons-until-empty> </t:cons-until-empty>
</lv:function> </function>
</lv:package> </package>

View File

@ -1,18 +1,12 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/matrix"
desc="Matrix (vector of vectors) arithmetic"> desc="Matrix (vector of vectors) arithmetic">
<lv:import package="../base" /> <import package="../base" />
<lv:import package="list" /> <import package="list" />
<!-- <!--
@ -52,36 +46,36 @@
above is true, the result is achieved in a slightly different manner.) above is true, the result is achieved in a slightly different manner.)
--> -->
<!-- TODO: more generic name and documentation; we are in the core, after all --> <!-- TODO: more generic name and documentation; we are in the core, after all -->
<lv:template name="_rate-vector_" desc="Matches against a matrix of classes and a matrix of rates and returns a vector representing the rates per location"> <template name="_rate-vector_" desc="Matches against a matrix of classes and a matrix of rates and returns a vector representing the rates per location">
<lv:param name="@line@" desc="Line code classification string" /> <param name="@line@" desc="Line code classification string" />
<lv:param name="@class_set@" desc="Matrix containing line classification matches" /> <param name="@class_set@" desc="Matrix containing line classification matches" />
<lv:param name="@into@" desc="Variable to which the vector will be assigned" /> <param name="@into@" desc="Variable to which the vector will be assigned" />
<!-- this would be the sum of all the rates, which really is useless, but the XML requires it --> <!-- this would be the sum of all the rates, which really is useless, but the XML requires it -->
<lv:param name="@yields@" desc="Variable to yield to (useless, but required)"> <param name="@yields@" desc="Variable to yield to (useless, but required)">
<lv:text>__</lv:text> <text>__</text>
<lv:param-value name="@into@" /> <param-value name="@into@" />
</lv:param> </param>
<lv:param name="@rate_matrix@" desc="Matrix containing the rates for the given line"> <param name="@rate_matrix@" desc="Matrix containing the rates for the given line">
<lv:text>rate_</lv:text> <text>rate_</text>
<lv:param-value name="@line@" /> <param-value name="@line@" />
</lv:param> </param>
<lv:rate-each class="@line@" accumulate="none" yields="@yields@" generates="@into@" index="k"> <rate-each class="@line@" accumulate="none" yields="@yields@" generates="@into@" index="k">
<!-- take the dot product of the two vectors (each part of a larger matrix) <!-- take the dot product of the two vectors (each part of a larger matrix)
to get the rate for the associated class code --> to get the rate for the associated class code -->
<c:product dot="true" label="Dot product between the class and rate vectors for each location will yield the respective rate per location"> <c:product dot="true" label="Dot product between the class and rate vectors for each location will yield the respective rate per location">
<c:value-of name="@class_set@" index="k" /> <c:value-of name="@class_set@" index="k" />
<c:value-of name="@rate_matrix@" index="k" /> <c:value-of name="@rate_matrix@" index="k" />
</c:product> </c:product>
</lv:rate-each> </rate-each>
</lv:template> </template>
<lv:function name="mcol" desc="Retrieve a matrix column as a vector"> <function name="mcol" desc="Retrieve a matrix column as a vector">
<lv:param name="matrix" type="float" set="matrix" desc="Matrix" /> <param name="matrix" type="float" set="matrix" desc="Matrix" />
<lv:param name="col" type="integer" desc="Column index (0-indexed)" /> <param name="col" type="integer" desc="Column index (0-indexed)" />
<!-- generate a vector containing only the requested column from each row --> <!-- generate a vector containing only the requested column from each row -->
<t:cons-until-empty set="matrix" car="row"> <t:cons-until-empty set="matrix" car="row">
@ -91,5 +85,6 @@
</c:index> </c:index>
</c:value-of> </c:value-of>
</t:cons-until-empty> </t:cons-until-empty>
</lv:function> </function>
</lv:package> </package>

View File

@ -1,28 +1,22 @@
<?xml-stylesheet type="text/xsl" href="summary.xsl"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<lv:package <package xmlns="http://www.lovullo.com/rater"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc" xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template" xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.lovullo.com/rater ../../rater.xsd"
core="true" core="true"
name="core/vector/table"
desc="Functions for performing table lookups"> desc="Functions for performing table lookups">
<lv:import package="../base" /> <import package="../base" />
<lv:import package="../numeric/common" /> <import package="../numeric/common" />
<lv:import package="list" /> <import package="list" />
<!-- since templates are inlined, we need to make these symbols available to <!-- since templates are inlined, we need to make these symbols available to
avoid terrible confusion --> avoid terrible confusion -->
<lv:import package="common" export="true" /> <import package="common" export="true" />
<lv:import package="matrix" export="true" /> <import package="matrix" export="true" />
<lv:const name="TABLE_WHEN_MASK_VALUE" type="float" value="-0.0001" desc="Used to mask when conditions" /> <const name="TABLE_WHEN_MASK_VALUE" type="float" value="-0.0001" desc="Used to mask when conditions" />
<lv:const name="MFILTER_BISECT_GAP_MAX" type="integer" value="10" desc="Quit bisect if size is less than or equal to this value" /> <const name="MFILTER_BISECT_GAP_MAX" type="integer" value="10" desc="Quit bisect if size is less than or equal to this value" />
<!-- <!--
@ -34,27 +28,27 @@
- _table_column_+ - Column definitions - _table_column_+ - Column definitions
- _table_rows_ - Begin table data definition - _table_rows_ - Begin table data definition
--> -->
<lv:template name="_create-table_" <template name="_create-table_"
desc="Create an arbitrary table for querying"> desc="Create an arbitrary table for querying">
<lv:param name="@name@" desc="Table name" /> <param name="@name@" desc="Table name" />
<lv:param name="@values@" desc="Table definition" /> <param name="@values@" desc="Table definition" />
<lv:param name="@desc@" desc="Table description"> <param name="@desc@" desc="Table description">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:param name="@__tid@" <param name="@__tid@"
desc="Internal table identifier"> desc="Internal table identifier">
<lv:param-value name="@name@" upper="true" snake="true" /> <param-value name="@name@" upper="true" snake="true" />
</lv:param> </param>
<lv:param-copy name="@values@"> <param-copy name="@values@">
<lv:param-meta name="create-table-id" value="@__tid@" /> <param-meta name="create-table-id" value="@__tid@" />
<lv:param-meta name="create-table-name" value="@name@" /> <param-meta name="create-table-name" value="@name@" />
<lv:param-meta name="create-table-desc" value="@desc@" /> <param-meta name="create-table-desc" value="@desc@" />
</lv:param-copy> </param-copy>
</lv:template> </template>
<!-- <!--
@ -68,52 +62,52 @@
If a table is especially large, the first column should be treated If a table is especially large, the first column should be treated
as the index and always be sequenced. as the index and always be sequenced.
--> -->
<lv:template name="_table-column_" <template name="_table-column_"
desc="Declare name for table column"> desc="Declare name for table column">
<lv:param name="@name@" desc="Column name" /> <param name="@name@" desc="Column name" />
<lv:param name="@index@" desc="Column index (0-indexed)" /> <param name="@index@" desc="Column index (0-indexed)" />
<lv:param name="@desc@" desc="Column description"> <param name="@desc@" desc="Column description">
<lv:param-value name="@name@" /> <param-value name="@name@" />
</lv:param> </param>
<!-- use carefully; leave alone unless data is definately sorted, <!-- use carefully; leave alone unless data is definately sorted,
or query results may be incorrect --> or query results may be incorrect -->
<lv:param name="@seq@" desc="Column is sorted (sequential)"> <param name="@seq@" desc="Column is sorted (sequential)">
<lv:text></lv:text> <text></text>
</lv:param> </param>
<lv:param name="@__tid@" <param name="@__tid@"
desc="Internal table identifier"> desc="Internal table identifier">
<lv:param-inherit meta="create-table-id" /> <param-inherit meta="create-table-id" />
</lv:param> </param>
<!-- FIXME: this doesn't contain @__tid@ because of a bug in the <!-- FIXME: this doesn't contain @__tid@ because of a bug in the
preprocessor; this is fixed in the new DSL --> preprocessor; this is fixed in the new DSL -->
<lv:param name="@__constname@" <param name="@__constname@"
desc="Name of internal constant used for column lookup"> desc="Name of internal constant used for column lookup">
<lv:text>RATE_TABLE_</lv:text> <text>RATE_TABLE_</text>
<lv:param-value name="@name@" upper="true" snake="true" /> <param-value name="@name@" upper="true" snake="true" />
</lv:param> </param>
<!-- column index identifier --> <!-- column index identifier -->
<lv:const name="{@__tid@}_{@__constname@}" <const name="{@__tid@}_{@__constname@}"
value="@index@" type="integer" value="@index@" type="integer"
desc="@desc@" /> desc="@desc@" />
<!-- column sequential flag to permit query optimizations --> <!-- column sequential flag to permit query optimizations -->
<lv:if name="@seq@" eq="true"> <if name="@seq@" eq="true">
<lv:const name="{@__tid@}_{@__constname@}_IS_SEQ" <const name="{@__tid@}_{@__constname@}_IS_SEQ"
value="1" type="integer" value="1" type="integer"
desc="{@name@} is sequenced" /> desc="{@name@} is sequenced" />
</lv:if> </if>
<lv:unless name="@seq@" eq="true"> <unless name="@seq@" eq="true">
<lv:const name="{@__tid@}_{@__constname@}_IS_SEQ" <const name="{@__tid@}_{@__constname@}_IS_SEQ"
value="0" type="integer" value="0" type="integer"
desc="{@name@} is unordered" /> desc="{@name@} is unordered" />
</lv:unless> </unless>
</lv:template> </template>
<!-- <!--
@ -125,30 +119,30 @@
Permitted children: Permitted children:
- _table-row_* - Table row definitions - _table-row_* - Table row definitions
--> -->
<lv:template name="_table-rows_" <template name="_table-rows_"
desc="Begin table data definition"> desc="Begin table data definition">
<lv:param name="@values@" desc="Row definitions" /> <param name="@values@" desc="Row definitions" />
<lv:param name="@__tid@" <param name="@__tid@"
desc="Table identifier"> desc="Table identifier">
<lv:param-inherit meta="create-table-id" /> <param-inherit meta="create-table-id" />
</lv:param> </param>
<lv:param name="@__tname@" <param name="@__tname@"
desc="Table name as provided by caller"> desc="Table name as provided by caller">
<lv:param-inherit meta="create-table-name" /> <param-inherit meta="create-table-name" />
</lv:param> </param>
<lv:param name="@__desc@" <param name="@__desc@"
desc="Table description"> desc="Table description">
<lv:param-inherit meta="create-table-desc" /> <param-inherit meta="create-table-desc" />
</lv:param> </param>
<lv:const name="{@__tid@}_RATE_TABLE" <const name="{@__tid@}_RATE_TABLE"
type="float" type="float"
desc="{@__tname@} table; {@__desc@}"> desc="{@__tname@} table; {@__desc@}">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</lv:const> </const>
</lv:template> </template>
<!-- <!--
@ -163,15 +157,15 @@
Permitted children: Permitted children:
_table-value_+ - Row column value _table-value_+ - Row column value
--> -->
<lv:template name="_table-row_" <template name="_table-row_"
desc="Define a constant table row (ordered)"> desc="Define a constant table row (ordered)">
<lv:param name="@values@" desc="Column values" /> <param name="@values@" desc="Column values" />
<lv:set desc="Row"> <set desc="Row">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</lv:set> </set>
</lv:template> </template>
<!-- <!--
@ -180,31 +174,31 @@
Column value order should match the defined column order. All Column value order should match the defined column order. All
values must be constants. values must be constants.
--> -->
<lv:template name="_table-value_" <template name="_table-value_"
desc="Table column value for row (ordered)"> desc="Table column value for row (ordered)">
<lv:param name="@const@" desc="Constant column value" /> <param name="@const@" desc="Constant column value" />
<lv:item value="@const@" desc="Column value" /> <item value="@const@" desc="Column value" />
</lv:template> </template>
<lv:template name="_query-first-field_" desc="Return the requested field from the first row returned by a query"> <template name="_query-first-field_" desc="Return the requested field from the first row returned by a query">
<lv:param name="@table@" desc="Table (matrix) to query" /> <param name="@table@" desc="Table (matrix) to query" />
<lv:param name="@values@" desc="Query parameters" /> <param name="@values@" desc="Query parameters" />
<!-- use either field or name[+index] --> <!-- use either field or name[+index] -->
<lv:param name="@field@" desc="Column to select (variable/constant); do not use with @name@" /> <param name="@field@" desc="Column to select (variable/constant); do not use with @name@" />
<lv:param name="@name@" desc="Name of field to query (variable/constant); overrides @field@" /> <param name="@name@" desc="Name of field to query (variable/constant); overrides @field@" />
<lv:param name="@index@" desc="Optional index for field name lookup (using @name@)" /> <param name="@index@" desc="Optional index for field name lookup (using @name@)" />
<c:car label="First row of query result"> <c:car label="First row of query result">
<t:query-field table="@table@" field="@field@" name="@name@" index="@index@"> <t:query-field table="@table@" field="@field@" name="@name@" index="@index@">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</t:query-field> </t:query-field>
</c:car> </c:car>
</lv:template> </template>
<!-- <!--
@ -240,59 +234,59 @@
predicate to query the first field to quickly reduce the size of the set predicate to query the first field to quickly reduce the size of the set
for the next predicate. for the next predicate.
--> -->
<lv:template name="_query-field_" desc="Return the requested field from rows returned by a query"> <template name="_query-field_" desc="Return the requested field from rows returned by a query">
<lv:param name="@table@" desc="Table (matrix) to query" /> <param name="@table@" desc="Table (matrix) to query" />
<lv:param name="@values@" desc="Query parameters" /> <param name="@values@" desc="Query parameters" />
<!-- use one or the other --> <!-- use one or the other -->
<lv:param name="@field@" desc="Column to select (variable/constant); do not use with @name@" /> <param name="@field@" desc="Column to select (variable/constant); do not use with @name@" />
<lv:param name="@index@" desc="Optional index for field name lookup (using @name@)" /> <param name="@index@" desc="Optional index for field name lookup (using @name@)" />
<!-- by default, if @field@ is provided instead of @name@, the field <!-- by default, if @field@ is provided instead of @name@, the field
constant will be generated (same concept as the 'when' template) --> constant will be generated (same concept as the 'when' template) -->
<lv:param name="@name@" desc="Name of field to query (variable/constant); overrides @field@"> <param name="@name@" desc="Name of field to query (variable/constant); overrides @field@">
<!-- convert @table@ to uppercase and snake case (replace - with _) --> <!-- convert @table@ to uppercase and snake case (replace - with _) -->
<lv:param-value name="@table@" upper="true" snake="true" /> <param-value name="@table@" upper="true" snake="true" />
<lv:text>_RATE_TABLE_</lv:text> <text>_RATE_TABLE_</text>
<lv:param-value name="@field@" upper="true" snake="true" /> <param-value name="@field@" upper="true" snake="true" />
</lv:param> </param>
<c:apply name="mcol" label="Query result"> <c:apply name="mcol" label="Query result">
<!-- the matrix (vector of rows) returned by the query --> <!-- the matrix (vector of rows) returned by the query -->
<c:arg name="matrix"> <c:arg name="matrix">
<t:query-row table="@table@"> <t:query-row table="@table@">
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</t:query-row> </t:query-row>
</c:arg> </c:arg>
<!-- the field (column) to retrieve; 0-based index --> <!-- the field (column) to retrieve; 0-based index -->
<c:arg name="col"> <c:arg name="col">
<!-- no index lookup needed --> <!-- no index lookup needed -->
<lv:unless name="@index@"> <unless name="@index@">
<c:value-of name="@name@" /> <c:value-of name="@name@" />
</lv:unless> </unless>
<!-- index lookup required --> <!-- index lookup required -->
<lv:if name="@index@"> <if name="@index@">
<c:value-of name="@name@" index="@index@" /> <c:value-of name="@name@" index="@index@" />
</lv:if> </if>
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:template> </template>
<lv:template name="_query-row_" desc="Query a table (matrix) for a row (vector) of values"> <template name="_query-row_" desc="Query a table (matrix) for a row (vector) of values">
<lv:param name="@table@" desc="Table (matrix)" /> <param name="@table@" desc="Table (matrix)" />
<lv:param name="@values@" desc="Query parameters" /> <param name="@values@" desc="Query parameters" />
<!-- this defaults to a table name constant as generated from the csv2xml <!-- this defaults to a table name constant as generated from the csv2xml
script; either this or @table@ should be used --> script; either this or @table@ should be used -->
<lv:param name="@matrix@" desc="Matrix to look up from"> <param name="@matrix@" desc="Matrix to look up from">
<!-- convert @table@ to uppercase and snake case (replace - with _) --> <!-- convert @table@ to uppercase and snake case (replace - with _) -->
<lv:param-value name="@table@" upper="true" snake="true" /> <param-value name="@table@" upper="true" snake="true" />
<lv:text>_RATE_TABLE</lv:text> <text>_RATE_TABLE</text>
</lv:param> </param>
<c:apply name="_mquery"> <c:apply name="_mquery">
<c:arg name="matrix"> <c:arg name="matrix">
@ -301,9 +295,9 @@
<c:arg name="criteria"> <c:arg name="criteria">
<c:set> <c:set>
<lv:param-copy name="@values@"> <param-copy name="@values@">
<lv:param-meta name="table_basename" value="@matrix@" /> <param-meta name="table_basename" value="@matrix@" />
</lv:param-copy> </param-copy>
</c:set> </c:set>
</c:arg> </c:arg>
@ -313,71 +307,71 @@
<t:dec> <t:dec>
<c:length-of> <c:length-of>
<c:set> <c:set>
<lv:param-copy name="@values@"> <param-copy name="@values@">
<lv:param-meta name="table_basename" value="@matrix@" /> <param-meta name="table_basename" value="@matrix@" />
</lv:param-copy> </param-copy>
</c:set> </c:set>
</c:length-of> </c:length-of>
</t:dec> </t:dec>
</c:arg> </c:arg>
</c:apply> </c:apply>
</lv:template> </template>
<lv:template name="_when_" desc="Create field predicate for query definition"> <template name="_when_" desc="Create field predicate for query definition">
<lv:param name="@id@" desc="Field index" /> <param name="@id@" desc="Field index" />
<lv:param name="@values@" desc="Field value (provide only one node)" /> <param name="@values@" desc="Field value (provide only one node)" />
<lv:param name="@sequential@" desc="Is data sequential?" /> <param name="@sequential@" desc="Is data sequential?" />
<!-- @name@ may be provided directly, or @field@ may be used when the <!-- @name@ may be provided directly, or @field@ may be used when the
basename is available (set by a query template), giving the illusion of basename is available (set by a query template), giving the illusion of
querying the table columns by name directly (magic!); pure syntatic querying the table columns by name directly (magic!); pure syntatic
sugary goodness --> sugary goodness -->
<lv:param name="@field@" desc="Field name (to be used with base)" /> <param name="@field@" desc="Field name (to be used with base)" />
<lv:param name="@name@" desc="Field name (as a variable/constant)"> <param name="@name@" desc="Field name (as a variable/constant)">
<lv:param-inherit meta="table_basename" /> <param-inherit meta="table_basename" />
<lv:text>_</lv:text> <text>_</text>
<lv:param-value name="@field@" upper="true" snake="true" /> <param-value name="@field@" upper="true" snake="true" />
</lv:param> </param>
<lv:param name="@seqvar@" desc="Var/constant containing whether field is sequential"> <param name="@seqvar@" desc="Var/constant containing whether field is sequential">
<lv:param-inherit meta="table_basename" /> <param-inherit meta="table_basename" />
<lv:text>_</lv:text> <text>_</text>
<lv:param-value name="@field@" upper="true" snake="true" /> <param-value name="@field@" upper="true" snake="true" />
<lv:text>_IS_SEQ</lv:text> <text>_IS_SEQ</text>
</lv:param> </param>
<c:set label="Conditional for {@field@}"> <c:set label="Conditional for {@field@}">
<!-- the first element will represent the column (field) index --> <!-- the first element will represent the column (field) index -->
<lv:unless name="@name@"> <unless name="@name@">
<c:const value="@id@" type="integer" desc="Field index" /> <c:const value="@id@" type="integer" desc="Field index" />
</lv:unless> </unless>
<lv:if name="@name@"> <if name="@name@">
<c:value-of name="@name@" /> <c:value-of name="@name@" />
</lv:if> </if>
<!-- the second element will represent the expected value(s) --> <!-- the second element will represent the expected value(s) -->
<c:set> <c:set>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:set> </c:set>
<!-- the final element will represent whether or not this field is sequential --> <!-- the final element will represent whether or not this field is sequential -->
<lv:if name="@sequential@"> <if name="@sequential@">
<c:const value="@sequential@" type="boolean" desc="Whether data is sequential" /> <c:const value="@sequential@" type="boolean" desc="Whether data is sequential" />
</lv:if> </if>
<lv:unless name="@sequential@"> <unless name="@sequential@">
<!-- if a field name was given, we can get the sequential information <!-- if a field name was given, we can get the sequential information
that was already generated for us --> that was already generated for us -->
<lv:if name="@field@"> <if name="@field@">
<c:value-of name="@seqvar@" /> <c:value-of name="@seqvar@" />
</lv:if> </if>
<!-- otherwise, default to non-sequential --> <!-- otherwise, default to non-sequential -->
<lv:unless name="@field@"> <unless name="@field@">
<c:value-of name="FALSE" /> <c:value-of name="FALSE" />
</lv:unless> </unless>
</lv:unless> </unless>
</c:set> </c:set>
</lv:template> </template>
@ -389,11 +383,11 @@
<!-- this function is intended to be called by the _query_ template, not directly --> <!-- this function is intended to be called by the _query_ template, not directly -->
<lv:function name="_mquery" desc="Query for vectors using a set of column criteria"> <function name="_mquery" desc="Query for vectors using a set of column criteria">
<lv:param name="matrix" type="float" set="matrix" desc="Matrix to query" /> <param name="matrix" type="float" set="matrix" desc="Matrix to query" />
<lv:param name="criteria" type="float" set="matrix" desc="Query criteria" /> <param name="criteria" type="float" set="matrix" desc="Query criteria" />
<lv:param name="i" type="integer" desc="Current criteria index" /> <param name="i" type="integer" desc="Current criteria index" />
<c:cases> <c:cases>
<c:case> <c:case>
@ -469,7 +463,7 @@
</c:apply> </c:apply>
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:function> </function>
<!-- <!--
@ -488,12 +482,12 @@
the gap and make this a general-purpose function if need be. Technically, the gap and make this a general-purpose function if need be. Technically,
the gap is useless and saves lg(g) steps, which may be very small.) the gap is useless and saves lg(g) steps, which may be very small.)
--> -->
<lv:function name="bisect" desc="Bisect a matrix toward the requested column value"> <function name="bisect" desc="Bisect a matrix toward the requested column value">
<lv:param name="matrix" type="float" set="matrix" desc="Matrix to bisect" /> <param name="matrix" type="float" set="matrix" desc="Matrix to bisect" />
<lv:param name="col" type="integer" desc="Column index to filter on" /> <param name="col" type="integer" desc="Column index to filter on" />
<lv:param name="val" type="float" desc="Column value to filter on" /> <param name="val" type="float" desc="Column value to filter on" />
<lv:param name="start" type="integer" desc="Start index" /> <param name="start" type="integer" desc="Start index" />
<lv:param name="end" type="integer" desc="Start end" /> <param name="end" type="integer" desc="Start end" />
<c:let> <c:let>
<c:values> <c:values>
@ -607,13 +601,13 @@
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</c:let> </c:let>
</lv:function> </function>
<lv:function name="foremost" desc="Search backwards for the first occurrance in a sorted list"> <function name="foremost" desc="Search backwards for the first occurrance in a sorted list">
<lv:param name="matrix" type="float" set="matrix" desc="Matrix to bisect" /> <param name="matrix" type="float" set="matrix" desc="Matrix to bisect" />
<lv:param name="col" type="integer" desc="Column index to search on" /> <param name="col" type="integer" desc="Column index to search on" />
<lv:param name="i" type="integer" desc="Current index" /> <param name="i" type="integer" desc="Current index" />
<c:let> <c:let>
<c:values> <c:values>
@ -687,35 +681,35 @@
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</c:let> </c:let>
</lv:function> </function>
<lv:template name="_mask-unless_" desc="Mask a value unless the condition is truthful"> <template name="_mask-unless_" desc="Mask a value unless the condition is truthful">
<lv:param name="@values@" desc="Body" /> <param name="@values@" desc="Body" />
<lv:param name="@name@" desc="Scalar to check" /> <param name="@name@" desc="Scalar to check" />
<lv:param name="@index@" desc="Optional index" /> <param name="@index@" desc="Optional index" />
<lv:param name="@desc@" desc="Optional description" /> <param name="@desc@" desc="Optional description" />
<c:cases> <c:cases>
<!-- if masked --> <!-- if masked -->
<c:case> <c:case>
<!-- no index provided --> <!-- no index provided -->
<lv:unless name="@index@"> <unless name="@index@">
<c:when name="@name@"> <c:when name="@name@">
<c:eq> <c:eq>
<c:value-of name="FALSE" /> <c:value-of name="FALSE" />
</c:eq> </c:eq>
</c:when> </c:when>
</lv:unless> </unless>
<!-- index provided --> <!-- index provided -->
<lv:if name="@index@"> <if name="@index@">
<c:when name="@name@" index="@index@"> <c:when name="@name@" index="@index@">
<c:eq> <c:eq>
<c:value-of name="FALSE" /> <c:value-of name="FALSE" />
</c:eq> </c:eq>
</c:when> </c:when>
</lv:if> </if>
<!-- TODO: configurable mask via meta and/or param --> <!-- TODO: configurable mask via meta and/or param -->
<c:value-of name="TABLE_WHEN_MASK_VALUE" /> <c:value-of name="TABLE_WHEN_MASK_VALUE" />
@ -723,17 +717,17 @@
<!-- if not masked --> <!-- if not masked -->
<c:otherwise> <c:otherwise>
<lv:param-copy name="@values@" /> <param-copy name="@values@" />
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:template> </template>
<lv:function name="mfilter" desc="Filter matrix rows by column value"> <function name="mfilter" desc="Filter matrix rows by column value">
<lv:param name="matrix" type="float" set="matrix" desc="Matrix to filter" /> <param name="matrix" type="float" set="matrix" desc="Matrix to filter" />
<lv:param name="col" type="integer" desc="Column index to filter on" /> <param name="col" type="integer" desc="Column index to filter on" />
<lv:param name="vals" type="float" desc="Column value to filter on" /> <param name="vals" type="float" desc="Column value to filter on" />
<lv:param name="seq" type="boolean" desc="Is data sequential?" /> <param name="seq" type="boolean" desc="Is data sequential?" />
<!-- merge the result of each condition in vals into a single set, which <!-- merge the result of each condition in vals into a single set, which
has the effect of supporting multiple conditions on a single column of has the effect of supporting multiple conditions on a single column of
@ -786,16 +780,16 @@
</c:arg> </c:arg>
</c:apply> </c:apply>
</t:merge-until-empty> </t:merge-until-empty>
</lv:function> </function>
<lv:function name="range" desc="Filter matrix rows by column value within a certain range of indexes (inclusive)"> <function name="range" desc="Filter matrix rows by column value within a certain range of indexes (inclusive)">
<lv:param name="matrix" type="float" set="matrix" desc="Matrix to filter" /> <param name="matrix" type="float" set="matrix" desc="Matrix to filter" />
<lv:param name="col" type="integer" desc="Column index to filter on" /> <param name="col" type="integer" desc="Column index to filter on" />
<lv:param name="val" type="float" desc="Column value to filter on" /> <param name="val" type="float" desc="Column value to filter on" />
<lv:param name="start" type="integer" desc="Starting index (inclusive)" /> <param name="start" type="integer" desc="Starting index (inclusive)" />
<lv:param name="end" type="integer" desc="Ending index (inclusive)" /> <param name="end" type="integer" desc="Ending index (inclusive)" />
<lv:param name="seq" type="boolean" desc="Is data sequential?" /> <param name="seq" type="boolean" desc="Is data sequential?" />
<c:let> <c:let>
<c:values> <c:values>
@ -882,18 +876,18 @@
</c:cases> </c:cases>
</c:let> </c:let>
</c:let> </c:let>
</lv:function> </function>
<lv:function name="_mfilter" desc="mfilter helper"> <function name="_mfilter" desc="mfilter helper">
<lv:param name="matrix" type="float" set="matrix" desc="Matrix to filter" /> <param name="matrix" type="float" set="matrix" desc="Matrix to filter" />
<lv:param name="col" type="integer" desc="Column index to filter on" /> <param name="col" type="integer" desc="Column index to filter on" />
<lv:param name="val" type="float" desc="Column value to filter on" /> <param name="val" type="float" desc="Column value to filter on" />
<lv:param name="start" type="integer" desc="Starting index (aka current index)" /> <param name="start" type="integer" desc="Starting index (aka current index)" />
<lv:param name="end" type="integer" desc="Ending index" /> <param name="end" type="integer" desc="Ending index" />
<lv:param name="seq" type="integer" desc="Is data sequential?" /> <param name="seq" type="integer" desc="Is data sequential?" />
<lv:param name="cur" type="float" desc="Current value" /> <param name="cur" type="float" desc="Current value" />
<c:cases> <c:cases>
<c:case> <c:case>
@ -932,5 +926,6 @@
</c:apply> </c:apply>
</c:otherwise> </c:otherwise>
</c:cases> </c:cases>
</lv:function> </function>
</lv:package> </package>