From 31bcd2d2bff4432136d240f28d146c465448af4d Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Sun, 6 Jul 2025 17:49:00 +0800 Subject: [PATCH] tmp --- CMakeLists.txt | 18 +++++++++++------- src/core/spmat_ex.cpp | 27 ++++++++++++++++++--------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d01e14..ab52146 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ if(GCTL_POTENTIAL_FOUND) message(STATUS "GCTL_POTENTIAL Version: " ${GCTL_POTENTIAL_VERSION}) endif() -macro(add_toolkit ex_dir name lib1 lib2 lib3 lib4) +macro(add_example ex_dir name lib1 lib2 lib3 lib4) #aux_source_directory(${name} src/${ex_dir}/${name}.cpp) add_executable(${name} src/${ex_dir}/${name}.cpp) set_target_properties(${name} PROPERTIES INSTALL_RPATH /usr/local/lib) @@ -67,9 +67,13 @@ macro(add_toolkit ex_dir name lib1 lib2 lib3 lib4) endif() endmacro() -if(GCTL_FOUND AND GCTL_MESH_FOUND) - add_toolkit(mesh create_tin_ex1 ON ON OFF OFF) - add_toolkit(mesh create_tin_ex2 ON ON OFF OFF) - add_toolkit(mesh create_tin_ex3 ON ON OFF OFF) - add_toolkit(mesh create_tin_ex4 ON ON OFF OFF) -endif() \ No newline at end of file +if(GCTL_FOUND) + add_example(core spmat_ex ON OFF OFF OFF) +endif() + +#if(GCTL_FOUND AND GCTL_MESH_FOUND) +# add_example(mesh create_tin_ex1 ON ON OFF OFF) +# add_example(mesh create_tin_ex2 ON ON OFF OFF) +# add_example(mesh create_tin_ex3 ON ON OFF OFF) +# add_example(mesh create_tin_ex4 ON ON OFF OFF) +#endif() \ No newline at end of file diff --git a/src/core/spmat_ex.cpp b/src/core/spmat_ex.cpp index 99526ec..3bdd6fd 100644 --- a/src/core/spmat_ex.cpp +++ b/src/core/spmat_ex.cpp @@ -25,7 +25,7 @@ * Also add information on how to contact you by electronic and paper mail. ******************************************************/ -#include "../lib/core.h" +#include "gctl/core/spmat.h" using namespace gctl; @@ -34,17 +34,26 @@ int main(int argc, char const *argv[]) try spmat mat(5, 5, 0.0); std::vector > triplts; - triplts.push_back(mat_node(0, 1, 0.23)); - triplts.push_back(mat_node(1, 2, 0.52)); - triplts.push_back(mat_node(2, 3, 0.31)); - triplts.push_back(mat_node(2, 3, 0.19)); - triplts.push_back(mat_node(3, 2, 0.65)); - triplts.push_back(mat_node(3, 4, 0.8)); - triplts.push_back(mat_node(4, 3, 1.6)); - triplts.push_back(mat_node(4, 3, 0.4)); + triplts.push_back(mat_node(0, 1, 0.23)); + triplts.push_back(mat_node(1, 2, 0.52)); + triplts.push_back(mat_node(2, 3, 0.31)); + triplts.push_back(mat_node(2, 3, 0.19)); + triplts.push_back(mat_node(3, 2, 0.65)); + triplts.push_back(mat_node(3, 4, 0.8)); + triplts.push_back(mat_node(4, 3, 1.6)); + triplts.push_back(mat_node(4, 3, 0.4)); mat.set_triplts(triplts, ReplaceVal); mat.init_pattern(); + + mat_node n; + for (size_t i = 0; i < mat.ele_size(); i++) + { + n = mat.get_valid_element_copy(i); + std::cout << n.r_id << "," << n.c_id << "," << n.val << "\n"; + } + std::cout << "=====\n"; + mat.show_matrix(); std::cout << "=====\n";