00001
00010 #ifndef BS_MAIN_LOOP_GENERATE_NUMERIC_JACOBIAN_H_
00011 #define BS_MAIN_LOOP_GENERATE_NUMERIC_JACOBIAN_H_
00012
00013 #include "string_formater.h"
00014
00015 namespace blue_sky
00016 {
00017
00018 namespace xxx
00019 {
00020
00021 template <typename strategy_t>
00022 struct clmn_holder
00023 {
00024 typedef typename strategy_t::index_t index_t;
00025 typedef typename strategy_t::item_t item_t;
00026
00027 typedef typename strategy_t::item_array_t item_array_t;
00028
00029 clmn_holder (item_array_t &dst, index_t index, index_t shift, index_t block)
00030 : dst (dst)
00031 , index (index)
00032 , shift (shift)
00033 , block (block)
00034 {
00035 }
00036
00037 template <typename op_t>
00038 clmn_holder <strategy_t> &
00039 operator-= (const op_t &op)
00040 {
00041 index_t idx = 0;
00042 for (index_t i = 0, cnt = (index_t)op.size (), clmn_count = (index_t)op.size () / block; i < clmn_count; ++i)
00043 {
00044 index_t i_idx = index * block * block + shift + i * clmn_count * block * block;
00045 for (index_t j = 0, k = 0; j < block; ++j, ++idx, k += block)
00046 {
00047 dst [i_idx + k] -= op[idx];
00048 }
00049 }
00050
00051 return *this;
00052 }
00053
00054 item_array_t &dst;
00055 index_t index;
00056 index_t shift;
00057 index_t block;
00058 };
00059
00060 template <typename array_t>
00061 struct clmn_sub
00062 {
00063 clmn_sub (const array_t &lhs, const array_t &rhs)
00064 : lhs (lhs)
00065 , rhs (rhs)
00066 {
00067 }
00068
00069 size_t
00070 size () const
00071 {
00072 return lhs.size ();
00073 }
00074
00075 typedef typename array_t::value_type value_type;
00076 value_type
00077 operator[] (size_t i) const
00078 {
00079 return lhs[i] - rhs[i];
00080 }
00081
00082 const array_t &lhs;
00083 const array_t &rhs;
00084 };
00085
00086 template <typename lhs_t>
00087 struct clmn_sub_div
00088 {
00089 typedef typename lhs_t::value_type value_type;
00090
00091 clmn_sub_div (const lhs_t &lhs, value_type scalar)
00092 : lhs (lhs)
00093 , scalar (scalar)
00094 {
00095 }
00096
00097 size_t
00098 size () const
00099 {
00100 return lhs.size ();
00101 }
00102
00103 value_type
00104 operator[] (size_t i) const
00105 {
00106 return lhs[i] / scalar;
00107 }
00108
00109 const lhs_t &lhs;
00110 value_type scalar;
00111 };
00112 template <typename lhs_t>
00113 struct clmn_sub_div_mul
00114 {
00115 typedef typename lhs_t::value_type value_type;
00116
00117 clmn_sub_div_mul (const lhs_t &lhs, value_type scalar)
00118 : lhs (lhs)
00119 , scalar (scalar)
00120 {
00121 }
00122
00123 size_t
00124 size () const
00125 {
00126 return lhs.size ();
00127 }
00128
00129 value_type
00130 operator[] (size_t i) const
00131 {
00132 return lhs[i] * scalar;
00133 }
00134
00135 const lhs_t &lhs;
00136 value_type scalar;
00137 };
00138
00139 template <typename array_t>
00140 clmn_sub <array_t>
00141 operator- (const array_t &lhs, const array_t &rhs)
00142 {
00143 return clmn_sub <array_t> (lhs, rhs);
00144 }
00145 template <typename lhs_t, typename item_t>
00146 clmn_sub_div <lhs_t>
00147 operator/ (const lhs_t &lhs, const item_t &scalar)
00148 {
00149 return clmn_sub_div <lhs_t> (lhs, scalar);
00150 }
00151 template <typename lhs_t, typename item_t>
00152 clmn_sub_div_mul <lhs_t>
00153 operator* (const lhs_t &lhs, const item_t &scalar)
00154 {
00155 return clmn_sub_div_mul <lhs_t> (lhs, scalar);
00156 }
00157 }
00158
00159
00160 template <typename strategy_t, bool is_w, bool is_g, bool is_o>
00161 inline void
00162 main_loop_calc <strategy_t, is_w, is_g, is_o>::generate_numeric_jacobian (int )
00163 {
00164 throw bs_exception ("generate_numeric_jacobian", "NOT IMPL YET");
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 #ifdef _DEBUG
00199
00200 #endif
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 }
00256
00257 }
00258
00259 #endif // #ifndef BS_MAIN_LOOP_GENERATE_NUMERIC_JACOBIAN_H_
00260