-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
tech.v3.datatype.rolling.html
94 lines (93 loc) · 17 KB
/
tech.v3.datatype.rolling.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>tech.v3.datatype.rolling documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="highlight/solarized-light.css" /><script type="text/javascript" src="highlight/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a> with <a href="https://github.com/xsc/codox-theme-rdash">RDash UI</a> theme</h2><h1><a href="index.html"><span class="project-title"><span class="project-name">dtype-next</span> <span class="project-version">8.042</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="buffered-image.html"><div class="inner"><span>Buffered Image Support</span></div></a></li><li class="depth-1 "><a href="cheatsheet.html"><div class="inner"><span>Cheatsheet</span></div></a></li><li class="depth-1 "><a href="datatype-to-dtype-next.html"><div class="inner"><span>Why dtype-next?</span></div></a></li><li class="depth-1 "><a href="dimensions-bytecode-gen.html"><div class="inner"><span>Dimensions and Bytecode Generation</span></div></a></li><li class="depth-1 "><a href="overview.html"><div class="inner"><span>Overview</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>tech</span></div></div></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>v3</span></div></div></li><li class="depth-3"><a href="tech.v3.datatype.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>datatype</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.argops.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>argops</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.bitmap.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>bitmap</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.convolve.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>convolve</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.datetime.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>datetime</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.errors.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>errors</span></div></a></li><li class="depth-4"><a href="tech.v3.datatype.ffi.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ffi</span></div></a></li><li class="depth-5 branch"><a href="tech.v3.datatype.ffi.clang.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>clang</span></div></a></li><li class="depth-5"><a href="tech.v3.datatype.ffi.graalvm.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>graalvm</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.functional.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>functional</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.gradient.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gradient</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.jna.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>jna</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.jvm-map.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>jvm-map</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.list.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>list</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.locker.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>locker</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.mmap.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mmap</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.mmap-writer.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mmap-writer</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.native-buffer.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>native-buffer</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.nippy.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>nippy</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.packing.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>packing</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.reductions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>reductions</span></div></a></li><li class="depth-4 branch current"><a href="tech.v3.datatype.rolling.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>rolling</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.sampling.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>sampling</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.struct.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>struct</span></div></a></li><li class="depth-4"><a href="tech.v3.datatype.wavelet.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wavelet</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree" style="top: -765px;"><span class="top" style="height: 774px;"></span><span class="bottom"></span></span><span>libs</span></div></div></li><li class="depth-4 branch"><a href="tech.v3.libs.buffered-image.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>buffered-image</span></div></a></li><li class="depth-4"><a href="tech.v3.libs.neanderthal.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>neanderthal</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>parallel</span></div></div></li><li class="depth-4"><a href="tech.v3.parallel.for.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>for</span></div></a></li><li class="depth-3"><a href="tech.v3.tensor.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>tensor</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.tensor.color-gradients.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>color-gradients</span></div></a></li><li class="depth-4"><a href="tech.v3.tensor.dimensions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>dimensions</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="tech.v3.datatype.rolling.html#var-expanding-window-ranges"><div class="inner"><span>expanding-window-ranges</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.rolling.html#var-fixed-rolling-window"><div class="inner"><span>fixed-rolling-window</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.rolling.html#var-fixed-rolling-window-ranges"><div class="inner"><span>fixed-rolling-window-ranges</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.rolling.html#var-variable-rolling-window-ranges"><div class="inner"><span>variable-rolling-window-ranges</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.rolling.html#var-window-ranges-.3Ewindow-reader"><div class="inner"><span>window-ranges->window-reader</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">tech.v3.datatype.rolling</h1><div class="doc"><div class="markdown"></div></div><div class="public anchor" id="var-expanding-window-ranges"><h3>expanding-window-ranges</h3><div class="usage"><code>(expanding-window-ranges n-elems)</code></div><div class="doc"><div class="markdown"><p>Return a reader of expanding window ranges used for cumsum type operations.</p></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/rolling.clj#L361">view source</a></div></div><div class="public anchor" id="var-fixed-rolling-window"><h3>fixed-rolling-window</h3><div class="usage"><code>(fixed-rolling-window item window-size window-fn {:keys [relative-window-position edge-mode datatype], :or {relative-window-position :center, edge-mode :clamp}, :as options})</code><code>(fixed-rolling-window item window-size window-fn)</code></div><div class="doc"><div class="markdown"><p>Return a lazily evaluated rolling window of window-fn applied to each window. The iterable or sequence is padded such that there are the same number of values in the result as in the input with repeated elements padding the beginning and end of the original sequence. If input is an iterator, output is an lazy sequence. If input is a reader, output is a reader.</p>
<p>:Options</p>
<ul>
<li><code>:relative-window-position</code> - Defaults to <code>:center</code> - controls the window’s relative positioning in the sequence.</li>
<li><code>:edge-mode</code> - Defaults to <code>:clamp</code> - either <code>:zero</code> in which case window values off the edge are zero for numeric types or nil for object types or <code>:clamp</code> - in which case window values off the edge of the data are bound to the first or last values respectively.</li>
</ul>
<p>Example (all results are same length):</p>
<pre><code class="clojure">user> (require '[tech.v3.datatype :as dtype])
nil
user> (require '[tech.v3.datatype.rolling :as rolling])
nil
user> (require '[tech.v3.datatype.functional :as dfn])
nil
user> (rolling/fixed-rolling-window (range 20) 5 dfn/sum {:relative-window-position :left})
[0 1 3 6 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85]
user> (rolling/fixed-rolling-window (range 20) 5 dfn/sum {:relative-window-position :center})
[3 6 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 89 92]
user> (rolling/fixed-rolling-window (range 20) 5 dfn/sum {:relative-window-position :right})
[10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 89 92 94 95]
user>
</code></pre></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/rolling.clj#L183">view source</a></div></div><div class="public anchor" id="var-fixed-rolling-window-ranges"><h3>fixed-rolling-window-ranges</h3><div class="usage"><code>(fixed-rolling-window-ranges n-elems window-size relative-window-position)</code></div><div class="doc"><div class="markdown"><p>Return a reader of window-ranges of n-elems length.</p>
<p>Example:</p>
<pre><code class="clojure">tech.v3.datatype.rolling> (fixed-rolling-window-ranges 10 3 :left)
[[-2 -1 0] [-1 0 1] [0 1 2] [1 2 3] [2 3 4] [3 4 5] [4 5 6] [5 6 7] [6 7 8] [7 8 9]]
tech.v3.datatype.rolling> (fixed-rolling-window-ranges 10 3 :center)
[[-1 0 1] [0 1 2] [1 2 3] [2 3 4] [3 4 5] [4 5 6] [5 6 7] [6 7 8] [7 8 9] [8 9 10]]
tech.v3.datatype.rolling> (fixed-rolling-window-ranges 10 3 :right)
[[0 1 2] [1 2 3] [2 3 4] [3 4 5] [4 5 6] [5 6 7] [6 7 8] [7 8 9] [8 9 10] [9 10 11]]
</code></pre></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/rolling.clj#L144">view source</a></div></div><div class="public anchor" id="var-variable-rolling-window-ranges"><h3>variable-rolling-window-ranges</h3><div class="usage"><code>(variable-rolling-window-ranges src-data window-length {:keys [stepsize comp-fn n-subset], :or {stepsize 0.0}})</code><code>(variable-rolling-window-ranges src-data window-length)</code></div><div class="doc"><div class="markdown"><p>Given a reader of monotonically increasing source data, a double window length and a comparison function that takes two elements of the src-data and returns a double return an iterable of ranges that describe the windows in index space. Once a window is found start index will be incremented by stepsize amount as according to comp-fn or 1 if stepsize is not provided or 0.0.</p>
<ul>
<li>src-data - convertible to reader.</li>
<li>window-length - double window length amount in the space of comp-fn.</li>
</ul>
<p>Returns an iterable of clojure ranges. Note the last N ranges will not be window-size in length; you can filter these out if you require exactly window-size windows.</p>
<p>Options:</p>
<ul>
<li><code>:stepsize</code> - double stepsize amount in the space of comp-fn.</li>
<li><code>:comp-fn</code> - defaults to (- rhs lhs), must return a double result that will be used to figure out the next window indexes and the amount to increment the start index in between windows.</li>
<li><code>:n-subset</code> - defaults to n-elems, used when parallelizing rolling windows over a single buffer this will exit the iteration prematurely and must be less than src-data n-elems.</li>
</ul>
<p>Examples:</p>
<pre><code class="clojure">tech.v3.datatype.rolling> (vec (variable-rolling-window-ranges
(range 20) 5))
[[0 1 2 3 4]
[1 2 3 4 5]
[2 3 4 5 6]
[3 4 5 6 7]
[4 5 6 7 8]
[5 6 7 8 9]
[6 7 8 9 10]
[7 8 9 10 11]
[8 9 10 11 12]
[9 10 11 12 13]
[10 11 12 13 14]
[11 12 13 14 15]
[12 13 14 15 16]
[13 14 15 16 17]
[14 15 16 17 18]
[15 16 17 18 19]
[16 17 18 19]
[17 18 19]
[18 19]
[19]]
tech.v3.datatype.rolling> (vec (variable-rolling-window-ranges
(range 20) 5 {:stepsize 2}))
[[0 1 2 3 4]
[2 3 4 5 6]
[4 5 6 7 8]
[6 7 8 9 10]
[8 9 10 11 12]
[10 11 12 13 14]
[12 13 14 15 16]
[14 15 16 17 18]
[16 17 18 19]
[18 19]]
</code></pre></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/rolling.clj#L274">view source</a></div></div><div class="public anchor" id="var-window-ranges-.3Ewindow-reader"><h3>window-ranges->window-reader</h3><div class="usage"><code>(window-ranges->window-reader src-data win-ranges edge-mode)</code></div><div class="doc"><div class="markdown"><p>Given src data, reader of window ranges and an edge mode return a reader that when read returns a reader of src-data appropriately padded depending on edge mode.</p>
<ul>
<li>src-data - buffer of source data</li>
<li>win-ranges - reader of WindowRange.</li>
<li>edge-mode - one of <code>:zero</code> pad with 0/nil or <code>:clamp</code> in which case the padding is the first/last values in src data, respectively.</li>
</ul>
<p>Example:</p>
<pre><code class="clojure">tech.v3.datatype.rolling> (window-ranges->window-reader
(range 10) (fixed-rolling-window-ranges 10 3 :center)
:clamp)
[[0 0 1] [0 1 2] [1 2 3] [2 3 4] [3 4 5] [4 5 6] [5 6 7] [6 7 8] [7 8 9] [8 9 9]]
tech.v3.datatype.rolling> (window-ranges->window-reader
(range 10) (fixed-rolling-window-ranges 10 3 :center)
:zero)
[[0 0 1] [0 1 2] [1 2 3] [2 3 4] [3 4 5] [4 5 6] [5 6 7] [6 7 8] [7 8 9] [8 9 0]]
</code></pre></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/rolling.clj#L70">view source</a></div></div></div></body></html>