Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions matlab_functions/+multem_input/parameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,15 @@
output_area_iy_e(1,1) double = 0.0; % y-final in pixel
end
methods
function out_mt = ilc_incident_wave(obj)
function out_mt = ilc_incident_wave(obj, space)
% Optional parameter space:
% 1: real space (default), 2: reciprocal space
if nargin < 2
space = 1;
end
prms = obj.toStruct;
clear ilc_incident_wave;
out_mt = ilc_incident_wave(prms.system_conf, prms);
out_mt = ilc_incident_wave(prms.system_conf, prms, space);
end
function out_mt = ilc_multem(obj)
prms = obj.toStruct;
Expand Down
18 changes: 12 additions & 6 deletions mex_files_multem/ilc_incident_wave.cu
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void set_struct_incident_wave(TOutput_Multislice &output_multislice, mxArray *&m
}

template <class T, mt::eDevice dev>
void run_incident_wave(mt::System_Configuration &system_conf, const mxArray *mx_input_multislice, mxArray *&mx_output_multislice)
void run_incident_wave(mt::System_Configuration &system_conf, const mxArray *mx_input_multislice, mxArray *&mx_output_multislice, enum mt::eSpace space)
{
mt::Input_Multislice<T> input_multislice;
read_input_multislice(mx_input_multislice, input_multislice);
Expand All @@ -157,7 +157,7 @@ void run_incident_wave(mt::System_Configuration &system_conf, const mxArray *mx_
mt::Output_Multislice<T> output_multislice;
output_multislice.set_input_data(&input_multislice);

incident_wave(mt::eS_Real, output_multislice);
incident_wave(space, output_multislice);

stream.synchronize();

Expand All @@ -172,21 +172,27 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
auto system_conf = mt::read_system_conf(prhs[0]);
int idx_0 = (system_conf.active)?1:0;
auto space = mt::eS_Real;

if (nrhs > idx_0+1)
{
space = (mt::eSpace)(int)mxGetScalar(prhs[idx_0+1]);
}

if(system_conf.is_float_host())
{
run_incident_wave<float, mt::e_host>(system_conf, prhs[idx_0], plhs[0]);
run_incident_wave<float, mt::e_host>(system_conf, prhs[idx_0], plhs[0], space);
}
else if(system_conf.is_double_host())
{
run_incident_wave<double, mt::e_host>(system_conf, prhs[idx_0], plhs[0]);
run_incident_wave<double, mt::e_host>(system_conf, prhs[idx_0], plhs[0], space);
}
else if(system_conf.is_float_device())
{
run_incident_wave<float, mt::e_device>(system_conf, prhs[idx_0], plhs[0]);
run_incident_wave<float, mt::e_device>(system_conf, prhs[idx_0], plhs[0], space);
}
else if(system_conf.is_double_device())
{
run_incident_wave<double, mt::e_device>(system_conf, prhs[idx_0], plhs[0]);
run_incident_wave<double, mt::e_device>(system_conf, prhs[idx_0], plhs[0], space);
}
}