Data Structures¶
-
class
pyroomacoustics.adaptive.data_structures.
Buffer
(length=20, dtype=<Mock id='139803631498192'>)¶ A simple buffer class with amortized cost
Parameters: - length (int) – buffer length
- dtype (numpy.type) – data type
-
flush
(n)¶ Removes the n oldest elements in the buffer
-
push
(val)¶ Add one element at the front of the buffer
-
size
()¶ Returns the number of elements in the buffer
-
top
(n)¶ Returns the n elements at the front of the buffer from newest to oldest
-
class
pyroomacoustics.adaptive.data_structures.
CoinFlipper
(p, length=10000)¶ This class efficiently generates large number of coin flips. Because each call to
numpy.random.rand
is a little bit costly, it is more efficient to generate many values at once. This class does this and stores them in advance. It generates new fresh numbers when needed.Parameters: - p (float, 0 < p < 1) – probability to output a 1
- length (int) – the number of flips to precompute
-
flip
(n)¶ Get n random binary values from the buffer
-
flip_all
()¶ Regenerates all the used up values
-
fresh_flips
(n)¶ Generates n binary random values now
-
class
pyroomacoustics.adaptive.data_structures.
Powers
(a, length=20, dtype=<Mock id='139803631498320'>)¶ This class allows to store all powers of a small number and get them ‘a la numpy’ with the bracket operator. There is automatic increase when new values are requested
Parameters: - a (float) – the number
- length (int) – the number of integer powers
- dtype (numpy.type, optional) – the data type (typically np.float32 or np.float64)
Example
>>> an = Powers(0.5) >>> print(an[4]) 0.0625