Made changes to allow to work with large datasets

Earlier sometimes error happened when a temporary buffer in ml module were created as a Mat,
since the length of the row of the buffer (in bytes) was sizeof(int) * (work_var_count + 1)*sample_count
-- in some cases it was greater than INT_MAX.