MCL
A C++ library mirroring some of the most common Matlab functions.
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
mcl
include
elementaryop.h
Go to the documentation of this file.
1
/*
2
MCL
3
Copyright (c) 2012-18, Enzo De Sena
4
All rights reserved.
5
6
Authors: Enzo De Sena, enzodesena@gmail.com
7
*/
8
9
#ifndef MCL_ELEMENTARYOP_H
10
#define MCL_ELEMENTARYOP_H
11
12
#include "
mcltypes.h
"
13
14
namespace
mcl {
15
16
template
<
class
T>
17
T
Max
(
const
T& scalar_a,
const
T& scalar_b) noexcept {
18
if
(scalar_a >= scalar_b) {
return
scalar_a; }
19
else
{
return
scalar_b; }
20
}
21
22
template
<
class
T>
23
T
Min
(
const
T& scalar_a,
const
T& scalar_b) noexcept {
24
if
(scalar_a < scalar_b) {
return
scalar_a; }
25
else
{
return
scalar_b; }
26
}
27
29
Real
Rem
(
const
Real
& scalar_a,
const
Real
& scalar_b);
30
32
Real
Mod
(
const
Real
& scalar_a,
const
Real
& scalar_b);
33
35
Int
Mod
(
const
Int
& scalar_a,
const
Int
& scalar_b);
36
38
Int
Fix
(
const
Real
scalar);
39
41
Real
Abs
(
Real
input);
42
44
Real
Abs
(
Complex
input);
45
47
Real
Pow
(
Real
input,
Real
exponent);
48
50
Real
Sqrt
(
Real
input);
51
54
inline
Int
RoundToInt
(
Real
input) {
55
Int
output =
static_cast<
int
>
(input);
56
output += (input-output >= 0.5) - (input-output <= -0.5);
57
return
output;
58
}
59
64
Int
Sign
(
const
Real
scalar);
65
67
Complex
Conj
(
Complex
scalar);
68
71
Real
RealPart
(
Complex
scalar);
72
75
Real
ImagPart
(
Complex
scalar);
76
78
Int
NextPow2
(
Real
input);
79
81
Int
Next2
(
Int
input);
82
84
double
StringToDouble
(
const
std::string& s);
85
87
Int
Factorial
(
const
Int
input);
88
90
Real
LinearInterpolation
(
Real
x1,
Real
y1,
Real
x2,
Real
y2,
Real
x);
91
96
bool
IsReal
(
const
std::vector<Complex>& input);
97
103
Real
Entropy
(std::vector<Real> pdf,
Real
base);
104
105
bool
ElementaryOpTest
();
106
107
#if MCL_LOAD_BOOST
108
113
Real
AssociatedLegendreP(
Int
n,
Int
m,
Real
x);
114
125
Complex
SphericalHarmonic(
Int
n,
Int
m,
Real
theta,
Real
phi);
126
#endif
127
128
129
}
131
#endif
Generated on Mon Mar 30 2020 09:25:16 for MCL by
1.8.2