Hi Jimmie, effectively I did not subsribe... Having efficient methods for sliding window average is possible, here is how I would do it: "Create a vector with 100,000 rows filles with random values (uniform distrubution in [0,1]" v := LapackDGEMatrix randUniform: #(100000 1). "extract values from rank 10001 to 20000" w1 := v atIntervalFrom: 10001 to: 20000 by: 1. "create a left multiplier matrix for performing average of w1" a := LapackDGEMatrix nrow: 1 ncol: w1 nrow withAll: 1.0 / w1 size. "get the average (this is a 1x1 matrix from which we take first element)" avg1 := (a * w1) at: 1. [ "select another slice of same size" w2 := v atIntervalFrom: 15001 to: 25000 by: 1. "get the average (we can recycle a)" avg2 := (a * w2) at: 1 ] bench. This gives: '16,500 per second. 60.7 microseconds per run.' versus: [w2 sum / w2 size] bench. '1,100 per second. 908 microseconds per run.' For max and min, it's harder. Lapack/Blas only provide max of absolute value as primitive: [w2 absMax] bench. '19,400 per second. 51.5 microseconds per run.' Everything else will be slower, unless we write new primitives in C and connect them... [w2 maxOf: [:each | each]] bench. '984 per second. 1.02 milliseconds per run.' Le dim. 19 mai 2019 à 14:58, Jimmie <jlhouchin@gmail.com> a écrit :
On 5/16/19 1:26 PM, Nicolas Cellier wrote:> Any feedback on this?
Did someone tried to use Smallapack in Pharo? Jimmie?
I am going to guess that you are not on pharo-users. My bad. I posted this in pharo-users as I it wasn't Pharo development question.
I probably should have posted here or emailed you directly.
All I really need is good performance with a simple array of floats. No matrix math. Nothing complicated. Moving Averages over a slice of the array. A variety of different averages, weighted, etc. Max/min of the array. But just a single simple array.
Any help greatly appreciated.
Thanks.
On 4/28/19 8:32 PM, Jimmie Houchin wrote: Hello,
I have installed Smallapack into Pharo 7.0.3. Thanks Nicholas.
I am very unsure on my use of Smallapack. I am not a mathematician or scientist. However the only part of Smallapack I am trying to use at the moment is something that would be 64bit and compare to FloatArray so that I can do some simple accessing, slicing, sum, and average on the array.
Here is some sample code I wrote just to play in a playground.
I have an ExternalDoubleArray, LapackDGEMatrix, and a FloatArray samples. The ones not in use are commented out for any run.
fp is a download from http://ratedata.gaincapital.com/2018/12%20December/EUR_USD_Week1.zip and unzipped to a directory.
fp := '/home/jimmie/data/EUR_USD_Week1.csv' index := 0. pricesSum := 0. asum := 0. ttr := [ lines := fp asFileReference contents lines allButFirst. a := ExternalDoubleArray new: lines size. "la := LapackDGEMatrix allocateNrow: lines size ncol: 1. a := la columnAt: 1." "a := FloatArray new: lines size." lines do: [ :line || parts price | parts := ',' split: line. index := index + 1. price := Float readFrom: (parts last). a at: index put: price. pricesSum := pricesSum + price. (index rem: 100) = 0 ifTrue: [ asum := a sum. ]]] timeToRun. { index. pricesSum. asum. ttr }. "ExternalDoubleArray an Array(337588 383662.5627699992 383562.2956199993 0:00:01:59.885)" "FloatArray an Array(337588 383662.5627699992 383562.2954441309 0:00:00:06.555)"
FloatArray is not the precision I need. But it is over 18x faster.
I am afraid I must be doing something badly wrong. Python/Numpy is over 4x faster than FloatArray for the above.
If I am using Smallapack incorrectly please help.
Any help greatly appreciated.
Thanks.