2 #include <gsl/gsl_nan.h> 11 const double*thetas,
const double*rhos,
double *alpha,
double*cov0_alpha );
16 for(i=0;i<ld->
nrays;i++){
18 ld->
alpha[i] = GSL_NAN;
25 size_t num_neighbours;
26 find_neighbours(ld, i, size_neighbourhood, neighbours, &num_neighbours);
28 if(0==num_neighbours) {
29 ld->
alpha[i] = GSL_NAN;
36 double thetas[num_neighbours];
37 double readings[num_neighbours];
39 for(a=0;a<num_neighbours;a++) {
40 thetas[a] = ld->
theta[neighbours[a]];
41 readings[a] = ld->
readings[neighbours[a]];
45 double alpha=42, cov0_alpha=32;
47 thetas,readings,&alpha,&cov0_alpha);
49 if(gsl_isnan(alpha)) {
50 ld->
alpha[i] = GSL_NAN;
65 const double*thetas,
const double*rhos,
double *alpha,
double*cov0_alpha ) {
73 size_t i;
for(i=0;i<n;i++) {
74 *
egsl_atmp(Y, i, 0) = (rhos[i]-rho0)/(thetas[i]-theta0);
75 *
egsl_atmp(R, i, 0) = -1/(thetas[i]-theta0);
76 *
egsl_atmp(R, i, i+1) = +1/(thetas[i]-theta0);
81 val vf1 =
m4(vcov_f1,
tr(L), eRinv, Y);
86 *alpha = theta0 - atan(f1/rho0);
88 if(cos(*alpha)*cos(theta0)+sin(*alpha)*sin(theta0)>0)
89 *alpha = *alpha +
M_PI;
94 *cov0_alpha =
square(dalpha_df1) * cov_f1 +
square(dalpha_drho);
97 if(gsl_isnan(*alpha)) {
104 printf(
" f1 = %f cov =%f \n", f1,cov_f1);
105 printf(
" f1/rho = %f \n", f1/rho0);
106 printf(
" atan = %f \n", atan(f1/rho0));
107 printf(
" theta0= %f \n", theta0);
139 indexes[(*num_found)++] = up;
142 while ((down >= i-max_num) && (down-1>=0) &&
ld_valid_ray(ld,down-1) &&
145 indexes[(*num_found)++] = down;
double *restrict cov_alpha
INLINE int ld_valid_ray(LDP ld, int i)
#define m4(v1, v2, v3, v4)
double *restrict readings
int *restrict alpha_valid
void find_neighbours(LDP ld, int i, int max_num, int *indexes, size_t *num_found)
double * egsl_atmp(val v, size_t i, size_t j)
void ld_compute_orientation(LDP ld, int size_neighbourhood, double sigma)
void egsl_print(const char *str, val v)
void filter_orientation(double theta0, double rho0, size_t n, const double *thetas, const double *rhos, double *alpha, double *cov0_alpha)
#define zeros(rows, cols)