1 /* 2 //////////////////////////////////////////////////////////////////////////////////// 3 // 4 // Prototypes and definitions for the Levenberg - Marquardt minimization algorithm 5 // Copyright (C) 2004 Manolis Lourakis (lourakis at ics forth gr) 6 // Institute of Computer Science, Foundation for Research & Technology - Hellas 7 // Heraklion, Crete, Greece. 8 // 9 // This program is free software; you can redistribute it and/or modify 10 // it under the terms of the GNU General Public License as published by 11 // the Free Software Foundation; either version 2 of the License, or 12 // (at your option) any later version. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 //////////////////////////////////////////////////////////////////////////////////// 20 */ 21 22 module dlevmar; 23 24 extern(C) 25 { 26 alias DLevmarCallback = void function( 27 double* p, 28 double* hx, 29 int m, 30 int n, 31 void* adata 32 ); 33 34 alias DLevmarJacobian = void function( 35 double* p, 36 double* j, 37 int m, 38 int n, 39 void* adata 40 ); 41 42 /+ - unconstrained minimization - +/ 43 44 int dlevmar_der( 45 DLevmarCallback func, 46 DLevmarJacobian jacf, 47 double* p, 48 double* x, 49 int m, 50 int n, 51 int itmax, 52 double* opts, 53 double* info, 54 double* work, 55 double* covar, 56 void* adata 57 ); 58 59 int dlevmar_dif( 60 DLevmarCallback func, 61 double* p, 62 double* x, 63 int m, 64 int n, 65 int itmax, 66 double* opts, 67 double* info, 68 double* work, 69 double* covar, 70 void* adata 71 ); 72 73 /+ - box-constrained minimization - +/ 74 75 int dlevmar_bc_der( 76 DLevmarCallback func, 77 DLevmarJacobian jacf, 78 double* p, 79 double* x, 80 int m, 81 int n, 82 double* lb, 83 double* ub, 84 double* dscl, 85 int itmax, 86 double* opts, 87 double* info, 88 double* work, 89 double* covar, 90 void* adata 91 ); 92 93 int dlevmar_bc_dif( 94 DLevmarCallback func, 95 double* p, 96 double* x, 97 int m, 98 int n, 99 double* lb, 100 double* ub, 101 double* dscl, 102 int itmax, 103 double* opts, 104 double* info, 105 double* work, 106 double* covar, 107 void* adata 108 ); 109 110 /+ - linear equation constrained minimization - +/ 111 112 int dlevmar_lec_der( 113 DLevmarCallback func, 114 DLevmarJacobian jacf, 115 double* p, 116 double* x, 117 int m, 118 int n, 119 double* A, 120 double* b, 121 int k, 122 int itmax, 123 double* opts, 124 double* info, 125 double* work, 126 double* covar, 127 void* adata 128 ); 129 130 int dlevmar_lec_dif( 131 DLevmarCallback func, 132 double* p, 133 double* x, 134 int m, 135 int n, 136 double* A, 137 double* b, 138 int k, 139 int itmax, 140 double* opts, 141 double* info, 142 double* work, 143 double* covar, 144 void* adata 145 ); 146 147 /+ - box & linear equation constrained minimization - +/ 148 149 int dlevmar_blec_der( 150 DLevmarCallback func, 151 DLevmarJacobian jacf, 152 double* p, 153 double* x, 154 int m, 155 int n, 156 double* lb, 157 double* ub, 158 double* A, 159 double* b, 160 int k, 161 double* wghts, 162 int itmax, 163 double* opts, 164 double* info, 165 double* work, 166 double* covar, 167 void* adata 168 ); 169 170 int dlevmar_blec_dif( 171 DLevmarCallback func, 172 double* p, 173 double* x, 174 int m, 175 int n, 176 double* lb, 177 double* ub, 178 double* A, 179 double* b, 180 int k, 181 double* wghts, 182 int itmax, 183 double* opts, 184 double* info, 185 double* work, 186 double* covar, 187 void* adata 188 ); 189 190 /+ - box, linear equations & inequalities constrained minimization - +/ 191 192 int dlevmar_bleic_der( 193 DLevmarCallback func, 194 DLevmarJacobian jacf, 195 double* p, 196 double* x, 197 int m, 198 int n, 199 double* lb, 200 double* ub, 201 double* A, 202 double* b, 203 int k1, 204 double* C, 205 double* d, 206 int k2, 207 int itmax, 208 double* opts, 209 double* info, 210 double* work, 211 double* covar, 212 void* adata 213 ); 214 215 int dlevmar_bleic_dif( 216 DLevmarCallback func, 217 double* p, 218 double* x, 219 int m, 220 int n, 221 double* lb, 222 double* ub, 223 double* A, 224 double* b, 225 int k1, 226 double* C, 227 double* d, 228 int k2, 229 int itmax, 230 double* opts, 231 double* info, 232 double* work, 233 double* covar, 234 void* adata 235 ); 236 237 /+ - box & linear inequality constraints - +/ 238 239 int dlevmar_blic_der( 240 DLevmarCallback func, 241 DLevmarJacobian jacf, 242 double* p, 243 double* x, 244 int m, 245 int n, 246 double* lb, 247 double* ub, 248 double* C, 249 double* d, 250 int k2, 251 int itmax, 252 double* opts, 253 double* info, 254 double* work, 255 double* covar, 256 void* adata 257 ); 258 259 int dlevmar_blic_dif( 260 DLevmarCallback func, 261 double* p, 262 double* x, 263 int m, 264 int n, 265 double* lb, 266 double* ub, 267 double* C, 268 double* d, 269 int k2, 270 int itmax, 271 double* opts, 272 double* info, 273 double* work, 274 double* covar, 275 void* adata 276 ); 277 278 /+ - linear equation & inequality constraints - +/ 279 280 int dlevmar_leic_der( 281 DLevmarCallback func, 282 DLevmarJacobian jacf, 283 double* p, 284 double* x, 285 int m, 286 int n, 287 double* A, 288 double* b, 289 int k1, 290 double* C, 291 double* d, 292 int k2, 293 int itmax, 294 double* opts, 295 double* info, 296 double* work, 297 double* covar, 298 void* adata 299 ); 300 301 int dlevmar_leic_dif( 302 DLevmarCallback func, 303 double* p, 304 double* x, 305 int m, 306 int n, 307 double* A, 308 double* b, 309 int k1, 310 double* C, 311 double* d, 312 int k2, 313 int itmax, 314 double* opts, 315 double* info, 316 double* work, 317 double* covar, 318 void* adata 319 ); 320 321 /+ - linear inequality constraints - +/ 322 323 int dlevmar_lic_der( 324 DLevmarCallback func, 325 DLevmarJacobian jacf, 326 double* p, 327 double* x, 328 int m, 329 int n, 330 double* C, 331 double* d, 332 int k2, 333 int itmax, 334 double* opts, 335 double* info, 336 double* work, 337 double* covar, 338 void* adata 339 ); 340 341 int dlevmar_lic_dif( 342 DLevmarCallback func, 343 double* p, 344 double* x, 345 int m, 346 int n, 347 double* C, 348 double* d, 349 int k2, 350 int itmax, 351 double* opts, 352 double* info, 353 double* work, 354 double* covar, 355 void* adata 356 ); 357 358 /+ - linear system solvers - +/ 359 360 int dAx_eq_b_QR(double* A, double* B, double* x, int m); 361 362 int dAx_eq_b_QRLS(double* A, double* B, double* x, int m, int n); 363 364 int dAx_eq_b_Chol(double* A, double* B, double* x, int m); 365 366 int dAx_eq_b_LU(double* A, double* B, double* x, int m); 367 368 int dAx_eq_b_SVD(double* A, double* B, double* x, int m); 369 370 int dAx_eq_b_BK(double* A, double* B, double* x, int m); 371 372 int dAx_eq_b_LU_noLapack(double* A, double* B, double* x, int n); 373 374 int dAx_eq_b_PLASMA_Chol(double* A, double* B, double* x, int m); 375 376 /+ - Jacobian verification - +/ 377 378 void dlevmar_chkjac( 379 DLevmarCallback func, 380 DLevmarJacobian jacf, 381 double* p, 382 int m, 383 int n, 384 void* adata, 385 double* err 386 ); 387 388 /+ miscellaneous: standard deviation, coefficient of determination (R2), 389 + Pearson's correlation coefficient for best-fit parameters 390 +/ 391 392 double dlevmar_stddev(double* covar, int m, int i); 393 double dlevmar_corcoef(double* covar, int m, int i, int j); 394 395 double dlevmar_R2( 396 DLevmarCallback func, 397 double* p, 398 double* x, 399 int m, 400 int n, 401 void* adata 402 ); 403 }