vector/filter: Formatting and minor doc
parent
ec7d1c2a24
commit
cac9d22cb2
|
@ -25,7 +25,14 @@
|
||||||
|
|
||||||
|
|
||||||
<section title="Matrix Filtering">
|
<section title="Matrix Filtering">
|
||||||
<function name="mfilter" desc="Filter matrix rows by column value">
|
\ref{mfilter} handles complex filtering of matrices.
|
||||||
|
If the requested column~\tt{@col@} is marked as sequential with~\tt{@seq@},
|
||||||
|
a~$O(lg n)$ bisect algorithm will be used;
|
||||||
|
otherwise,
|
||||||
|
it will undergo a~$O(n)$ linear scan.
|
||||||
|
|
||||||
|
<function name="mfilter"
|
||||||
|
desc="Filter matrix rows by column value">
|
||||||
<param name="matrix" type="float" set="matrix" desc="Matrix to filter" />
|
<param name="matrix" type="float" set="matrix" desc="Matrix to filter" />
|
||||||
<param name="col" type="integer" desc="Column index to filter on" />
|
<param name="col" type="integer" desc="Column index to filter on" />
|
||||||
<param name="vals" type="float" desc="Column value to filter on" />
|
<param name="vals" type="float" desc="Column value to filter on" />
|
||||||
|
@ -37,7 +44,7 @@
|
||||||
the lookups separately for each, we preserve the bisect-ability of the
|
the lookups separately for each, we preserve the bisect-ability of the
|
||||||
condition. -->
|
condition. -->
|
||||||
<t:merge-until-empty set="vals" car="val" glance="TABLE_WHEN_MASK_VALUE">
|
<t:merge-until-empty set="vals" car="val" glance="TABLE_WHEN_MASK_VALUE">
|
||||||
<c:apply name="range" matrix="matrix" col="col" val="val" seq="seq">
|
<c:apply name="mrange" matrix="matrix" col="col" val="val" seq="seq">
|
||||||
<c:arg name="start">
|
<c:arg name="start">
|
||||||
<c:cases>
|
<c:cases>
|
||||||
<!-- if we know that the data is sequential, then we may not need to
|
<!-- if we know that the data is sequential, then we may not need to
|
||||||
|
@ -52,7 +59,7 @@
|
||||||
|
|
||||||
<c:apply name="bisect" matrix="matrix" col="col" val="val">
|
<c:apply name="bisect" matrix="matrix" col="col" val="val">
|
||||||
<c:arg name="start">
|
<c:arg name="start">
|
||||||
<c:const value="0" type="integer" desc="Start bisect at beginning" />
|
<c:const value="0" desc="Start bisect at beginning" />
|
||||||
</c:arg>
|
</c:arg>
|
||||||
|
|
||||||
<c:arg name="end">
|
<c:arg name="end">
|
||||||
|
@ -68,7 +75,7 @@
|
||||||
|
|
||||||
<!-- we have no good guess; linear search :x -->
|
<!-- we have no good guess; linear search :x -->
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
<c:const value="0" type="integer" desc="Start at the first element" />
|
<c:const value="0" desc="Start at the first element" />
|
||||||
</c:otherwise>
|
</c:otherwise>
|
||||||
</c:cases>
|
</c:cases>
|
||||||
</c:arg>
|
</c:arg>
|
||||||
|
@ -85,7 +92,9 @@
|
||||||
</function>
|
</function>
|
||||||
|
|
||||||
|
|
||||||
<function name="range" desc="Filter matrix rows by column value within a certain range of indexes (inclusive)">
|
<function name="mrange"
|
||||||
|
desc="Filter matrix rows by column value within a certain
|
||||||
|
range of indexes (inclusive)">
|
||||||
<param name="matrix" type="float" set="matrix" desc="Matrix to filter" />
|
<param name="matrix" type="float" set="matrix" desc="Matrix to filter" />
|
||||||
<param name="col" type="integer" desc="Column index to filter on" />
|
<param name="col" type="integer" desc="Column index to filter on" />
|
||||||
<param name="val" type="float" desc="Column value to filter on" />
|
<param name="val" type="float" desc="Column value to filter on" />
|
||||||
|
@ -114,7 +123,8 @@
|
||||||
<c:values>
|
<c:values>
|
||||||
<!-- determine if the value we're looking for is over the current value
|
<!-- determine if the value we're looking for is over the current value
|
||||||
in a sorted list (meaning that we will not find it) -->
|
in a sorted list (meaning that we will not find it) -->
|
||||||
<c:value name="over" type="boolean" desc="Did we pass the potential value in a sorted list?">
|
<c:value name="over" type="boolean"
|
||||||
|
desc="Did we pass the potential value in a sorted list?">
|
||||||
<c:value-of name="TRUE">
|
<c:value-of name="TRUE">
|
||||||
<c:when name="seq">
|
<c:when name="seq">
|
||||||
<c:eq>
|
<c:eq>
|
||||||
|
@ -159,7 +169,8 @@
|
||||||
|
|
||||||
|
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
<c:apply name="_mfilter" matrix="matrix" col="col" val="val" start="start" end="end" seq="seq">
|
<c:apply name="_mfilter" matrix="matrix" col="col" val="val"
|
||||||
|
start="start" end="end" seq="seq">
|
||||||
<c:arg name="cur">
|
<c:arg name="cur">
|
||||||
<c:value-of name="matrix">
|
<c:value-of name="matrix">
|
||||||
<!-- current row -->
|
<!-- current row -->
|
||||||
|
@ -206,11 +217,12 @@
|
||||||
</c:index>
|
</c:index>
|
||||||
</c:value-of>
|
</c:value-of>
|
||||||
|
|
||||||
<c:apply name="range" matrix="matrix" col="col" val="val" end="end" seq="seq">
|
<c:apply name="mrange" matrix="matrix" col="col" val="val"
|
||||||
|
end="end" seq="seq">
|
||||||
<c:arg name="start">
|
<c:arg name="start">
|
||||||
<c:sum>
|
<c:sum>
|
||||||
<c:value-of name="start" />
|
<c:value-of name="start" />
|
||||||
<c:const value="1" type="integer" desc="Check next element" />
|
<c:const value="1" desc="Check next element" />
|
||||||
</c:sum>
|
</c:sum>
|
||||||
</c:arg>
|
</c:arg>
|
||||||
</c:apply>
|
</c:apply>
|
||||||
|
@ -218,11 +230,12 @@
|
||||||
</c:case>
|
</c:case>
|
||||||
|
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
<c:apply name="range" matrix="matrix" col="col" val="val" end="end" seq="seq">
|
<c:apply name="mrange" matrix="matrix" col="col" val="val"
|
||||||
|
end="end" seq="seq">
|
||||||
<c:arg name="start">
|
<c:arg name="start">
|
||||||
<c:sum>
|
<c:sum>
|
||||||
<c:value-of name="start" />
|
<c:value-of name="start" />
|
||||||
<c:const value="1" type="integer" desc="Check next element" />
|
<c:const value="1" desc="Check next element" />
|
||||||
</c:sum>
|
</c:sum>
|
||||||
</c:arg>
|
</c:arg>
|
||||||
</c:apply>
|
</c:apply>
|
||||||
|
|
Loading…
Reference in New Issue