beta-parameterization 2.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- beta_parameterization-2.3.3/.gitignore +82 -0
- beta_parameterization-2.3.3/CMakeLists.txt +152 -0
- beta_parameterization-2.3.3/LICENSE +21 -0
- beta_parameterization-2.3.3/PKG-INFO +11 -0
- beta_parameterization-2.3.3/ci/build-wheel.sh +39 -0
- beta_parameterization-2.3.3/include/beta_parameterization.h +207 -0
- beta_parameterization-2.3.3/include/beta_parameterization.hpp +292 -0
- beta_parameterization-2.3.3/pyproject.toml +33 -0
- beta_parameterization-2.3.3/python/beta_parameterization/__init__.py +23 -0
- beta_parameterization-2.3.3/python/beta_parameterization/_cdefs.py +59 -0
- beta_parameterization-2.3.3/python/beta_parameterization/_libloader.py +38 -0
- beta_parameterization-2.3.3/python/beta_parameterization/api.py +297 -0
- beta_parameterization-2.3.3/python/tests/test_api.py +185 -0
- beta_parameterization-2.3.3/src/beta_parameterization_c_api_mod.f08 +425 -0
- beta_parameterization-2.3.3/src/beta_parameterization_mod.f08 +828 -0
- beta_parameterization-2.3.3/src/beta_parameterization_workers_mod.f08 +304 -0
- beta_parameterization-2.3.3/tests/beta_param_breakdown_test.f08 +123 -0
- beta_parameterization-2.3.3/tests/beta_param_com_test.f08 +97 -0
- beta_parameterization-2.3.3/tests/beta_param_core_test.f08 +105 -0
- beta_parameterization-2.3.3/tests/beta_param_error_test.f08 +153 -0
- beta_parameterization-2.3.3/tests/beta_param_golden_test.f08 +165 -0
- beta_parameterization-2.3.3/tests/beta_param_node_set_test.f08 +335 -0
- beta_parameterization-2.3.3/tests/c_api_smoke_test.cpp +214 -0
- beta_parameterization-2.3.3/tests/golden_capture.f08 +84 -0
- beta_parameterization-2.3.3/tests/test_utils_mod.f08 +56 -0
- beta_parameterization-2.3.3/tests/thread_stress_test.cpp +60 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Build directories
|
|
2
|
+
build/
|
|
3
|
+
cmake-build-*/
|
|
4
|
+
bin/
|
|
5
|
+
lib/
|
|
6
|
+
|
|
7
|
+
# Local wheel build artifacts
|
|
8
|
+
dist_raw/
|
|
9
|
+
wheelhouse/
|
|
10
|
+
*.whl
|
|
11
|
+
dist_sdist/
|
|
12
|
+
dist/
|
|
13
|
+
|
|
14
|
+
# Fortran compiled files
|
|
15
|
+
*.o
|
|
16
|
+
*.mod
|
|
17
|
+
*.smod
|
|
18
|
+
*.a
|
|
19
|
+
*.so
|
|
20
|
+
*.exe
|
|
21
|
+
|
|
22
|
+
# Generated documentation
|
|
23
|
+
doc/
|
|
24
|
+
docs/
|
|
25
|
+
**/doc/
|
|
26
|
+
deployment/docs-deploy/
|
|
27
|
+
deployment/docs-fixed/
|
|
28
|
+
netlify-docs/
|
|
29
|
+
|
|
30
|
+
# But keep the auth configuration template
|
|
31
|
+
!deployment/docs/netlify/
|
|
32
|
+
|
|
33
|
+
# Output and data files
|
|
34
|
+
*.dat
|
|
35
|
+
*.out
|
|
36
|
+
*.log
|
|
37
|
+
results/
|
|
38
|
+
output/
|
|
39
|
+
*.hdf5
|
|
40
|
+
*.nc
|
|
41
|
+
|
|
42
|
+
# IDE files
|
|
43
|
+
.idea/workspace.xml
|
|
44
|
+
.idea/tasks.xml
|
|
45
|
+
.idea/usage.statistics.xml
|
|
46
|
+
.idea/shelf/
|
|
47
|
+
.vscode/
|
|
48
|
+
*.swp
|
|
49
|
+
*~
|
|
50
|
+
|
|
51
|
+
# Python
|
|
52
|
+
__pycache__/
|
|
53
|
+
*.pyc
|
|
54
|
+
*.pyo
|
|
55
|
+
.pytest_cache/
|
|
56
|
+
*.egg-info/
|
|
57
|
+
|
|
58
|
+
# System files
|
|
59
|
+
.DS_Store
|
|
60
|
+
Thumbs.db
|
|
61
|
+
*.bak
|
|
62
|
+
*.tmp
|
|
63
|
+
|
|
64
|
+
# Large test files (add specific patterns)
|
|
65
|
+
test_data_large/
|
|
66
|
+
benchmark_results/
|
|
67
|
+
|
|
68
|
+
# Environment
|
|
69
|
+
.env
|
|
70
|
+
venv/
|
|
71
|
+
env/
|
|
72
|
+
|
|
73
|
+
# Slurm files (optional - depends on your needs)
|
|
74
|
+
slurm-*.out
|
|
75
|
+
*.sbatch.log
|
|
76
|
+
|
|
77
|
+
# Backup files
|
|
78
|
+
*.backup
|
|
79
|
+
|
|
80
|
+
# AI files
|
|
81
|
+
GEMINI.md
|
|
82
|
+
CLAUDE.local.md
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20)
|
|
2
|
+
|
|
3
|
+
include(FetchContent)
|
|
4
|
+
|
|
5
|
+
project(beta-parameterization
|
|
6
|
+
VERSION 2.3.3
|
|
7
|
+
LANGUAGES Fortran CXX
|
|
8
|
+
DESCRIPTION "Beta parameterization for nuclear physics applications"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
12
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
13
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
14
|
+
|
|
15
|
+
# --- Fetch GCC compiler options package ---
|
|
16
|
+
FetchContent_Declare(
|
|
17
|
+
GCC-Compiler-Options
|
|
18
|
+
GIT_REPOSITORY https://github.com/AleksanderAugustyn/GCC-Compiler-Options.git
|
|
19
|
+
GIT_TAG 1.6.0
|
|
20
|
+
)
|
|
21
|
+
FetchContent_MakeAvailable(GCC-Compiler-Options)
|
|
22
|
+
|
|
23
|
+
# --- Fetch foundational Fortran modules ---
|
|
24
|
+
FetchContent_Declare(
|
|
25
|
+
Fortran-Foundations
|
|
26
|
+
GIT_REPOSITORY https://github.com/AleksanderAugustyn/Fortran-Foundations.git
|
|
27
|
+
GIT_TAG 2.3.1
|
|
28
|
+
)
|
|
29
|
+
FetchContent_MakeAvailable(Fortran-Foundations)
|
|
30
|
+
|
|
31
|
+
# --- Preprocessor & build type ---
|
|
32
|
+
set(CMAKE_Fortran_PREPROCESS ON)
|
|
33
|
+
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
34
|
+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
|
|
35
|
+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "RelWithDebInfo" "Release")
|
|
36
|
+
endif ()
|
|
37
|
+
|
|
38
|
+
# --- Compiler flags via GCC-Compiler-Options ---
|
|
39
|
+
include(GCCCompilerOptions/FortranCompilerOptions)
|
|
40
|
+
create_fortran_library_interface(TARGET beta_parameterization_flags)
|
|
41
|
+
|
|
42
|
+
# --- Source files ---
|
|
43
|
+
set(BETA_PARAM_SOURCES
|
|
44
|
+
src/beta_parameterization_workers_mod.f08
|
|
45
|
+
src/beta_parameterization_mod.f08
|
|
46
|
+
src/beta_parameterization_c_api_mod.f08
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# --- Static library target ---
|
|
50
|
+
add_library(beta_parameterization STATIC ${BETA_PARAM_SOURCES})
|
|
51
|
+
target_link_libraries(beta_parameterization
|
|
52
|
+
PUBLIC fortran_foundations
|
|
53
|
+
PRIVATE beta_parameterization_flags
|
|
54
|
+
)
|
|
55
|
+
target_compile_definitions(beta_parameterization PRIVATE
|
|
56
|
+
$<$<CONFIG:Debug>:DEBUG>
|
|
57
|
+
$<$<CONFIG:RelWithDebInfo>:RELWITHDEBINFO>
|
|
58
|
+
$<$<CONFIG:Release>:RELEASE>
|
|
59
|
+
)
|
|
60
|
+
set_target_properties(beta_parameterization PROPERTIES
|
|
61
|
+
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod_files
|
|
62
|
+
)
|
|
63
|
+
target_include_directories(beta_parameterization
|
|
64
|
+
PUBLIC
|
|
65
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod_files>
|
|
66
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
67
|
+
)
|
|
68
|
+
add_library(BetaParameterization::beta_parameterization ALIAS beta_parameterization)
|
|
69
|
+
|
|
70
|
+
# --- Shared library target (for FFI consumers: Python ctypes, Rust, etc.) ---
|
|
71
|
+
add_library(beta_parameterization_shared SHARED ${BETA_PARAM_SOURCES})
|
|
72
|
+
target_link_libraries(beta_parameterization_shared
|
|
73
|
+
PUBLIC fortran_foundations
|
|
74
|
+
PRIVATE beta_parameterization_flags
|
|
75
|
+
)
|
|
76
|
+
target_compile_definitions(beta_parameterization_shared PRIVATE
|
|
77
|
+
$<$<CONFIG:Debug>:DEBUG>
|
|
78
|
+
$<$<CONFIG:RelWithDebInfo>:RELWITHDEBINFO>
|
|
79
|
+
$<$<CONFIG:Release>:RELEASE>
|
|
80
|
+
)
|
|
81
|
+
set_target_properties(beta_parameterization_shared PROPERTIES
|
|
82
|
+
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod_files_shared
|
|
83
|
+
OUTPUT_NAME beta_parameterization
|
|
84
|
+
)
|
|
85
|
+
target_include_directories(beta_parameterization_shared
|
|
86
|
+
PUBLIC
|
|
87
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod_files_shared>
|
|
88
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
89
|
+
)
|
|
90
|
+
add_library(BetaParameterization::beta_parameterization_shared
|
|
91
|
+
ALIAS beta_parameterization_shared)
|
|
92
|
+
|
|
93
|
+
# --- C++ header-only wrapper (consumes the shared library) ---
|
|
94
|
+
add_library(beta_parameterization_cxx INTERFACE)
|
|
95
|
+
target_include_directories(beta_parameterization_cxx INTERFACE
|
|
96
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
|
97
|
+
target_link_libraries(beta_parameterization_cxx INTERFACE
|
|
98
|
+
beta_parameterization_shared)
|
|
99
|
+
target_compile_features(beta_parameterization_cxx INTERFACE cxx_std_20)
|
|
100
|
+
add_library(BetaParameterization::beta_parameterization_cxx
|
|
101
|
+
ALIAS beta_parameterization_cxx)
|
|
102
|
+
|
|
103
|
+
# --- Install the shared library into the Python package (wheel builds) ---
|
|
104
|
+
install(TARGETS beta_parameterization_shared
|
|
105
|
+
LIBRARY DESTINATION beta_parameterization)
|
|
106
|
+
|
|
107
|
+
# --- Tests (skipped for wheel builds via -DBETA_PARAM_BUILD_TESTS=OFF) ---
|
|
108
|
+
option(BETA_PARAM_BUILD_TESTS "Build the Fortran/C++ test suite" ON)
|
|
109
|
+
if (BETA_PARAM_BUILD_TESTS)
|
|
110
|
+
enable_testing()
|
|
111
|
+
|
|
112
|
+
add_library(beta_param_test_utils STATIC tests/test_utils_mod.f08)
|
|
113
|
+
target_link_libraries(beta_param_test_utils
|
|
114
|
+
PUBLIC fortran_foundations
|
|
115
|
+
PRIVATE beta_parameterization_flags)
|
|
116
|
+
set_target_properties(beta_param_test_utils PROPERTIES
|
|
117
|
+
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod_files_tests)
|
|
118
|
+
target_include_directories(beta_param_test_utils PUBLIC
|
|
119
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod_files_tests>)
|
|
120
|
+
|
|
121
|
+
set(BETA_PARAM_TEST_SUITES core com error breakdown golden node_set)
|
|
122
|
+
foreach (suite IN LISTS BETA_PARAM_TEST_SUITES)
|
|
123
|
+
add_executable(beta_param_${suite}_test tests/beta_param_${suite}_test.f08)
|
|
124
|
+
target_link_libraries(beta_param_${suite}_test PRIVATE
|
|
125
|
+
beta_parameterization beta_param_test_utils beta_parameterization_flags)
|
|
126
|
+
set_target_properties(beta_param_${suite}_test PROPERTIES
|
|
127
|
+
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod_files_tests/${suite})
|
|
128
|
+
add_test(NAME ${suite} COMMAND beta_param_${suite}_test)
|
|
129
|
+
endforeach ()
|
|
130
|
+
|
|
131
|
+
# Golden literals carry 17 significant digits (exact double round-trip);
|
|
132
|
+
# gfortran's conversion-extra warning flags the 17th digit as non-significant.
|
|
133
|
+
# Source-file property so it lands after the flags-interface options (last wins).
|
|
134
|
+
set_source_files_properties(tests/beta_param_golden_test.f08 PROPERTIES
|
|
135
|
+
COMPILE_OPTIONS "-Wno-conversion-extra;-Wno-error=conversion-extra")
|
|
136
|
+
|
|
137
|
+
add_executable(golden_capture tests/golden_capture.f08)
|
|
138
|
+
target_link_libraries(golden_capture PRIVATE
|
|
139
|
+
beta_parameterization beta_param_test_utils beta_parameterization_flags)
|
|
140
|
+
set_target_properties(golden_capture PROPERTIES
|
|
141
|
+
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod_files_tests/capture)
|
|
142
|
+
|
|
143
|
+
add_executable(c_api_smoke_test tests/c_api_smoke_test.cpp)
|
|
144
|
+
target_link_libraries(c_api_smoke_test PRIVATE beta_parameterization_cxx)
|
|
145
|
+
add_test(NAME c_api_smoke COMMAND c_api_smoke_test)
|
|
146
|
+
|
|
147
|
+
find_package(Threads REQUIRED)
|
|
148
|
+
add_executable(thread_stress_test tests/thread_stress_test.cpp)
|
|
149
|
+
target_link_libraries(thread_stress_test PRIVATE beta_parameterization_cxx Threads::Threads)
|
|
150
|
+
add_test(NAME thread_stress COMMAND thread_stress_test)
|
|
151
|
+
|
|
152
|
+
endif ()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aleksander Augustyn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: beta-parameterization
|
|
3
|
+
Version: 2.3.3
|
|
4
|
+
Summary: Python bindings for the beta (Legendre) nuclear-shape parameterization library
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Requires-Dist: numpy>=1.21
|
|
9
|
+
Provides-Extra: test
|
|
10
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
11
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Build the manylinux2014 x86_64 wheel. Runs INSIDE
|
|
3
|
+
# quay.io/pypa/manylinux2014_x86_64 (CentOS 7, devtoolset-10 GCC 10.2):
|
|
4
|
+
#
|
|
5
|
+
# docker run --rm -v "$PWD":/io -w /io quay.io/pypa/manylinux2014_x86_64 ./ci/build-wheel.sh
|
|
6
|
+
#
|
|
7
|
+
# CI passes SETUPTOOLS_SCM_PRETEND_VERSION_FOR_<DIST> via -e; local runs fall
|
|
8
|
+
# back to git describe. Identical local and CI by design.
|
|
9
|
+
set -euxo pipefail
|
|
10
|
+
|
|
11
|
+
PYBIN=/opt/python/cp312-cp312/bin
|
|
12
|
+
gfortran --version | head -1
|
|
13
|
+
|
|
14
|
+
# The bind-mounted repo belongs to the host user; git (setuptools_scm)
|
|
15
|
+
# refuses to read it otherwise.
|
|
16
|
+
git config --global --add safe.directory "$PWD"
|
|
17
|
+
|
|
18
|
+
rm -rf dist_raw wheelhouse
|
|
19
|
+
|
|
20
|
+
"$PYBIN/python" -m pip install --upgrade --quiet build
|
|
21
|
+
# nehalem == the x86-64-v2 feature floor (SSE4.2+POPCNT, no AVX) in GCC-10
|
|
22
|
+
# vocabulary: devtoolset-10 predates the psABI level names (GCC 11). Portable
|
|
23
|
+
# down to the cluster's Haswell nodes; the libs cost 0.1-0.4 ms/call, so
|
|
24
|
+
# portability wins over host-tuned codegen.
|
|
25
|
+
"$PYBIN/python" -m build --wheel --outdir dist_raw \
|
|
26
|
+
-Ccmake.define.GCC_OPTS_MARCH=nehalem
|
|
27
|
+
|
|
28
|
+
# --plat makes auditwheel fail loudly if any symbol exceeds glibc 2.17.
|
|
29
|
+
auditwheel repair dist_raw/*.whl --plat manylinux2014_x86_64 -w wheelhouse
|
|
30
|
+
|
|
31
|
+
# Wheel-floor guard: a regression to the host tag must fail the build.
|
|
32
|
+
wheel_file=(wheelhouse/*.whl)
|
|
33
|
+
case "$(basename "${wheel_file[0]}")" in
|
|
34
|
+
*manylinux_2_17_x86_64*|*manylinux2014_x86_64*)
|
|
35
|
+
echo "wheel floor OK: ${wheel_file[0]}" ;;
|
|
36
|
+
*)
|
|
37
|
+
echo "ERROR: wheel is not manylinux2014: ${wheel_file[0]}" >&2
|
|
38
|
+
exit 1 ;;
|
|
39
|
+
esac
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file beta_parameterization.h
|
|
3
|
+
* @brief C API for the Fortran beta parameterization library (v2.2.0).
|
|
4
|
+
*
|
|
5
|
+
* Two-tier API:
|
|
6
|
+
* - Cache-backed (recommended for batch use): create one cache up front,
|
|
7
|
+
* reuse it across many shape evaluations. The cache is immutable after
|
|
8
|
+
* creation and safe to share across threads.
|
|
9
|
+
* - Standalone single-shape (one-off, inefficient for batch): builds and
|
|
10
|
+
* discards a cache internally per call.
|
|
11
|
+
*
|
|
12
|
+
* All radius-grid functions return a status code; 0 (BETA_PARAM_VALID) means
|
|
13
|
+
* success. The message buffer is always null-terminated (truncated to fit
|
|
14
|
+
* if needed). Recommended buffer size: 256.
|
|
15
|
+
*
|
|
16
|
+
* Status-code notes:
|
|
17
|
+
* BETA_PARAM_ERROR_INVALID_MAX_PARAMS (5) covers every invalid cache-init
|
|
18
|
+
* parameter (max_beta_params outside [1, 64] or n_grid < 2), a NULL cache
|
|
19
|
+
* handle passed to a compute function, and - through the standalone entry
|
|
20
|
+
* points, where max_beta_params is taken as n_params - an empty params
|
|
21
|
+
* array. On any failure, output buffers (radii, corrected_beta10) are
|
|
22
|
+
* zero-filled.
|
|
23
|
+
*
|
|
24
|
+
* Thread safety:
|
|
25
|
+
* A `beta_param_cache_t*` is immutable after `beta_param_cache_create`.
|
|
26
|
+
* Multiple threads may concurrently call any combination of the
|
|
27
|
+
* `beta_param_cache_compute_*` functions on the same cache. Only
|
|
28
|
+
* `beta_param_cache_create` and `beta_param_cache_destroy` require
|
|
29
|
+
* exclusive access.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
#ifndef BETA_PARAMETERIZATION_H
|
|
33
|
+
#define BETA_PARAMETERIZATION_H
|
|
34
|
+
|
|
35
|
+
#ifdef __cplusplus
|
|
36
|
+
extern "C" {
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
/* --- Limits --- */
|
|
40
|
+
#define BETA_PARAM_MAX_PARAMS_LIMIT 64
|
|
41
|
+
|
|
42
|
+
/* --- Status codes (mirror Fortran LEGENDRE_* parameters) --- */
|
|
43
|
+
#define BETA_PARAM_VALID 0
|
|
44
|
+
#define BETA_PARAM_ERROR_NORTH_POLE 1
|
|
45
|
+
#define BETA_PARAM_ERROR_SOUTH_POLE 2
|
|
46
|
+
#define BETA_PARAM_ERROR_EMPTY_PARAMS 3
|
|
47
|
+
#define BETA_PARAM_ERROR_INTERIOR_NEGATIVE 4
|
|
48
|
+
#define BETA_PARAM_ERROR_INVALID_MAX_PARAMS 5
|
|
49
|
+
#define BETA_PARAM_ERROR_TOO_MANY_PARAMS 6
|
|
50
|
+
#define BETA_PARAM_ERROR_COM_NOT_CONVERGED 7
|
|
51
|
+
#define BETA_PARAM_ERROR_INVALID_BUFFER_SIZE 8
|
|
52
|
+
#define BETA_PARAM_ERROR_POLE_NODE 9
|
|
53
|
+
#define BETA_PARAM_ERROR_NO_UNIFORM_GRID 10
|
|
54
|
+
|
|
55
|
+
/* --- Opaque cache handle --- */
|
|
56
|
+
typedef struct beta_param_cache beta_param_cache_t;
|
|
57
|
+
|
|
58
|
+
/* --- Opaque node-set handle (precomputed Legendre tables at fixed thetas) --- */
|
|
59
|
+
typedef struct beta_param_node_set beta_param_node_set_t;
|
|
60
|
+
|
|
61
|
+
/* --- Cache lifecycle --- */
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Create a cache. Returns NULL on failure (reason in message_buf).
|
|
65
|
+
*
|
|
66
|
+
* @param max_beta_params 1 .. BETA_PARAM_MAX_PARAMS_LIMIT
|
|
67
|
+
* @param n_grid Number of θ grid points (>= 2). n_grid <= 0 builds a
|
|
68
|
+
* node-set-only cache: the uniform-grid entry points
|
|
69
|
+
* (beta_param_cache_compute_radius_grid[_with_com_shift])
|
|
70
|
+
* then return BETA_PARAM_ERROR_NO_UNIFORM_GRID; the
|
|
71
|
+
* node-set API is unaffected.
|
|
72
|
+
* @param message_buf_len Size of message_buf including null terminator
|
|
73
|
+
* @param message_buf Buffer to receive failure reason (empty on success)
|
|
74
|
+
*/
|
|
75
|
+
beta_param_cache_t* beta_param_cache_create(
|
|
76
|
+
int max_beta_params, int n_grid,
|
|
77
|
+
int message_buf_len, char* message_buf);
|
|
78
|
+
|
|
79
|
+
/** Destroy a cache. Null-safe. */
|
|
80
|
+
void beta_param_cache_destroy(beta_param_cache_t* cache);
|
|
81
|
+
|
|
82
|
+
/* --- Cache hot path --- */
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Compute R(θ) on the cache's θ grid.
|
|
86
|
+
*
|
|
87
|
+
* @param cache Cache (must be non-NULL)
|
|
88
|
+
* @param params Deformation parameters β₁..βₙ
|
|
89
|
+
* @param n_params Number of deformation parameters
|
|
90
|
+
* @param radii Output buffer; must hold at least cache's n_grid doubles
|
|
91
|
+
* @param message_buf_len Size of message_buf
|
|
92
|
+
* @param message_buf Buffer to receive validation message (empty on success)
|
|
93
|
+
* @return BETA_PARAM_VALID (0) on success, error code otherwise
|
|
94
|
+
*/
|
|
95
|
+
int beta_param_cache_compute_radius_grid(
|
|
96
|
+
const beta_param_cache_t* cache,
|
|
97
|
+
const double* params, int n_params,
|
|
98
|
+
double* radii,
|
|
99
|
+
int message_buf_len, char* message_buf);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Compute R(θ) with COM shift applied to β₁₀ first.
|
|
103
|
+
* `corrected_beta10` receives the post-shift β₁₀.
|
|
104
|
+
*/
|
|
105
|
+
int beta_param_cache_compute_radius_grid_with_com_shift(
|
|
106
|
+
const beta_param_cache_t* cache,
|
|
107
|
+
const double* params, int n_params,
|
|
108
|
+
double* radii, double* corrected_beta10,
|
|
109
|
+
int message_buf_len, char* message_buf);
|
|
110
|
+
|
|
111
|
+
/* --- Node-set API (arbitrary thetas, R + analytic dR/dtheta) --- */
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Build a node set: precomputed Legendre P_k and P_k' tables at the given
|
|
115
|
+
* thetas, sized to the cache's max_beta_params. Returns NULL on failure
|
|
116
|
+
* (reason in message_buf) — including any pole node (theta where
|
|
117
|
+
* cos(theta)^2 == 1 in double precision), which is rejected with
|
|
118
|
+
* BETA_PARAM_ERROR_POLE_NODE; use the resolve_shape polar radii instead.
|
|
119
|
+
*
|
|
120
|
+
* Thread safety: a node set is immutable after create; multiple threads may
|
|
121
|
+
* concurrently pass it to beta_param_cache_compute_radius_and_derivative.
|
|
122
|
+
*
|
|
123
|
+
* @param cache Cache the tables are sized to (must be non-NULL)
|
|
124
|
+
* @param thetas Node angles in radians (need not be uniform)
|
|
125
|
+
* @param n_thetas Number of nodes (>= 1)
|
|
126
|
+
* @param message_buf_len Size of message_buf including null terminator
|
|
127
|
+
* @param message_buf Buffer to receive failure reason (empty on success)
|
|
128
|
+
*/
|
|
129
|
+
beta_param_node_set_t* beta_param_node_set_create(
|
|
130
|
+
const beta_param_cache_t* cache, const double* thetas, int n_thetas,
|
|
131
|
+
int message_buf_len, char* message_buf);
|
|
132
|
+
|
|
133
|
+
/** Destroy a node set. Null-safe. */
|
|
134
|
+
void beta_param_node_set_destroy(beta_param_node_set_t* node_set);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Resolve a shape once: pad + normalize params, run the COM iteration,
|
|
138
|
+
* polar pre-check. Node-set-independent — feed the resulting beta_con to
|
|
139
|
+
* beta_param_cache_compute_radius_and_derivative for any number of node sets.
|
|
140
|
+
* On failure all outputs are zero-filled.
|
|
141
|
+
*
|
|
142
|
+
* @param cache Cache (must be non-NULL)
|
|
143
|
+
* @param params Deformation parameters (beta10 is the COM dipole)
|
|
144
|
+
* @param n_params Number of deformation parameters
|
|
145
|
+
* @param beta_con Output; must hold at least the cache's max_beta_params doubles
|
|
146
|
+
* @param corrected_beta10 Receives the post-shift beta10
|
|
147
|
+
* @param r_north Receives analytic R(0)
|
|
148
|
+
* @param r_south Receives analytic R(pi)
|
|
149
|
+
* @param apply_com_correction Nonzero (default behavior): run the COM
|
|
150
|
+
* iteration. Zero: skip it; corrected_beta10
|
|
151
|
+
* receives the input beta10 (no-COM semantics
|
|
152
|
+
* of beta_param_compute_radius_grid).
|
|
153
|
+
* @param message_buf_len Size of message_buf
|
|
154
|
+
* @param message_buf Buffer to receive validation message (empty on success)
|
|
155
|
+
* @return BETA_PARAM_VALID (0) on success, error code otherwise
|
|
156
|
+
*/
|
|
157
|
+
int beta_param_cache_resolve_shape(
|
|
158
|
+
const beta_param_cache_t* cache, const double* params, int n_params,
|
|
159
|
+
double* beta_con, double* corrected_beta10, double* r_north, double* r_south,
|
|
160
|
+
int apply_com_correction, int message_buf_len, char* message_buf);
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Evaluate R and dR/dtheta at a node set for a shape already resolved by
|
|
164
|
+
* beta_param_cache_resolve_shape. Dot products only — no iteration.
|
|
165
|
+
* On failure radii and dr_dtheta are zero-filled.
|
|
166
|
+
*
|
|
167
|
+
* @param cache Cache (must be non-NULL)
|
|
168
|
+
* @param node_set Node set built by this cache (must be non-NULL)
|
|
169
|
+
* @param beta_con Resolved coefficients; n_beta_con must equal the
|
|
170
|
+
* cache's max_beta_params
|
|
171
|
+
* @param n_beta_con Number of beta_con entries
|
|
172
|
+
* @param radii Output R(theta_i); n_nodes doubles
|
|
173
|
+
* @param dr_dtheta Output dR/dtheta(theta_i); n_nodes doubles
|
|
174
|
+
* @param n_nodes Must equal the node set's node count
|
|
175
|
+
* @param message_buf_len Size of message_buf
|
|
176
|
+
* @param message_buf Buffer to receive validation message (empty on success)
|
|
177
|
+
* @return BETA_PARAM_VALID (0) on success, error code otherwise
|
|
178
|
+
*/
|
|
179
|
+
int beta_param_cache_compute_radius_and_derivative(
|
|
180
|
+
const beta_param_cache_t* cache, const beta_param_node_set_t* node_set,
|
|
181
|
+
const double* beta_con, int n_beta_con,
|
|
182
|
+
double* radii, double* dr_dtheta, int n_nodes,
|
|
183
|
+
int message_buf_len, char* message_buf);
|
|
184
|
+
|
|
185
|
+
/* --- Standalone single-shape (one-off, inefficient for batch) ---
|
|
186
|
+
*
|
|
187
|
+
* Return BETA_PARAM_VALID (0) on success, an error code otherwise.
|
|
188
|
+
* max_beta_params is taken as n_params, so n_params must be in [1, 64]
|
|
189
|
+
* and n_grid >= 2; violations return BETA_PARAM_ERROR_INVALID_MAX_PARAMS.
|
|
190
|
+
* On failure, radii (and corrected_beta10) are zero-filled.
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
int beta_param_compute_radius_grid_standalone(
|
|
194
|
+
const double* params, int n_params, int n_grid,
|
|
195
|
+
double* radii,
|
|
196
|
+
int message_buf_len, char* message_buf);
|
|
197
|
+
|
|
198
|
+
int beta_param_compute_radius_grid_standalone_with_com_shift(
|
|
199
|
+
const double* params, int n_params, int n_grid,
|
|
200
|
+
double* radii, double* corrected_beta10,
|
|
201
|
+
int message_buf_len, char* message_buf);
|
|
202
|
+
|
|
203
|
+
#ifdef __cplusplus
|
|
204
|
+
}
|
|
205
|
+
#endif
|
|
206
|
+
|
|
207
|
+
#endif /* BETA_PARAMETERIZATION_H */
|