From 4c2541ac38f7a951f67d6d7a1afe74ee3e284121 Mon Sep 17 00:00:00 2001 From: Paco Zamora Martinez Date: Wed, 30 Oct 2013 17:05:15 +0100 Subject: [PATCH] Solved bug at matrix select method --- CHANGELIST.md | 2 ++ packages/basics/matrix/c_src/matrix.impl.h | 4 ++-- tools/MapReduce/task-example.lua | 13 ++++++++----- .../statistics/pearson-correlation-coefficient.lua | 3 ++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index b59c6ebf7..bad1d94b7 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -4,6 +4,8 @@ ChangeList Master branch release --------------------- +- Solved bug at `Matrix::select(...)` C++ method. The matrix offset wasn't be + added to the resulting matrix offset. - Solved bug at `SlidingWindow::setAtWindow(...)` C++ method. The matrix offset wasn't be added to the computed window position. - Solved bug at `buffered_memory.h`. Such bug introduces an early stop when diff --git a/packages/basics/matrix/c_src/matrix.impl.h b/packages/basics/matrix/c_src/matrix.impl.h index 43b4da997..8e1105841 100644 --- a/packages/basics/matrix/c_src/matrix.impl.h +++ b/packages/basics/matrix/c_src/matrix.impl.h @@ -545,7 +545,7 @@ Matrix *Matrix::select(int dim, int index, Matrix *dest) { result->matrixSize = new int[d]; result->stride = new int[d]; result->major_order = major_order; - result->offset = index*stride[dim]; // the select implies an offset + result->offset = offset + index*stride[dim]; // the select implies an offset result->last_raw_pos = result->offset; result->data = data; result->mmapped_data = 0; @@ -567,7 +567,7 @@ Matrix *Matrix::select(int dim, int index, Matrix *dest) { april_assert(dest->total_size == total_size/matrixSize[dim]); april_assert(dest->numDim == numDim-1); // - int dest_offset = index*stride[dim]; + int dest_offset = offset + index*stride[dim]; int dest_last_raw_pos = dest_offset; for(int i=0; i= first and idx <= last end): + select(2): map(string.tokenize): - iterate(ipairs):select(2): + iterate(ipairs): + select(2): reduce(function(acc,w) acc[w] = (acc[w] or 0) + 1 return acc @@ -73,7 +76,7 @@ end -- receive a key and an array of values, and produces a pair of strings -- key,value (or able to be string-converted by Lua) pairs local function mreduce(key,values) - local sum = 0 for i=1,#values do sum=sum+values[i] end + local sum = iterator(ipairs(values)):select(2):reduce(math.add,0) return key,sum end @@ -81,7 +84,7 @@ end -- between all workers, and shows the result on user screen local function sequential(list) iterator(pairs(list)):apply(function(k,v)print(v,k)end) - return {1,2,3,4} + return {} end -- this function receives the shared value returned by sequential function diff --git a/tools/statistics/pearson-correlation-coefficient.lua b/tools/statistics/pearson-correlation-coefficient.lua index 1bf7db3b9..00b3a69d1 100644 --- a/tools/statistics/pearson-correlation-coefficient.lua +++ b/tools/statistics/pearson-correlation-coefficient.lua @@ -12,8 +12,9 @@ col1 = tonumber(arg[2]) col2 = tonumber(arg[3]) seed = tonumber(arg[4]) conf = tonumber(arg[5]) -reps = 1000 +reps = 100 +if conf > 0.5 then reps = 1000 end if conf > 0.95 then reps = 10000 end if conf > 0.99 then reps = 100000 end