scaleex-scale.html
doubleCode_samples.html
mergeex-merge.html
sumex-sum.html
dxex-dx.html
wiring functionsex-msfl.html
histo
RLEex-rle.html
convolex-conv.html
higher order
actorex-fmap.html
 

actor histo

  in (a:unsigned<8> dc)

  out (c:unsigned<8> dc)

var s: {Wait,Accum,Dump} = Wait

var h: unsigned<8> array[256] = [ 0 | i=0 to 255 ]

var i: unsigned<9>

rules

| (s:Wait, a:'<)  -> (s:Accum)

| (s:Accum, a:'p) -> (s:Accum, h[p]:h[p]+1)

| (s:Accum, a:'>) -> (s:Dump, c:'<, i:0)

| (s:Dump, i:256) -> (s:Wait, c:'>)

| (s:Dump)        -> (s:Dump, c:'h[i], h[i]:0, i:i+1)

;



This actor computes the histogram of a sequence of values, encoded as a list.


For example, if the stream on input a is : 

    < 1 2 2 4 4 4 4 8 8 8 8 8 8 8 8 15 >

then the stream on output c will be :

         <  0 1 2 0 4 0 0 0 8 0 0 0 0 0 0 1 0 ... >

 

The histogram is accumulated in the local variable h. It is updated when reading data values in the second rule and output in the last three rules.