Construct a matrix by accumulation of indexed values (C, C++, or Fortran)
$30-250 USD
Paid on delivery
INTRO: The function 'accumarray' in MATLAB is too slow for my codes (because they use large vectors and matrices), so I am seeking a FASTER version satisfying my needs. I am seeking the fastest possible implementation.
GOAL: Write a C, C++, or Fortran code which performs part of the functionality of the MATLAB function "accumarray". Your code must then be made into a MEX function for calling from MATLAB.
DETAILS: Your function must reproduce the following behavior (or similar):
%% GIVEN EXAMPLE INPUTS (This is MATLAB code):
numvalues = 10^6; % number of values to accumulate
matSize = 288; % width of matrix
vals = ones(numvalues,1); % values to be accumulated
xn = uint32(randi(matSize,numvalues,1)); % x index for values
yn = uint32(randi(matSize,numvalues,1)); % y index for values
zn = uint32(randi(matSize,numvalues,1)); % z index for values
pos3 = yn+(xn-1)*matSize+(zn-1)*matSize^2; % only needed for alternative code
%% YOUR FUNCTION WILL GIVE THE SAME OUTPUT THAT MATLAB GIVES USING ACCUMARRAY AS FOLLOWS:
newMat3 = accumarray([yn, xn, zn], vals, [matSize matSize matSize]); % a 3D evaluation
newMat2 = accumarray([yn, xn], vals, [matSize matSize]); % a 2D evaluation
newMat1 = accumarray(yn, vals, [matSize 1]); % a 1D evaluation
%% The above form is preferred, but the following alternative is also acceptable if it improves speed in your function:
newMat3 = accumarray(pos3,vals,[matSize^3 1]);
If possible, please report your expected speedup times.
I am also open to other ideas about how to speedup this function.
Project ID: #15873044
About the project
14 freelancers are bidding on average $144 for this job
Hello I can help you with your task please check my reviews for more information I have also some questions Relevant Skills and Experience MATLAB c cpp python algorithms
Hi. I am good in both Matlab and Fortran (you can find this from my profile with a lot of projects done). So I am sure I will be able to do this functionality using Fortran. Regards
cool project, speeding up is always a challenge I enjoy. I quickly tested your Matlab script, the 3D version is 10x faster when gpuArray() (needs CUDA support) is used, with 1D I don't think you can see any special More
Greetings, I can help you in Construct a matrix by accumulation of indexed values . Please ping me for more discussion. Please see my profile i have deliver almost 280 projects with 100% client satisfaction. I More
Hello More 20 years mathematics and programming experience. I need more details to set real price and time. Regards.
I have interested in your project, talk with me for know more about my experience or your requirements. Best regards, Enderson J. Falcón G.