Direct-BT
v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
jaulib
include
jau
math
math_error.hpp
Go to the documentation of this file.
1
/*
2
* Author: Sven Gothel <sgothel@jausoft.com>
3
* Copyright (c) 2024 Gothel Software e.K.
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining
6
* a copy of this software and associated documentation files (the
7
* "Software"), to deal in the Software without restriction, including
8
* without limitation the rights to use, copy, modify, merge, publish,
9
* distribute, sublicense, and/or sell copies of the Software, and to
10
* permit persons to whom the Software is furnished to do so, subject to
11
* the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be
14
* included in all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*/
24
25
#ifndef JAU_MATH_HPP_
26
#define JAU_MATH_HPP_
27
28
#include <stdexcept>
29
#include <
jau/int_math.hpp
>
30
#include <
jau/basic_types.hpp
>
31
32
namespace
jau::math
{
33
34
/** @defgroup Math Math Support
35
* Math Support Functionality, e.g. linear algebra, meta group
36
*
37
* Further support is coming from
38
* - \ref Integer
39
* - \ref ConstantTime
40
* - \ref Floats
41
*
42
* @{
43
*/
44
45
/** Error types as specified by [C++ Math Error Handling](https://en.cppreference.com/w/cpp/numeric/math/math_errhandling) */
46
enum class
math_error_t
{
47
/** See FE_INVALID */
48
invalid
,
49
/** See FE_DIVBYZERO */
50
div_by_zero
,
51
/** See FE_OVERFLOW */
52
overflow
,
53
/** See FE_UNDERFLOW */
54
underflow
,
55
/** See FE_INEXACT */
56
inexact
57
};
58
/** Returns std::string representation of math_error_t */
59
std::string
to_string
(
const
math_error_t
v)
noexcept
;
60
61
class
MathError
:
public
RuntimeException
{
62
private
:
63
math_error_t
m_error;
64
65
public
:
66
MathError
(
math_error_t
err, std::string
const
& m,
const
char
* file,
int
line) noexcept
67
:
RuntimeException
(
"MathError("
+
to_string
(err)+
")"
, m, file, line), m_error(err) {}
68
69
math_error_t
error
() const noexcept;
70
};
71
/** math_error_t::invalid */
72
class
MathDomainError
: public
MathError
{
73
public
:
74
MathDomainError
(std::string
const
& m,
const
char
* file,
int
line) noexcept
75
:
MathError
(
math_error_t::invalid
, m, file, line) {}
76
};
77
/** math_error_t::div_by_zero, i.e. pole error */
78
class
MathDivByZeroError
:
public
MathError
{
79
public
:
80
MathDivByZeroError
(std::string
const
& m,
const
char
* file,
int
line) noexcept
81
:
MathError
(
math_error_t::div_by_zero
, m, file, line) {}
82
};
83
/** math_error_t::overflow */
84
class
MathOverflowError
:
public
MathError
{
85
public
:
86
MathOverflowError
(std::string
const
& m,
const
char
* file,
int
line) noexcept
87
:
MathError
(
math_error_t::overflow
, m, file, line) {}
88
};
89
/** math_error_t::underflow */
90
class
MathUnderflowError
:
public
MathError
{
91
public
:
92
MathUnderflowError
(std::string
const
& m,
const
char
* file,
int
line) noexcept
93
:
MathError
(
math_error_t::underflow
, m, file, line) {}
94
};
95
/** math_error_t::inexact */
96
class
MathInexactError
:
public
MathError
{
97
public
:
98
MathInexactError
(std::string
const
& m,
const
char
* file,
int
line) noexcept
99
:
MathError
(
math_error_t::inexact
, m, file, line) {}
100
};
101
102
/**@}*/
103
104
}
// namespace jau
105
106
#endif
// JAU_MATH_HPP_
basic_types.hpp
jau::RuntimeException
Definition:
basic_types.hpp:349
jau::RuntimeException::RuntimeException
RuntimeException(std::string type, std::string const &m, const char *file, int line) noexcept
Definition:
basic_types.hpp:351
jau::math::MathDivByZeroError
math_error_t::div_by_zero, i.e.
Definition:
math_error.hpp:78
jau::math::MathDivByZeroError::MathDivByZeroError
MathDivByZeroError(std::string const &m, const char *file, int line) noexcept
Definition:
math_error.hpp:80
jau::math::MathDomainError
math_error_t::invalid
Definition:
math_error.hpp:72
jau::math::MathDomainError::MathDomainError
MathDomainError(std::string const &m, const char *file, int line) noexcept
Definition:
math_error.hpp:74
jau::math::MathError
Definition:
math_error.hpp:61
jau::math::MathError::MathError
MathError(math_error_t err, std::string const &m, const char *file, int line) noexcept
Definition:
math_error.hpp:66
jau::math::MathError::error
math_error_t error() const noexcept
jau::math::MathInexactError
math_error_t::inexact
Definition:
math_error.hpp:96
jau::math::MathInexactError::MathInexactError
MathInexactError(std::string const &m, const char *file, int line) noexcept
Definition:
math_error.hpp:98
jau::math::MathOverflowError
math_error_t::overflow
Definition:
math_error.hpp:84
jau::math::MathOverflowError::MathOverflowError
MathOverflowError(std::string const &m, const char *file, int line) noexcept
Definition:
math_error.hpp:86
jau::math::MathUnderflowError
math_error_t::underflow
Definition:
math_error.hpp:90
jau::math::MathUnderflowError::MathUnderflowError
MathUnderflowError(std::string const &m, const char *file, int line) noexcept
Definition:
math_error.hpp:92
jau::math::math_error_t
math_error_t
Error types as specified by C++ Math Error Handling
Definition:
math_error.hpp:46
jau::math::to_string
std::string to_string(const math_error_t v) noexcept
Returns std::string representation of math_error_t.
Definition:
basic_types.cpp:627
jau::math::math_error_t::underflow
@ underflow
See FE_UNDERFLOW.
jau::math::math_error_t::overflow
@ overflow
See FE_OVERFLOW.
jau::math::math_error_t::div_by_zero
@ div_by_zero
See FE_DIVBYZERO.
jau::math::math_error_t::inexact
@ inexact
See FE_INEXACT.
jau::math::math_error_t::invalid
@ invalid
See FE_INVALID.
int_math.hpp
jau::math
Definition:
fov_hv_halves.hpp:35
Generated on Sun May 12 2024 09:25:36 for Direct-BT by
1.9.4