From d1bf361e432ba9ab2d43c651f1f525f7477fa292 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Sat, 19 Jul 2025 07:43:12 +0800 Subject: [PATCH] tmp --- CMakeLists.txt | 1 + src/core/fft2d_ex.cpp | 2 +- src/core/getoption_ex.cpp | 1 + src/core/matrix_ex.cpp | 55 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/core/matrix_ex.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ce88762..117c4ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ endmacro() if(GCTL_FOUND) add_example(core array_ex ON OFF OFF OFF) + add_example(core matrix_ex ON OFF OFF OFF) add_example(core autodiff_ex ON OFF OFF OFF) add_example(core ceemdan_ex ON OFF OFF OFF) add_example(core cliplot_ex ON OFF OFF OFF) diff --git a/src/core/fft2d_ex.cpp b/src/core/fft2d_ex.cpp index e945a67..91e582d 100644 --- a/src/core/fft2d_ex.cpp +++ b/src/core/fft2d_ex.cpp @@ -64,7 +64,7 @@ void average_radian_spec(const array &in_freq, const array &in_p if (!bin.empty()) { - bin_arr.input(bin); + bin_arr.import_vector(bin); out_power[i] = bin_arr.mean(); out_std[i] = bin_arr.std(); } diff --git a/src/core/getoption_ex.cpp b/src/core/getoption_ex.cpp index c49991c..b77fff0 100644 --- a/src/core/getoption_ex.cpp +++ b/src/core/getoption_ex.cpp @@ -25,6 +25,7 @@ * Also add information on how to contact you by electronic and paper mail. ******************************************************/ +#include "gctl/core.h" #include "gctl/utility.h" #include "gctl/poly.h" diff --git a/src/core/matrix_ex.cpp b/src/core/matrix_ex.cpp new file mode 100644 index 0000000..fc871dd --- /dev/null +++ b/src/core/matrix_ex.cpp @@ -0,0 +1,55 @@ +/******************************************************** + * ██████╗ ██████╗████████╗██╗ + * ██╔════╝ ██╔════╝╚══██╔══╝██║ + * ██║ ███╗██║ ██║ ██║ + * ██║ ██║██║ ██║ ██║ + * ╚██████╔╝╚██████╗ ██║ ███████╗ + * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ + * Geophysical Computational Tools & Library (GCTL) + * + * Copyright (c) 2022 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. + ******************************************************/ + +#include "gctl/core.h" +#include "gctl/io.h" + +using namespace gctl; + +int main(int argc, char const *argv[]) try +{ + _2d_matrix m(5, 4); + m.sequence(1.0, 1.0, 0.1); + m.show(); + + m.resize(2, 10); + m.show(); + + _2d_matrix m2 = m.transpose(); + m2.show(); + + _1d_array a, a2; + m.export_array(a); + m2.export_array(a2); + a.show(); + a2.show(); + return 0; +} +catch(std::exception &e) +{ + GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0); +} \ No newline at end of file