accelerate 3D matrix multiptication using bsxfun
Hi
I have athe following code
it takes forever to run, and disable my CPU in the prosess…
I’m looking for a way to make it run better (GPU is also an option)
norm_mode is 256×256 double matrix (X,Y) image
fields is 16384×15 complex double matrix (time,mode)
in the end’ I need a 3D matrix take each norm_mode image will also be a function for time and suming all the modes- 3D matrix 256x256x16384
that is the total_field
do you have any sugestions on how to make it run better?
Thanks,
Barak
function total_field = BuildSpatialField(fields,fiber, sim, others)
total_field = zeros( newSize, newSize, length(others.t) ); % total_field(X,Y,t)
h = waitbar(0, ‘calculate field…’);
for ii=1:others.modes
norm_mode = % load new phi
tmp = bsxfun(@times, norm_mode, reshape(fields(:,ii),1,1,[]));
total_field = total_field + tmp;
waitbar(ii/others.modes, h, [‘mode ‘ num2str(ii) ‘ from ‘ num2str(others.modes)]);
end
close(h);
endHi
I have athe following code
it takes forever to run, and disable my CPU in the prosess…
I’m looking for a way to make it run better (GPU is also an option)
norm_mode is 256×256 double matrix (X,Y) image
fields is 16384×15 complex double matrix (time,mode)
in the end’ I need a 3D matrix take each norm_mode image will also be a function for time and suming all the modes- 3D matrix 256x256x16384
that is the total_field
do you have any sugestions on how to make it run better?
Thanks,
Barak
function total_field = BuildSpatialField(fields,fiber, sim, others)
total_field = zeros( newSize, newSize, length(others.t) ); % total_field(X,Y,t)
h = waitbar(0, ‘calculate field…’);
for ii=1:others.modes
norm_mode = % load new phi
tmp = bsxfun(@times, norm_mode, reshape(fields(:,ii),1,1,[]));
total_field = total_field + tmp;
waitbar(ii/others.modes, h, [‘mode ‘ num2str(ii) ‘ from ‘ num2str(others.modes)]);
end
close(h);
end Hi
I have athe following code
it takes forever to run, and disable my CPU in the prosess…
I’m looking for a way to make it run better (GPU is also an option)
norm_mode is 256×256 double matrix (X,Y) image
fields is 16384×15 complex double matrix (time,mode)
in the end’ I need a 3D matrix take each norm_mode image will also be a function for time and suming all the modes- 3D matrix 256x256x16384
that is the total_field
do you have any sugestions on how to make it run better?
Thanks,
Barak
function total_field = BuildSpatialField(fields,fiber, sim, others)
total_field = zeros( newSize, newSize, length(others.t) ); % total_field(X,Y,t)
h = waitbar(0, ‘calculate field…’);
for ii=1:others.modes
norm_mode = % load new phi
tmp = bsxfun(@times, norm_mode, reshape(fields(:,ii),1,1,[]));
total_field = total_field + tmp;
waitbar(ii/others.modes, h, [‘mode ‘ num2str(ii) ‘ from ‘ num2str(others.modes)]);
end
close(h);
end bsxfun, acceleration MATLAB Answers — New Questions