X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=epclust%2FR%2Futils.R;h=708367482bbd093ff18166d29d5df1968bdfb77b;hb=0e2dce80a3fddaca50c96c6c27a8b32468095d6c;hp=6dcc2cdfca13d3c41ee5175e3f20ac549b83fe41;hpb=7b13d0c28da62d91684a29ced50c740120e2b7a9;p=epclust.git diff --git a/epclust/R/utils.R b/epclust/R/utils.R index 6dcc2cd..7083674 100644 --- a/epclust/R/utils.R +++ b/epclust/R/utils.R @@ -10,27 +10,20 @@ toInteger <- function(x, condition) x } -#TODO: merge these 2 next ?! -serialize = function(coeffs) +writeCoeffs = function(coeffs) { + file = ".coeffs" #......... #C function (from data.frame, type of IDs ??! force integers ? [yes]) #return raw vector -} -appendBinary = function(.......) -{ #take raw vector, append it (binary mode) to a file #TODO: appendCoeffs() en C --> serialize et append to file } -#finalizeSerialization = function(...) -#{ -# #write number of series, and length of each... -#} - -deserialize = function(coeffs, range) +readCoeffs = function(indices) { #...... + file = ".coeffs" #C function (from file name) } @@ -39,7 +32,14 @@ getSeries(data, rank=NULL, id=NULL) #TODO: } -getCoeffs(.....) #FROM BINARY FILE !!! +curvesToCoeffs = function(series, wf) { - + L = length(series[1,]) + D = ceiling( log2(L) ) + nb_sample_points = 2^D + apply(series, 1, function(x) { + interpolated_curve = spline(1:L, x, n=nb_sample_points)$y + W = wavelets::dwt(interpolated_curve, filter=wf, D)@W + rev( sapply( W, function(v) ( sqrt( sum(v^2) ) ) ) ) + }) }