| 1 |
/* |
| 2 |
* Copyright (C) 1996-2011 Daniel Waggoner |
| 3 |
* |
| 4 |
* This free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 3 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* It is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* If you did not received a copy of the GNU General Public License |
| 15 |
* with this software, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef __HISTOGRAMS__ |
| 19 |
#define __HISTOGRAMS__ |
| 20 |
|
| 21 |
#include "dw_matrix.h" |
| 22 |
|
| 23 |
#define HISTOGRAM_FIXED 1 |
| 24 |
#define HISTOGRAM_VARIABLE 2 |
| 25 |
|
| 26 |
/* Matrix histograms */ |
| 27 |
typedef struct |
| 28 |
{ |
| 29 |
TMatrix Min; |
| 30 |
TMatrix Max; |
| 31 |
int **low; |
| 32 |
int **high; |
| 33 |
int ***freq; |
| 34 |
int rows; |
| 35 |
int cols; |
| 36 |
int intervals; |
| 37 |
int sample_size; |
| 38 |
int type; |
| 39 |
} TMatrixHistogram; |
| 40 |
|
| 41 |
/* Vector histograms */ |
| 42 |
typedef struct |
| 43 |
{ |
| 44 |
TVector Min; |
| 45 |
TVector Max; |
| 46 |
int *low; |
| 47 |
int *high; |
| 48 |
int **freq; |
| 49 |
int dim; |
| 50 |
int intervals; |
| 51 |
int sample_size; |
| 52 |
int type; |
| 53 |
} TVectorHistogram; |
| 54 |
|
| 55 |
/* Scalar histograms */ |
| 56 |
typedef struct |
| 57 |
{ |
| 58 |
PRECISION Min; |
| 59 |
PRECISION Max; |
| 60 |
int low; |
| 61 |
int high; |
| 62 |
int *freq; |
| 63 |
int intervals; |
| 64 |
int sample_size; |
| 65 |
int type; |
| 66 |
} TScalarHistogram; |
| 67 |
|
| 68 |
TMatrixHistogram *CreateMatrixHistogram(int rows, int cols, int intervals, int type); |
| 69 |
void SetMaxMinMatrixHistogram(TMatrix Min, TMatrix Max, TMatrixHistogram *h); |
| 70 |
void FreeMatrixHistogram(TMatrixHistogram *h); |
| 71 |
void AddMatrixObservation(TMatrix X, TMatrixHistogram *h); |
| 72 |
TMatrix MatrixPercentile(TMatrix X, PRECISION percentile, TMatrixHistogram *h); |
| 73 |
void MatrixCumulative(TMatrix P, TMatrix Level, TMatrixHistogram *h); |
| 74 |
TMatrix PlotMatrixHistogramAuto(int i, int j, int bins, TMatrixHistogram *h); |
| 75 |
TMatrix PlotMatrixHistogram(int i, int j, PRECISION min, PRECISION max, int bins, TMatrixHistogram *h); |
| 76 |
|
| 77 |
TVectorHistogram *CreateVectorHistogram(int dim, int intervals, int type); |
| 78 |
void SetMaxMinVectorHistogram(TVector Min, TVector Max, TVectorHistogram *h); |
| 79 |
void FreeVectorHistogram(TVectorHistogram *h); |
| 80 |
void AddVectorObservation(TVector X, TVectorHistogram *h); |
| 81 |
TVector VectorPercentile(TVector X, PRECISION percentile, TVectorHistogram *h); |
| 82 |
void VectorCumulative(TVector p, TVector level, TVectorHistogram *h); |
| 83 |
TMatrix PlotVectorHistogramAuto(int i, int bins, TVectorHistogram *h); |
| 84 |
TMatrix PlotVectorHistogram(int i, PRECISION min, PRECISION max, int bins, TVectorHistogram *h); |
| 85 |
|
| 86 |
TScalarHistogram *CreateScalarHistogram(int intervals, int type); |
| 87 |
void SetMaxMinScalarHistogram(PRECISION Min, PRECISION Max, TScalarHistogram *h); |
| 88 |
void FreeScalarHistogram(TScalarHistogram *h); |
| 89 |
void AddScalarObservation(PRECISION x, TScalarHistogram *h); |
| 90 |
PRECISION ScalarPercentile(PRECISION percentile, TScalarHistogram *h); |
| 91 |
PRECISION ScalarCumulative(PRECISION level, TScalarHistogram *h); |
| 92 |
TMatrix PlotScalarHistogramAuto(int bins, TScalarHistogram *h); |
| 93 |
TMatrix PlotScalarHistogram(PRECISION min, PRECISION max, int bins, TScalarHistogram *h); |
| 94 |
#endif |