From f47df2ac6ed275ec64695143c6cbef8991d69b7b Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 18 Jul 2025 15:09:59 +0800 Subject: [PATCH] tmp --- src/extra/use_armadillo_ex.cpp | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/extra/use_armadillo_ex.cpp diff --git a/src/extra/use_armadillo_ex.cpp b/src/extra/use_armadillo_ex.cpp new file mode 100644 index 0000000..eaf5666 --- /dev/null +++ b/src/extra/use_armadillo_ex.cpp @@ -0,0 +1,70 @@ +/******************************************************** + * ██████╗ ██████╗████████╗██╗ + * ██╔════╝ ██╔════╝╚══██╔══╝██║ + * ██║ ███╗██║ ██║ ██║ + * ██║ ██║██║ ██║ ██║ + * ╚██████╔╝╚██████╗ ██║ ███████╗ + * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ + * 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. + ******************************************************/ + +// Declare the marco to enable armadillo wrappers before include the head file. +// To compile the code, use: g++ use_armadillo_ex.cpp -larmadillo +#define GCTL_USE_ARMADILLO + +#include "gctl/core/armadillo_wrapper.h" + +using namespace gctl; + +int main(int argc, char const *argv[]) +{ + _1d_array a(10, 1, 0.5); + a.show(); + + arma::Col b; + array2armaCol(a, b); + std::cout << b; + + _1d_array c; + armaCol2array(b, c); + c.show(); + + arma::Row d; + array2armaRow(c, d); + std::cout << d; + + armaRow2array(d, a); + a.show(); + + matrix m(10, 10); + m.random_float(1.0, 2.0, RdUniform); + m.show(); + + arma::Mat amat; + matrix2armaMat(m, amat); + std::cout << amat; + + arma::Col r = amat*b; + + _1d_array v; + armaCol2array(r, v); + v.show(); + return 0; +}