This commit is contained in:
Timur A. Fatkhullin 2025-05-07 12:31:08 +03:00
parent cfe1fc8fab
commit b610a38682
4 changed files with 22 additions and 8 deletions

View File

@ -146,5 +146,6 @@ if (WITH_TESTS)
set(FITPACK_TEST_APP fitpack_test) set(FITPACK_TEST_APP fitpack_test)
add_executable(${FITPACK_TEST_APP} tests/fitpack_test.cpp) add_executable(${FITPACK_TEST_APP} tests/fitpack_test.cpp)
target_link_libraries(${FITPACK_TEST_APP} fitpack) target_link_libraries(${FITPACK_TEST_APP} fitpack)
# target_include_directories(${FITPACK_TEST_APP} PRIVATE fitpack) target_include_directories(${FITPACK_TEST_APP} PRIVATE ${FITPACK_INCLUDE_DIR})
message(STATUS "INC UP: " ${FITPACK_INCLUDE_DIR})
endif() endif()

View File

@ -28,4 +28,4 @@ FortranCInterface_HEADER(FortranCInterface.h
FortranCInterface_VERIFY(CXX) FortranCInterface_VERIFY(CXX)
add_library(fitpack STATIC ${src_files} fitpack.h) add_library(fitpack STATIC ${src_files} fitpack.h)
set(FITPACK_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)

View File

@ -1,11 +1,10 @@
#pragma once #pragma once
#include <limits> #include <limits>
#include <memory>
#include <ranges> #include <ranges>
#include <vector> #include <vector>
#include "/home/timur/PROGRAMS/C++/build-mountcontrol-Desktop-Debug/cxx/fitpack/FortranCInterface.h" #include <FortranCInterface.h>
extern "C" { extern "C" {
void surfit(int* iopt, void surfit(int* iopt,

View File

@ -9,8 +9,8 @@
int main() int main()
{ {
// size_t nt = 3, np = 5, N = nt * np, i = 1; size_t nt = 30, np = 60, N = nt * np, i = 1;
size_t nt = 10, np = 20, N = nt * np, i = 1; // size_t nt = 10, np = 20, N = nt * np, i = 1;
double ts = std::numbers::pi / (nt + 1); double ts = std::numbers::pi / (nt + 1);
double ps = 2.0 * std::numbers::pi / (np + 1); double ps = 2.0 * std::numbers::pi / (np + 1);
@ -46,7 +46,8 @@ int main()
k = 1; k = 1;
} }
std::uniform_real_distribution<double> distr{-0.1, 0.1}; // std::uniform_real_distribution<double> distr{-0.1, 0.1};
std::normal_distribution<double> distr{0.0, 1.0};
std::random_device device; std::random_device device;
std::mt19937 engine{device()}; std::mt19937 engine{device()};
@ -57,7 +58,8 @@ int main()
}); });
size_t ntk = 3, npk = 6, nf = (ntk + 4) * (npk + 4); int ntk = 24, npk = 29, nf = (ntk + 4) * (npk + 4);
// int ntk = 3, npk = 6, nf = (ntk + 4) * (npk + 4);
std::vector<double> tk(ntk + 8), pk(npk + 8), coeffs(nf); std::vector<double> tk(ntk + 8), pk(npk + 8), coeffs(nf);
ts = std::numbers::pi / (ntk + 1); ts = std::numbers::pi / (ntk + 1);
ps = 2.0 * std::numbers::pi / (npk + 1); ps = 2.0 * std::numbers::pi / (npk + 1);
@ -74,11 +76,23 @@ int main()
std::cout << "FIT EC = " << ec << "\n"; std::cout << "FIT EC = " << ec << "\n";
std::cout << "FIT RESI = " << rs << "\n"; std::cout << "FIT RESI = " << rs << "\n";
ntk += 8;
npk += 8;
std::ranges::fill(tk, -1);
std::ranges::fill(pk, -1);
ec = mcc::fitpack::fitpack_sphere_smooth(tetha, phi, func, 1.0, 56000.0, ntk, npk, tk, pk, coeffs, rs);
std::cout << "FIT EC = " << ec << "\n";
std::cout << "FIT RESI = " << rs << "\n";
std::cout << "NKNOTS: " << ntk << ", " << npk << "\n";
print_func(coeffs, "coeffs"); print_func(coeffs, "coeffs");
// print_func(tetha, "tetha"); // print_func(tetha, "tetha");
// print_func(phi, "phi"); // print_func(phi, "phi");
print_func(tk, "tetha_knots"); print_func(tk, "tetha_knots");
print_func(pk, "phi_knots");
print_func(func, "func"); print_func(func, "func");
std::cout << "\n\n"; std::cout << "\n\n";