/******************************************************** * ██████╗ ██████╗████████╗██╗ * ██╔════╝ ██╔════╝╚══██╔══╝██║ * ██║ ███╗██║ ██║ ██║ * ██║ ██║██║ ██║ ██║ * ╚██████╔╝╚██████╗ ██║ ███████╗ * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ * 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" int main(int argc, char const *argv[]) { gctl::spmat A(10, 10, 0.0); A.insert(3, 3, 1.3); A.insert(5, 6, 4.6); A.insert(8, 1, 2.8); A.insert(2, 3, 7.2); A.insert(5, 9, 2.2); A.insert(2, 9, 5.4); A.insert(7, 4, 8.5); A.insert(0, 1, 8.5); A.insert(0, 7, 5.3); A.insert(1, 2, 8.1); A.insert(1, 5, 1.2); A.insert(1, 6, 3.4); gctl::spmat B(A); A.show_matrix(); std::cout << "#########" << std::endl; std::cout << A.sum() << std::endl; for (int i = 0; i < A.row_size(); i++) { std::cout << A.sum(i) << std::endl; } /* double sum; gctl::mat_node *node_ptr; for (int i = 0; i < A.row_size(); i++) { sum = 0.0; node_ptr = A.row_head(i); while (node_ptr != nullptr) { sum += node_ptr->value(); node_ptr = A.next(node_ptr); } node_ptr = A.row_head(i); while (node_ptr != nullptr) { node_ptr->value(node_ptr->value()/sum); node_ptr = A.next(node_ptr); } } */ std::cout << A.sum() << std::endl; for (int i = 0; i < A.row_size(); i++) { std::cout << A.sum(i) << std::endl; } A.show_matrix(); std::cout << "#########" << std::endl; for (int i = 0; i < B.row_size(); i++) { B.normalize(i, 1.0); } B.show_matrix(); B.clear(1); B.clear(3, gctl::ColMajor); std::cout << "#########" << std::endl; B.show_matrix(); B.show_list(gctl::ColMajor, ','); return 0; }