18 #ifndef PIC_UTIL_INDEXED_ARRAY_HPP 19 #define PIC_UTIL_INDEXED_ARRAY_HPP 23 #include "../util/math.hpp" 60 return (val < T(0)) || (val > T(0));
82 for(
int i = 0; i < nData; i += stride) {
96 static void find(
float *data,
int nData,
bool(*func)(
float,
97 std::vector<float>), std::vector<float> param,
IntCoord &ret)
99 for(
int i = 0; i < nData; i++) {
100 if(func(data[i], param)) {
118 T ret = data[coord[0]];
120 for(
unsigned int i = 1; i < coord.size(); i++) {
125 ret /= T(coord.size());
142 float ret = data[coord[0]];
144 for(
unsigned int i = 1; i < coord.size(); i++) {
146 ret =
MIN(ret, data[j]);
164 T ret = data[coord[0]];
166 for(
unsigned int i = 1; i < coord.size(); i++) {
168 ret =
MAX(ret, data[j]);
187 int n = int(coord.size());
190 for(
int i = 0; i < n; i++) {
195 std::sort(tmp, tmp + n);
197 percent =
CLAMPi(percent, 0.0f, 1.0f);
199 T ret = tmp[int(
float(n - 1) * percent)];
212 for(
unsigned int i = 0; i < coord.size(); i++) {
213 coord.at(i) = coord.at(i) *
scale;
232 for(
unsigned int i = 0; i < coord.size(); i++) {
234 ret += log10f(data[j] + delta);
237 return ret / float(coord.size());
254 float log2f = logf(2.0f);
256 for(
unsigned int i = 0; i < coord.size(); i++) {
258 ret += logf(data[j] + delta) /
log2f;
261 return ret / float(coord.size());
272 for(
unsigned int i = 0; i < coord.size(); i++) {
274 data[j] = referencePoint - data[j];
286 for(
unsigned int i = 0; i < coord.size(); i++) {
300 for(
unsigned int i = 0; i < coord.size(); i++) {
314 for(
unsigned int i = 0; i < coord.size(); i++) {
328 for(
unsigned int i = 0; i < coord.size(); i++) {
342 for(
unsigned int i = 0; i < coord.size(); i++) {
344 dataDst[j] = dataSrc;
356 for(
unsigned int i = 0; i < coord.size(); i++) {
358 dataDst[j] = dataSrc[j];
IndexedArray< int > IndexedArrayi
Definition: indexed_array.hpp:365
static void negative(T *data, IntCoord &coord, T referencePoint=T(1))
negative computes the negative value given a val reference point.
Definition: indexed_array.hpp:270
static void assign(T *dataDst, IntCoord &coord, T dataSrc)
assign
Definition: indexed_array.hpp:340
static T max(T *data, IntCoord &coord)
max computes the max value.
Definition: indexed_array.hpp:158
static void findSimple(T *data, int nData, bool(*func)(float), IntCoord &ret, int stride=1)
findSimple collects coordinates of data which satisfies a bool function func.
Definition: indexed_array.hpp:80
static bool bFuncNotNeg(T val)
bFuncNotNeg
Definition: indexed_array.hpp:48
static void find(float *data, int nData, bool(*func)(float, std::vector< float >), std::vector< float > param, IntCoord &ret)
find collects coordinates of data which satisfies a bool function func.
Definition: indexed_array.hpp:96
static T min(T *data, IntCoord &coord)
min computes the min value.
Definition: indexed_array.hpp:136
static void mul(T *data, IntCoord &coord, T val)
mul is the multiplicative operator.
Definition: indexed_array.hpp:312
std::vector< int > IntCoord
IntCoord.
Definition: indexed_array.hpp:30
static void assign(T *dataDst, IntCoord &coord, T *dataSrc)
Assign.
Definition: indexed_array.hpp:354
PIC_INLINE float log2f(float x)
log2f logarithm in base 2 for floating point
Definition: math.hpp:375
static void div(T *dataDst, IntCoord &coord, T val)
div is the division operator.
Definition: indexed_array.hpp:326
IndexedArray< unsigned int > IndexedArrayui
Definition: indexed_array.hpp:367
#define MIN(a, b)
Definition: math.hpp:69
The IndexedArray class.
Definition: indexed_array.hpp:36
static void add(T *data, IntCoord &coord, T val)
add is the additive operator.
Definition: indexed_array.hpp:284
static T percentile(T *data, IntCoord &coord, float percent)
percentile
Definition: indexed_array.hpp:181
static float log10Mean(float *data, IntCoord &coord)
log10Mean computes mean in the log10 domain.
Definition: indexed_array.hpp:223
static void scale(IntCoord &coord, int scale)
scale scales values.
Definition: indexed_array.hpp:210
static bool bFuncNotZero(T val)
bFuncNotZero
Definition: indexed_array.hpp:58
static float log2Mean(float *data, IntCoord &coord)
log2Mean computes mean in the log2 domain.
Definition: indexed_array.hpp:246
#define CLAMPi(x, a, b)
Definition: math.hpp:81
static void sub(T *data, IntCoord &coord, T val)
sub is the subtractive operator.
Definition: indexed_array.hpp:298
Definition: bilateral_separation.hpp:25
#define MAX(a, b)
Definition: math.hpp:73
IndexedArray< float > IndexedArrayf
Definition: indexed_array.hpp:363
IndexedArray()
Definition: indexed_array.hpp:39
static T mean(T *data, IntCoord &coord)
mean computes the mean value.
Definition: indexed_array.hpp:112
static bool bFuncNeg(T val)
bFuncNeg
Definition: indexed_array.hpp:68