#ifndef SPHERE_ADAPT_FUNCTIONS_H #define SPHERE_ADAPT_FUNCTIONS_H /* Define the Sphere data structure for magnetic anomaly calculation */ typedef struct { double northing; // northing coordinate of the sphere center (m) double easting; // easting coordinate of the sphere center (m) double z; // depth to sphere center (m) double a; // radius of the sphere (m) double minc; //inclination of the vector of magnetization of the sphere (degrees) double mdec; //inclination of the vector of magnetization of the sphere (degrees) double mi; //intensity of the vector of magnetization of the sphere (amp/m) double einc; //inclination of the Earth's magnetic field (degrees) double edec; //declination of the Earth's magnetic field (degrees) } Sphere; /* Define the Datapoint data structure to hold the easting, northing, and mag values for magnetic observations and calculated mag values */ typedef struct { double northing; //northing coordinate of the observation point (m) double easting; //easting coordinate of the observation point (m) double mag_obs; //total field magnetic anomaly at observation point (nT) double mag_calc; // calculated magnetic anomaly at obs point (nT, may initially be 0.0) } DataPoint; /* declare the functions used in the sphere inversion code */ double magnetized_sphere_anomaly(double x, double y, Sphere sphere); double calculate_rmse(DataPoint *mag_anomaly, int size); double coarse_to_fine_search(DataPoint *mag_anomaly, Sphere *sphere, int size, double z_min, double z_max, int grid_points); double adaptive_gradient_search(DataPoint *mag_anomaly, Sphere *sphere, int size, double alpha_init, double tol, int max_iter); int read_data_file(const char *filename, DataPoint **mag_anomaly, int *row_count); #endif