This URL hosts a Git repository (ie. git clone https://steady.supply/git/sample-buf
will work). For your convenience,
the file README.md
from this repository is rendered below.
To us, a buffer is a finite sequence of real numbers. To the computer, a buffer is a (hopefully) contiguous block of memory where a representation of this sequence is stored. In the computer’s memory, each number is represented using some fixed-width binary format.
Attempting to capture both considerations, we let two integers a
and b
write a buffer as the tuple (a, b)
. We let a
be the
location in memory of the buffer’s first element and b > 0
be the
offset such that a + b
is the location in memory of the buffer’s
last element.
Let A = (a, b)
be a buffer. We write the n
th element of the
buffer A
as A[n]
, which has memory location a + n
.
Let A = (a, b)
be a buffer. Suppose we wish to construct a buffer
B = (c, d)
from A
, presumably offering a reasonable
representation of A
.
When b = d
we may simply let the elements of B
equal those of
A
, writing B[n] = A[n]
for all n ∈ [a, a + b]
.
When b ≠ d
, we construct B
from elements of A
according to
some function f
where B[n] = f(A, n)
. There are several choices
for f
depending on if b < d
or d < b
, where our function f
is called decant
or pour
respectively.
decant
when B
has fewer elements than does A
; each
element of B
will be a “summary” of several elements of A
.pour
when B
has more elements than does A
; elements
of B
may be “in between” elements of A
.decant
ingLet A = (a, b)
and B = (c, d)
be buffers with d < b
. To
construct B
from A
we collect some number of elements from A
and summarise them to produce a single element in B
.
pour
ingLet A = (a, b)
and B = (c, d)
be buffers with b < d
. To
construct B
from A
, given some point B[n]
where
We can do so in the following ways:
INTRP_NEAR
where B[n] = A[⌊(b - a) / (d - c) × n⌋]
INTRP_LINE
INTRP_CUBE
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.