fennec
Loading...
Searching...
No Matches
exponential.h
Go to the documentation of this file.
1// =====================================================================================================================
2// fennec, a free and open source game engine
3// Copyright © 2025 Medusa Slockbower
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17// =====================================================================================================================
18
30
31
32#ifndef FENNEC_MATH_EXPONENTIAL_H
33#define FENNEC_MATH_EXPONENTIAL_H
34
89
90#include <fennec/math/detail/_math.h>
91#include <fennec/math/vector.h>
92
93namespace fennec
94{
95
96
97// pow =================================================================================================================
98
107template<typename genType>
108constexpr genType pow(genType x, genType y) {
109 return ::pow(x, y);
110}
111
112
113// exp =================================================================================================================
114
121template<typename genType>
122constexpr genType exp(genType x) {
123 return ::exp(x);
124}
125
126
127// exp2 ================================================================================================================
128
135template<typename genType> constexpr genType exp2(genType x) {
136 return ::exp2(x);
137}
138
139
140// log =================================================================================================================
141
149template<typename genType> constexpr genType log(genType x) {
150 return ::log(x);
151}
152
153
154// log2 ================================================================================================================
155
164template<typename genType> constexpr genType log2(genType x) {
165 return ::log2(x);
166}
167
168
169// sqrt ================================================================================================================
170
178template<typename genType> constexpr genType sqrt(genType x) {
179 return ::sqrt(x);
180}
181
182
183// inversesqrt =========================================================================================================
184
192template<typename genType> constexpr genType inversesqrt(genType x) {
193 return 1.0f / ::sqrt(x);
194}
195
196
197// Internal ============================================================================================================
198
199template<typename genType, size_t...i>
200constexpr vector<genType, i...> pow(const vector<genType, i...> & x, const vector<genType, i...> & y) {
201 return vector<genType, i...>(fennec::pow(x[i], y[i]) ...);
202}
203
204template<typename genType, size_t...i> constexpr vector<genType, i...> exp(const vector<genType, i...>& x) {
205 return vector<genType, i...>(fennec::exp(x[i]) ...);
206}
207
208template<typename genType, size_t...i> constexpr vector<genType, i...> exp2(const vector<genType, i...>& x) {
209 return vector<genType, i...>(fennec::exp2(x[i]) ...);
210}
211
212template<typename genType, size_t...i> constexpr genType log(const vector<genType, i...>& x) {
213 return vector<genType, i...>(log(x[i]) ...);
214}
215
216template<typename genType, size_t...i> constexpr genType log2(const vector<genType, i...>& x) {
217 return vector<genType, i...>(log2(x[i]) ...);
218}
219
220template<typename genType, size_t...i> constexpr genType sqrt(const vector<genType, i...>& x) {
221 return vector<genType, i...>(fennec::sqrt(x[i]) ...);
222}
223
224template<typename genType, size_t...i>
225constexpr vector<genType, i...> inversesqrt(const vector<genType, i...>& x) {
226 return vector<genType, i...>(fennec::inversesqrt(x[i]) ...);
227}
228
229
230}
231
232#endif // FENNEC_MATH_EXPONENTIAL_H
constexpr genType log(genType x)
Returns the natural logarithm of .
Definition exponential.h:149
constexpr genType exp2(genType x)
Returns 2 raised to the power, i.e., .
Definition exponential.h:135
constexpr genType log2(genType x)
Returns the base 2 logarithm of .
Definition exponential.h:164
constexpr genType inversesqrt(genType x)
Returns .
Definition exponential.h:192
constexpr genType pow(genType x, genType y)
Returns raised to the power, i.e., .
Definition exponential.h:108
constexpr genType sqrt(genType x)
Returns .
Definition exponential.h:178
constexpr genType exp(genType x)
Returns the natural exponentiation of , i.e., .
Definition exponential.h:122
constexpr genType y()
Definition constants.h:672
the Vectors