source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/sba-1.3/sba.h @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 5.8 KB
Line 
1/////////////////////////////////////////////////////////////////////////////////
2////
3////  Prototypes and definitions for sparse bundle adjustment
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////
18///////////////////////////////////////////////////////////////////////////////////
19
20#ifndef _SBA_H_
21#define _SBA_H_
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#define SBA_APPEND_UNDERSCORE_SUFFIX // undef this for AIX
28
29#define SBA_MIN_DELTA     1E-06 // finite differentiation minimum delta
30#define SBA_DELTA_SCALE   1E-04 // finite differentiation delta scale
31
32#define SBA_OPTSSZ        4
33#define SBA_INFOSZ        10
34#define SBA_INIT_MU       1E-03
35#define SBA_STOP_THRESH   1E-12
36#define SBA_CG_NOPREC     0
37#define SBA_CG_JACOBI     1
38#define SBA_CG_SSOR       2
39#define SBA_VERSION       "1.3 (Jun. 2006)"
40
41
42/* Sparse matrix representation using Compressed Row Storage (CRS) format.
43 * See http://www.netlib.org/linalg/html_templates/node91.html#SECTION00931100000000000000
44 */
45
46struct sba_crsm{
47    int nr, nc;   /* #rows, #cols for the sparse matrix */
48    int nnz;      /* number of nonzero array elements */
49    int *val;     /* storage for nonzero array elements. size: nnz */
50    int *colidx;  /* column indexes of nonzero elements. size: nnz */
51    int *rowptr;  /* locations in val that start a row. size: nr+1.
52                   * By convention, rowptr[nr]=nnz
53                   */
54};
55
56/* sparse LM */
57
58/* simple drivers */
59extern int
60sba_motstr_levmar(const int n, const int m, const int mcon, char *vmask, double *p, const int cnp, const int pnp, double *x, const int mnp,
61           void (*proj)(int j, int i, double *aj, double *bi, double *xij, void *adata),
62           void (*projac)(int j, int i, double *aj, double *bi, double *Aij, double *Bij, void *adata),
63           void *adata, int itmax, int verbose, double opts[SBA_OPTSSZ], double info[SBA_INFOSZ]);
64
65extern int
66sba_mot_levmar(const int n, const int m, const int mcon, char *vmask, double *p, const int cnp, double *x, const int mnp,
67           void (*proj)(int j, int i, double *aj, double *xij, void *adata),
68           void (*projac)(int j, int i, double *aj, double *Aij, void *adata),
69           void *adata, int itmax, int verbose, double opts[SBA_OPTSSZ], double info[SBA_INFOSZ]);
70
71extern int
72sba_str_levmar(const int n, const int m, char *vmask, double *p, const int pnp, double *x, const int mnp,
73           void (*proj)(int j, int i, double *bi, double *xij, void *adata),
74           void (*projac)(int j, int i, double *bi, double *Bij, void *adata),
75           void *adata, int itmax, int verbose, double opts[SBA_OPTSSZ], double info[SBA_INFOSZ]);
76
77
78/* expert drivers */
79extern int
80sba_motstr_levmar_x(const int n, const int m, const int mcon, char *vmask, double *p, int const cnp, const int pnp, double *x, const int mnp,
81           void (*func)(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *hx, void *adata),
82           void (*fjac)(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *jac, void *adata),
83           void *adata, int itmax, int verbose, double opts[SBA_OPTSSZ], double info[SBA_INFOSZ]);
84
85extern int
86sba_mot_levmar_x(const int n, const int m, const int mcon, char *vmask, double *p, int const cnp, double *x, const int mnp,
87           void (*func)(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *hx, void *adata),
88           void (*fjac)(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *jac, void *adata),
89           void *adata, int itmax, int verbose, double opts[SBA_OPTSSZ], double info[SBA_INFOSZ]);
90
91extern int
92sba_str_levmar_x(const int n, const int m, char *vmask, double *p, const int pnp, double *x, const int mnp,
93           void (*func)(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *hx, void *adata),
94           void (*fjac)(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *jac, void *adata),
95           void *adata, int itmax, int verbose, double opts[SBA_OPTSSZ], double info[SBA_INFOSZ]);
96
97
98/* interfaces to LAPACK routines: solution of linear systems, matrix inversion */
99extern int sba_Axb_QR(double *A, double *B, double *x, int m, int iscolmaj);
100extern int sba_Axb_QRnoQ(double *A, double *B, double *x, int m, int iscolmaj);
101extern int sba_Axb_Chol(double *A, double *B, double *x, int m, int iscolmaj);
102extern int sba_Axb_LU(double *A, double *B, double *x, int m, int iscolmaj);
103extern int sba_Axb_SVD(double *A, double *B, double *x, int m, int iscolmaj);
104extern int sba_Axb_BK(double *A, double *B, double *x, int m, int iscolmaj);
105extern int sba_Axb_CG(double *A, double *B, double *x, int m, int niter, double eps, int prec, int iscolmaj);
106extern int sba_mat_invert_LU(double *A, double *B, int m);
107extern int sba_mat_invert_Chol(double *A, double *B, int m);
108
109/* CRS sparse matrices manipulation routines */
110extern void sba_crsm_alloc(struct sba_crsm *sm, int nr, int nc, int nnz);
111extern void sba_crsm_free(struct sba_crsm *sm);
112extern int sba_crsm_elmidx(struct sba_crsm *sm, int i, int j);
113extern int sba_crsm_row_elmidxs(struct sba_crsm *sm, int i, int *vidxs, int *jidxs);
114extern int sba_crsm_col_elmidxs(struct sba_crsm *sm, int j, int *vidxs, int *iidxs);
115
116#ifdef __cplusplus
117}
118#endif
119
120#endif /* _SBA_H_ */
Note: See TracBrowser for help on using the repository browser.