| 1 | /* File: u8_interval.h; Copyright and License: see below */ |
| 2 | |
| 3 | #ifndef U8_INTERVAL_H |
| 4 | #define U8_INTERVAL_H |
| 5 | |
| 6 | /* public file for the doxygen documentation: */ |
| 7 | /*! |
| 8 | * \file |
| 9 | * \brief Provides a representation of an interval of double values |
| 10 | */ |
| 11 | |
| 12 | /*! |
| 13 | * \brief attributes of the interval |
| 14 | */ |
| 15 | struct u8_interval_struct { |
| 16 | double low; |
| 17 | double high; |
| 18 | }; |
| 19 | |
| 20 | typedef struct u8_interval_struct u8_interval_t; |
| 21 | |
| 22 | /*! |
| 23 | * \brief initializes a new interval covering void. |
| 24 | * |
| 25 | * \return a new interval |
| 26 | */ |
| 27 | static inline u8_interval_t u8_interval_new_void(); |
| 28 | |
| 29 | /*! |
| 30 | * \brief initializes a new interval by unordered boundry values |
| 31 | * |
| 32 | * \param a one of the boundaries |
| 33 | * \param b one of the boundaries |
| 34 | * \return the interval |
| 35 | */ |
| 36 | static inline u8_interval_t u8_interval_new_unordered ( double a, double b ); |
| 37 | |
| 38 | /*! |
| 39 | * \brief initializes a new interval by lesser and greater bounds |
| 40 | * |
| 41 | * \param low the lesser boundary |
| 42 | * \param high the greater boundary |
| 43 | * \return the interval |
| 44 | */ |
| 45 | static inline u8_interval_t u8_interval_new ( double low, double high ); |
| 46 | |
| 47 | /*! |
| 48 | * \brief initializes a new interval by the intersect of a and b |
| 49 | * |
| 50 | * \param a an interval |
| 51 | * \param b another interval |
| 52 | * \return the interval |
| 53 | */ |
| 54 | static inline u8_interval_t u8_interval_new_intersect ( const u8_interval_t *a, const u8_interval_t *b ); |
| 55 | |
| 56 | /*! |
| 57 | * \brief checks if the interval is valid |
| 58 | * |
| 59 | * \param this_ pointer to own object attributes |
| 60 | * \return true if both boundaries are not NaN |
| 61 | */ |
| 62 | static inline bool u8_interval_is_valid ( const u8_interval_t *this_ ); |
| 63 | |
| 64 | /*! |
| 65 | * \brief gets the lesser boundary |
| 66 | * |
| 67 | * \param this_ pointer to own object attributes |
| 68 | * \return the lesser boundary |
| 69 | */ |
| 70 | static inline double u8_interval_get_low ( const u8_interval_t *this_ ); |
| 71 | |
| 72 | /*! |
| 73 | * \brief gets the greater boundary |
| 74 | * |
| 75 | * \param this_ pointer to own object attributes |
| 76 | * \return the greater boundary |
| 77 | */ |
| 78 | static inline double u8_interval_get_high ( const u8_interval_t *this_ ); |
| 79 | |
| 80 | /*! |
| 81 | * \brief gets the width/size of the interval |
| 82 | * |
| 83 | * \param this_ pointer to own object attributes |
| 84 | * \return the size of the interval |
| 85 | */ |
| 86 | static inline double u8_interval_get_size ( const u8_interval_t *this_ ); |
| 87 | |
| 88 | #include "u8/u8_interval.inl" |
| 89 | |
| 90 | #endif /* U8_INTERVAL_H */ |
| 91 | |
| 92 | |
| 93 | /* |
| 94 | Copyright 2025-2026 Andreas Warnke |
| 95 | |
| 96 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 97 | you may not use this file except in compliance with the License. |
| 98 | You may obtain a copy of the License at |
| 99 | |
| 100 | http://www.apache.org/licenses/LICENSE-2.0 |
| 101 | |
| 102 | Unless required by applicable law or agreed to in writing, software |
| 103 | distributed under the License is distributed on an "AS IS" BASIS, |
| 104 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 105 | See the License for the specific language governing permissions and |
| 106 | limitations under the License. |
| 107 | */ |