Skip to content

Commit

Permalink
Solved bug at matrix select method
Browse files Browse the repository at this point in the history
  • Loading branch information
pakozm committed Oct 30, 2013
1 parent 3425f81 commit 4c2541a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ChangeList
Master branch release
---------------------

- Solved bug at `Matrix<T>::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
Expand Down
4 changes: 2 additions & 2 deletions packages/basics/matrix/c_src/matrix.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ Matrix<T> *Matrix<T>::select(int dim, int index, Matrix<T> *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;
Expand All @@ -567,7 +567,7 @@ Matrix<T> *Matrix<T>::select(int dim, int index, Matrix<T> *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<dim; ++i)
dest_last_raw_pos += (matrixSize[i]-1)*stride[i];
Expand Down
13 changes: 8 additions & 5 deletions tools/MapReduce/task-example.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ local function mmap(key,value)
local data,first,last = load(value)()
local f = io.open(data)
for i=1,first-1 do f:read("*l") end
local out = iterator(range(first,last)):
map(function(i) return f:read("*l") or "" end):
local out = iterator(io.lines(data)):
enumerate():
filter(function(idx, line) return idx >= 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
Expand All @@ -73,15 +76,15 @@ 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

-- receives a dictionary of [key]=>value, produces a value which is shared
-- 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
Expand Down
3 changes: 2 additions & 1 deletion tools/statistics/pearson-correlation-coefficient.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4c2541a

Please sign in to comment.