20 #include "../include/exageostatcore.h" 23 static double deg2rad(
double deg) {
24 return (deg *
PI / 180);
27 static double rad2deg(
double rad) {
28 return (rad * 180 /
PI);
39 static double distanceEarth(
double lat1d,
double lon1d,
double lat2d,
double lon2d) {
40 double lat1r, lon1r, lat2r, lon2r, u, v;
41 lat1r = deg2rad(lat1d);
42 lon1r = deg2rad(lon1d);
43 lat2r = deg2rad(lat2d);
44 lon2r = deg2rad(lon2d);
45 u = sin((lat2r - lat1r)/2);
46 v = sin((lon2r - lon1r)/2);
47 return 2.0 *
earthRadiusKm * asin(sqrt(u * u + cos(lat1r) * cos(lat2r) * v * v));
50 static double calculateDistance(
double x1,
double y1,
double x2,
double y2,
int distance_metric) {
52 if(distance_metric == 1)
53 return distanceEarth(x1, y1, x2, y2);
54 return sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));
98 double l1x, l1y, l2x, l2y;
101 double sigma_square = localtheta[0];
103 con = pow(2,(localtheta[2]-1)) * tgamma(localtheta[2]);
105 con = sigma_square * con;
107 for (j = 0; j < n; j++) {
110 for (i = 0; i < m; i++) {
113 expr = calculateDistance(l1x, l1y, l2x, l2y, distance_metric)/localtheta[1];
115 A[i + j * m] = sigma_square;
117 A[i + j * m] = con*pow(expr, localtheta[2])*gsl_sf_bessel_Knu(localtheta[2],expr);
double * y
Values in Y dimension.
void core_dcmg(double *A, int m, int n, int m0, int n0, location *l1, location *l2, double *localtheta, int distance_metric)
double * x
Values in X dimension.