14 std::shared_ptr<CbmLitField> field)
22 std::vector<litfloat>* F) {
29 std::vector<litfloat>* F) {
33 std::vector<litfloat> xOut(6, 0.);
34 std::vector<litfloat> F1(36, 0.);
39 std::vector<litfloat> cOut(21);
46 if (F != NULL) { F->assign(F1.begin(), F1.end()); }
53 std::vector<litfloat>& xOut,
55 std::vector<litfloat>& derivs)
const {
58 litfloat coef[4] = {0.0, 0.5, 0.5, 1.0};
61 litfloat dAx_dtx[4], dAy_dtx[4], dAx_dty[4], dAy_dty[4];
71 litfloat x[5] = {xIn[0], xIn[1], xIn[2], xIn[3], xIn[5]};
73 for (
unsigned int iStep = 0; iStep < 4; iStep++) {
75 for (
unsigned int i = 0;
i < 5;
i++) {
76 x[
i] = xIn[4 ==
i ? 5 :
i] + coef[iStep] * k[
i][iStep - 1];
81 fField->GetFieldValue(
x[0],
x[1], zIn + coef[iStep] *
h, Bx, By, Bz);
90 litfloat txtxtyty1 = 1.0 + txtx + tyty;
94 Ax[iStep] = (txty * Bx + ty * Bz - (1.0 + txtx) * By) * t1;
95 Ay[iStep] = (-txty * By - tx * Bz + (1.0 + tyty) * Bx) * t1;
97 dAx_dtx[iStep] = Ax[iStep] * tx * t2 + (ty * Bx - 2.0 * tx * By) * t1;
98 dAx_dty[iStep] = Ax[iStep] * ty * t2 + (tx * Bx + Bz) * t1;
99 dAy_dtx[iStep] = Ay[iStep] * tx * t2 + (-ty * By - Bz) * t1;
100 dAy_dty[iStep] = Ay[iStep] * ty * t2 + (-tx * By + 2.0 * ty * Bx) * t1;
102 k[0][iStep] = tx *
h;
103 k[1][iStep] = ty *
h;
104 k[2][iStep] = Ax[iStep] * hCqp;
105 k[3][iStep] = Ay[iStep] * hCqp;
109 for (
unsigned int i = 0;
i < 4;
i++) {
113 xOut[5] =
CalcOut(xIn[5], k[4]);
149 for (
unsigned int iStep = 0; iStep < 4; iStep++) {
151 for (
unsigned int i = 0;
i < 5;
i++) {
152 if (
i != 2) {
x[
i] = x0[
i] + coef[iStep] * k[
i][iStep - 1]; }
156 k[0][iStep] =
x[2] *
h;
157 k[1][iStep] =
x[3] *
h;
159 k[3][iStep] = (dAy_dtx[iStep] *
x[2] + dAy_dty[iStep] *
x[3]) * hCqp;
160 k[4][iStep] = (fTx[iStep] *
x[2] + fTy[iStep] *
x[3]) *
h
164 derivs[2] =
CalcOut(x0[0], k[0]);
165 derivs[8] =
CalcOut(x0[1], k[1]);
167 derivs[20] =
CalcOut(x0[3], k[3]);
169 derivs[32] =
CalcOut(x0[4], k[4]);
178 for (
unsigned int iStep = 0; iStep < 4; iStep++) {
180 for (
unsigned int i = 0;
i < 5;
i++) {
181 if (
i != 3) {
x[
i] = x0[
i] + coef[iStep] * k[
i][iStep - 1]; }
185 k[0][iStep] =
x[2] *
h;
186 k[1][iStep] =
x[3] *
h;
187 k[2][iStep] = (dAx_dtx[iStep] *
x[2] + dAx_dty[iStep] *
x[3]) * hCqp;
189 k[4][iStep] = (fTx[iStep] *
x[2] + fTy[iStep] *
x[3]) *
h
193 derivs[3] =
CalcOut(x0[0], k[0]);
194 derivs[9] =
CalcOut(x0[1], k[1]);
195 derivs[15] =
CalcOut(x0[2], k[2]);
198 derivs[33] =
CalcOut(x0[4], k[4]);
207 for (
unsigned int iStep = 0; iStep < 4; iStep++) {
209 for (
unsigned int i = 0;
i < 5;
i++) {
210 x[
i] = x0[
i] + coef[iStep] * k[
i][iStep - 1];
214 k[0][iStep] =
x[2] *
h;
215 k[1][iStep] =
x[3] *
h;
217 Ax[iStep] * hC + hCqp * (dAx_dtx[iStep] *
x[2] + dAx_dty[iStep] *
x[3]);
219 Ay[iStep] * hC + hCqp * (dAy_dtx[iStep] *
x[2] + dAy_dty[iStep] *
x[3]);
220 k[4][iStep] = (fTx[iStep] *
x[2] + fTy[iStep] *
x[3]) *
h
224 derivs[4] =
CalcOut(x0[0], k[0]);
225 derivs[10] =
CalcOut(x0[1], k[1]);
226 derivs[16] =
CalcOut(x0[2], k[2]);
227 derivs[22] =
CalcOut(x0[3], k[3]);
229 derivs[34] =
CalcOut(x0[4], k[4]);
237 return in + k[0] / 6. + k[1] / 3. + k[2] / 3. + k[3] / 6.;
241 const std::vector<litfloat>& rm,
242 std::vector<litfloat>& res) {
243 for (
int i = 0;
i < 6; ++
i) {
244 for (
int j = 0; j < 6; ++j) {
248 for (
int k = 0; k < 6; ++k)
249 r += lm[6 *
i + k] * rm[j + 6 * k];
255 std::vector<litfloat>& res) {
256 for (
int i = 0;
i < 6; ++
i) {
257 for (
int j = 0; j < 6; ++j)
258 res[
i + 6 * j] =
m[6 *
i + j];
263 const std::vector<litfloat>& F,
264 std::vector<litfloat>& cOut)
const {
299 std::vector<litfloat> C(36);
302 for (
int i = 0;
i < 6; ++
i) {
303 for (
int j =
i; j < 6; ++j) {
304 C[6 *
i + j] = cIn[k++];
306 if (
i < j) C[
i + 6 * j] = C[6 *
i + j];
310 std::vector<litfloat> tmp(36);
312 std::vector<litfloat> FT(36);
314 std::vector<litfloat> tmp2(36);
318 for (
int i = 0;
i < 6; ++
i) {
319 for (
int j =
i; j < 6; ++j)
320 cOut[k++] = tmp2[6 *
i + j];