17 #if 0 // use lookUpTable rather than polinom aproximation
22 vector<float> bX, bY, bZ;
23 float xMin, yMin,
dx,
dy;
26 void GetBBin(
float x,
float y,
float &bX_,
float &bY_,
float &bZ_ )
const {
27 int iXBin =
static_cast<int>((x - xMin)/dx);
28 int iYBin =
static_cast<int>((y - yMin)/dy);
29 iXBin =
min( iXBin, nXBins-1 );
30 iXBin =
max( 0, iXBin );
31 iYBin =
min( iYBin, nYBins-1 );
32 iYBin =
max( 0, iYBin );
33 const int iBin = iXBin*nYBins + iYBin;
39 void AlocateMemory() {
40 const int NBins = nXBins*nYBins;
53 foreach_bit(
int iV, mask ) {
54 GetBBin( x[iV], y[iV], bX_, bY_, bZ_ );
98 B.x(mask) = cx[0] +cx[1]*x +cx[2]*y +cx[3]*x2 +cx[4]*xy +cx[5]*y2 +cx[6]*x3 +cx[7]*x2y +cx[8]*xy2 +cx[9]*y3
99 +cx[10]*x4 +cx[11]*x3y +cx[12]*x2y2 +cx[13]*xy3 +cx[14]*y4
100 +cx[15]*x5 +cx[16]*x4y +cx[17]*x3y2 +cx[18]*x2y3 +cx[19]*xy4 +cx[20]*y5;
102 B.y(mask) = cy[0] +cy[1]*x +cy[2]*y +cy[3]*x2 +cy[4]*xy +cy[5]*y2 +cy[6]*x3 +cy[7]*x2y +cy[8]*xy2 +cy[9]*y3
103 +cy[10]*x4 +cy[11]*x3y +cy[12]*x2y2 +cy[13]*xy3 +cy[14]*y4
104 +cy[15]*x5 +cy[16]*x4y +cy[17]*x3y2 +cy[18]*x2y3 +cy[19]*xy4 +cy[20]*y5;
106 B.z(mask) = cz[0] +cz[1]*x +cz[2]*y +cz[3]*x2 +cz[4]*xy +cz[5]*y2 +cz[6]*x3 +cz[7]*x2y +cz[8]*xy2 +cz[9]*y3
107 +cz[10]*x4 +cz[11]*x3y +cz[12]*x2y2 +cz[13]*xy3 +cz[14]*y4
108 +cz[15]*x5 +cz[16]*x4y +cz[17]*x3y2 +cz[18]*x2y3 +cz[19]*xy4 +cz[20]*y5;
141 B.x = cx0 + cx1*dz + cx2*dz2;
142 B.y = cy0 + cy1*dz + cy2*dz2;
143 B.z = cz0 + cz1*dz + cz2*dz2;
152 float_v dz1 = B1z-B0z, dz2 = B2z-B0z;
154 float_v deti = dz1*dz2*(dz2-dz1);
155 float_m mask = abs(deti) > float_v(1.e-8
f);
157 float_v det =
rcp(float_v(dz1*dz2*(dz2-dz1)));
158 float_v w21 = -dz2*det;
159 float_v w22 = dz1*det;
160 float_v w11 = -dz2*w21;
161 float_v w12 = -dz1*w22;
163 float_v dB1 = B1.x - B0.x;
164 float_v dB2 = B2.x - B0.x;
166 cx1(mask) = dB1*w11 + dB2*w12 ;
167 cx2(mask) = dB1*w21 + dB2*w22 ;
172 cy1(mask) = dB1*w11 + dB2*w12 ;
173 cy2(mask) = dB1*w21 + dB2*w22 ;
178 cz1(mask) = dB1*w11 + dB2*w12 ;
179 cz2(mask) = dB1*w21 + dB2*w22;
186 float_v dzi =
rcp(float_v( B1z - B0z));
190 cx1 = ( B1.x - B0.x )*dzi;
191 cy1 = ( B1.y - B0.y )*dzi;
192 cz1 = ( B1.z - B0.z )*dzi;
199 float_v cx2dz = cx2*
dz;
200 float_v cy2dz = cy2*
dz;
201 float_v cz2dz = cz2*
dz;
203 cx0+= ( cx1 + cx2dz )*dz;
204 cy0+= ( cy1 + cy2dz )*dz;
205 cz0+= ( cz1 + cz2dz )*dz;
213 cx0[i0] = f1.
cx0[i1];
214 cx1[i0] = f1.
cx1[i1];
215 cx2[i0] = f1.
cx2[i1];
216 cy0[i0] = f1.
cy0[i1];
217 cy1[i0] = f1.
cy1[i1];
218 cy2[i0] = f1.
cy2[i1];
219 cz0[i0] = f1.
cz0[i1];
220 cz1[i0] = f1.
cz1[i1];
221 cz2[i0] = f1.
cz2[i1];
254 return out <<
" FieldRegion " << endl <<
255 B.
cx0 << endl << B.
cx1 << endl << B.
cx2 << endl <<
256 B.
cy0 << endl << B.
cy1 << endl << B.
cy2 << endl <<
257 B.
cz0 << endl << B.
cz1 << endl << B.
cz2 << endl <<
void Set(const CAFieldValue &B0, const float_v B0z, const CAFieldValue &B1, const float_v B1z)
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
friend ostream & operator<<(ostream &out, L1FieldRegion &B)
void GetFieldValue(const float_v &x, const float_v &y, CAFieldValue &B, const float_m &mask=float_m(true)) const
basic_ostream< char, char_traits< char > > ostream
void GetOneEntry(float reg[10], const int iVec)
L1FieldRegion(float reg[10])
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
void Set(const CAFieldValue &B0, const float_v B0z, const CAFieldValue &B1, const float_v B1z, const CAFieldValue &B2, const float_v B2z)
void SetOneEntry(const L1FieldRegion &f1, const int i1)
CAFieldValue Get(const float_v z)
void SetOneEntry(const int i0, const L1FieldRegion &f1, const int i1)