Skip to content

Commit

Permalink
Merge pull request #433 from bluescarni/pr/sg4
Browse files Browse the repository at this point in the history
SGP4 model
  • Loading branch information
bluescarni authored Jul 16, 2024
2 parents 62d9c09 + 88caeac commit 8150bad
Show file tree
Hide file tree
Showing 45 changed files with 3,050 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gha_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Build
shell: pwsh
run: |
conda install -y cmake llvmdev tbb-devel tbb libboost-devel xtensor xtensor-blas blas blas-devel fmt spdlog sleef zlib libzlib 'mppp=1.*'
conda install -y cmake llvmdev tbb-devel tbb libboost-devel xtensor xtensor-blas blas blas-devel 'fmt<11' spdlog sleef zlib libzlib 'mppp=1.*'
mkdir build
cd build
cmake ../ -G "Visual Studio 17 2022" -A x64 -DHEYOKA_BUILD_TESTS=yes -DHEYOKA_WITH_MPPP=yes -DHEYOKA_BUILD_TUTORIALS=ON -DHEYOKA_ENABLE_IPO=yes -DBoost_NO_BOOST_CMAKE=ON -DHEYOKA_WITH_SLEEF=yes
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ set(HEYOKA_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/empty_callable_s11n.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/setup_variational_ics.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/tm_data.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/debug.cpp"
# NOTE: this will be an empty file in case we are not
# building with support for real.
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/real_helpers.cpp"
Expand Down Expand Up @@ -282,6 +283,7 @@ set(HEYOKA_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/cart2geo.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/nrlmsise00_tn.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/jb08_tn.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/sgp4.cpp"
# Callbacks.
"${CMAKE_CURRENT_SOURCE_DIR}/src/callback/angle_reducer.cpp"
# Math functions.
Expand Down
9 changes: 3 additions & 6 deletions doc/cfunc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ The :cpp:class:`cfunc` class
class is available.

.. cpp:type:: in_1d = mdspan<const T, dextents<std::size_t, 1>>

.. cpp:type:: out_1d = mdspan<T, dextents<std::size_t, 1>>

.. cpp:type:: in_2d = mdspan<const T, dextents<std::size_t, 2>>

.. cpp:type:: out_2d = mdspan<T, dextents<std::size_t, 2>>
out_1d = mdspan<T, dextents<std::size_t, 1>>
in_2d = mdspan<const T, dextents<std::size_t, 2>>
out_2d = mdspan<T, dextents<std::size_t, 2>>

Views over 1D and 2D input/output arrays.

Expand Down
2 changes: 2 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changelog
New
~~~

- Add a fully differentiable implementation of the SGP4 analytical propagator
(`#433 <https://github.com/bluescarni/heyoka/pull/433>`__).
- Add the ``select()`` primitive to the expression system
(`#432 <https://github.com/bluescarni/heyoka/pull/432>`__).
- Add relational and logical operators to the expression system
Expand Down
54 changes: 18 additions & 36 deletions doc/expression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,10 @@ The :cpp:class:`expression` class
This constructor initialises the expression to a double-precision :ref:`number <api_number>` with a value of zero.

.. cpp:function:: explicit expression(float x) noexcept

.. cpp:function:: explicit expression(double x) noexcept

.. cpp:function:: explicit expression(long double x) noexcept

.. cpp:function:: explicit expression(mppp::real128 x) noexcept

.. cpp:function:: explicit expression(mppp::real x)
explicit expression(double x) noexcept
explicit expression(long double x) noexcept
explicit expression(mppp::real128 x) noexcept
explicit expression(mppp::real x)

Constructors from floating-point objects.

Expand All @@ -75,12 +71,9 @@ The :cpp:class:`expression` class
:exception: any exception thrown by the copy constructor of ``std::string``.

.. cpp:function:: explicit expression(number x)

.. cpp:function:: explicit expression(variable x)

.. cpp:function:: explicit expression(func x) noexcept

.. cpp:function:: explicit expression(param x) noexcept
explicit expression(variable x)
explicit expression(func x) noexcept
explicit expression(param x) noexcept

Constructors from objects of the node types.

Expand All @@ -91,14 +84,10 @@ The :cpp:class:`expression` class
:exception: any exception raised by the copy constructor of :cpp:class:`number` or :cpp:class:`variable`.

.. cpp:function:: expression(const expression &)

.. cpp:function:: expression(expression &&) noexcept

.. cpp:function:: expression &operator=(const expression &)

.. cpp:function:: expression &operator=(expression &&) noexcept

.. cpp:function:: ~expression()
expression(expression &&) noexcept
expression &operator=(const expression &)
expression &operator=(expression &&) noexcept
~expression()

Expressions are copy/move constructible/assignable and destructible.

Expand Down Expand Up @@ -164,8 +153,7 @@ Comparison operators
^^^^^^^^^^^^^^^^^^^^

.. cpp:function:: bool operator==(const expression &e1, const expression &e2) noexcept

.. cpp:function:: bool operator!=(const expression &e1, const expression &e2) noexcept
bool operator!=(const expression &e1, const expression &e2) noexcept

Expression (in)equality.

Expand All @@ -184,15 +172,9 @@ User-defined literals
---------------------

.. cpp:function:: expression literals::operator""_flt(long double)

.. cpp:function:: expression literals::operator""_flt(unsigned long long)

.. cpp:function:: expression literals::operator""_dbl(long double)

.. cpp:function:: expression literals::operator""_dbl(unsigned long long)

.. cpp:function:: expression literals::operator""_ldbl(long double)

.. cpp:function:: expression literals::operator""_ldbl(unsigned long long)

.. cpp:function:: template <char... Chars> expression literals::operator""_f128()
expression literals::operator""_flt(unsigned long long)
expression literals::operator""_dbl(long double)
expression literals::operator""_dbl(unsigned long long)
expression literals::operator""_ldbl(long double)
expression literals::operator""_ldbl(unsigned long long)
template <char... Chars> expression literals::operator""_f128()
16 changes: 8 additions & 8 deletions doc/func.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ The :cpp:class:`~heyoka::func_base` class
:exception std\:\:invalid_argument: if *name* is empty.

.. cpp:function:: func_base(const func_base &)
.. cpp:function:: func_base(func_base &&) noexcept
.. cpp:function:: func_base &operator=(const func_base &)
.. cpp:function:: func_base &operator=(func_base &&) noexcept
.. cpp:function:: ~func_base()
func_base(func_base &&) noexcept
func_base &operator=(const func_base &)
func_base &operator=(func_base &&) noexcept
~func_base()

:cpp:class:`func_base` is copy/move constructible, copy/move assignable and destructible.

Expand Down Expand Up @@ -87,10 +87,10 @@ The :cpp:class:`~heyoka::func` class
:exception: any exception thrown by memory allocation failures or by the copy/move constructor of the user-defined function *x*.

.. cpp:function:: func(const func &) noexcept
.. cpp:function:: func(func &&) noexcept
.. cpp:function:: func &operator=(const func &) noexcept
.. cpp:function:: func &operator=(func &&) noexcept
.. cpp:function:: ~func()
func(func &&) noexcept
func &operator=(const func &) noexcept
func &operator=(func &&) noexcept
~func()

:cpp:class:`func` is copy/move constructible, copy/move assignable and destructible.

Expand Down
2 changes: 1 addition & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ heyoka has the following **mandatory** dependencies:

* the `LLVM <https://llvm.org/>`__ compiler infrastructure library (version >= 13 and <=18),
* the `Boost <https://www.boost.org/>`__ C++ libraries (version >= 1.69),
* the `{fmt} <https://fmt.dev/latest/index.html>`__ library (version 9 or 10),
* the `{fmt} <https://fmt.dev/latest/index.html>`__ library (version >=9 and <= 10),
* the `spdlog <https://github.com/gabime/spdlog>`__ library,
* the `TBB <https://github.com/oneapi-src/oneTBB>`__ library.

Expand Down
2 changes: 2 additions & 0 deletions doc/kwargs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Keyword arguments
=================

*#include <heyoka/kw.hpp>*

heyoka makes extensive use of the `igor library <https://github.com/bluescarni/igor>`__ to implement
keyword/named arguments.

Expand Down
7 changes: 3 additions & 4 deletions doc/mdspan.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mdspan
======
Multidimensional array views
============================

.. cpp:namespace-push:: heyoka

Expand All @@ -20,8 +20,7 @@ function call operator.
and `tutorial <https://github.com/kokkos/mdspan/wiki/A-Gentle-Introduction-to-mdspan>`__.

.. cpp:type:: template <typename IndexType, std::size_t... Extents> extents = std::experimental::extents<IndexType, Extents...>

.. cpp:type:: template <typename IndexType, std::size_t Rank> dextents = std::experimental::dextents<IndexType, Rank>
template <typename IndexType, std::size_t Rank> dextents = std::experimental::dextents<IndexType, Rank>

Classes representing static and dynamic extents.

Expand Down
26 changes: 13 additions & 13 deletions doc/number.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ The :cpp:class:`~heyoka::number` class
The default constructor initialises the internal union with the ``0.`` literal.

.. cpp:function:: number(const number &)
.. cpp:function:: number(number &&) noexcept
.. cpp:function:: number &operator=(const number &)
.. cpp:function:: number &operator=(number &&) noexcept
.. cpp:function:: ~number()
number(number &&) noexcept
number &operator=(const number &)
number &operator=(number &&) noexcept
~number()

Numbers are copy/move constructible, copy/move assignable and destructible.

Expand All @@ -43,10 +43,10 @@ The :cpp:class:`~heyoka::number` class
:exception: any exception thrown by the copy constructor/copy assignment operator of :cpp:class:`mppp::real`.

.. cpp:function:: explicit number(float x) noexcept
.. cpp:function:: explicit number(double x) noexcept
.. cpp:function:: explicit number(long double x) noexcept
.. cpp:function:: explicit number(mppp::real128 x) noexcept
.. cpp:function:: explicit number(mppp::real x)
explicit number(double x) noexcept
explicit number(long double x) noexcept
explicit number(mppp::real128 x) noexcept
explicit number(mppp::real x)

.. note::

Expand Down Expand Up @@ -92,7 +92,7 @@ Operators
---------

.. cpp:function:: number operator+(number n)
.. cpp:function:: number operator-(const number &n)
number operator-(const number &n)

The :cpp:class:`~heyoka::number` class supports the identity and negation operators.

Expand All @@ -103,9 +103,9 @@ Operators
:exception: any exception raised by the constructors of :cpp:class:`~heyoka::number`.

.. cpp:function:: number operator+(const number &x, const number &y)
.. cpp:function:: number operator-(const number &x, const number &y)
.. cpp:function:: number operator*(const number &x, const number &y)
.. cpp:function:: number operator/(const number &x, const number &y)
number operator-(const number &x, const number &y)
number operator*(const number &x, const number &y)
number operator/(const number &x, const number &y)

The :cpp:class:`~heyoka::number` class supports elementary binary arithmetics.

Expand All @@ -122,7 +122,7 @@ Operators
:exception std\:\:invalid_argument: if the active types of *x* and *y* differ and they don't support mixed-mode airthmetics.

.. cpp:function:: bool operator==(const number &x, const number &y) noexcept
.. cpp:function:: bool operator!=(const number &x, const number &y) noexcept
bool operator!=(const number &x, const number &y) noexcept

Equality comparison operators.

Expand Down
10 changes: 5 additions & 5 deletions doc/param.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ The :cpp:class:`~heyoka::param` class
:param idx: the index value for the parameter.

.. cpp:function:: param(const param &) noexcept
.. cpp:function:: param(param &&) noexcept
.. cpp:function:: param &operator=(const param &) noexcept
.. cpp:function:: param &operator=(param &&) noexcept
.. cpp:function:: ~param()
param(param &&) noexcept
param &operator=(const param &) noexcept
param &operator=(param &&) noexcept
~param()

Parameters are copy/move constructible, copy/move assignable and destructible.

Expand Down Expand Up @@ -78,7 +78,7 @@ Operators
---------

.. cpp:function:: bool operator==(const param &a, const param &b) noexcept
.. cpp:function:: bool operator!=(const param &a, const param &b) noexcept
bool operator!=(const param &a, const param &b) noexcept

Equality comparison operators.

Expand Down
10 changes: 5 additions & 5 deletions doc/variable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ The :cpp:class:`~heyoka::variable` class
:exception: any exception thrown by the copy constructor of ``std::string``.

.. cpp:function:: variable(const variable &)
.. cpp:function:: variable(variable &&) noexcept
.. cpp:function:: variable &operator=(const variable &)
.. cpp:function:: variable &operator=(variable &&) noexcept
.. cpp:function:: ~variable()
variable(variable &&) noexcept
variable &operator=(const variable &)
variable &operator=(variable &&) noexcept
~variable()

Variables are copy/move constructible, copy/move assignable and destructible.

Expand Down Expand Up @@ -79,7 +79,7 @@ Operators
---------

.. cpp:function:: bool operator==(const variable &a, const variable &b) noexcept
.. cpp:function:: bool operator!=(const variable &a, const variable &b) noexcept
bool operator!=(const variable &a, const variable &b) noexcept

Equality comparison operators.

Expand Down
17 changes: 5 additions & 12 deletions include/heyoka/callable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,14 @@ namespace detail

// Machinery to detect std::function.
template <typename>
struct is_any_std_func : std::false_type {
};
inline constexpr bool is_any_std_func = false;

template <typename R, typename... Args>
struct is_any_std_func<std::function<R(Args...)>> : std::true_type {
};

template <typename T>
inline constexpr bool is_any_std_func_v = is_any_std_func<T>::value;
inline constexpr bool is_any_std_func<std::function<R(Args...)>> = true;

// Detect callable instances.
template <typename>
struct is_any_callable : std::false_type {
};
inline constexpr bool is_any_callable = false;

// An empty struct used in the default initialisation
// of callable objects.
Expand Down Expand Up @@ -79,7 +73,7 @@ struct HEYOKA_DLL_PUBLIC_INLINE_CLASS callable_iface_impl<Base, Holder, T, R, Ar

if constexpr (std::is_pointer_v<unrefT> || std::is_member_pointer_v<unrefT>) {
return getval<Holder>(this) != nullptr;
} else if constexpr (is_any_callable<unrefT>::value || is_any_std_func_v<unrefT>) {
} else if constexpr (is_any_callable<unrefT> || is_any_std_func<unrefT>) {
return static_cast<bool>(getval<Holder>(this));
} else {
return true;
Expand Down Expand Up @@ -183,8 +177,7 @@ using callable_wrap_t = tanuki::wrap<callable_iface<R, Args...>, callable_wrap_c

// Specialise is_any_callable to detect callables.
template <typename R, typename... Args>
struct is_any_callable<detail::callable_wrap_t<R, Args...>> : std::true_type {
};
inline constexpr bool is_any_callable<detail::callable_wrap_t<R, Args...>> = true;

template <typename T>
struct callable_impl {
Expand Down
38 changes: 38 additions & 0 deletions include/heyoka/detail/debug.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2020, 2021, 2022, 2023, 2024 Francesco Biscani ([email protected]), Dario Izzo ([email protected])
//
// This file is part of the heyoka library.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef HEYOKA_DETAIL_DEBUG_HPP
#define HEYOKA_DETAIL_DEBUG_HPP

#include <heyoka/config.hpp>
#include <heyoka/detail/visibility.hpp>

HEYOKA_BEGIN_NAMESPACE

namespace detail
{

// RAII-style disabler of expensive debug checks.
struct HEYOKA_DLL_PUBLIC edb_disabler {
edb_disabler();
~edb_disabler();

edb_disabler(const edb_disabler &) = delete;
edb_disabler(edb_disabler &&) = delete;
edb_disabler &operator=(const edb_disabler &) = delete;
edb_disabler &operator=(edb_disabler &&) = delete;
};

// Are expensive debug checks enabled?
[[nodiscard]] HEYOKA_DLL_PUBLIC bool edb_enabled();

} // namespace detail

HEYOKA_END_NAMESPACE

#endif
Loading

0 comments on commit 8150bad

Please sign in to comment.