From c413814a8b667ec9628c2b168a3ab32932d820c6 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 6 Feb 2025 21:17:24 +0800 Subject: [PATCH] tmp --- CMakeLists.txt | 3 + lib/CMakeLists.txt | 12 ++-- lib/{algorithm.h => algorithms.h} | 32 +++++----- .../algorithm_func.cpp | 0 .../algorithm_func.h | 2 +- lib/{algorithm => algorithms}/autodiff.cpp | 0 lib/{algorithm => algorithms}/autodiff.h | 2 +- lib/{algorithm => algorithms}/boxsort2d.h | 2 +- lib/{algorithm => algorithms}/boxsort_sph.h | 0 lib/{algorithm => algorithms}/emd.cpp | 0 lib/{algorithm => algorithms}/emd.h | 2 +- lib/{algorithm => algorithms}/extrapolate.cpp | 0 lib/{algorithm => algorithms}/extrapolate.h | 2 +- lib/{algorithm => algorithms}/fft_filter.cpp | 0 lib/{algorithm => algorithms}/fft_filter.h | 2 +- lib/{algorithm => algorithms}/fir_filter.cpp | 0 lib/{algorithm => algorithms}/fir_filter.h | 2 +- lib/{algorithm => algorithms}/glni.cpp | 0 lib/{algorithm => algorithms}/glni.h | 2 +- lib/{algorithm => algorithms}/heap_sort.h | 2 +- lib/{algorithm => algorithms}/interpolate.cpp | 0 lib/{algorithm => algorithms}/interpolate.h | 2 +- lib/{algorithm => algorithms}/kde.cpp | 0 lib/{algorithm => algorithms}/kde.h | 2 +- lib/{algorithm => algorithms}/multinary.cpp | 0 lib/{algorithm => algorithms}/multinary.h | 2 +- lib/{algorithm => algorithms}/sinkhorn.cpp | 0 lib/{algorithm => algorithms}/sinkhorn.h | 2 +- .../space_filter.cpp | 0 lib/{algorithm => algorithms}/space_filter.h | 2 +- lib/{algorithm => algorithms}/variogram.cpp | 0 lib/{algorithm => algorithms}/variogram.h | 2 +- lib/{algorithm => algorithms}/windowfunc.cpp | 0 lib/{algorithm => algorithms}/windowfunc.h | 2 +- lib/core/array.h | 64 ++++++++----------- lib/core/enum.h | 2 +- lib/core/exceptions.h | 20 +++--- lib/core/matrix.h | 4 +- lib/core/sparray.h | 2 +- lib/core/spmat.h | 5 +- lib/core/sptr.h | 4 +- lib/core/vector_t.h | 2 +- lib/geometry/block.h | 2 +- lib/geometry/edge.h | 3 +- lib/geometry/edge2d.h | 3 +- lib/geometry/entity.h | 2 +- lib/geometry/geometry2d.cpp | 14 ++-- lib/geometry/geometry2d.h | 3 +- lib/geometry/geometry3d.cpp | 15 +++-- lib/geometry/geometry3d.h | 3 +- lib/geometry/node.h | 3 +- lib/geometry/point.h | 55 ++++++++++++++++ lib/geometry/point2c.h | 21 +----- lib/geometry/point2p.h | 21 +----- lib/geometry/point3c.h | 21 +----- lib/geometry/point3s.h | 21 +----- lib/geometry/prism.h | 2 +- lib/geometry/rectangle2d.h | 2 +- lib/geometry/refellipsoid.h | 2 +- lib/geometry/sphere.h | 3 +- lib/geometry/tensor.h | 2 +- lib/geometry/tesseroid.h | 2 +- lib/geometry/tetrahedron.h | 3 +- lib/geometry/tri_cone.h | 1 + lib/geometry/triangle.h | 3 +- lib/geometry/triangle2d.h | 3 +- lib/geometry/triangle2d2o.h | 3 +- lib/geometry/vertex.h | 2 +- lib/io/dsv_io.h | 2 +- lib/io/gmsh_io.h | 3 +- lib/io/mesh_io.cpp | 8 +-- lib/io/mesh_io.h | 3 +- lib/io/native_io.h | 2 +- lib/io/netcdf_io.h | 2 +- lib/io/off_io.h | 2 +- lib/io/surfer_io.h | 2 +- lib/io/tetgen_io.h | 3 +- lib/io/text_io.h | 3 +- lib/io/triangle_io.h | 4 +- lib/maths/fft.h | 2 +- lib/maths/gaussfunc.h | 2 +- lib/maths/legendre.h | 2 +- lib/maths/linear_algebra.h | 2 +- lib/maths/mathfunc.h | 12 ++-- lib/maths/mathfunc_ext.h | 2 +- lib/maths/mathfunc_t.h | 9 +-- lib/maths/shapefunc.h | 2 +- lib/utility/assess.h | 12 ++-- lib/utility/get_option.h | 15 +++-- lib/utility/getopt_help.h | 8 +-- lib/utility/process_monitor.h | 12 ++-- lib/utility/progress_bar.h | 18 +++--- lib/utility/stream.h | 22 +++---- lib/utility/utc_time.h | 14 ++-- 94 files changed, 282 insertions(+), 283 deletions(-) rename lib/{algorithm.h => algorithms.h} (76%) rename lib/{algorithm => algorithms}/algorithm_func.cpp (100%) rename lib/{algorithm => algorithms}/algorithm_func.h (99%) rename lib/{algorithm => algorithms}/autodiff.cpp (100%) rename lib/{algorithm => algorithms}/autodiff.h (99%) rename lib/{algorithm => algorithms}/boxsort2d.h (99%) rename lib/{algorithm => algorithms}/boxsort_sph.h (100%) rename lib/{algorithm => algorithms}/emd.cpp (100%) rename lib/{algorithm => algorithms}/emd.h (99%) rename lib/{algorithm => algorithms}/extrapolate.cpp (100%) rename lib/{algorithm => algorithms}/extrapolate.h (99%) rename lib/{algorithm => algorithms}/fft_filter.cpp (100%) rename lib/{algorithm => algorithms}/fft_filter.h (99%) rename lib/{algorithm => algorithms}/fir_filter.cpp (100%) rename lib/{algorithm => algorithms}/fir_filter.h (99%) rename lib/{algorithm => algorithms}/glni.cpp (100%) rename lib/{algorithm => algorithms}/glni.h (99%) rename lib/{algorithm => algorithms}/heap_sort.h (99%) rename lib/{algorithm => algorithms}/interpolate.cpp (100%) rename lib/{algorithm => algorithms}/interpolate.h (99%) rename lib/{algorithm => algorithms}/kde.cpp (100%) rename lib/{algorithm => algorithms}/kde.h (99%) rename lib/{algorithm => algorithms}/multinary.cpp (100%) rename lib/{algorithm => algorithms}/multinary.h (99%) rename lib/{algorithm => algorithms}/sinkhorn.cpp (100%) rename lib/{algorithm => algorithms}/sinkhorn.h (99%) rename lib/{algorithm => algorithms}/space_filter.cpp (100%) rename lib/{algorithm => algorithms}/space_filter.h (99%) rename lib/{algorithm => algorithms}/variogram.cpp (100%) rename lib/{algorithm => algorithms}/variogram.h (99%) rename lib/{algorithm => algorithms}/windowfunc.cpp (100%) rename lib/{algorithm => algorithms}/windowfunc.h (99%) create mode 100644 lib/geometry/point.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a698620..79693d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ project(GCTL VERSION 1.0) # 添加配置配件编写的函数 include(CMakePackageConfigHelpers) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + # 添加编译选项 option(GCTL_OPENMP "Use the OpenMP library" ON) option(GCTL_NETCDF "Use the NetCDF library" ON) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0d68666..3e79deb 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -6,7 +6,7 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) # 设定库源文件文件夹 aux_source_directory(geometry/ GCTL_GEOMETRY_SRC) -aux_source_directory(algorithm/ GCTL_ALGORITHM_SRC) +aux_source_directory(algorithms/ GCTL_ALGORITHMS_SRC) aux_source_directory(io/ GCTL_IO_SRC) aux_source_directory(utility/ GCTL_UTILITY_SRC) aux_source_directory(maths/ GCTL_MATHS_SRC) @@ -24,10 +24,10 @@ endif() # 以下部分为库的编译 # 注意目标名必须唯一 所以不能直接生成相同名称的动态库与静态库 # 注意此处不必为目标名称添加lib前缀和相应后缀,cmake会自行添加 -add_library(gctl SHARED ${GCTL_UTILITY_SRC} ${GCTL_ALGORITHM_SRC} ${GCTL_GEODESY_SRC} +add_library(gctl SHARED ${GCTL_UTILITY_SRC} ${GCTL_ALGORITHMS_SRC} ${GCTL_GEODESY_SRC} ${GCTL_GEOMETRY_SRC} ${GCTL_IO_SRC} ${GCTL_MATHS_SRC}) # 首先添加静态库的生成命令 -add_library(gctl_static STATIC ${GCTL_UTILITY_SRC} ${GCTL_ALGORITHM_SRC} ${GCTL_GEODESY_SRC} +add_library(gctl_static STATIC ${GCTL_UTILITY_SRC} ${GCTL_ALGORITHMS_SRC} ${GCTL_GEODESY_SRC} ${GCTL_GEOMETRY_SRC} ${GCTL_IO_SRC} ${GCTL_MATHS_SRC}) # 设置静态库的输出名称从而获得与动态库名称相同的静态库 set_target_properties(gctl_static PROPERTIES OUTPUT_NAME "gctl") @@ -101,7 +101,7 @@ endif() file(GLOB GCTL_HEAD *.h) file(GLOB GCTL_CORE_HEAD core/*.h) file(GLOB GCTL_IO_HEAD io/*.h) -file(GLOB GCTL_ALGORITHM_HEAD algorithm/*.h) +file(GLOB GCTL_ALGORITHMS_HEAD algorithms/*.h) file(GLOB GCTL_MATHS_HEAD maths/*.h) file(GLOB GCTL_GEOMETRY_HEAD geometry/*.h) file(GLOB GCTL_UTILITY_HEAD utility/*.h) @@ -113,7 +113,7 @@ if(NOT WIN32) endif() if(NOT GCTL_FFTW3) - list(REMOVE_ITEM GCTL_ALGORITHM_HEAD "${PROJECT_SOURCE_DIR}/lib/algorithm/fft.h") + list(REMOVE_ITEM GCTL_ALGORITHMS_HEAD "${PROJECT_SOURCE_DIR}/lib/algorithms/fft.h") endif() if(NOT GCTL_NETCDF) @@ -124,7 +124,7 @@ install(FILES ${GCTL_HEAD} DESTINATION include/gctl) install(FILES ${GCTL_CORE_HEAD} DESTINATION include/gctl/core) install(FILES ${GCTL_IO_HEAD} DESTINATION include/gctl/io) install(FILES ${GCTL_MATHS_HEAD} DESTINATION include/gctl/maths) -install(FILES ${GCTL_ALGORITHM_HEAD} DESTINATION include/gctl/algorithm) +install(FILES ${GCTL_ALGORITHMS_HEAD} DESTINATION include/gctl/algorithms) install(FILES ${GCTL_GEOMETRY_HEAD} DESTINATION include/gctl/geometry) install(FILES ${GCTL_UTILITY_HEAD} DESTINATION include/gctl/utility) install(FILES ${GCTL_MESH_HEAD} DESTINATION include/gctl/mesh) diff --git a/lib/algorithm.h b/lib/algorithms.h similarity index 76% rename from lib/algorithm.h rename to lib/algorithms.h index 1756d88..221d8a0 100644 --- a/lib/algorithm.h +++ b/lib/algorithms.h @@ -28,21 +28,21 @@ #ifndef _GCTL_ALGORITHM_H #define _GCTL_ALGORITHM_H -#include "algorithm/algorithm_func.h" -#include "algorithm/glni.h" -#include "algorithm/interpolate.h" -#include "algorithm/extrapolate.h" -#include "algorithm/heap_sort.h" -#include "algorithm/boxsort2d.h" -#include "algorithm/boxsort_sph.h" -#include "algorithm/variogram.h" -#include "algorithm/fir_filter.h" -#include "algorithm/space_filter.h" -#include "algorithm/sinkhorn.h" -#include "algorithm/kde.h" -#include "algorithm/autodiff.h" -#include "algorithm/multinary.h" -#include "algorithm/emd.h" -#include "algorithm/fft_filter.h" +#include "algorithms/algorithm_func.h" +#include "algorithms/glni.h" +#include "algorithms/interpolate.h" +#include "algorithms/extrapolate.h" +#include "algorithms/heap_sort.h" +#include "algorithms/boxsort2d.h" +#include "algorithms/boxsort_sph.h" +#include "algorithms/variogram.h" +#include "algorithms/fir_filter.h" +#include "algorithms/space_filter.h" +#include "algorithms/sinkhorn.h" +#include "algorithms/kde.h" +#include "algorithms/autodiff.h" +#include "algorithms/multinary.h" +#include "algorithms/emd.h" +#include "algorithms/fft_filter.h" #endif // _GCTL_ALGORITHM_H \ No newline at end of file diff --git a/lib/algorithm/algorithm_func.cpp b/lib/algorithms/algorithm_func.cpp similarity index 100% rename from lib/algorithm/algorithm_func.cpp rename to lib/algorithms/algorithm_func.cpp diff --git a/lib/algorithm/algorithm_func.h b/lib/algorithms/algorithm_func.h similarity index 99% rename from lib/algorithm/algorithm_func.h rename to lib/algorithms/algorithm_func.h index e0860f8..bc39580 100644 --- a/lib/algorithm/algorithm_func.h +++ b/lib/algorithms/algorithm_func.h @@ -134,6 +134,6 @@ namespace gctl */ void difference_2d(const array &in, array &diff, int row_size, int col_size, double spacing, gradient_type_e d_type, int order = 1); -} +}; #endif // _GCTL_ALGORITHM_FUNC_H \ No newline at end of file diff --git a/lib/algorithm/autodiff.cpp b/lib/algorithms/autodiff.cpp similarity index 100% rename from lib/algorithm/autodiff.cpp rename to lib/algorithms/autodiff.cpp diff --git a/lib/algorithm/autodiff.h b/lib/algorithms/autodiff.h similarity index 99% rename from lib/algorithm/autodiff.h rename to lib/algorithms/autodiff.h index 3852412..bd05966 100644 --- a/lib/algorithm/autodiff.h +++ b/lib/algorithms/autodiff.h @@ -56,6 +56,6 @@ namespace gctl private: double val_, der_; }; -} +}; #endif // _GCTL_AUTODIFF_H \ No newline at end of file diff --git a/lib/algorithm/boxsort2d.h b/lib/algorithms/boxsort2d.h similarity index 99% rename from lib/algorithm/boxsort2d.h rename to lib/algorithms/boxsort2d.h index 7cbb873..933ea46 100644 --- a/lib/algorithm/boxsort2d.h +++ b/lib/algorithms/boxsort2d.h @@ -486,6 +486,6 @@ namespace gctl } return; } -} +}; #endif // _BOXSORT2D_H \ No newline at end of file diff --git a/lib/algorithm/boxsort_sph.h b/lib/algorithms/boxsort_sph.h similarity index 100% rename from lib/algorithm/boxsort_sph.h rename to lib/algorithms/boxsort_sph.h diff --git a/lib/algorithm/emd.cpp b/lib/algorithms/emd.cpp similarity index 100% rename from lib/algorithm/emd.cpp rename to lib/algorithms/emd.cpp diff --git a/lib/algorithm/emd.h b/lib/algorithms/emd.h similarity index 99% rename from lib/algorithm/emd.h rename to lib/algorithms/emd.h index 193309f..db1134c 100644 --- a/lib/algorithm/emd.h +++ b/lib/algorithms/emd.h @@ -46,7 +46,7 @@ namespace gctl void ceemdan1d(const array &in, matrix &out, size_t M, unsigned int ensemble_size, double noise_strength, unsigned int S_number, unsigned int num_siftings, unsigned long int rng_seed); -} +}; #endif // GCTL_EEMD diff --git a/lib/algorithm/extrapolate.cpp b/lib/algorithms/extrapolate.cpp similarity index 100% rename from lib/algorithm/extrapolate.cpp rename to lib/algorithms/extrapolate.cpp diff --git a/lib/algorithm/extrapolate.h b/lib/algorithms/extrapolate.h similarity index 99% rename from lib/algorithm/extrapolate.h rename to lib/algorithms/extrapolate.h index 8b90fe6..b597d0a 100644 --- a/lib/algorithm/extrapolate.h +++ b/lib/algorithms/extrapolate.h @@ -105,6 +105,6 @@ namespace gctl */ void zeros_extrapolate_2d(const array &in_arr, array &out_arr, int in_row, int in_col, int &out_row, int &out_col, int &ori_row, int &ori_col); -} +}; #endif // _GCTL_EXTRAPOLATE_H \ No newline at end of file diff --git a/lib/algorithm/fft_filter.cpp b/lib/algorithms/fft_filter.cpp similarity index 100% rename from lib/algorithm/fft_filter.cpp rename to lib/algorithms/fft_filter.cpp diff --git a/lib/algorithm/fft_filter.h b/lib/algorithms/fft_filter.h similarity index 99% rename from lib/algorithm/fft_filter.h rename to lib/algorithms/fft_filter.h index aa07231..63bff6a 100644 --- a/lib/algorithm/fft_filter.h +++ b/lib/algorithms/fft_filter.h @@ -94,7 +94,7 @@ namespace gctl array fid_; array > freqs_; }; -} +}; #endif // GCTL_FFTW3 diff --git a/lib/algorithm/fir_filter.cpp b/lib/algorithms/fir_filter.cpp similarity index 100% rename from lib/algorithm/fir_filter.cpp rename to lib/algorithms/fir_filter.cpp diff --git a/lib/algorithm/fir_filter.h b/lib/algorithms/fir_filter.h similarity index 99% rename from lib/algorithm/fir_filter.h rename to lib/algorithms/fir_filter.h index 5864a93..011e37a 100644 --- a/lib/algorithm/fir_filter.h +++ b/lib/algorithms/fir_filter.h @@ -98,6 +98,6 @@ namespace gctl int taps_; ///< Number of taps of the filter }; -} +}; #endif // _RIF_FILTER_H \ No newline at end of file diff --git a/lib/algorithm/glni.cpp b/lib/algorithms/glni.cpp similarity index 100% rename from lib/algorithm/glni.cpp rename to lib/algorithms/glni.cpp diff --git a/lib/algorithm/glni.h b/lib/algorithms/glni.h similarity index 99% rename from lib/algorithm/glni.h rename to lib/algorithms/glni.h index b0add92..78b517f 100644 --- a/lib/algorithm/glni.h +++ b/lib/algorithms/glni.h @@ -374,6 +374,6 @@ namespace gctl size_t size_; }; } -} +}; #endif // _GCTL_GLNI_H \ No newline at end of file diff --git a/lib/algorithm/heap_sort.h b/lib/algorithms/heap_sort.h similarity index 99% rename from lib/algorithm/heap_sort.h rename to lib/algorithms/heap_sort.h index ef79339..11f9678 100644 --- a/lib/algorithm/heap_sort.h +++ b/lib/algorithms/heap_sort.h @@ -246,6 +246,6 @@ namespace gctl return; } }; -} +}; #endif //_GCTL_HEAPSORT_H \ No newline at end of file diff --git a/lib/algorithm/interpolate.cpp b/lib/algorithms/interpolate.cpp similarity index 100% rename from lib/algorithm/interpolate.cpp rename to lib/algorithms/interpolate.cpp diff --git a/lib/algorithm/interpolate.h b/lib/algorithms/interpolate.h similarity index 99% rename from lib/algorithm/interpolate.h rename to lib/algorithms/interpolate.h index ce38ca7..1746b7b 100644 --- a/lib/algorithm/interpolate.h +++ b/lib/algorithms/interpolate.h @@ -316,6 +316,6 @@ namespace gctl */ array *p2p_dist_sph(point3ds * out_posi, int out_num, point3ds *in_posi, double *in_val, int in_num, double search_rlen, double search_deg); -} +}; #endif // _GCTL_INTERPOLATE_H \ No newline at end of file diff --git a/lib/algorithm/kde.cpp b/lib/algorithms/kde.cpp similarity index 100% rename from lib/algorithm/kde.cpp rename to lib/algorithms/kde.cpp diff --git a/lib/algorithm/kde.h b/lib/algorithms/kde.h similarity index 99% rename from lib/algorithm/kde.h rename to lib/algorithms/kde.h index f0c1bf6..a60b40b 100644 --- a/lib/algorithm/kde.h +++ b/lib/algorithms/kde.h @@ -171,6 +171,6 @@ namespace gctl double gaussian_kernel(double x, double y); }; -} +}; #endif // _GCTL_KERNEL_DENSITY_ESTIMATION_H \ No newline at end of file diff --git a/lib/algorithm/multinary.cpp b/lib/algorithms/multinary.cpp similarity index 100% rename from lib/algorithm/multinary.cpp rename to lib/algorithms/multinary.cpp diff --git a/lib/algorithm/multinary.h b/lib/algorithms/multinary.h similarity index 99% rename from lib/algorithm/multinary.h rename to lib/algorithms/multinary.h index 4faa6da..db7106d 100644 --- a/lib/algorithm/multinary.h +++ b/lib/algorithms/multinary.h @@ -56,6 +56,6 @@ namespace gctl array std_; array ys_; }; -} +}; #endif // _GCTL_MULTINARY_H \ No newline at end of file diff --git a/lib/algorithm/sinkhorn.cpp b/lib/algorithms/sinkhorn.cpp similarity index 100% rename from lib/algorithm/sinkhorn.cpp rename to lib/algorithms/sinkhorn.cpp diff --git a/lib/algorithm/sinkhorn.h b/lib/algorithms/sinkhorn.h similarity index 99% rename from lib/algorithm/sinkhorn.h rename to lib/algorithms/sinkhorn.h index 1f89280..79c8c21 100644 --- a/lib/algorithm/sinkhorn.h +++ b/lib/algorithms/sinkhorn.h @@ -114,6 +114,6 @@ namespace gctl matrix RP_; // 整理后的转换矩阵 matrix rp_maxi_; // RP_中每一快的最大值 }; -} +}; #endif // _GCTL_SINKHORN_H \ No newline at end of file diff --git a/lib/algorithm/space_filter.cpp b/lib/algorithms/space_filter.cpp similarity index 100% rename from lib/algorithm/space_filter.cpp rename to lib/algorithms/space_filter.cpp diff --git a/lib/algorithm/space_filter.h b/lib/algorithms/space_filter.h similarity index 99% rename from lib/algorithm/space_filter.h rename to lib/algorithms/space_filter.h index 6d5b0f1..c72588d 100644 --- a/lib/algorithm/space_filter.h +++ b/lib/algorithms/space_filter.h @@ -161,6 +161,6 @@ namespace gctl * @param m_OrderNumClm 滑动窗口的列的多项式阶次 */ void trend_2d(matrix &data, int m_RowNum, int m_ClmNum, int m_OrderNumRow, int m_OrderNumClm); -} +}; #endif // _GCTL_SPACE_FILTER_H \ No newline at end of file diff --git a/lib/algorithm/variogram.cpp b/lib/algorithms/variogram.cpp similarity index 100% rename from lib/algorithm/variogram.cpp rename to lib/algorithms/variogram.cpp diff --git a/lib/algorithm/variogram.h b/lib/algorithms/variogram.h similarity index 99% rename from lib/algorithm/variogram.h rename to lib/algorithms/variogram.h index 50a8731..8f5fc3b 100644 --- a/lib/algorithm/variogram.h +++ b/lib/algorithms/variogram.h @@ -137,6 +137,6 @@ namespace gctl * @return Semi-variogram value */ double variogram(const double &d, const variogram_model &vm, variogram_type_e type); -} +}; #endif // _VARIOGRAM_H \ No newline at end of file diff --git a/lib/algorithm/windowfunc.cpp b/lib/algorithms/windowfunc.cpp similarity index 100% rename from lib/algorithm/windowfunc.cpp rename to lib/algorithms/windowfunc.cpp diff --git a/lib/algorithm/windowfunc.h b/lib/algorithms/windowfunc.h similarity index 99% rename from lib/algorithm/windowfunc.h rename to lib/algorithms/windowfunc.h index ac9702b..b195a41 100644 --- a/lib/algorithm/windowfunc.h +++ b/lib/algorithms/windowfunc.h @@ -63,6 +63,6 @@ namespace gctl * @param coeff Window coefficients */ void window_blackman(int taps, array &coeff); -} +}; #endif // _WINDOWFUNC_H \ No newline at end of file diff --git a/lib/core/array.h b/lib/core/array.h index 95c3375..d297bdd 100644 --- a/lib/core/array.h +++ b/lib/core/array.h @@ -107,7 +107,7 @@ namespace gctl * * @param[in] len Length of the array. Must be equal to or bigger than zero. */ - array(size_t len); + explicit array(size_t len); /** * @brief Construct an array with the given length and initial values. @@ -145,7 +145,7 @@ namespace gctl * * @param init_val Initial values */ - array(std::initializer_list init_val); + explicit array(std::initializer_list init_val); /** * @brief Construct a new array object as a sequence @@ -1509,18 +1509,6 @@ namespace gctl } #endif // GCTL_EIGEN -/* - template - void array::for_each(foreach_a_ptr func) - { - for (size_t i = 0; i < length_; i++) - { - func(val_[i], i); - } - return; - } -*/ - template void array::show(std::ostream &os, char sep) { @@ -1709,7 +1697,7 @@ namespace gctl throw std::runtime_error("Incompatible array sizes. gctl::array::dot(...)"); } - ArrValType s = 0; + ArrValType s = (ArrValType) 0; for (size_t i = 0; i < length_; i++) { s += val_[i]*a[i]; @@ -1744,15 +1732,32 @@ namespace gctl return sum()/static_cast(length_); } + template + ArrValType array::variance() const + { + static_assert(std::is_arithmetic::value, + "gctl::array::variance(...) could only be used with an arithmetic type."); + + if (length_ == 0 || val_ == nullptr) return ArrValType{}; + + ArrValType m = mean(); + ArrValType d = ArrValType(0); + for (size_t i = 0; i < length_; i++) + { + d += (val_[i] - m)*(val_[i] - m); + } + return d/static_cast(length_); + } + template ArrValType array::std() const { static_assert(std::is_arithmetic::value, "gctl::array::std(...) could only be used with an arithmetic type."); - if (length_ == 0 || length_ == 1) return ArrValType{}; + if (length_ == 0 || val_ == nullptr) return ArrValType{}; - ArrValType m = mean(), s = 0; + ArrValType m = mean(), s = ArrValType(0); for (size_t i = 0; i < length_; i++) { s += (val_[i] - m)*(val_[i] - m); @@ -1913,28 +1918,13 @@ namespace gctl static_assert(std::is_arithmetic::value, "gctl::array::linear2log(...) could only be used with an arithmetic type."); - for (size_t i = 0; i < length_; ++i) - { - val_[i] = log(val_[i])/log(base); - } - return; - } + if (length_ == 0 || val_ == nullptr) return; - template - ArrValType array::variance() const - { - static_assert(std::is_arithmetic::value, - "gctl::array::variance(...) could only be used with an arithmetic type."); - - if (length_ == 0) return ArrValType{}; - - ArrValType mn = mean(); - ArrValType d = 0; for (size_t i = 0; i < length_; i++) { - d = d + (val_[i] - mn)*(val_[i] - mn); + if (val_[i] <= ArrValType(0)) continue; // 跳过非正值 + val_[i] = std::log(val_[i])/std::log(base); } - return d/static_cast(length_); } template @@ -1946,7 +1936,7 @@ namespace gctl if (length_ < 2) return 0; ArrValType mn = mean(); - ArrValType d = 0; + ArrValType d = (ArrValType) 0; for (size_t i = 0; i < length_; i++) { d = d + (val_[i] - mn)*(val_[i] - mn); @@ -2044,6 +2034,6 @@ namespace gctl else os << byte << " B\n"; return; } -} +}; #endif // _GCTL_ARRAY_H \ No newline at end of file diff --git a/lib/core/enum.h b/lib/core/enum.h index 1983024..32690c7 100644 --- a/lib/core/enum.h +++ b/lib/core/enum.h @@ -257,6 +257,6 @@ namespace gctl SoftScale, // 所有数据按比例映射至max(min, min(arr))和min(max, max(arr))范围内 CutOff, // 超过min和max范围数据直接设置为边界值 }; -} +}; #endif // _GCTL_ENUM_H \ No newline at end of file diff --git a/lib/core/exceptions.h b/lib/core/exceptions.h index 5dc7c9b..c4bf435 100644 --- a/lib/core/exceptions.h +++ b/lib/core/exceptions.h @@ -113,28 +113,28 @@ namespace gctl { public: runtime_error() : std::runtime_error("GCTL: Unexpected runtime error."){} - runtime_error(std::string estr) : std::runtime_error(("GCTL: Unexpected runtime error. "+estr).c_str()){} + explicit runtime_error(std::string estr) : std::runtime_error(("GCTL: Unexpected runtime error. "+estr).c_str()){} }; class range_error : public std::range_error { public: range_error() : std::range_error("GCTL: Invalid range detected."){} - range_error(std::string estr) : std::range_error(("GCTL: Invalid range detected. "+estr).c_str()){} + explicit range_error(std::string estr) : std::range_error(("GCTL: Invalid range detected. "+estr).c_str()){} }; class overflow_error : public std::overflow_error { public: overflow_error() : std::overflow_error("GCTL: Overflow error."){} - overflow_error(std::string estr) : std::overflow_error(("GCTL: Overflow error. "+estr).c_str()){} + explicit overflow_error(std::string estr) : std::overflow_error(("GCTL: Overflow error. "+estr).c_str()){} }; class underflow_error : public std::underflow_error { public: underflow_error() : std::underflow_error("GCTL: Underflow error."){} - underflow_error(std::string estr) : std::underflow_error(("GCTL: Underflow error. "+estr).c_str()){} + explicit underflow_error(std::string estr) : std::underflow_error(("GCTL: Underflow error. "+estr).c_str()){} }; @@ -142,36 +142,36 @@ namespace gctl { public: logic_error() : std::logic_error("GCTL: Logic error."){} - logic_error(std::string estr) : std::logic_error(("GCTL: Logic error. "+estr).c_str()){} + explicit logic_error(std::string estr) : std::logic_error(("GCTL: Logic error. "+estr).c_str()){} }; class domain_error : public std::domain_error { public: domain_error() : std::domain_error("GCTL: Domain error."){} - domain_error(std::string estr) : std::domain_error(("GCTL: Domain error. "+estr).c_str()){} + explicit domain_error(std::string estr) : std::domain_error(("GCTL: Domain error. "+estr).c_str()){} }; class invalid_argument : public std::invalid_argument { public: invalid_argument() : std::invalid_argument("GCTL: Invalid argument."){} - invalid_argument(std::string estr) : std::invalid_argument(("GCTL: Invalid argument. "+estr).c_str()){} + explicit invalid_argument(std::string estr) : std::invalid_argument(("GCTL: Invalid argument. "+estr).c_str()){} }; class length_error : public std::length_error { public: length_error() : std::length_error("GCTL: Length error."){} - length_error(std::string estr) : std::length_error(("GCTL: Length error. "+estr).c_str()){} + explicit length_error(std::string estr) : std::length_error(("GCTL: Length error. "+estr).c_str()){} }; class out_of_range : public std::out_of_range { public: out_of_range() : std::out_of_range("GCTL: Out of range."){} - out_of_range(std::string estr) : std::out_of_range(("GCTL: Out of range. "+estr).c_str()){} + explicit out_of_range(std::string estr) : std::out_of_range(("GCTL: Out of range. "+estr).c_str()){} }; -} +}; #endif // _GCTL_EXCEPTIONS_H \ No newline at end of file diff --git a/lib/core/matrix.h b/lib/core/matrix.h index 048b7dc..a8bddb9 100644 --- a/lib/core/matrix.h +++ b/lib/core/matrix.h @@ -114,7 +114,7 @@ namespace gctl * * @param[in] b 输入向量的引用 */ - matrix(const std::vector > &b); + explicit matrix(const std::vector > &b); /** * @brief 构造函数:从一维数组初始化二维数组 @@ -1093,6 +1093,6 @@ namespace gctl } return; } -} +}; #endif // _GCTL_MATRIX_H \ No newline at end of file diff --git a/lib/core/sparray.h b/lib/core/sparray.h index 63a1481..dfa75f5 100644 --- a/lib/core/sparray.h +++ b/lib/core/sparray.h @@ -653,6 +653,6 @@ namespace gctl { return arr2d.size(); } -} +}; #endif // _GCTL_SPARRAY_H \ No newline at end of file diff --git a/lib/core/spmat.h b/lib/core/spmat.h index 9d334f3..161d9f1 100644 --- a/lib/core/spmat.h +++ b/lib/core/spmat.h @@ -61,6 +61,7 @@ namespace gctl */ mat_node() { + val = (NodeValueType) 0; r_id = c_id = -1; next_right = next_down = nullptr; } @@ -626,6 +627,7 @@ namespace gctl r_end = c_end = nullptr; d_link = nullptr; r_count = c_count = nullptr; + zero_val = (MatrixValueType) 0; } template @@ -2939,6 +2941,7 @@ namespace gctl { if (!empty()) clear(); + zero_val = b.zero_val; r_num = b.row_size(); c_num = b.col_size(); r_head = new mat_node* [r_num]; @@ -3302,6 +3305,6 @@ namespace gctl #endif // GCTL_EIGEN -} +}; #endif //_GCTL_SPMAT_H \ No newline at end of file diff --git a/lib/core/sptr.h b/lib/core/sptr.h index b20c24d..2fc5660 100644 --- a/lib/core/sptr.h +++ b/lib/core/sptr.h @@ -41,7 +41,7 @@ namespace gctl //该类成员访问权限全部为private,因为不想让用户直接使用该类 //定义智能指针类为友元,因为智能指针类需要直接操纵辅助类 friend class smart_ptr; - ref_ptr() : p(nullptr) {} + ref_ptr() : p(nullptr), count(0) {} //构造函数的参数为基础对象的指针 ref_ptr(T *ptr) : p(ptr), count(1) {} //析构函数 @@ -94,6 +94,6 @@ namespace gctl private: ref_ptr *rp; //辅助类对象指针 }; -} +}; #endif //_GCTL_SPTR_H \ No newline at end of file diff --git a/lib/core/vector_t.h b/lib/core/vector_t.h index b142c57..d10eeaa 100644 --- a/lib/core/vector_t.h +++ b/lib/core/vector_t.h @@ -129,6 +129,6 @@ namespace gctl while (os >> t){a.push_back(t);} return os; } -} +}; #endif // _GCTL_VECTOR_TYPE_H \ No newline at end of file diff --git a/lib/geometry/block.h b/lib/geometry/block.h index 4cbb0e2..fc29529 100644 --- a/lib/geometry/block.h +++ b/lib/geometry/block.h @@ -274,6 +274,6 @@ namespace gctl tar->ur = src->ur; return; } -} +}; #endif // _GCTL_BLOCK_H \ No newline at end of file diff --git a/lib/geometry/edge.h b/lib/geometry/edge.h index 7d9f1bf..395ca01 100644 --- a/lib/geometry/edge.h +++ b/lib/geometry/edge.h @@ -28,6 +28,7 @@ #ifndef _GCTL_EDGE_H #define _GCTL_EDGE_H +#include "point3c.h" #include "vertex.h" #include "entity.h" @@ -148,6 +149,6 @@ namespace gctl } return; } -} +}; #endif // _GCTL_EDGE_H \ No newline at end of file diff --git a/lib/geometry/edge2d.h b/lib/geometry/edge2d.h index a88413b..ba4b185 100644 --- a/lib/geometry/edge2d.h +++ b/lib/geometry/edge2d.h @@ -28,6 +28,7 @@ #ifndef _GCTL_EDGE2D_H #define _GCTL_EDGE2D_H +#include "point2c.h" #include "vertex.h" #include "entity.h" #include "triangle2d.h" @@ -181,6 +182,6 @@ namespace gctl neigh[1] = &nei1; return; } -} +}; #endif // _GCTL_EDGE2D_H \ No newline at end of file diff --git a/lib/geometry/entity.h b/lib/geometry/entity.h index 756498e..3c30108 100644 --- a/lib/geometry/entity.h +++ b/lib/geometry/entity.h @@ -251,6 +251,6 @@ namespace gctl } return; } -} +}; #endif // _GCTL_ENTITY_H \ No newline at end of file diff --git a/lib/geometry/geometry2d.cpp b/lib/geometry/geometry2d.cpp index 7c652d9..5aa901e 100644 --- a/lib/geometry/geometry2d.cpp +++ b/lib/geometry/geometry2d.cpp @@ -25,12 +25,14 @@ * Also add information on how to contact you by electronic and paper mail. ******************************************************/ -#include "geometry2d.h" +#include +#include +#include +#include +#include +#include -#include "string" -#include "cmath" -#include "map" -#include "algorithm" +#include "geometry2d.h" // 计算点t是否在直线ab上。 bool gctl::geometry2d::collinear(const point2dc &a, const point2dc &b, @@ -39,7 +41,7 @@ bool gctl::geometry2d::collinear(const point2dc &a, const point2dc &b, point2dc at = t - a; point2dc ab = b - a; double cos_arc = dot(at, ab)/(at.module()*ab.module()); - if (sqrt(1 - cos_arc*cos_arc)*at.module() <= cut_off) + if (sqrt(1.0 - cos_arc*cos_arc)*at.module() <= cut_off) return true; else return false; } diff --git a/lib/geometry/geometry2d.h b/lib/geometry/geometry2d.h index 9627163..a8a7fd2 100644 --- a/lib/geometry/geometry2d.h +++ b/lib/geometry/geometry2d.h @@ -239,5 +239,6 @@ namespace gctl void extract_triangular_mesh_2d(const array &in_eles, const array &out_list, array &out_nodes, array &out_eles); } -} +}; + #endif // _GCTL_GEOMETRY2D_H \ No newline at end of file diff --git a/lib/geometry/geometry3d.cpp b/lib/geometry/geometry3d.cpp index 5d75cef..bc87f46 100644 --- a/lib/geometry/geometry3d.cpp +++ b/lib/geometry/geometry3d.cpp @@ -25,15 +25,16 @@ * Also add information on how to contact you by electronic and paper mail. ******************************************************/ +#include +#include +#include +#include +#include +#include +#include + #include "geometry3d.h" -#include "string" -#include "cmath" -#include "vector" -#include "map" -#include "algorithm" - - double gctl::geometry3d::angle(const point3dc &a, const point3dc &b) //向量夹角 { double d = GCTL_SetToBox(-1.0, 1.0, dot(a, b)/(a.module() * b.module())); diff --git a/lib/geometry/geometry3d.h b/lib/geometry/geometry3d.h index 728a217..70d02a9 100644 --- a/lib/geometry/geometry3d.h +++ b/lib/geometry/geometry3d.h @@ -361,5 +361,6 @@ namespace gctl void cut_triangular_mesh(const array &in_eles, const point3dc &nor, const point3dc &surf, array &out_nodes, array &out_eles); } -} +}; + #endif // _GCTL_GEOMETRY3D_H \ No newline at end of file diff --git a/lib/geometry/node.h b/lib/geometry/node.h index dce850f..a15da5e 100644 --- a/lib/geometry/node.h +++ b/lib/geometry/node.h @@ -28,6 +28,7 @@ #ifndef _GCTL_NODE_H #define _GCTL_NODE_H +#include "point3c.h" #include "vertex.h" #include "entity.h" @@ -147,6 +148,6 @@ namespace gctl copy_entity(tar, src); return; } -} +}; #endif // _GCTL_NODE_H \ No newline at end of file diff --git a/lib/geometry/point.h b/lib/geometry/point.h new file mode 100644 index 0000000..7eff0ff --- /dev/null +++ b/lib/geometry/point.h @@ -0,0 +1,55 @@ +/******************************************************** + * ██████╗ ██████╗████████╗██╗ + * ██╔════╝ ██╔════╝╚══██╔══╝██║ + * ██║ ███╗██║ ██║ ██║ + * ██║ ██║██║ ██║ ██║ + * ╚██████╔╝╚██████╗ ██║ ███████╗ + * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ + * Geophysical Computational Tools & Library (GCTL) + * + * Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn) + * + * GCTL is distributed under a dual licensing scheme. You can redistribute + * it and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either version 2 + * of the License, or (at your option) any later version. You should have + * received a copy of the GNU Lesser General Public License along with this + * program. If not, see . + * + * If the terms and conditions of the LGPL v.2. would prevent you from using + * the GCTL, please consider the option to obtain a commercial license for a + * fee. These licenses are offered by the GCTL's original author. As a rule, + * licenses are provided "as-is", unlimited in time for a one time fee. Please + * send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget + * to include some description of your company and the realm of its activities. + * Also add information on how to contact you by electronic and paper mail. + ******************************************************/ + +#ifndef _GCTL_POINT_H +#define _GCTL_POINT_H + +#include "iostream" +#include "string" +#include "cmath" +#include "iomanip" +#include "regex" + +#include "../core/macro.h" +#include "../core/exceptions.h" + +namespace gctl +{ + template struct point2c; + template struct point2p; + template struct point3c; + template struct point3s; + +#ifndef IO_PSN +#define IO_PSN + // static variable for controlling the IO process + static int io_psn = 6; +#endif // IO_PSN + +}; + +#endif // _GCTL_POINT_H \ No newline at end of file diff --git a/lib/geometry/point2c.h b/lib/geometry/point2c.h index 341461e..ad20676 100644 --- a/lib/geometry/point2c.h +++ b/lib/geometry/point2c.h @@ -28,30 +28,13 @@ #ifndef _GCTL_POINT2C_H #define _GCTL_POINT2C_H -#include "../core/macro.h" -#include "../core/exceptions.h" -#include "point2p.h" - -#include "iostream" -#include "string" -#include "cmath" -#include "iomanip" -#include "regex" +#include "point.h" namespace gctl { - template struct point2c; - template struct point2p; - typedef point2c point2dc; typedef point2c point2fc; -#ifndef IO_PSN -#define IO_PSN - // static variable for controlling the IO process - static int io_psn = 6; -#endif // IO_PSN - /** * @brief A point under the 2D Cartesian coordinates (aka. 2D vector). */ @@ -549,6 +532,6 @@ namespace gctl } return; } -} +}; #endif // _GCTL_POINT2C_H \ No newline at end of file diff --git a/lib/geometry/point2p.h b/lib/geometry/point2p.h index 9664244..4b46817 100644 --- a/lib/geometry/point2p.h +++ b/lib/geometry/point2p.h @@ -28,30 +28,13 @@ #ifndef _GCTL_POINT2P_H #define _GCTL_POINT2P_H -#include "../core/macro.h" -#include "../core/exceptions.h" -#include "point2c.h" - -#include "iostream" -#include "string" -#include "cmath" -#include "iomanip" -#include "regex" +#include "point.h" namespace gctl { - template struct point2c; - template struct point2p; - typedef point2p point2dp; typedef point2p point2fp; -#ifndef IO_PSN -#define IO_PSN - // static variable for controlling the IO process - static int io_psn = 6; -#endif // IO_PSN - /** * @brief A point under the 2-D Polar coordinates. */ @@ -389,6 +372,6 @@ namespace gctl } return; } -} +}; #endif // _GCTL_POINT2P_H \ No newline at end of file diff --git a/lib/geometry/point3c.h b/lib/geometry/point3c.h index a4c6ed5..2e20767 100644 --- a/lib/geometry/point3c.h +++ b/lib/geometry/point3c.h @@ -28,31 +28,14 @@ #ifndef _GCTL_POINT3C_H #define _GCTL_POINT3C_H -#include "../core/macro.h" -#include "../core/exceptions.h" +#include "point.h" #include "../core/array.h" -#include "point3s.h" - -#include "iostream" -#include "string" -#include "cmath" -#include "iomanip" -#include "regex" namespace gctl { - template struct point3c; - template struct point3s; - typedef point3c point3dc; typedef point3c point3fc; -#ifndef IO_PSN -#define IO_PSN - // static variable for controlling the IO process - static int io_psn = 6; -#endif // IO_PSN - /** * @brief 直角坐标系内的实点 */ @@ -714,6 +697,6 @@ namespace gctl } return; } -} +}; #endif // _GCTL_POINT3C_H \ No newline at end of file diff --git a/lib/geometry/point3s.h b/lib/geometry/point3s.h index 9b60050..91826ee 100644 --- a/lib/geometry/point3s.h +++ b/lib/geometry/point3s.h @@ -28,30 +28,13 @@ #ifndef _GCTL_POINT3S_H #define _GCTL_POINT3S_H -#include "../core/macro.h" -#include "../core/exceptions.h" -#include "point3c.h" - -#include "iostream" -#include "string" -#include "cmath" -#include "iomanip" -#include "regex" +#include "point.h" namespace gctl { - template struct point3c; - template struct point3s; - typedef point3s point3ds; typedef point3s point3fs; -#ifndef IO_PSN -#define IO_PSN - // static variable for controlling the IO process - static int io_psn = 6; -#endif // IO_PSN - /** * @brief 球坐标系中的一个点(经纬度表示的) */ @@ -514,6 +497,6 @@ namespace gctl } return; } -} +}; #endif // _GCTL_POINT3S_H \ No newline at end of file diff --git a/lib/geometry/prism.h b/lib/geometry/prism.h index 12cca00..a668a70 100644 --- a/lib/geometry/prism.h +++ b/lib/geometry/prism.h @@ -178,6 +178,6 @@ namespace gctl copy_entity(tar, src); return; } -} +}; #endif // _GCTL_PRISM_H \ No newline at end of file diff --git a/lib/geometry/rectangle2d.h b/lib/geometry/rectangle2d.h index 83906ea..ede38cd 100644 --- a/lib/geometry/rectangle2d.h +++ b/lib/geometry/rectangle2d.h @@ -204,6 +204,6 @@ namespace gctl } return; } -} +}; #endif // _GCTL_RECTANGLE2D_H \ No newline at end of file diff --git a/lib/geometry/refellipsoid.h b/lib/geometry/refellipsoid.h index 752717e..69244e2 100644 --- a/lib/geometry/refellipsoid.h +++ b/lib/geometry/refellipsoid.h @@ -86,6 +86,6 @@ namespace gctl double r_, R_; }; -} +}; #endif // _GCTL_REFELLIPSOID_H \ No newline at end of file diff --git a/lib/geometry/sphere.h b/lib/geometry/sphere.h index d7b10f1..a6031a4 100644 --- a/lib/geometry/sphere.h +++ b/lib/geometry/sphere.h @@ -28,6 +28,7 @@ #ifndef _GCTL_SPHERE_H #define _GCTL_SPHERE_H +#include "point3c.h" #include "vertex.h" #include "entity.h" @@ -171,6 +172,6 @@ namespace gctl tar->rad = src->rad; return; } -} +}; #endif // _GCTL_SPHERE_H \ No newline at end of file diff --git a/lib/geometry/tensor.h b/lib/geometry/tensor.h index 218af0c..66420e2 100644 --- a/lib/geometry/tensor.h +++ b/lib/geometry/tensor.h @@ -397,6 +397,6 @@ namespace gctl t.val[2][0]=a.z*b.x; t.val[2][1]=a.z*b.y; t.val[2][2]=a.z*b.z; return t; } -} +}; #endif // _GCTL_TENSOR_H \ No newline at end of file diff --git a/lib/geometry/tesseroid.h b/lib/geometry/tesseroid.h index d4568f6..0e9893f 100644 --- a/lib/geometry/tesseroid.h +++ b/lib/geometry/tesseroid.h @@ -273,6 +273,6 @@ namespace gctl tar->ur = src->ur; return; } -} +}; #endif // _GCTL_TESSEROID_H \ No newline at end of file diff --git a/lib/geometry/tetrahedron.h b/lib/geometry/tetrahedron.h index 0fca997..2a44739 100644 --- a/lib/geometry/tetrahedron.h +++ b/lib/geometry/tetrahedron.h @@ -28,6 +28,7 @@ #ifndef _GCTL_TETRAHEDRON_H #define _GCTL_TETRAHEDRON_H +#include "point3c.h" #include "vertex.h" #include "entity.h" @@ -577,6 +578,6 @@ namespace gctl tar->vec_order = src->vec_order; return; } -} +}; #endif // _GCTL_TETRAHEDRON_H \ No newline at end of file diff --git a/lib/geometry/tri_cone.h b/lib/geometry/tri_cone.h index ba88327..4e678c6 100644 --- a/lib/geometry/tri_cone.h +++ b/lib/geometry/tri_cone.h @@ -28,6 +28,7 @@ #ifndef _GCTL_TRI_CONE_H #define _GCTL_TRI_CONE_H +#include "point3c.h" #include "vertex.h" #include "entity.h" diff --git a/lib/geometry/triangle.h b/lib/geometry/triangle.h index de4804d..8f87881 100644 --- a/lib/geometry/triangle.h +++ b/lib/geometry/triangle.h @@ -28,6 +28,7 @@ #ifndef _GCTL_TRIANGLE_H #define _GCTL_TRIANGLE_H +#include "point3c.h" #include "vertex.h" #include "entity.h" @@ -221,6 +222,6 @@ namespace gctl hgt_x = sqrt(edge_len[(c_id+2)%3]*edge_len[(c_id+2)%3] - hgt_y*hgt_y); return; } -} +}; #endif // _GCTL_TRIANGLE_H \ No newline at end of file diff --git a/lib/geometry/triangle2d.h b/lib/geometry/triangle2d.h index 4270441..1953911 100644 --- a/lib/geometry/triangle2d.h +++ b/lib/geometry/triangle2d.h @@ -28,6 +28,7 @@ #ifndef _GCTL_TRIANGLE2D_H #define _GCTL_TRIANGLE2D_H +#include "point2c.h" #include "vertex.h" #include "entity.h" @@ -214,6 +215,6 @@ namespace gctl copy_entity(tar, src); return; } -} +}; #endif // _GCTL_TRIANGLE2D_H \ No newline at end of file diff --git a/lib/geometry/triangle2d2o.h b/lib/geometry/triangle2d2o.h index 33f31ce..5b1c5d0 100644 --- a/lib/geometry/triangle2d2o.h +++ b/lib/geometry/triangle2d2o.h @@ -28,6 +28,7 @@ #ifndef _GCTL_TRIANGLE2D2O_H #define _GCTL_TRIANGLE2D2O_H +#include "point2c.h" #include "vertex.h" #include "entity.h" @@ -296,6 +297,6 @@ namespace gctl copy_entity(tar, src); return; } -} +}; #endif // _GCTL_TRIANGLE2D2O_H \ No newline at end of file diff --git a/lib/geometry/vertex.h b/lib/geometry/vertex.h index 691516d..2d07c6a 100644 --- a/lib/geometry/vertex.h +++ b/lib/geometry/vertex.h @@ -168,6 +168,6 @@ namespace gctl os >> a.id; a.in_loc(os); return os; } -} +}; #endif // _GCTL_VERTEX_H \ No newline at end of file diff --git a/lib/io/dsv_io.h b/lib/io/dsv_io.h index 10e1c9d..5d1369e 100644 --- a/lib/io/dsv_io.h +++ b/lib/io/dsv_io.h @@ -1023,6 +1023,6 @@ namespace gctl */ void get_column_point3ds(array &data, std::string rname, std::string pname, std::string tname); }; -} +}; #endif //_GCTL_DSV_IO_H \ No newline at end of file diff --git a/lib/io/gmsh_io.h b/lib/io/gmsh_io.h index 1da881b..6d1e40b 100644 --- a/lib/io/gmsh_io.h +++ b/lib/io/gmsh_io.h @@ -3837,5 +3837,6 @@ namespace gctl #endif // GCTL_EIGEN -} +}; + #endif //_GCTL_GMSH_IO_H \ No newline at end of file diff --git a/lib/io/mesh_io.cpp b/lib/io/mesh_io.cpp index b0b55b1..a810d8d 100644 --- a/lib/io/mesh_io.cpp +++ b/lib/io/mesh_io.cpp @@ -319,8 +319,8 @@ void gctl::mesh_io::info(std::ostream &ss) { if (reinterpret_cast(datas_[d].tar_ptrs[l])->id != DEFAULT_INVALID_TAG) { - min = std::min(min, datas_[d].val[l]); - max = std::max(max, datas_[d].val[l]); + min = GCTL_MIN(min, datas_[d].val[l]); + max = GCTL_MAX(max, datas_[d].val[l]); d_size++; } } @@ -332,8 +332,8 @@ void gctl::mesh_io::info(std::ostream &ss) { if (reinterpret_cast(datas_[d].tar_ptrs[l])->enabled) { - min = std::min(min, datas_[d].val[l]); - max = std::max(max, datas_[d].val[l]); + min = GCTL_MIN(min, datas_[d].val[l]); + max = GCTL_MAX(max, datas_[d].val[l]); d_size++; } } diff --git a/lib/io/mesh_io.h b/lib/io/mesh_io.h index 40998c8..bc8707c 100644 --- a/lib/io/mesh_io.h +++ b/lib/io/mesh_io.h @@ -38,7 +38,6 @@ #include "gmsh_io.h" #include "map" - namespace gctl { /** @@ -521,6 +520,6 @@ namespace gctl void update_indexing(); // 更新索引(对网格的元素进行操作后需调用) void sort_groups(); // 对单元体组进行梳理(对网格的元素进行操作后需调用) }; -} +}; #endif // _GCTL_MESH_IO_H \ No newline at end of file diff --git a/lib/io/native_io.h b/lib/io/native_io.h index 2f31dc3..91fcbb8 100644 --- a/lib/io/native_io.h +++ b/lib/io/native_io.h @@ -428,6 +428,6 @@ namespace gctl outfile.close(); return; } -} +}; #endif // _GCTL_NATIVE_IO_H \ No newline at end of file diff --git a/lib/io/netcdf_io.h b/lib/io/netcdf_io.h index 0596aad..3e0e009 100644 --- a/lib/io/netcdf_io.h +++ b/lib/io/netcdf_io.h @@ -775,7 +775,7 @@ namespace gctl return; } -} +}; #endif // GCTL_NETCDF diff --git a/lib/io/off_io.h b/lib/io/off_io.h index 1235308..6d6d4b9 100644 --- a/lib/io/off_io.h +++ b/lib/io/off_io.h @@ -141,6 +141,6 @@ namespace gctl outfile.close(); return; } -} +}; #endif // _GCTL_OFF_IO_H \ No newline at end of file diff --git a/lib/io/surfer_io.h b/lib/io/surfer_io.h index 85ffc41..a125495 100644 --- a/lib/io/surfer_io.h +++ b/lib/io/surfer_io.h @@ -187,6 +187,6 @@ namespace gctl void save_surfer7_grid(std::string filename, const array &out_data, int xnum, int ynum, double xmin, double ymin, double dx, double dy, double zmin = NAN, double zmax = NAN, double blank_val = 1.70141e38); -} +}; #endif // _GCTL_SURFER_IO_H \ No newline at end of file diff --git a/lib/io/tetgen_io.h b/lib/io/tetgen_io.h index 926ea1b..8eb9b1c 100644 --- a/lib/io/tetgen_io.h +++ b/lib/io/tetgen_io.h @@ -1192,5 +1192,6 @@ namespace gctl tetout.close(); return; } -} +}; + #endif //_GCTL_TETGEN_IO_H \ No newline at end of file diff --git a/lib/io/text_io.h b/lib/io/text_io.h index 6a263a5..4103222 100644 --- a/lib/io/text_io.h +++ b/lib/io/text_io.h @@ -1322,6 +1322,7 @@ namespace gctl */ void save_data_column(std::ofstream &outfile, std::initializer_list*> dat_val, std::initializer_list dat_name, char delimiter = ' ', int precision = GCTL_PRECISION); -} + +}; #endif //_GCTL_TEXT_IO_H diff --git a/lib/io/triangle_io.h b/lib/io/triangle_io.h index 8422315..78000a2 100644 --- a/lib/io/triangle_io.h +++ b/lib/io/triangle_io.h @@ -1270,5 +1270,7 @@ namespace gctl triout.close(); return; } -} + +}; + #endif //_GCTL_TRIANGLE_H \ No newline at end of file diff --git a/lib/maths/fft.h b/lib/maths/fft.h index a2ef4a6..12467b7 100644 --- a/lib/maths/fft.h +++ b/lib/maths/fft.h @@ -90,6 +90,6 @@ namespace gctl * @param out_arr Output real array */ void idct1d(const _1d_array &in_arr, _1d_array &out_arr); -} +}; #endif // _GCTL_FFT_H \ No newline at end of file diff --git a/lib/maths/gaussfunc.h b/lib/maths/gaussfunc.h index 252a2de..8b623aa 100644 --- a/lib/maths/gaussfunc.h +++ b/lib/maths/gaussfunc.h @@ -77,6 +77,6 @@ namespace gctl */ double gaussian_dist2d(double x, double y, const gaussian_para2d &p, gradient_type_e mode = Value); -} +}; #endif // _GAUSSFUNC_H \ No newline at end of file diff --git a/lib/maths/legendre.h b/lib/maths/legendre.h index 7cfdac1..a6eb75e 100644 --- a/lib/maths/legendre.h +++ b/lib/maths/legendre.h @@ -98,6 +98,6 @@ namespace gctl void nalf_sfcm(array> &nalf, const array> &a_nm, const array> &b_nm, int max_order, double theta, legendre_norm_e norm, bool derivative = false); -} +}; #endif //_GCTL_LEGENDRE_H \ No newline at end of file diff --git a/lib/maths/linear_algebra.h b/lib/maths/linear_algebra.h index 98ac664..1688b4b 100644 --- a/lib/maths/linear_algebra.h +++ b/lib/maths/linear_algebra.h @@ -350,6 +350,6 @@ namespace gctl * @return New standard deviation value. */ double dynamic_stddev(double old_stddev, size_t old_count, double old_mean, double new_input, double &new_mean); -} +}; #endif // _GCTL_LINEAR_ALGEBRA_H \ No newline at end of file diff --git a/lib/maths/mathfunc.h b/lib/maths/mathfunc.h index 702e4d4..89674c4 100644 --- a/lib/maths/mathfunc.h +++ b/lib/maths/mathfunc.h @@ -28,16 +28,16 @@ #ifndef _GCTL_MATHFUNC_H #define _GCTL_MATHFUNC_H +// system's head files +#include +#include +#include + // library's head files #include "../core/macro.h" #include "../core/spmat.h" #include "mathfunc_t.h" -// system's head files -#include "cmath" -#include "random" -#include "vector" - namespace gctl { /** @@ -212,6 +212,6 @@ namespace gctl * @param[in] a_s 向量的个数 */ void schmidt_orthogonal(const array &a, array &e, int a_s); -} +}; #endif // _GCTL_MATHFUNC_H \ No newline at end of file diff --git a/lib/maths/mathfunc_ext.h b/lib/maths/mathfunc_ext.h index d6e6e39..dda184a 100644 --- a/lib/maths/mathfunc_ext.h +++ b/lib/maths/mathfunc_ext.h @@ -51,6 +51,6 @@ namespace gctl void tran(double **a,int n); void metrimult(double **a,double **b,int m,int n,int l,double **c); void svd_standalone(double **a,int m,int n,double **u,double **v,double *q,int Index); -} +}; #endif // _GCTL_MATHFUNC_EXT_H \ No newline at end of file diff --git a/lib/maths/mathfunc_t.h b/lib/maths/mathfunc_t.h index 040402d..fb6148c 100644 --- a/lib/maths/mathfunc_t.h +++ b/lib/maths/mathfunc_t.h @@ -28,11 +28,8 @@ #ifndef _GCTL_MATHFUNC_TEMPLATE_H #define _GCTL_MATHFUNC_TEMPLATE_H -#include "../core/enum.h" -#include "../core/array.h" +#include #include "../core/matrix.h" -#include "../core/exceptions.h" -#include "cmath" namespace gctl { @@ -142,7 +139,7 @@ namespace gctl { T ang; if(v>=0) ang=atan(v); - else if(v<0) ang=atan(v)+GCTL_Pi; + else ang=atan(v)+GCTL_Pi; return ang; } @@ -162,7 +159,7 @@ namespace gctl } return ang; } -} +}; #endif //_GCTL_MATHFUNC_TEMPLATE_H diff --git a/lib/maths/shapefunc.h b/lib/maths/shapefunc.h index 3c84917..83a10c9 100644 --- a/lib/maths/shapefunc.h +++ b/lib/maths/shapefunc.h @@ -535,6 +535,6 @@ namespace gctl size_t idx, eshape_value_e vt, edge_orient_e ot, double &xval, double &yval, double &zval, double &xval2, double &yval2, double &zval2); }; -} +}; #endif // _GCTL_SHAPEFUNC_H \ No newline at end of file diff --git a/lib/utility/assess.h b/lib/utility/assess.h index dcf2a78..f9e9214 100644 --- a/lib/utility/assess.h +++ b/lib/utility/assess.h @@ -28,11 +28,11 @@ #ifndef _GCTL_ASSESS_H #define _GCTL_ASSESS_H -#include "iostream" -#include "string" -#include "cmath" -#include "ctime" -#include "chrono" +#include +#include +#include +#include +#include /* Basic assess. If fails, returns msg. If passes, returns 0 */ #define GCTL_Assess(test, msg) \ @@ -96,6 +96,6 @@ namespace gctl int tests_run, tests_passed, tests_failed; std::chrono::system_clock::time_point start_t; }; -} +}; #endif // _GCTL_ASSESS_H \ No newline at end of file diff --git a/lib/utility/get_option.h b/lib/utility/get_option.h index 367a137..b4b3fa1 100644 --- a/lib/utility/get_option.h +++ b/lib/utility/get_option.h @@ -28,16 +28,16 @@ #ifndef _GCTL_GETOPTION_H #define _GCTL_GETOPTION_H +// system's head file +#include +#include +#include +#include + // library's head file #include "../core/array.h" #include "stream.h" -// system's head file -#include "vector" -#include "string" -#include "iostream" -#include "fstream" - namespace gctl { /** @@ -263,5 +263,6 @@ namespace gctl std::vector group_idx_; }; -} +}; + #endif //_GCTL_GETOPTION_H \ No newline at end of file diff --git a/lib/utility/getopt_help.h b/lib/utility/getopt_help.h index 97d2858..f80a9cf 100644 --- a/lib/utility/getopt_help.h +++ b/lib/utility/getopt_help.h @@ -28,16 +28,16 @@ #ifndef _GCTL_GETOPT_HELP_H #define _GCTL_GETOPT_HELP_H -#include "stream.h" - #ifdef _WINDOWS -#include "windows.h" +#include #include "getopt_win.h" #else -#include "sys/ioctl.h" +#include #include "getopt.h" #endif +#include "stream.h" + namespace gctl { struct option_info diff --git a/lib/utility/process_monitor.h b/lib/utility/process_monitor.h index b5649e4..540f7b7 100644 --- a/lib/utility/process_monitor.h +++ b/lib/utility/process_monitor.h @@ -28,11 +28,11 @@ #ifndef _GCTL_PROCESS_MONITOR_H #define _GCTL_PROCESS_MONITOR_H -#include "thread" -#include "mutex" -#include "condition_variable" -#include "termios.h" -#include "iostream" +#include +#include +#include +#include +#include namespace gctl { @@ -107,6 +107,6 @@ namespace gctl std::mutex mtx_; std::condition_variable cv_; }; -} +}; #endif // _GCTL_PROCESS_MONITOR_H \ No newline at end of file diff --git a/lib/utility/progress_bar.h b/lib/utility/progress_bar.h index 1f9c477..d89d16a 100644 --- a/lib/utility/progress_bar.h +++ b/lib/utility/progress_bar.h @@ -28,19 +28,19 @@ #ifndef _GCTL_PROGRESS_BAR_H #define _GCTL_PROGRESS_BAR_H -#include "../core/exceptions.h" - #ifdef _WINDOWS -#include "windows.h" +#include #else -#include "sys/ioctl.h" +#include #endif -#include "cstring" -#include "iostream" -#include "iomanip" -#include "thread" -#include "chrono" +#include +#include +#include +#include +#include + +#include "../core/exceptions.h" //进度条宏定义 #define TOTAL_PERCENTAGE 100.0 ///< 设置总的百分比为100%。 diff --git a/lib/utility/stream.h b/lib/utility/stream.h index b9b15d0..6dc284b 100644 --- a/lib/utility/stream.h +++ b/lib/utility/stream.h @@ -27,23 +27,23 @@ #ifndef _GCTL_STREAM_H #define _GCTL_STREAM_H -// library's head files -#include "stream_t.h" - // system's head files -#include "cstring" -#include "iostream" -#include "fstream" -#include "iomanip" -#include "ctime" +#include +#include +#include +#include +#include #include "stdio.h" #ifdef _WINDOWS -#include "windows.h" +#include #else -#include "sys/ioctl.h" +#include #endif +// library's head files +#include "stream_t.h" + namespace gctl { /** @@ -197,6 +197,6 @@ namespace gctl * @param exten_name 文件后缀名 */ void parse_filename(std::string filename, std::string &naked_name, std::string &exten_name); -} +}; #endif // _GCTL_STREAM_H \ No newline at end of file diff --git a/lib/utility/utc_time.h b/lib/utility/utc_time.h index c24d848..e231be9 100644 --- a/lib/utility/utc_time.h +++ b/lib/utility/utc_time.h @@ -28,12 +28,12 @@ #ifndef _GCTL_UTC_TIME_H #define _GCTL_UTC_TIME_H -#include "iostream" -#include "sstream" -#include "iomanip" -#include "cmath" -#include "sys/time.h" -#include "unistd.h" +#include +#include +#include +#include +#include +#include namespace gctl { @@ -95,6 +95,6 @@ namespace gctl bool operator!=(const UTC_TIME &ta, const UTC_TIME &tb); bool operator<(const UTC_TIME &ta, const UTC_TIME &tb); bool operator<=(const UTC_TIME &ta, const UTC_TIME &tb); -} +}; #endif // _GCTL_UTC_TIME_H \ No newline at end of file