tame/core/numeric/common.xml

114 lines
2.9 KiB
XML
Raw Normal View History

2015-03-18 11:31:47 -04:00
<?xml version="1.0" encoding="ISO-8859-1"?>
<package xmlns="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template"
core="true"
desc="General numeric opreations">
2015-03-18 11:31:47 -04:00
<import package="../base" />
2015-03-18 11:31:47 -04:00
<template name="_inc_" desc="Increment value [by 1]">
<param name="@values@" desc="Value to increment (nodes)" />
2015-03-18 11:31:47 -04:00
<param name="@value@" desc="Value to decrement by (default 1)">
<text>1</text>
</param>
<c:sum>
2015-03-18 11:31:47 -04:00
<param-copy name="@values@" />
<c:const value="@value@" type="integer" desc="Increment by 1" />
</c:sum>
2015-03-18 11:31:47 -04:00
</template>
2015-03-18 11:31:47 -04:00
<template name="_dec_" desc="Decrement value [by 1]">
<param name="@values@" desc="Value to decrement (nodes)" />
2015-03-18 11:31:47 -04:00
<param name="@value@" desc="Value to decrement by (default 1)">
<text>1</text>
</param>
<c:sum>
2015-03-18 11:31:47 -04:00
<param-copy name="@values@" />
<c:product>
<c:value-of name="NEGATE" />
<c:const value="@value@" type="integer" desc="Decrement by 1" />
</c:product>
</c:sum>
2015-03-18 11:31:47 -04:00
</template>
2015-03-18 11:31:47 -04:00
<template name="_negate_" desc="Negate a value">
<param name="@values@" desc="Value to decrement (nodes)" />
<param name="@label@" desc="Application label">
<!-- default empty -->
2015-03-18 11:31:47 -04:00
<text></text>
</param>
<c:product label="@label@">
<c:value-of name="NEGATE" />
2015-03-18 11:31:47 -04:00
<param-copy name="@values@" />
</c:product>
2015-03-18 11:31:47 -04:00
</template>
2015-03-18 11:31:47 -04:00
<template name="_percent-of_" desc="Take percentage of a value">
<param name="@value@" desc="Value to take percentage of" />
<param name="@index@" desc="Index" />
<param name="@percent@" desc="Percent (as a whole number)" />
2015-03-18 11:31:47 -04:00
<param name="@desc@" desc="Optional description">
<text>Percent to reduce</text>
</param>
<c:product>
<c:value-of name="@value@" index="@index@" />
<t:ptor value="@percent@" desc="@desc@" />
</c:product>
2015-03-18 11:31:47 -04:00
</template>
<!--
Calculates a value based on the given multiplier if the given value falls
within the given range
-->
2015-03-18 11:31:47 -04:00
<function name="rangeadd" desc="Add a value multiplier for a given range">
<param name="low" type="float" desc="Lower bound, inclusive" />
<param name="high" type="float" desc="Upper bound, inclusive" />
<param name="val" type="float" desc="Value to compare" />
<param name="mult" type="float" desc="Range multiplier" />
<c:product>
<c:when name="val">
<c:gte>
<c:value-of name="low" />
</c:gte>
</c:when>
<c:when name="val">
<c:lte>
<c:value-of name="high" />
</c:lte>
</c:when>
<!-- atop of the 0.00003 we've already provided = 0.000035 -->
<c:value-of name="mult" />
<c:sum>
<c:value-of name="val" />
<!-- subtract -->
<c:product>
<c:value-of name="NEGATE" />
<c:value-of name="low" />
</c:product>
</c:sum>
</c:product>
2015-03-18 11:31:47 -04:00
</function>
</package>