diff --git a/compile/fullCompile/makeCompileArgsFull.m b/compile/fullCompile/makeCompileArgsFull.m index f8e58ac5c..f6e03cac4 100644 --- a/compile/fullCompile/makeCompileArgsFull.m +++ b/compile/fullCompile/makeCompileArgsFull.m @@ -16,7 +16,7 @@ ARGS_1_1.oilChiDataPresent = coder.typeof(0,[1 maxArraySize],[0 1]); ARGS_1_1.numberOfContrasts = coder.typeof(0); ARGS_1_1.geometry = coder.typeof('X',[1 maxArraySize],[0 1]); -ARGS_1_1.useImaginary = coder.typeof(true,[1 1],[0 0]); +ARGS_1_1.useImaginary = coder.typeof(true); ARGS_1_1.contrastBackgroundParams = coder.typeof(0,[1 maxArraySize],[0 1]); ARGS_1_1.contrastBackgroundActions = coder.typeof(0,[1 maxArraySize],[0 1]); ARGS_1_1.contrastQzshifts = coder.typeof(0,[1 maxArraySize],[0 1]); @@ -45,7 +45,7 @@ ARGS_1_2 = cell([1 21]); ARG = coder.typeof(0,[1 2]); ARGS_1_2{1} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); -ARG = coder.typeof(0,[maxDataSize 5],[1 1]); +ARG = coder.typeof(0,[maxDataSize 5],[1 1]); ARGS_1_2{2} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); ARG = coder.typeof(0,[1 2]); ARGS_1_2{3} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); @@ -75,7 +75,7 @@ ARGS_1_2{15} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); ARG = coder.typeof('X',[1 maxArraySize],[0 1]); ARGS_1_2{16} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); -ARG = coder.typeof(0,[maxArraySize 5],[1 1]); +ARG = coder.typeof(0,[maxArraySize 5],[1 1]); ARGS_1_2{17} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); ARG = coder.typeof(0,[1 2]); ARGS_1_2{18} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); @@ -108,8 +108,8 @@ ARGS_1_4.funcTolerance = coder.typeof(0); ARGS_1_4.maxFuncEvals = coder.typeof(0); ARGS_1_4.maxIterations = coder.typeof(0); -ARGS_1_4.updateFreq = coder.typeof(0,[1 1]); -ARGS_1_4.updatePlotFreq = coder.typeof(0,[1 1]); +ARGS_1_4.updateFreq = coder.typeof(0); +ARGS_1_4.updatePlotFreq = coder.typeof(0); ARGS_1_4.populationSize = coder.typeof(0); ARGS_1_4.fWeight = coder.typeof(0); ARGS_1_4.crossoverProbability = coder.typeof(0); @@ -120,10 +120,10 @@ ARGS_1_4.nMCMC = coder.typeof(0); ARGS_1_4.propScale = coder.typeof(0); ARGS_1_4.nsTolerance = coder.typeof(0); -ARGS_1_4.nSamples = coder.typeof(0,[1 1]); -ARGS_1_4.nChains = coder.typeof(0,[1 1]); -ARGS_1_4.jumpProbability = coder.typeof(0,[1 1]); -ARGS_1_4.pUnitGamma = coder.typeof(0,[1 1]); +ARGS_1_4.nSamples = coder.typeof(0); +ARGS_1_4.nChains = coder.typeof(0); +ARGS_1_4.jumpProbability = coder.typeof(0); +ARGS_1_4.pUnitGamma = coder.typeof(0); ARGS_1_4.boundHandling = coder.typeof('X',[1 maxArraySize],[0 1]); ARGS_1_4.adaptPCR = coder.typeof(true); ARGS_1_4_checks = struct; diff --git a/compile/reflectivityCalculation/makeCompileArgs.m b/compile/reflectivityCalculation/makeCompileArgs.m index a049b0159..d3690f511 100644 --- a/compile/reflectivityCalculation/makeCompileArgs.m +++ b/compile/reflectivityCalculation/makeCompileArgs.m @@ -16,7 +16,7 @@ ARGS_1_1.oilChiDataPresent = coder.typeof(0,[1 maxArraySize],[0 1]); ARGS_1_1.numberOfContrasts = coder.typeof(0); ARGS_1_1.geometry = coder.typeof('X',[1 maxArraySize],[0 1]); -ARGS_1_1.useImaginary = coder.typeof(true,[1 1],[0 0]); +ARGS_1_1.useImaginary = coder.typeof(true); ARGS_1_1.contrastBackgroundParams = coder.typeof(0,[1 maxArraySize],[0 1]); ARGS_1_1.contrastBackgroundActions = coder.typeof(0,[1 maxArraySize],[0 1]); ARGS_1_1.contrastQzshifts = coder.typeof(0,[1 maxArraySize],[0 1]); @@ -45,7 +45,7 @@ ARGS_1_2 = cell([1 21]); ARG = coder.typeof(0,[1 2]); ARGS_1_2{1} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); -ARG = coder.typeof(0,[maxDataSize 5],[1 1]); +ARG = coder.typeof(0,[maxDataSize 5],[1 1]); ARGS_1_2{2} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); ARG = coder.typeof(0,[1 2]); ARGS_1_2{3} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); @@ -75,7 +75,7 @@ ARGS_1_2{15} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); ARG = coder.typeof('X',[1 maxArraySize],[0 1]); ARGS_1_2{16} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); -ARG = coder.typeof(0,[maxArraySize 5],[1 1]); +ARG = coder.typeof(0,[maxArraySize 5],[1 1]); ARGS_1_2{17} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); ARG = coder.typeof(0,[1 2]); ARGS_1_2{18} = coder.typeof({ARG}, [1 maxArraySize],[0 1]); @@ -108,8 +108,8 @@ ARGS_1_4.funcTolerance = coder.typeof(0); ARGS_1_4.maxFuncEvals = coder.typeof(0); ARGS_1_4.maxIterations = coder.typeof(0); -ARGS_1_4.updateFreq = coder.typeof(0,[1 1]); -ARGS_1_4.updatePlotFreq = coder.typeof(0,[1 1]); +ARGS_1_4.updateFreq = coder.typeof(0); +ARGS_1_4.updatePlotFreq = coder.typeof(0); ARGS_1_4.populationSize = coder.typeof(0); ARGS_1_4.fWeight = coder.typeof(0); ARGS_1_4.crossoverProbability = coder.typeof(0); @@ -120,10 +120,10 @@ ARGS_1_4.nMCMC = coder.typeof(0); ARGS_1_4.propScale = coder.typeof(0); ARGS_1_4.nsTolerance = coder.typeof(0); -ARGS_1_4.nSamples = coder.typeof(0,[1 1]); -ARGS_1_4.nChains = coder.typeof(0,[1 1]); -ARGS_1_4.jumpProbability = coder.typeof(0,[1 1]); -ARGS_1_4.pUnitGamma = coder.typeof(0,[1 1]); +ARGS_1_4.nSamples = coder.typeof(0); +ARGS_1_4.nChains = coder.typeof(0); +ARGS_1_4.jumpProbability = coder.typeof(0); +ARGS_1_4.pUnitGamma = coder.typeof(0); ARGS_1_4.boundHandling = coder.typeof('X',[1 maxArraySize],[0 1]); ARGS_1_4.adaptPCR = coder.typeof(true); ARGS_1_4_checks = struct; diff --git a/minimisers/DE/deopt.m b/minimisers/DE/deopt.m index 0c2324698..1f31c0bdc 100644 --- a/minimisers/DE/deopt.m +++ b/minimisers/DE/deopt.m @@ -84,7 +84,7 @@ %-----This is just for notational convenience and to keep the code uncluttered.-------- -coder.varsize('problemStruct.resample',[Inf,1],[1 0]); +coder.varsize('problemStruct.resample',[Inf 1],[1 0]); coder.varsize('FVr_bestmem',[1 Inf],[0 1]); coder.varsize('FVr_bestmemit',[1 Inf],[0 1]); diff --git a/minimisers/DREAM/functions/drawCR.m b/minimisers/DREAM/functions/drawCR.m index b3f40a1a2..d1cb5a2c5 100755 --- a/minimisers/DREAM/functions/drawCR.m +++ b/minimisers/DREAM/functions/drawCR.m @@ -2,7 +2,7 @@ % Generates CR values based on current crossover probabilities CR = [1,1]; - coder.varsize('CR',[1e2,1e6],[1,1]); + coder.varsize('CR',[1e2 1e6],[1,1]); if DREAMPar.adaptPCR diff --git a/minimisers/generalUtils/bayesStats/refPercentileConfidenceIntervals.m b/minimisers/generalUtils/bayesStats/refPercentileConfidenceIntervals.m index 4dead54fe..6152305ea 100644 --- a/minimisers/generalUtils/bayesStats/refPercentileConfidenceIntervals.m +++ b/minimisers/generalUtils/bayesStats/refPercentileConfidenceIntervals.m @@ -29,10 +29,7 @@ numberOfContrasts = problemStruct.numberOfContrasts; vals = zeros(1,3); -coder.varsize('vals',[1e4 1e4],[1 1]); - rowVals = zeros(1,3); -coder.varsize('rowVals',[1 1e4],[0 1]); refXVals = makeCell(numberOfContrasts, 1, rowVals); %cell(numberOfContrasts,1); refYVals = makeCell(numberOfContrasts, 1, vals); %cell(numberOfContrasts,1); diff --git a/targetFunctions/+domainsTF/+customLayers/processCustomFunction.m b/targetFunctions/+domainsTF/+customLayers/processCustomFunction.m index 47cf4e12a..e77a2fdfa 100644 --- a/targetFunctions/+domainsTF/+customLayers/processCustomFunction.m +++ b/targetFunctions/+domainsTF/+customLayers/processCustomFunction.m @@ -5,18 +5,13 @@ % contrasts. % Do some pre-definitions to keep the compiler happy... - %totNumCalcs = numberOfContrasts * 2; - tempResampledLayers = cell(numberOfContrasts,2); resampledLayers = cell(numberOfContrasts,2); subRoughs = zeros(numberOfContrasts,1); for i = 1:numberOfContrasts - resampledLayers{i,1} = [1, 1]; % Type def as double (size not important) - resampledLayers{i,2} = [1, 1]; - tempResampledLayers{i,1} = [0 0 0 0 0]; - tempResampledLayers{i,2} = [0 0 0 0 0]; + resampledLayers{i,1} = [0 0 0 0 0]; + resampledLayers{i,2} = [0 0 0 0 0]; end - coder.varsize('tempResampledLayers{:}',[10000 6],[1 1]); coder.varsize('resampledLayers{:}',[10000 6],[1 1]); bulkOuts = bulkOutArray(contrastBulkOuts); @@ -28,10 +23,10 @@ % Find values of 'bulkIn' and 'bulkOut' for this % contrast... thisContrastLayers1 = [1 1 1]; % typeDef - coder.varsize('thisContrastLayers1',[10000, 6],[1 1]); + coder.varsize('thisContrastLayers1',[10000 6],[1 1]); thisContrastLayers2 = [1 1 1]; % typeDef - coder.varsize('thisContrastLayers2',[10000, 6],[1 1]); + coder.varsize('thisContrastLayers2',[10000 6],[1 1]); thisBulkIn = bulkInArray(contrastBulkIns(i)); thisBulkOut = bulkOuts(i); @@ -55,10 +50,8 @@ thisContrastLayers2 = applyHydrationImag(thisContrastLayers2,thisBulkIn,thisBulkOut); end - tempResampledLayers{i,1} = thisContrastLayers1; - tempResampledLayers{i,2} = thisContrastLayers2; + resampledLayers{i,1} = thisContrastLayers1; + resampledLayers{i,2} = thisContrastLayers2; end - resampledLayers = tempResampledLayers; - end diff --git a/targetFunctions/+domainsTF/+customXY/processCustomFunction.m b/targetFunctions/+domainsTF/+customXY/processCustomFunction.m index e9958a06d..422fa574d 100644 --- a/targetFunctions/+domainsTF/+customXY/processCustomFunction.m +++ b/targetFunctions/+domainsTF/+customXY/processCustomFunction.m @@ -5,17 +5,14 @@ % contrasts. % Do some pre-definitions to keep the compiler happy... - tempSLDs = cell(numberOfContrasts,2); slds = cell(numberOfContrasts,2); subRoughs = zeros(numberOfContrasts,1); for i = 1:numberOfContrasts - slds{i,1} = [1,1]; % Type def as double (size not important) - slds{i,2} = [1,1]; - tempSLDs{i,1} = [0 0]; - tempSLDs{i,2} = [0 0]; + slds{i,1} = [0 0]; + slds{i,2} = [0 0]; end - coder.varsize('tempSLDs{:}',[10000 3],[1 1]); % 3 columns to allow for potential imaginary curve + coder.varsize('slds{:}',[10000 3],[1 1]); % 3 columns to allow for potential imaginary curve bulkOuts = bulkOutArray(contrastBulkOuts); for i = 1:numberOfContrasts % TODO - the ambition is for parfor here, but would fail for Matlab and Python CM's.. @@ -27,13 +24,11 @@ thisBulkIn = bulkInArray(contrastBulkIns(i)); if isnan(str2double(functionHandle)) - [tempSLDs{i, 1}, subRoughs(i)] = callMatlabFunction(functionHandle, params, thisBulkIn, bulkOuts, i, 1); - [tempSLDs{i, 2}, ~] = callMatlabFunction(functionHandle, params, thisBulkIn, bulkOuts, i, 2); + [slds{i, 1}, subRoughs(i)] = callMatlabFunction(functionHandle, params, thisBulkIn, bulkOuts, i, 1); + [slds{i, 2}, ~] = callMatlabFunction(functionHandle, params, thisBulkIn, bulkOuts, i, 2); else - [tempSLDs{i, 1}, subRoughs(i)] = callCppFunction(functionHandle, params, thisBulkIn, bulkOuts, i-1, 0); - [tempSLDs{i, 2}, ~] = callCppFunction(functionHandle, params, thisBulkIn, bulkOuts, i-1, 1); + [slds{i, 1}, subRoughs(i)] = callCppFunction(functionHandle, params, thisBulkIn, bulkOuts, i-1, 0); + [slds{i, 2}, ~] = callCppFunction(functionHandle, params, thisBulkIn, bulkOuts, i-1, 1); end end - - slds = tempSLDs; end diff --git a/targetFunctions/+nonPolarisedTF/+customLayers/processCustomFunction.m b/targetFunctions/+nonPolarisedTF/+customLayers/processCustomFunction.m index 64e77f0b5..5f8df89c4 100644 --- a/targetFunctions/+nonPolarisedTF/+customLayers/processCustomFunction.m +++ b/targetFunctions/+nonPolarisedTF/+customLayers/processCustomFunction.m @@ -5,15 +5,13 @@ % contrasts. % Do some pre-definitions to keep the compiler happy... - tempResampledLayers = cell(numberOfContrasts,1); resampledLayers = cell(numberOfContrasts,1); subRoughs = zeros(numberOfContrasts,1); for i = 1:numberOfContrasts - resampledLayers{i} = [1 , 1]; % Type def as double (size not important) - tempResampledLayers{i} = [0 0 0 0 0]; + resampledLayers{i} = [0 0 0 0 0]; end - coder.varsize('tempResampledLayers{:}',[10000 6],[1 1]); + coder.varsize('resampledLayers{:}',[10000 6],[1 1]); bulkOuts = bulkOutArray(contrastBulkOuts); for i = 1:numberOfContrasts % TODO - the ambition is for parfor here, but would fail for Matlab and Python CM's.. @@ -27,7 +25,7 @@ thisBulkOut = bulkOuts(i); thisContrastLayers = [1 1 1]; % typeDef - coder.varsize('thisContrastLayers',[10000, 6],[1 1]); + coder.varsize('thisContrastLayers',[10000 6],[1 1]); if isnan(str2double(functionHandle)) [thisContrastLayers,subRoughs(i)] = callMatlabFunction(functionHandle, params, thisBulkIn, bulkOuts, i, 0); else @@ -43,9 +41,7 @@ thisContrastLayers = applyHydrationImag(thisContrastLayers,thisBulkIn,thisBulkOut); end - tempResampledLayers{i} = thisContrastLayers; + resampledLayers{i} = thisContrastLayers; end - resampledLayers = tempResampledLayers; - end diff --git a/targetFunctions/+nonPolarisedTF/+customXY/processCustomFunction.m b/targetFunctions/+nonPolarisedTF/+customXY/processCustomFunction.m index 6bcefffab..7222bb98f 100644 --- a/targetFunctions/+nonPolarisedTF/+customXY/processCustomFunction.m +++ b/targetFunctions/+nonPolarisedTF/+customXY/processCustomFunction.m @@ -1,19 +1,17 @@ function [slds,subRoughs] = processCustomFunction(contrastBulkIns,contrastBulkOuts,... - bulkInArray,bulkOutArray,cCustFiles,numberOfContrasts,customFiles,params) + bulkInArray,bulkOutArray,cCustFiles,numberOfContrasts,customFiles,params) % Top-level function for processing custom XY profiles for all the % contrasts. % Do some pre-definitions to keep the compiler happy... - tempSLDs = cell(numberOfContrasts,1); slds = cell(numberOfContrasts,1); subRoughs = zeros(numberOfContrasts,1); for i = 1:numberOfContrasts - slds{i} = [1,1]; % Type def as double (size not important) - tempSLDs{i} = [0 0]; + slds{i} = [0 0]; end - coder.varsize('tempSLDs{:}',[10000 3],[1 1]); % 3 columns to allow for potential imaginary curve + coder.varsize('slds{:}',[10000 3],[1 1]); % 3 columns to allow for potential imaginary curve bulkOuts = bulkOutArray(contrastBulkOuts); for i = 1:numberOfContrasts % TODO - the ambition is for parfor here, but would fail for Matlab and Python CM's.. @@ -26,11 +24,9 @@ thisBulkIn = bulkInArray(contrastBulkIns(i)); if isnan(str2double(functionHandle)) - [tempSLDs{i}, subRoughs(i)] = callMatlabFunction(functionHandle, params, thisBulkIn, bulkOuts, i, 0); + [slds{i}, subRoughs(i)] = callMatlabFunction(functionHandle, params, thisBulkIn, bulkOuts, i, 0); else - [tempSLDs{i}, subRoughs(i)] = callCppFunction(functionHandle, params, thisBulkIn, bulkOuts, i-1, -1); + [slds{i}, subRoughs(i)] = callCppFunction(functionHandle, params, thisBulkIn, bulkOuts, i-1, -1); end end - - slds = tempSLDs; end diff --git a/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m b/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m index c8b21976e..587333e8f 100644 --- a/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m +++ b/targetFunctions/+nonPolarisedTF/coreLayersCalculation.m @@ -48,12 +48,8 @@ % % Pre-definition for Coder -thisSldLaysIm = [0 0]; +sldProfile = [0 0]; sldProfileIm = [0 0]; -coder.varsize('thisSldLays',[10000 3],[1 1]); -coder.varsize('thisSldLaysIm',[10000 3],[1 1]); -coder.varsize('sldProfile',[10000 3],[1 1]); -coder.varsize('sldProfileIm',[10000 3],[1 1]); % Build up the layers matrix for this contrast if ~useImaginary @@ -79,6 +75,7 @@ thisSldLaysIm = [theseLayers(:,1) theseLayers(:,3:end)]; else thisSldLays = theseLayers; + thisSldLaysIm = [0 0]; % Dummy value for coder end sldProfile = makeSLDProfiles(bulkIn,bulkOut,thisSldLays,ssubs,repeatLayers); @@ -90,9 +87,6 @@ % the bulk phases.. sldProfileIm = makeSLDProfiles(0,0,thisSldLaysIm,ssubs,repeatLayers); end - -else - sldProfile = [0 0]; end % If required, then resample the SLD diff --git a/targetFunctions/common/groupLayers/groupLayersMod.m b/targetFunctions/common/groupLayers/groupLayersMod.m index a177ae083..ae4cf4ace 100644 --- a/targetFunctions/common/groupLayers/groupLayersMod.m +++ b/targetFunctions/common/groupLayers/groupLayersMod.m @@ -20,68 +20,54 @@ % * outLayers: cell array of layers param values for each contrast. % * outSsubs: vector of substrate roughness values. -%outLayers = cell(1,numberOfContrasts); -%outSsubs = zeros(1,numberOfContrasts); - - -coder.varsize('layers',[Inf,6],[1 1]); - -%for i = 1:numberOfContrasts - output = resampledLayers; - ssub = subRoughs; - layers = zeros(size(output)); - if ~isempty(output) - if strcmpi(geometry, coderEnums.geometryOptions.AirSubstrate) - layers = output; - %ssub = rsub; - else - roughs = output(:,3); - sldss = output(:,2); - thicks = output(:,1); - rsub = roughs(end); - if length(roughs) > 1 - roughs = [ssub ; roughs(1:end-1)]; - else - roughs = ssub; - end - n = size(output,2); - if n == 5 - cov = output(:,4); - layers = [thicks(:) sldss(:) roughs(:) cov(:)]; - else - layers = [thicks(:) sldss(:) roughs(:)]; - end - ssub = rsub; - end - - %Deal with the %coverage if present - n = size(output,2); - l = size(output,1); - if n == 5 - for j = 1:l - this_pcw = output(j,4); - if output(j,5) == 1 - pc_add = bulkIns; - else - pc_add = bulkOuts; - end - if ~isnan(this_pcw) - layers(j,2) = pc_add*(this_pcw/100) + (1-(this_pcw/100))*layers(j,2); - end +outSsubs = subRoughs; +layers = zeros(size(resampledLayers)); +if ~isempty(resampledLayers) + if strcmpi(geometry, coderEnums.geometryOptions.AirSubstrate) + layers = resampledLayers; + else + roughs = resampledLayers(:,3); + sldss = resampledLayers(:,2); + thicks = resampledLayers(:,1); + rsub = roughs(end); + if length(roughs) > 1 + roughs = [outSsubs ; roughs(1:end-1)]; + else + roughs = outSsubs; + end + n = size(resampledLayers,2); + if n == 5 + cov = resampledLayers(:,4); + layers = [thicks(:) sldss(:) roughs(:) cov(:)]; + else + layers = [thicks(:) sldss(:) roughs(:)]; end - end + outSsubs = rsub; end + + %Deal with the %coverage if present + n = size(resampledLayers,2); + l = size(resampledLayers,1); + if n == 5 + for j = 1:l + this_pcw = resampledLayers(j,4); + if resampledLayers(j,5) == 1 + pc_add = bulkIns; + else + pc_add = bulkOuts; + end + if ~isnan(this_pcw) + layers(j,2) = pc_add*(this_pcw/100) + (1-(this_pcw/100))*layers(j,2); + end + end + end +end if ~isempty(layers) outLayers = layers(:,1:3); else outLayers = zeros(1,3); end -outSsubs = ssub; - end - - -%end \ No newline at end of file diff --git a/targetFunctions/common/groupLayers/groupLayersModImaginary.m b/targetFunctions/common/groupLayers/groupLayersModImaginary.m index 1df9ee2c6..566f61582 100644 --- a/targetFunctions/common/groupLayers/groupLayersModImaginary.m +++ b/targetFunctions/common/groupLayers/groupLayersModImaginary.m @@ -20,69 +20,54 @@ % * outLayers: cell array of layers param values for each contrast. % * outSsubs: vector of substrate roughness values. -%outLayers = cell(1,numberOfContrasts); -%outSsubs = zeros(1,numberOfContrasts); - - -coder.varsize('layers',[Inf,6],[1 1]); - -%for i = 1:numberOfContrasts - output = resampledLayers; - ssub = subRoughs; - layers = zeros(size(output)); - if ~isempty(output) - if strcmpi(geometry, coderEnums.geometryOptions.AirSubstrate) - layers = output; - %ssub = rsub; - else - roughs = output(:,4); - sldss = output(:,2:3); - thicks = output(:,1); - rsub = roughs(end); - if length(roughs) > 1 - roughs = [ssub ; roughs(1:end-1)]; - else - roughs = ssub; - end - n = size(output,2); - if n == 5 - cov = output(:,5); - layers = [thicks sldss roughs cov]; - else - layers = [thicks sldss roughs]; - end - ssub = rsub; - end - - %Deal with the %coverage if present - n = size(output,2); - l = size(output,1); - if n == 6 - for j = 1:l - this_pcw = output(j,5); - if output(j,5) == 1 - pc_add = bulkIns; - else - pc_add = bulkOuts; - end - if ~isnan(this_pcw) - layers(j,2) = pc_add*(this_pcw/100) + (1-(this_pcw/100))*layers(j,2); - %layers(j,3) = pc_add*(this_pcw/100) + (1-(this_pcw/100))*layers(j,3); - end +outSsubs = subRoughs; +layers = zeros(size(resampledLayers)); +if ~isempty(resampledLayers) + if strcmpi(geometry, coderEnums.geometryOptions.AirSubstrate) + layers = resampledLayers; + else + roughs = resampledLayers(:,4); + sldss = resampledLayers(:,2:3); + thicks = resampledLayers(:,1); + rsub = roughs(end); + if length(roughs) > 1 + roughs = [outSsubs ; roughs(1:end-1)]; + else + roughs = outSsubs; + end + n = size(resampledLayers,2); + if n == 5 + cov = resampledLayers(:,5); + layers = [thicks sldss roughs cov]; + else + layers = [thicks sldss roughs]; end - end + outSsubs = rsub; end + + %Deal with the %coverage if present + n = size(resampledLayers,2); + l = size(resampledLayers,1); + if n == 6 + for j = 1:l + this_pcw = resampledLayers(j,5); + if resampledLayers(j,6) == 1 + pc_add = bulkIns; + else + pc_add = bulkOuts; + end + if ~isnan(this_pcw) + layers(j,2) = pc_add*(this_pcw/100) + (1-(this_pcw/100))*layers(j,2); + end + end + end +end if ~isempty(layers) outLayers = layers(:,1:4); else outLayers = zeros(1,4); end -outSsubs = ssub; - end - - -%end \ No newline at end of file diff --git a/targetFunctions/common/resampleLayers/adaptive.m b/targetFunctions/common/resampleLayers/adaptive.m index f10c51f5d..74ee3d395 100644 --- a/targetFunctions/common/resampleLayers/adaptive.m +++ b/targetFunctions/common/resampleLayers/adaptive.m @@ -253,7 +253,6 @@ %dataPoints = [initialDomain(:), func(initialDomain(:))]; dataPoints = [initialDomain(:), hiVal]; -coder.varsize('dataPoints',[Inf Inf],[1 1]); %% Iterative function refinement % if displayWaitbar @@ -424,7 +423,6 @@ noPointsToAdd = numel(segmentsToSplit(segmentsToSplit==true)); newDataPoints = zeros(noPointsToAdd, size(dataPoints,2)); -coder.varsize('newDataPoints',[Inf Inf],[1 1]); newDataPoints(:,1) = 0.5 * (dataPoints([segmentsToSplit;false],1) + ... dataPoints([false;segmentsToSplit],1)); diff --git a/targetFunctions/reflectivityCalculation.m b/targetFunctions/reflectivityCalculation.m index 6c0ab6d48..944356f25 100644 --- a/targetFunctions/reflectivityCalculation.m +++ b/targetFunctions/reflectivityCalculation.m @@ -60,7 +60,6 @@ domainLayerSlds{i,1} = [1 1 1; 1 1 1]; domainLayerSlds{i,2} = [1 1 1; 1 1 1]; end -coder.varsize('domainLayerSlds',[10000 2],[1 0]); coder.varsize('domainLayerSlds{:}',[10000 6],[1 1]); sldProfiles = cell(numberOfContrasts,1); @@ -74,7 +73,6 @@ domainSldProfiles{i,1} = [1 1; 1 1]; domainSldProfiles{i,2} = [1 1; 1 1]; end -coder.varsize('domainSldProfiles',[10000 2],[1 0]); coder.varsize('domainSldProfiles{:}',[10000 2],[1 0]); resampledLayers = cell(numberOfContrasts,1); @@ -88,7 +86,6 @@ domainResampledLayers{i,1} = [1 1 1; 1 1 1]; domainResampledLayers{i,2} = [1 1 1; 1 1 1]; end -coder.varsize('domainResampledLayers',[10000 2],[1 0]); coder.varsize('domainResampledLayers{:}',[10000 3],[1 0]); % Decide which target function we are calling and call the relevant routines