with parallel::export
[epclust.git] / epclust / R / utils.R
index 347c2c6..7083674 100644 (file)
@@ -10,8 +10,9 @@ toInteger <- function(x, condition)
        x
 }
 
-serialize = function(coeffs, file, append)
+writeCoeffs = function(coeffs)
 {
+       file = ".coeffs"
        #.........
        #C function (from data.frame, type of IDs ??! force integers ? [yes])
        #return raw vector
@@ -19,9 +20,10 @@ serialize = function(coeffs, file, append)
 #TODO: appendCoeffs() en C --> serialize et append to file
 }
 
-deserialize = function(file, range, ncoefs)
+readCoeffs = function(indices)
 {
        #......
+       file = ".coeffs"
        #C function (from file name)
 }
 
@@ -30,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) ) ) ) )
+       })
 }