{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcalculate4.cpp
More file actions
214 lines (205 loc) · 9.7 KB
/
Copy pathcalculate4.cpp
File metadata and controls
214 lines (205 loc) · 9.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
//
// Non-Degree Granting Education License -- for use at non-degree
// granting, nonprofit, education, and research organizations only. Not
// for commercial or industrial use.
//
// calculate4.cpp
//
// Code generation for function 'calculate4'
//
// Include files
#include "calculate4.h"
#include "RATMain_internal_types.h"
#include "RATMain_types.h"
#include "parallelContrasts4.h"
#include "parallelPoints4.h"
#include "rt_nonfinite.h"
#include "single4.h"
#include "strcmp.h"
#include "sum.h"
#include "coder_array.h"
#include "coder_bounded_array.h"
// Function Definitions
namespace RAT
{
namespace domainsTF
{
namespace customLayers
{
void calculate(const c_struct_T *problemStruct, const cell_11
*problemCells, const struct2_T *controls, d_struct_T
*contrastParams, ::coder::array<cell_wrap_20, 1U>
&reflectivity, ::coder::array<cell_wrap_20, 1U> &simulation,
::coder::array<cell_wrap_8, 1U> &shiftedData, ::coder::
array<cell_wrap_8, 2U> &layerSlds, ::coder::array<
cell_wrap_8, 2U> &domainSldProfiles, ::coder::array<
cell_wrap_8, 2U> &allLayers)
{
::coder::array<cell_wrap_8, 2U> b_allLayers;
int32_T loop_ub_tmp;
// Custom layers reflectivity calculation for domainsTF
// This function decides on parallelisation options before calling the
// relevant version of the main custom layers calculation. It is more
// efficient to have multiple versions of the core calculation, each dealing
// with a different scheme for parallelisation. These are:
// single - single threaded reflectivity calculation
// points - parallelise over points in the reflectivity calculation
// contrasts - parallelise over contrasts.
// Pre-allocation - It's necessary to
// pre-allocate the memory for all the arrays
// for compilation, so do this in this block.
loop_ub_tmp = static_cast<int32_T>(problemStruct->numberOfContrasts);
contrastParams->ssubs.set_size(loop_ub_tmp);
contrastParams->backgroundParams.set_size(loop_ub_tmp);
contrastParams->qzshifts.set_size(loop_ub_tmp);
contrastParams->scalefactors.set_size(loop_ub_tmp);
contrastParams->bulkIn.set_size(loop_ub_tmp);
contrastParams->bulkOut.set_size(loop_ub_tmp);
contrastParams->calculations.allChis.set_size(loop_ub_tmp);
contrastParams->resolutionParams.set_size(loop_ub_tmp);
contrastParams->allSubRough.set_size(loop_ub_tmp);
reflectivity.set_size(loop_ub_tmp);
simulation.set_size(loop_ub_tmp);
shiftedData.set_size(loop_ub_tmp);
layerSlds.set_size(loop_ub_tmp, 2);
domainSldProfiles.set_size(loop_ub_tmp, 2);
allLayers.set_size(loop_ub_tmp, 2);
for (int32_T i{0}; i < loop_ub_tmp; i++) {
contrastParams->ssubs[i] = 0.0;
contrastParams->backgroundParams[i] = 0.0;
contrastParams->qzshifts[i] = 0.0;
contrastParams->scalefactors[i] = 0.0;
contrastParams->bulkIn[i] = 0.0;
contrastParams->bulkOut[i] = 0.0;
contrastParams->calculations.allChis[i] = 0.0;
contrastParams->resolutionParams[i] = 0.0;
contrastParams->allSubRough[i] = 0.0;
reflectivity[i].f1.set_size(2, 2);
reflectivity[i].f1[0] = 1.0;
reflectivity[i].f1[1] = 1.0;
reflectivity[i].f1[reflectivity[i].f1.size(0)] = 1.0;
reflectivity[i].f1[reflectivity[i].f1.size(0) + 1] = 1.0;
simulation[i].f1.set_size(2, 2);
simulation[i].f1[0] = 1.0;
simulation[i].f1[1] = 1.0;
simulation[i].f1[simulation[i].f1.size(0)] = 1.0;
simulation[i].f1[simulation[i].f1.size(0) + 1] = 1.0;
shiftedData[i].f1.set_size(2, 3);
layerSlds[i].f1.set_size(2, 3);
layerSlds[i + layerSlds.size(0)].f1.set_size(2, 3);
domainSldProfiles[i].f1.set_size(2, 2);
domainSldProfiles[i + domainSldProfiles.size(0)].f1.set_size(2, 2);
domainSldProfiles[i].f1[0] = 1.0;
domainSldProfiles[i + domainSldProfiles.size(0)].f1[0] = 1.0;
domainSldProfiles[i].f1[1] = 1.0;
domainSldProfiles[i + domainSldProfiles.size(0)].f1[1] = 1.0;
domainSldProfiles[i].f1[domainSldProfiles[i].f1.size(0)] = 1.0;
domainSldProfiles[i + domainSldProfiles.size(0)]
.f1[domainSldProfiles[i + domainSldProfiles.size(0)].f1.size(0)] =
1.0;
domainSldProfiles[i].f1[domainSldProfiles[i].f1.size(0) + 1] = 1.0;
domainSldProfiles[i + domainSldProfiles.size(0)]
.f1[domainSldProfiles[i + domainSldProfiles.size(0)].f1.size(0) + 1]
= 1.0;
allLayers[i].f1.set_size(2, 3);
allLayers[i + allLayers.size(0)].f1.set_size(2, 3);
for (int32_T b_i{0}; b_i < 3; b_i++) {
shiftedData[i].f1[shiftedData[i].f1.size(0) * b_i] = 1.0;
shiftedData[i].f1[shiftedData[i].f1.size(0) * b_i + 1] = 1.0;
layerSlds[i].f1[layerSlds[i].f1.size(0) * b_i] = 1.0;
layerSlds[i + layerSlds.size(0)].f1[layerSlds[i + layerSlds.size(0)]
.f1.size(0) * b_i] = 1.0;
layerSlds[i].f1[layerSlds[i].f1.size(0) * b_i + 1] = 1.0;
layerSlds[i + layerSlds.size(0)].f1[layerSlds[i + layerSlds.size(0)]
.f1.size(0) * b_i + 1] = 1.0;
allLayers[i].f1[allLayers[i].f1.size(0) * b_i] = 1.0;
allLayers[i + allLayers.size(0)].f1[allLayers[i + allLayers.size(0)]
.f1.size(0) * b_i] = 1.0;
allLayers[i].f1[allLayers[i].f1.size(0) * b_i + 1] = 1.0;
allLayers[i + allLayers.size(0)].f1[allLayers[i + allLayers.size(0)]
.f1.size(0) * b_i + 1] = 1.0;
}
}
// End pre-allocation
if (coder::internal::n_strcmp(controls->parallel.data,
controls->parallel.size)) {
loop_ub_tmp = 0;
} else if (coder::internal::o_strcmp(controls->parallel.data,
controls->parallel.size)) {
loop_ub_tmp = 1;
} else if (coder::internal::p_strcmp(controls->parallel.data,
controls->parallel.size)) {
loop_ub_tmp = 2;
} else {
loop_ub_tmp = -1;
}
switch (loop_ub_tmp) {
case 0:
b_single(problemStruct, problemCells, controls, contrastParams->ssubs,
contrastParams->backgroundParams, contrastParams->qzshifts,
contrastParams->scalefactors, contrastParams->bulkIn,
contrastParams->bulkOut, contrastParams->resolutionParams,
contrastParams->calculations.allChis, reflectivity,
simulation, shiftedData, layerSlds, domainSldProfiles,
b_allLayers, contrastParams->allSubRough);
allLayers.set_size(b_allLayers.size(0), 2);
loop_ub_tmp = b_allLayers.size(0);
for (int32_T b_i{0}; b_i < 2; b_i++) {
for (int32_T i1{0}; i1 < loop_ub_tmp; i1++) {
allLayers[i1 + allLayers.size(0) * b_i] = b_allLayers[i1 +
b_allLayers.size(0) * b_i];
}
}
break;
case 1:
parallelPoints(problemStruct, problemCells, controls,
contrastParams->ssubs, contrastParams->backgroundParams,
contrastParams->qzshifts, contrastParams->scalefactors,
contrastParams->bulkIn, contrastParams->bulkOut,
contrastParams->resolutionParams,
contrastParams->calculations.allChis, reflectivity,
simulation, shiftedData, layerSlds, domainSldProfiles,
b_allLayers, contrastParams->allSubRough);
allLayers.set_size(b_allLayers.size(0), 2);
loop_ub_tmp = b_allLayers.size(0);
for (int32_T b_i{0}; b_i < 2; b_i++) {
for (int32_T i1{0}; i1 < loop_ub_tmp; i1++) {
allLayers[i1 + allLayers.size(0) * b_i] = b_allLayers[i1 +
b_allLayers.size(0) * b_i];
}
}
break;
case 2:
c_parallelContrasts(problemStruct, problemCells, controls,
contrastParams->ssubs,
contrastParams->backgroundParams,
contrastParams->qzshifts,
contrastParams->scalefactors,
contrastParams->bulkIn, contrastParams->bulkOut,
contrastParams->resolutionParams,
contrastParams->calculations.allChis, reflectivity,
simulation, shiftedData, layerSlds,
domainSldProfiles, b_allLayers,
contrastParams->allSubRough);
allLayers.set_size(b_allLayers.size(0), 2);
loop_ub_tmp = b_allLayers.size(0);
for (int32_T b_i{0}; b_i < 2; b_i++) {
for (int32_T i1{0}; i1 < loop_ub_tmp; i1++) {
allLayers[i1 + allLayers.size(0) * b_i] = b_allLayers[i1 +
b_allLayers.size(0) * b_i];
}
}
break;
}
contrastParams->calculations.sumChi = coder::sum
(contrastParams->calculations.allChis);
contrastParams->resample.set_size(1, problemStruct->resample.size(1));
loop_ub_tmp = problemStruct->resample.size(1);
for (int32_T b_i{0}; b_i < loop_ub_tmp; b_i++) {
contrastParams->resample[b_i] = problemStruct->resample[b_i];
}
}
}
}
}
// End of code generation (calculate4.cpp)
You can’t perform that action at this time.
