function hLib = Ifl_IpoCur_CRLEntry(hLib)
% Key: interp1D
% y1: Result
% u1: dpResult->Index
% u2: dpResult->Ratio
% u3: Val_array
% u4: N    
    
%% Code Replacement Library Entries       
% Code replacement library entries when index and fraction are on separate
% output lines:
inputIsBus = false;
inputs = {'u1','u2','u3','u4'};
hLib = Ifl_addEntries_IpoCur(hLib, inputIsBus, inputs);
% Code replacement library entries when index and fraction are on the same
% output line via a bus:
inputIsBus = true;
inputs = {'u1','dummy','u2','u3'};
hLib = Ifl_addEntries_IpoCur(hLib, inputIsBus, inputs);

end

function hLib = Ifl_addEntries_IpoCur(hLib, inputIsBus, inputs)
%% Code Replacement Library Entries
%% Column-major routines (COLUMN_DIR)
%0x004
hLib.addEntry( Ifl_addEntry_IpoCur('Ifl_IpoCur_f32', 'single', 'uint32', 'single', 'single', inputIsBus, inputs, false) );

%% Row-major routines (ROW_DIR)
%0x004
hLib.addEntry( Ifl_addEntry_IpoCur('Ifl_IpoCur_f32', 'single', 'uint32', 'single', 'single', inputIsBus, inputs, true) );

end

function hEnt = Ifl_addEntry_IpoCur(signature, datatype_y1, datatype_u1, datatype_u2, datatype_u3, inputIsBus, inputs, createRowMajorRoutine)

if inputIsBus
    hEnt = coder.Ifl_IpoCurBusCustomEntry;
else
    hEnt = coder.Ifl_IpoCurCustomEntry;
end

%% Set Function Entry Parameters
hEnt.setTflCFunctionEntryParameters( ...
          'Key', 'interp1D', ...
          'Priority', 100, ...
          'SupportSymbolicDimensions', true, ...
          'ImplementationName', signature, ...
          'ImplementationHeaderFile', 'Ifl.h');

%% Add Algorithm Properties
                   % Parameter                                  Value
algPropertyList = {{'InterpMethod',                              'Linear'},...
                   {'ExtrapMethod',                              'Clip'},...
                   {'ValidIndexMayReachLast'                     'on'},...
                   {'RemoveProtectionIndex'                      'off'}};   
               
%% Set ArrayLayout and UseRowMajorAlgorithm
[hEnt, algPropertyList] = Ifl_setMapRowMajorAttributes(hEnt, algPropertyList, createRowMajorRoutine);

hEnt = addAlgorithmParameters(hEnt, algPropertyList);
      
%% Add Conceptual and implementation Arguments
% Conceptual Arguments
arg = hEnt.getTflArgFromString('y1', datatype_y1);
arg.IOType = 'RTW_IO_OUTPUT';
hEnt.addConceptualArg(arg);

hEnt = Ifl_addIndexFractionConceptualArguments(hEnt, {inputs{1}, inputs{2}}, {datatype_u1, datatype_u2}, ...
	'RTW_IO_INPUT', inputIsBus);

arg = RTW.TflArgMatrix(inputs{3}, 'RTW_IO_INPUT', datatype_u3);
arg.DimRange = [1 1 ; Inf Inf];
hEnt.addConceptualArg(arg);

arg = hEnt.getTflArgFromString(inputs{4}, 'uint32');
hEnt.addConceptualArg(arg);

% Implementation Arguments
arg = hEnt.getTflArgFromString('y1', datatype_y1);
arg.IOType = 'RTW_IO_OUTPUT';
hEnt.Implementation.setReturn(arg); 

hEnt = Ifl_addIndexFractionImplementationArguments(hEnt, {inputs{1}, inputs{2}}, 'dpResult', 'RTW_IO_INPUT', inputIsBus);

arg = hEnt.getTflArgFromString(inputs{3}, strcat(datatype_u3, '*'));
arg.Type.BaseType.ReadOnly = true;
hEnt.Implementation.addArgument(arg);

%% Map and cache argument locations for use in do_match tasks
hEnt.mapAndCacheLabeledArgLocations();

end

