@@ -39,18 +39,25 @@ namespace Splines {
3939
4040 real_type
4141 BilinearSpline::eval ( real_type x, real_type y ) const {
42- integer const i { this ->search_x ( x ) };
43- integer const j { this ->search_y ( y ) };
42+ std::pair<integer,real_type> X (0 ,x), Y (0 ,y);
43+
44+ m_search_x.find ( X );
45+ m_search_y.find ( Y );
46+
47+ integer const i { X.first };
48+ integer const j { Y.first };
4449 real_type const DX { m_X[i+1 ] - m_X[i] };
4550 real_type const DY { m_Y[j+1 ] - m_Y[j] };
46- real_type const u { (x -m_X[i])/DX };
47- real_type const v { (y -m_Y[j])/DY };
51+ real_type const u { (X. second -m_X[i])/DX };
52+ real_type const v { (Y. second -m_Y[j])/DY };
4853 real_type const u1 { 1 -u };
4954 real_type const v1 { 1 -v };
50- real_type const Z00 { m_Z[this ->ipos_C (i,j)] };
51- real_type const Z01 { m_Z[this ->ipos_C (i,j+1 )] };
52- real_type const Z10 { m_Z[this ->ipos_C (i+1 ,j)] };
53- real_type const Z11 { m_Z[this ->ipos_C (i+1 ,j+1 )] };
55+
56+ real_type const Z00 { m_Z[ipos_C (i,j)] };
57+ real_type const Z01 { m_Z[ipos_C (i,j+1 )] };
58+ real_type const Z10 { m_Z[ipos_C (i+1 ,j)] };
59+ real_type const Z11 { m_Z[ipos_C (i+1 ,j+1 )] };
60+
5461 return u1 * ( Z00 * v1 + Z01 * v ) +
5562 u * ( Z10 * v1 + Z11 * v );
5663 }
@@ -59,11 +66,18 @@ namespace Splines {
5966
6067 real_type
6168 BilinearSpline::Dx ( real_type x, real_type y ) const {
62- integer const i { this ->search_x ( x ) };
63- integer const j { this ->search_y ( y ) };
69+ std::pair<integer,real_type> X (0 ,x), Y (0 ,y);
70+
71+ m_search_x.find ( X );
72+ m_search_y.find ( Y );
73+
74+ integer const i { X.first };
75+ integer const j { Y.first };
76+
6477 real_type const DX { m_X[i+1 ] - m_X[i] };
6578 real_type const DY { m_Y[j+1 ] - m_Y[j] };
66- real_type const v { (y-m_Y[j])/DY };
79+ real_type const v { (Y.second -m_Y[j])/DY };
80+
6781 real_type const Z00 { m_Z[ipos_C (i,j)] };
6882 real_type const Z01 { m_Z[ipos_C (i,j+1 )] };
6983 real_type const Z10 { m_Z[ipos_C (i+1 ,j)] };
@@ -75,11 +89,18 @@ namespace Splines {
7589
7690 real_type
7791 BilinearSpline::Dy ( real_type x, real_type y ) const {
78- integer const i { this ->search_x ( x ) };
79- integer const j { this ->search_y ( y ) };
92+ std::pair<integer,real_type> X (0 ,x), Y (0 ,y);
93+
94+ m_search_x.find ( X );
95+ m_search_y.find ( Y );
96+
97+ integer const i { X.first };
98+ integer const j { Y.first };
99+
80100 real_type const DX { m_X[i+1 ] - m_X[i] };
81101 real_type const DY { m_Y[j+1 ] - m_Y[j] };
82- real_type const u { (x-m_X[i])/DX };
102+ real_type const u { (X.second -m_X[i])/DX };
103+
83104 real_type const Z00 { m_Z[ipos_C (i,j)] };
84105 real_type const Z01 { m_Z[ipos_C (i,j+1 )] };
85106 real_type const Z10 { m_Z[ipos_C (i+1 ,j)] };
@@ -91,18 +112,27 @@ namespace Splines {
91112
92113 void
93114 BilinearSpline::D ( real_type x, real_type y, real_type d[3 ] ) const {
94- integer const i { this ->search_x ( x ) };
95- integer const j { this ->search_y ( y ) };
115+ std::pair<integer,real_type> X (0 ,x), Y (0 ,y);
116+
117+ m_search_x.find ( X );
118+ m_search_y.find ( Y );
119+
120+ integer const i { X.first };
121+ integer const j { Y.first };
122+
96123 real_type const DX { m_X[i+1 ] - m_X[i] };
97124 real_type const DY { m_Y[j+1 ] - m_Y[j] };
98- real_type const u { (x-m_X[i])/DX };
99- real_type const v { (y-m_Y[j])/DY };
125+
126+ real_type const u { (X.second -m_X[i])/DX };
127+ real_type const v { (Y.second -m_Y[j])/DY };
100128 real_type const u1 { 1 -u };
101129 real_type const v1 { 1 -v };
130+
102131 real_type const Z00 { m_Z[this ->ipos_C (i,j)] };
103132 real_type const Z01 { m_Z[this ->ipos_C (i,j+1 )] };
104133 real_type const Z10 { m_Z[this ->ipos_C (i+1 ,j)] };
105134 real_type const Z11 { m_Z[this ->ipos_C (i+1 ,j+1 )] };
135+
106136 d[0 ] = u1 * ( Z00 * v1 + Z01 * v ) + u * ( Z10 * v1 + Z11 * v );
107137 d[1 ] = v1 * (Z10-Z00) + v * (Z11-Z01); d[1 ] /= DX;
108138 d[2 ] = u1 * (Z01-Z00) + u * (Z11-Z10); d[2 ] /= DY;
0 commit comments