6 #ifndef THEORETICA_PARALLEL_H
7 #define THEORETICA_PARALLEL_H
10 #include "../core/dataset.h"
11 #include "../core/real_analysis.h"
12 #include "../complex/complex_analysis.h"
13 #include "../autodiff/dual_functions.h"
14 #include "../autodiff/dual2_functions.h"
15 #include "../autodiff/multidual_functions.h"
34 template<
typename Function,
typename Vector>
40 #pragma omp parallel for
41 for (
unsigned int i = 0; i < v.size(); i++)
52 template<
typename Vector>
53 inline Vector
square(
const Vector& v) {
58 #pragma omp parallel for
59 for (
unsigned int i = 0; i < v.size(); i++)
70 template<
typename Vector>
71 inline Vector
cube(
const Vector& v) {
76 #pragma omp parallel for
77 for (
unsigned int i = 0; i < v.size(); i++)
88 template<
typename Vector>
89 inline Vector
abs(
const Vector& v) {
94 #pragma omp parallel for
95 for (
unsigned int i = 0; i < v.size(); i++)
106 template<
typename Vector>
107 inline Vector
pow(
const Vector& v,
int n) {
110 res.resize(v.size());
112 #pragma omp parallel for
113 for (
unsigned int i = 0; i < v.size(); i++)
124 template<
typename Vector>
128 res.resize(v.size());
130 #pragma omp parallel for
131 for (
unsigned int i = 0; i < v.size(); i++)
142 template<
typename Vector>
143 inline Vector
sqrt(
const Vector& v) {
146 res.resize(v.size());
148 #pragma omp parallel for
149 for (
unsigned int i = 0; i < v.size(); i++)
160 template<
typename Vector>
161 inline Vector
cbrt(
const Vector& v) {
164 res.resize(v.size());
166 #pragma omp parallel for
167 for (
unsigned int i = 0; i < v.size(); i++)
178 template<
typename Vector>
179 inline Vector
exp(
const Vector& v) {
182 res.resize(v.size());
184 #pragma omp parallel for
185 for (
unsigned int i = 0; i < v.size(); i++)
196 template<
typename Vector>
197 inline Vector
ln(
const Vector& v) {
200 res.resize(v.size());
202 #pragma omp parallel for
203 for (
unsigned int i = 0; i < v.size(); i++)
214 template<
typename Vector>
215 inline Vector
log2(
const Vector& v) {
218 res.resize(v.size());
220 #pragma omp parallel for
221 for (
unsigned int i = 0; i < v.size(); i++)
232 template<
typename Vector>
233 inline Vector
log10(
const Vector& v) {
236 res.resize(v.size());
238 #pragma omp parallel for
239 for (
unsigned int i = 0; i < v.size(); i++)
250 template<
typename Vector>
251 inline Vector
sin(
const Vector& v) {
254 res.resize(v.size());
256 #pragma omp parallel for
257 for (
unsigned int i = 0; i < v.size(); i++)
268 template<
typename Vector>
269 inline Vector
cos(
const Vector& v) {
272 res.resize(v.size());
274 #pragma omp parallel for
275 for (
unsigned int i = 0; i < v.size(); i++)
286 template<
typename Vector>
287 inline Vector
tan(
const Vector& v) {
290 res.resize(v.size());
292 #pragma omp parallel for
293 for (
unsigned int i = 0; i < v.size(); i++)
304 template<
typename Vector>
305 inline Vector
cot(
const Vector& v) {
308 res.resize(v.size());
310 #pragma omp parallel for
311 for (
unsigned int i = 0; i < v.size(); i++)
322 template<
typename Vector>
323 inline Vector
asin(
const Vector& v) {
326 res.resize(v.size());
328 #pragma omp parallel for
329 for (
unsigned int i = 0; i < v.size(); i++)
340 template<
typename Vector>
341 inline Vector
acos(
const Vector& v) {
344 res.resize(v.size());
346 #pragma omp parallel for
347 for (
unsigned int i = 0; i < v.size(); i++)
358 template<
typename Vector>
359 inline Vector
atan(
const Vector& v) {
362 res.resize(v.size());
364 #pragma omp parallel for
365 for (
unsigned int i = 0; i < v.size(); i++)
376 template<
typename Vector>
377 inline Vector
sinh(
const Vector& v) {
380 res.resize(v.size());
382 #pragma omp parallel for
383 for (
unsigned int i = 0; i < v.size(); i++)
394 template<
typename Vector>
395 inline Vector
cosh(
const Vector& v) {
398 res.resize(v.size());
400 #pragma omp parallel for
401 for (
unsigned int i = 0; i < v.size(); i++)
412 template<
typename Vector>
413 inline Vector
tanh(
const Vector& v) {
416 res.resize(v.size());
418 #pragma omp parallel for
419 for (
unsigned int i = 0; i < v.size(); i++)
430 template<
typename Vector>
431 inline Vector
coth(
const Vector& v) {
434 res.resize(v.size());
436 #pragma omp parallel for
437 for (
unsigned int i = 0; i < v.size(); i++)
Vector exp(const Vector &v)
Parallel element-wise evaluation of the exp function.
Definition: parallel.h:179
Vector cbrt(const Vector &v)
Parallel element-wise evaluation of the cbrt function.
Definition: parallel.h:161
Vector tan(const Vector &v)
Vectorized (element-wise evaluation) of the tan function.
Definition: parallel.h:287
Vector cos(const Vector &v)
Parallel element-wise evaluation of the cos function.
Definition: parallel.h:269
Vector cot(const Vector &v)
Vectorized (element-wise evaluation) of the cot function.
Definition: parallel.h:305
Vector atan(const Vector &v)
Vectorized (element-wise evaluation) of the atan function.
Definition: parallel.h:359
Vector log10(const Vector &v)
Parallel element-wise evaluation of the log10 function.
Definition: parallel.h:233
Vector square(const Vector &v)
Parallel element-wise evaluation of the square function.
Definition: parallel.h:53
Vector tanh(const Vector &v)
Vectorized (element-wise evaluation) of the tanh function.
Definition: parallel.h:413
Vector cube(const Vector &v)
Parallel element-wise evaluation of the cube function.
Definition: parallel.h:71
Vector sinh(const Vector &v)
Vectorized (element-wise evaluation) of the sinh function.
Definition: parallel.h:377
Vector apply_function(Function f, const Vector &v)
Parallel element-wise evaluation of a function, using OpenMP to speed up execution over a vector.
Definition: parallel.h:35
Vector coth(const Vector &v)
Vectorized (element-wise evaluation) of the coth function.
Definition: parallel.h:431
Vector ln(const Vector &v)
Parallel element-wise evaluation of the ln function.
Definition: parallel.h:197
Vector abs(const Vector &v)
Parallel element-wise evaluation of the abs function.
Definition: parallel.h:89
Vector sqrt(const Vector &v)
Parallel element-wise evaluation of the sqrt function.
Definition: parallel.h:143
Vector pow(const Vector &v, int n)
Parallel element-wise evaluation of the pow function.
Definition: parallel.h:107
Vector sin(const Vector &v)
Parallel element-wise evaluation of the sin function.
Definition: parallel.h:251
Vector powf(const Vector &v, real x)
Parallel element-wise evaluation of the powf function.
Definition: parallel.h:125
Vector log2(const Vector &v)
Parallel element-wise evaluation of the log2 function.
Definition: parallel.h:215
Vector cosh(const Vector &v)
Vectorized (element-wise evaluation) of the cosh function.
Definition: parallel.h:395
Vector asin(const Vector &v)
Vectorized (element-wise evaluation) of the asin function.
Definition: parallel.h:323
Vector acos(const Vector &v)
Vectorized (element-wise evaluation) of the acos function.
Definition: parallel.h:341
Main namespace of the library which contains all functions and objects.
Definition: algebra.h:27
double real
A real number, defined as a floating point type.
Definition: constants.h:188
dual2 sqrt(dual2 x)
Compute the square root of a second order dual number.
Definition: dual2_functions.h:54
dual cosh(dual x)
Compute the hyperbolic cosine of a dual number.
Definition: dual_functions.h:194
dual2 ln(dual2 x)
Compute the natural logarithm of a second order dual number.
Definition: dual2_functions.h:139
dual sinh(dual x)
Compute the hyperbolic sine of a dual number.
Definition: dual_functions.h:186
dual2 abs(dual2 x)
Compute the absolute value of a second order dual number.
Definition: dual2_functions.h:183
dual2 log2(dual2 x)
Compute the natural logarithm of a second order dual number.
Definition: dual2_functions.h:153
dual2 asin(dual2 x)
Compute the arcsine of a second order dual number.
Definition: dual2_functions.h:189
dual2 exp(dual2 x)
Compute the exponential of a second order dual number.
Definition: dual2_functions.h:130
dual2 log10(dual2 x)
Compute the natural logarithm of a second order dual number.
Definition: dual2_functions.h:168
real cbrt(real x)
Compute the cubic root of x.
Definition: real_analysis.h:199
real powf(real x, real a)
Approximate x elevated to a real exponent.
Definition: real_analysis.h:796
real coth(real x)
Compute the hyperbolic cotangent.
Definition: real_analysis.h:1153
dual2 cos(dual2 x)
Compute the cosine of a second order dual number.
Definition: dual2_functions.h:82
dual2 cot(dual2 x)
Compute the cotangent of a second order dual number.
Definition: dual2_functions.h:112
dual2 tan(dual2 x)
Compute the tangent of a second order dual number.
Definition: dual2_functions.h:94
dual2 acos(dual2 x)
Compute the arcosine of a second order dual number.
Definition: dual2_functions.h:206
dual2 sin(dual2 x)
Compute the sine of a second order dual number.
Definition: dual2_functions.h:70
dual2 square(dual2 x)
Return the square of a second order dual number.
Definition: dual2_functions.h:23
dual2 atan(dual2 x)
Compute the arctangent of a second order dual number.
Definition: dual2_functions.h:223
dual tanh(dual x)
Compute the hyperbolic tangent of a dual number.
Definition: dual_functions.h:202
dual2 pow(dual2 x, int n)
Compute the n-th power of a second order dual number.
Definition: dual2_functions.h:41
dual2 cube(dual2 x)
Return the cube of a second order dual number.
Definition: dual2_functions.h:29
Vector class and operations.