#ifndef _HEAD_FUNC_H #define _HEAD_FUNC_H #include "iostream" #include "fstream" #include "sstream" #include "string.h" #include "cmath" #include "iomanip" #include "stdio.h" #include "stdlib.h" #include "unistd.h" #include "vector" #include "map" #include "algorithm" #include "ctime" #include "omp.h" #include "random" using namespace std; //数学常量 #define BDL_MAX 1e+30 ///< 定义变量的最大值 #define BDL_MIN -1e+30 ///< 定义变量的最小值 #define PRECISION 16 ///< 定义小数点后需要使用的位数 #define ZERO 1e-16 ///< 定义零值 //物理常量 #define Pi (4.0*atan(1.0)) ///< 圆周率 #define G0 6.67408e-3 ///< 万有引力常数。注意这里的量级本来应该是e-11,考虑到单位转换,取维度单位为m,密度单位为g/cm^3,乘以G0则重力单位即为mGal #define T0 5.0e+4 ///< 地磁场平均强度 //宏函数 #define MAX(a,b) (a>b?a:b) ///< 返回a与b的最大值 #define MIN(a,b) (a _1iArray; ///< 整形一维向量 typedef vector _1dArray; ///< 双精度浮点一维向量 typedef vector _1sArray; ///< 字符串一维向量 typedef vector > _2iArray; ///< 整形浮点二维向量 typedef vector > _2dArray; ///< 双精度浮点二维向量 typedef map _int2intMap; ///< 整型到整形的映射 //模型块体参数 struct modelist{ char mod_type[1024]; char val_type[1024]; char mod_para[1024]; double mod_value; }; typedef vector modelistArray; //直角坐标系点 struct cpoint{ int id = -1; double x = BDL_MAX; double y = BDL_MAX; double z = BDL_MAX; }; typedef vector cpointArray; typedef map _str2pointMap; //观测点 struct obspoint : public cpoint{ double val = BDL_MAX; double dev = BDL_MAX; }; typedef vector obspointArray; //块体 struct cube{ cpoint cen; int ids[8] = {-1,-1,-1,-1,-1,-1,-1,-1}; double dx = BDL_MAX; double dy = BDL_MAX; double dz = BDL_MAX; }; typedef vector cubeArray; /*************************数据结构函数********************************/ cpoint operator -(cpoint,cpoint); //矢量减法 double modCpoint(cpoint); //矢量模 /*************************全局函数********************************/ double arctg(double); //正负分离的atan函数 正数返回atan 负数返回atan+pi stringstream str2ss(string); //将string转换为stringstream string cpoint_id(cpoint); //返回一个cpoint的位置id int open_infile(ifstream&,char*); //测试打开输入文件 如果成功则返回0并输出信息 否则返回1 int open_outfile(ofstream&,char*); //测试打开输出文件 如果成功则返回0并输出信息 否则返回1 double grid_interpolate(double,double,double,double,double,double,double,double,double,double); //规则网络插值 #endif