Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adiosMath.h math functions used in the ADIOS framework
*
* Created on: May 17, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#ifndef ADIOS2_HELPER_ADIOSMATH_H_
#define ADIOS2_HELPER_ADIOSMATH_H_
/// \cond EXCLUDE_FROM_DOXYGEN
#include <vector>
/// \endcond
#include "adios2/ADIOSTypes.h"
namespace adios
{
/**
* Loops through a vector containing dimensions and returns the product of all
* elements
* @param dimensions input containing size on each dimension {Nx, Ny, Nz}
* @return product of all dimensions Nx * Ny * Nz
*/
size_t GetTotalSize(const Dims &dimensions) noexcept;
/**
* Gets the min and max from a values array of primitive types (not including
* complex)
* @param values input array
* @param size of values array
* @param min of values
* @param max of values
*/
template <class T>
void GetMinMax(const T *values, const size_t size, T &min, T &max) noexcept;
/**
* Version for complex types of GetMinMax, gets the "doughnut" range between min
* and max modulus. Needed a different function as thread can't resolve the
* overload of a GetMinMax with complex types
* @param values array of complex numbers
* @param size of the values array
* @param min modulus from values
* @param max modulus from values
*/
template <class T>
void GetMinMaxComplex(const std::complex<T> *values, const size_t size, T &min,
T &max) noexcept;
/**
* Threaded version of GetMinMax.
* Gets the min and max from a values array of primitive types (not including
* complex) using threads
* @param values input array of complex
* @param size of values array
* @param min of values
* @param max of values
* @param threads used for parallel computation
*/
template <class T>
void GetMinMaxThreads(const T *values, const size_t size, T &min, T &max,
const unsigned int threads = 1) noexcept;
/**
* Overloaded version of GetMinMaxThreads for complex types
* @param values input array of complex
* @param size of values array
* @param min of values
* @param max of values
* @param threads used for parallel computation
*/
template <class T>
void GetMinMaxThreads(const std::complex<T> *values, const size_t size, T &min,
T &max, const unsigned int threads = 1) noexcept;
/**
* Check if index is within (inclusive) limits
* lowerLimit <= index <= upperLimit
* @param index input to be checked
* @param upperLimit
* @param lowerLimit
* @return true index is within limits
*/
bool CheckIndexRange(const int index, const int upperLimit,
const int lowerLimit = 0) noexcept;
} // end namespace adios
#include "adiosMath.inl"
#endif /* ADIOS2_HELPER_ADIOSMATH_H_ */