codac 2.0.0
Loading...
Searching...
No Matches
codac2_math.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <numbers>
13#include <cmath>
14
15namespace codac2
16{
17 constexpr double PI = std::numbers::pi; // Need C++20
18
19 inline int sign(double x)
20 {
21 return (x > 0) ? 1 : ((x < 0) ? -1 : 0);
22 }
23
24 inline int integer(double x)
25 {
26 return (int)x;
27 }
28
29 inline double pow(double v, double p)
30 {
31 return v < 0 ? -std::pow(-v,p) : std::pow(v,p);
32 }
33
34 inline double root(double v, double p)
35 {
36 return pow(v, 1./p);
37 }
38}
Interval pow(const Interval &x, int n)
Returns , .
Definition codac2_Interval_operations_impl.h:33
Interval root(const Interval &x, int p)
Returns the p-th root: .
Definition codac2_Interval_operations_impl.h:60
Interval integer(const Interval &x)
Returns the largest integer interval included in .
Definition codac2_Interval_operations_impl.h:284
Interval sign(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:279