/******************************************************** * ██████╗ ██████╗████████╗██╗ * ██╔════╝ ██╔════╝╚══██╔══╝██║ * ██║ ███╗██║ ██║ ██║ * ██║ ██║██║ ██║ ██║ * ╚██████╔╝╚██████╗ ██║ ███████╗ * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ * 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 "../lib/core.h" #include "../lib/io.h" using namespace gctl; double get_x(const point3dc &p) { return p.x; } int main(int argc, char const *argv[]) try { // create a new array and give initial values array A(10, 0.0, 1.0); A.memory_usage(); A.log2linear(2); A.show(); A.linear2log(2); A.show(); A.for_each([](double &a){a += 1;}); A.show(); A.sequence(1.0, 0.5, 3, 4, 1); A.show(); // copy A to a new array array B = A; B.normalize(); B.show(); array S = A + B; std::cout << "B + A = "; S.show(); S.normalize(); S.show(); array P(5); P.sequence(point3dc(0, 0, 0), point3dc(2, 1, 0.5)); P.show(std::cout, '\n'); //array Px = P.extract([](const point3dc &p)->double{return p.x;}); array Px = P.extract(get_x); Px.show(); // create a new 2D array matrix C(5, 5, 1); C.sequence(0, 1, 10); std::cout << "C = \n"; C.show(); // save array to a binary file save_matrix2binary("tmp/array_ex_out", C, "Int"); // import 2D array to a new object matrix D; read_binary2matrix("tmp/array_ex_out", D); std::cout << "D = \n"; D.show(); return 0; } catch(std::exception &e) { GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0); }