-
Notifications
You must be signed in to change notification settings - Fork 2
/
DWN_utilitym.h
132 lines (109 loc) · 4.94 KB
/
DWN_utilitym.h
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef MATH_CHUCK
#define MATH_CHUCK
#include <cstdlib>
#include <cmath>
using namespace std;
#include "DWN_utilityconstants.h"
//Array initialization---
void Zero_Array(double*, int);
//Sets all values in an array to zero.
void Zero_Array(int*, int);
//Sets all values in an array to zero.
void False_Array(bool*, int);
//Sets all values in an array to false (0 = FALSEV).
void Initialize_Array(double*, int, double);
//Initializes an array to the passed value.
void Initialize_Array(int*, int, int);
//Initializes an array to the passed value.
void Initialize_Array(bool*, int, bool);
//Initializes an array to the passed value.
void Initialize_Array(char*, int, char);
//Initializes an array to the passed value.
//Relative math---
int Get_Largest(int, int, int);
//Returns the largest of the three passed integers.
double Get_Largest(double, double, double);
//Returns the largest of the three passed values.
int Get_Smallest(int, int, int);
//Returns the smallest of the three passed integers.
double Get_Smallest(double, double, double);
//Returns the smallest of the three passed values.
int Get_Smallest_NonZero(int, int, int);
//Returns the smallest non-zero of the three passed integers.
double Get_Smallest_NonZero(double, double, double);
//Returns the smallest non-zero of the three passed values.
int Get_Largest_3DVec_Component(const double*);
//Returns the index of the component in the passed 3-D vector
//that has the largest magnitude.
int Get_Largest_RelVec_Component(const double*, const double*);
//Returns the index of the components in the passed relative
//3-D vector that has the largest magnitude.
int Abs_Difference(int, int);
//Returns the absolute difference between the integers.
double Abs_Difference(double, double);
//Returns the absolute difference between the values.
//Numerical range enforcement---
void Set_Max(int&, int);
//If passed variable is greater than the maximum value,
//the variable is set to that maximum value.
void Set_Max(double&, double);
//If passed variable is greater than the maximum value,
//the variable is set to that maximum value.
void Set_Min(int&, int);
//If passed variable is greater than the minimum value,
//the variable is set to that maximum value.
void Set_Min(double&, double);
//If passed variable is greater than the minimum value,
//the variable is set to that maximum value.
void Set_Maxs(double*, const double*, int);
//Enforces maximum values on a set of variables.
void Set_Mins(double*, const double*, int);
//Enforces minimum values on a set of variables.
//Safe floating-point math---
void Check_FP_Zero(double&);
//Makes sure a floating-point value of zero is actually stored as zero
//in computational floating-point terms. See the "utilityconstants.h"
//file for the FP-range that is considered effectively zero.
void Check_FP_Zeros(double*);
//Makes sure the three passed FP values are stored as zero if they
//effectively are zero.
bool Check_FP_Equality(double, double);
//Determines if the passed FP variables are effectively equal to
//each other, i.e. the difference between them is effectively zero.
bool Check_FP_LessOrEqual(double, double);
//<= operation between FP variables. Ignores insignificant differences.
//Here, that means effectively equal FP variables will return TRUEV.
bool Check_FP_GreaterOrEqual(double, double);
//>= operation between FP variables. Ignores insignificant differences.
//Here, that means effectively equal FP variables will return TRUEV.
bool Check_FP_LessThan(double, double);
//< operation between FP variables. Ignores insignificant differences.
//Here, that means effectively equal FP variables will return FALSEV.
bool Check_FP_GreaterThan(double, double);
//> operation between FP variables. Ignores insignificant differences.
//Here, that means effectively equal FP variables will return FALSEV.
void Protect_Truncation(double&);
//Increases the magnitude of the passed variable by a very small value, such
//that truncation will return the desired integer value.
void Safe_Truncation(int&, double, double);
//Obtains the integer truncation of the result of an FP division.
//Peak analysis---
void Analyze_Peaks(double*, int, double, double, double**, int&, const int);
/*Analyzes a data set and determines peak locations, maximums,
FWHMs, and integrated intensity are determined. Assumes
a zero-baseline for determination of FWHM and integrated intensity.*/
//Memory management---
//Dynamic two-dimensional memory handling---
void Get_Memory(double**&, int, int);
//Dynamically allocates memory of two-dimensional FP array.
void Free_Memory(double**&, int);
//Dynamic deallocation of memory.
void Get_Memory(int**&, int, int);
//Dynamically allocates memory of two-dimensional integer array.
void Free_Memory(int**&, int);
//Dynamic deallocation of memory.
void Get_Memory(char**&, int, int);
//Dynamically allocates memory of two-dimensional character array.
void Free_Memory(char**&, int);
//Dynamic deallocation of memory.
#endif