MPQC  3.0.0-alpha
misc.h
1 //
3 // Levenberg - Marquardt non-linear minimization algorithm
4 // Copyright (C) 2004 Manolis Lourakis (lourakis@ics.forth.gr)
5 // Institute of Computer Science, Foundation for Research & Technology - Hellas
6 // Heraklion, Crete, Greece.
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
19 
20 #ifndef _MISC_H_
21 #define _MISC_H_
22 
23 /* common prefix for BLAS subroutines */
24 #define LM_BLAS_PREFIX // none
25 //#define LM_BLAS_PREFIX f2c_ // f2c'd BLAS
26 //#define LM_BLAS_PREFIX cblas_ // C interface to BLAS
27 
28 #define LCAT_(a, b) #a b
29 #define LCAT(a, b) LCAT_(a, b) // force substitution
30 #define RCAT_(a, b) a #b
31 #define RCAT(a, b) RCAT_(a, b) // force substitution
32 
33 #define __BLOCKSZ__ 32 /* block size for cache-friendly matrix-matrix multiply. It should be
34  * such that __BLOCKSZ__^2*sizeof(LM_REAL) is smaller than the CPU (L1)
35  * data cache size. Notice that a value of 32 when LM_REAL=double assumes
36  * an 8Kb L1 data cache (32*32*8=8K). This is a concervative choice since
37  * newer Pentium 4s have a L1 data cache of size 16K, capable of holding
38  * up to 45x45 double blocks.
39  */
40 #define __BLOCKSZ__SQ (__BLOCKSZ__)*(__BLOCKSZ__)
41 
42 #ifdef _MSC_VER
43 #define inline __inline //MSVC
44 #elif !defined(__GNUC__)
45 #define inline //other than MSVC, GCC: define empty
46 #endif
47 
48 /* add a prefix in front of a token */
49 #define LM_CAT__(a, b) a ## b
50 #define LM_CAT_(a, b) LM_CAT__(a, b) // force substitution
51 #define LM_ADD_PREFIX(s) LM_CAT_(LM_PREFIX, s)
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /* blocking-based matrix multiply */
58 extern void strans_mat_mat_mult(float *a, float *b, int n, int m);
59 extern void dtrans_mat_mat_mult(double *a, double *b, int n, int m);
60 
61 /* forward finite differences */
62 extern void sfdif_forw_jac_approx(void (*func)(float *p, float *hx, int m, int n, void *adata),
63  float *p, float *hx, float *hxx, float delta,
64  float *jac, int m, int n, void *adata);
65 extern void dfdif_forw_jac_approx(void (*func)(double *p, double *hx, int m, int n, void *adata),
66  double *p, double *hx, double *hxx, double delta,
67  double *jac, int m, int n, void *adata);
68 
69 /* central finite differences */
70 extern void sfdif_cent_jac_approx(void (*func)(float *p, float *hx, int m, int n, void *adata),
71  float *p, float *hxm, float *hxp, float delta,
72  float *jac, int m, int n, void *adata);
73 extern void dfdif_cent_jac_approx(void (*func)(double *p, double *hx, int m, int n, void *adata),
74  double *p, double *hxm, double *hxp, double delta,
75  double *jac, int m, int n, void *adata);
76 
77 /* covariance of LS fit */
78 extern int slevmar_covar(float *JtJ, float *C, float sumsq, int m, int n);
79 extern int dlevmar_covar(double *JtJ, double *C, double sumsq, int m, int n);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif /* _MISC_H */

Generated at Sun Jan 26 2020 23:24:00 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.