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 slevmar; 23 24 extern(C) 25 { 26 alias SLevmarCallback = void function( 27 float* p, 28 float* hx, 29 int m, 30 int n, 31 void* adata 32 ); 33 34 alias SLevmarJacobian = void function( 35 float* p, 36 float* j, 37 int m, 38 int n, 39 void* adata 40 ); 41 42 /+ - unconstrained minimization - +/ 43 44 int slevmar_der( 45 SLevmarCallback func, 46 SLevmarJacobian jacf, 47 float* p, 48 float* x, 49 int m, 50 int n, 51 int itmax, 52 float* opts, 53 float* info, 54 float* work, 55 float* covar, 56 void* adata 57 ); 58 59 int slevmar_dif( 60 SLevmarCallback func, 61 float* p, 62 float* x, 63 int m, 64 int n, 65 int itmax, 66 float* opts, 67 float* info, 68 float* work, 69 float* covar, 70 void* adata 71 ); 72 73 /+ - box-constrained minimization - +/ 74 75 int slevmar_bc_der( 76 SLevmarCallback func, 77 SLevmarJacobian jacf, 78 float* p, 79 float* x, 80 int m, 81 int n, 82 float* lb, 83 float* ub, 84 float* dscl, 85 int itmax, 86 float* opts, 87 float* info, 88 float* work, 89 float* covar, 90 void* adata 91 ); 92 93 int slevmar_bc_dif( 94 SLevmarCallback func, 95 float* p, 96 float* x, 97 int m, 98 int n, 99 float* lb, 100 float* ub, 101 float* dscl, 102 int itmax, 103 float* opts, 104 float* info, 105 float* work, 106 float* covar, 107 void* adata 108 ); 109 110 /+ - linear equation constrained minimization - +/ 111 112 int slevmar_lec_der( 113 SLevmarCallback func, 114 SLevmarJacobian jacf, 115 float* p, 116 float* x, 117 int m, 118 int n, 119 float* A, 120 float* b, 121 int k, 122 int itmax, 123 float* opts, 124 float* info, 125 float* work, 126 float* covar, 127 void* adata 128 ); 129 130 int slevmar_lec_dif( 131 SLevmarCallback func, 132 float* p, 133 float* x, 134 int m, 135 int n, 136 float* A, 137 float* b, 138 int k, 139 int itmax, 140 float* opts, 141 float* info, 142 float* work, 143 float* covar, 144 void* adata 145 ); 146 147 /+ - box & linear equation constrained minimization - +/ 148 149 int slevmar_blec_der( 150 SLevmarCallback func, 151 SLevmarJacobian jacf, 152 float* p, 153 float* x, 154 int m, 155 int n, 156 float* lb, 157 float* ub, 158 float* A, 159 float* b, 160 int k, 161 float* wghts, 162 int itmax, 163 float* opts, 164 float* info, 165 float* work, 166 float* covar, 167 void* adata 168 ); 169 170 int slevmar_blec_dif( 171 SLevmarCallback func, 172 float* p, 173 float* x, 174 int m, 175 int n, 176 float* lb, 177 float* ub, 178 float* A, 179 float* b, 180 int k, 181 float* wghts, 182 int itmax, 183 float* opts, 184 float* info, 185 float* work, 186 float* covar, 187 void* adata 188 ); 189 190 /+ - box, linear equations & inequalities constrained minimization - +/ 191 192 int slevmar_bleic_der( 193 SLevmarCallback func, 194 SLevmarJacobian jacf, 195 float* p, 196 float* x, 197 int m, 198 int n, 199 float* lb, 200 float* ub, 201 float* A, 202 float* b, 203 int k1, 204 float* C, 205 float* d, 206 int k2, 207 int itmax, 208 float* opts, 209 float* info, 210 float* work, 211 float* covar, 212 void* adata 213 ); 214 215 int slevmar_bleic_dif( 216 SLevmarCallback func, 217 float* p, 218 float* x, 219 int m, 220 int n, 221 float* lb, 222 float* ub, 223 float* A, 224 float* b, 225 int k1, 226 float* C, 227 float* d, 228 int k2, 229 int itmax, 230 float* opts, 231 float* info, 232 float* work, 233 float* covar, 234 void* adata 235 ); 236 237 /+ - box & linear inequality constraints - +/ 238 239 int slevmar_blic_der( 240 SLevmarCallback func, 241 SLevmarJacobian jacf, 242 float* p, 243 float* x, 244 int m, 245 int n, 246 float* lb, 247 float* ub, 248 float* C, 249 float* d, 250 int k2, 251 int itmax, 252 float* opts, 253 float* info, 254 float* work, 255 float* covar, 256 void* adata 257 ); 258 259 int slevmar_blic_dif( 260 SLevmarCallback func, 261 float* p, 262 float* x, 263 int m, 264 int n, 265 float* lb, 266 float* ub, 267 float* C, 268 float* d, 269 int k2, 270 int itmax, 271 float* opts, 272 float* info, 273 float* work, 274 float* covar, 275 void* adata 276 ); 277 278 /+ - linear equation & inequality constraints - +/ 279 280 int slevmar_leic_der( 281 SLevmarCallback func, 282 SLevmarJacobian jacf, 283 float* p, 284 float* x, 285 int m, 286 int n, 287 float* A, 288 float* b, 289 int k1, 290 float* C, 291 float* d, 292 int k2, 293 int itmax, 294 float* opts, 295 float* info, 296 float* work, 297 float* covar, 298 void* adata 299 ); 300 301 int slevmar_leic_dif( 302 SLevmarCallback func, 303 float* p, 304 float* x, 305 int m, 306 int n, 307 float* A, 308 float* b, 309 int k1, 310 float* C, 311 float* d, 312 int k2, 313 int itmax, 314 float* opts, 315 float* info, 316 float* work, 317 float* covar, 318 void* adata 319 ); 320 321 /+ - linear inequality constraints - +/ 322 323 int slevmar_lic_der( 324 SLevmarCallback func, 325 SLevmarJacobian jacf, 326 float* p, 327 float* x, 328 int m, 329 int n, 330 float* C, 331 float* d, 332 int k2, 333 int itmax, 334 float* opts, 335 float* info, 336 float* work, 337 float* covar, 338 void* adata 339 ); 340 341 int slevmar_lic_dif( 342 SLevmarCallback func, 343 float* p, 344 float* x, 345 int m, 346 int n, 347 float* C, 348 float* d, 349 int k2, 350 int itmax, 351 float* opts, 352 float* info, 353 float* work, 354 float* covar, 355 void* adata 356 ); 357 358 /+ - linear system solvers - +/ 359 360 int sAx_eq_b_QR(float* A, float* B, float* x, int m); 361 362 int sAx_eq_b_QRLS(float* A, float* B, float* x, int m, int n); 363 364 int sAx_eq_b_Chol(float* A, float* B, float* x, int m); 365 366 int sAx_eq_b_LU(float* A, float* B, float* x, int m); 367 368 int sAx_eq_b_SVD(float* A, float* B, float* x, int m); 369 370 int sAx_eq_b_BK(float* A, float* B, float* x, int m); 371 372 int sAx_eq_b_LU_noLapack(float* A, float* B, float* x, int n); 373 374 int sAx_eq_b_PLASMA_Chol(float* A, float* B, float* x, int m); 375 376 /+ - Jacobian verification - +/ 377 378 void slevmar_chkjac( 379 SLevmarCallback func, 380 SLevmarJacobian jacf, 381 float* p, 382 int m, 383 int n, 384 void* adata, 385 float* err 386 ); 387 388 /+ miscellaneous: standard deviation, coefficient of determination (R2), 389 + Pearson's correlation coefficient for best-fit parameters 390 +/ 391 392 float slevmar_stddev(float* covar, int m, int i); 393 float slevmar_corcoef(float* covar, int m, int i, int j); 394 395 float slevmar_R2( 396 SLevmarCallback func, 397 float* p, 398 float* x, 399 int m, 400 int n, 401 void* adata 402 ); 403 404 void slevmar_locscale( 405 SLevmarCallback func, 406 float* p, 407 float* x, 408 int m, 409 int n, 410 void* adata, 411 int howto, 412 float* locscl, 413 float** residptr 414 ); 415 416 int slevmar_outlid( 417 float* r, 418 int n, 419 float thresh, 420 float* ls, 421 char* outlmap 422 ); 423 }