# [PD] writing to cyclone/coll takes a long time

Orm Finnendahl orm.finnendahl at selma.hfmdk-frankfurt.de
Sat Nov 30 14:59:34 CET 2019

```Hi Jakob,

using a matrix for markov chains in your use case might not be the
best choice as the matrix most likely will be pretty sparse and you
quickly run out of space for higher orders. In any case: There exists
a markov object which I wrote quite some time ago (originally for Max
but later translated to pd). It still compiles and I can send you the
sources (or a binary for linux). You have to specify the maximum order
on initialization, but you can change the order while it is running to
see/hear the effects. For maximum efficiency it used multidimensional
rb-trees. I remember that in 1993 it inserted 2000 elements per second
for a maxorder of 3 (on a 16MHz machine ;-). Let me know off list
whether you're interested and I'll put them online.

--
Orm

Am Samstag, den 30. November 2019 um 14:00:50 Uhr (+0100) schrieb Jakob Laue:
> Dear list,
> For a university project we are building a melody generator based on markov chains. This includes generating a big matrix of probabilities for playing a certain note. The number of rows in the matrix depends on the markov order and the pitch range that our patch works with. We have a pitch range of 9, hence markov order 3 means writing 9^3 rows = 729.
> We want to work with the fifth order which means writing 9^5 = 59049 rows into the matrix. We use the coll object from the cyclone library to generate our matrix because it has the handy gui for looking at your matrix after you generated it.
> Our problem is that it takes more than 3 minutes to write 60000 rows into the coll object and we don't understand why.
> Attached we have a test patch that simulates our matrix generation. Writing 700 rows into coll takes less than a second, writing 6000 rows takes round about 1.5 seconds (simulating fourth order/9^4), writing 60000 rows takes 3 minutes and 45 seconds.
> Do you have any hint why it takes that long to write 60000 rows into coll? Maybe we do something wrong or have missed some smarter way to write our rows into the coll matrix.
>
> We are on:
> MacBook Pro 13" early 2011, macOS Sierra 10.12.6
> Pd 0.48-0
>
>
> Thanks, Hajar and Jakob

> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list

```