1
/*****************************************************************************
2
TRAVIS - Trajectory Analyzer and Visualizer
3
http://www.travis-analyzer.de/
5
Copyright (c) 2009-2013 Martin Brehm
6
2012-2013 Martin Thomas
8
This file written by Martin Brehm.
10
This program is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*****************************************************************************/
24
#include "statistics.h"
27
CStatistics::CStatistics()
35
m_waXValues.SetName("CStatistics::m_waXValues");
36
m_waYValues.SetName("CStatistics::m_waYValues");
40
CStatistics::~CStatistics()
65
void CStatistics::Init(int x, int y)
72
try { m_pMin = new double[x*y]; } catch(...) { m_pMin = NULL; }
73
if (m_pMin == NULL) NewException((double)x*y*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
75
try { m_pMax = new double[x*y]; } catch(...) { m_pMax = NULL; }
76
if (m_pMax == NULL) NewException((double)x*y*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
78
try { m_pAvg = new double[x*y]; } catch(...) { m_pAvg = NULL; }
79
if (m_pAvg == NULL) NewException((double)x*y*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
81
try { m_pCount = new double[x*y]; } catch(...) { m_pCount = NULL; }
82
if (m_pCount == NULL) NewException((double)x*y*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
86
m_pMin[z] = 9999999999.0;
94
void CStatistics::Evaluate()
98
for (z=0;z<m_iSizeX*m_iSizeY;z++)
100
m_pAvg[z] /= m_pCount[z];
104
void CStatistics::Write(const char *pre, const char *s, const char *post)
116
a = OpenFileWrite(buf,true);
117
for (x=0;x<m_iSizeX;x++)
118
for (y=0;y<m_iSizeY;y++)
120
fprintf(a,"%8d; %8d; ",m_waXValues[x]+1,m_waYValues[y]+1);
121
if (m_pCount[y*m_iSizeX+x] == 0)
122
fprintf(a," - ; - ; - \n");
123
else fprintf(a,"%10.3f; %10.3f; %10.3f\n",m_pMin[y*m_iSizeX+x],m_pMax[y*m_iSizeX+x],m_pAvg[y*m_iSizeX+x]);
1
/*****************************************************************************
2
TRAVIS - Trajectory Analyzer and Visualizer
3
http://www.travis-analyzer.de/
5
Copyright (c) 2009-2014 Martin Brehm
6
2012-2014 Martin Thomas
8
This file written by Martin Brehm.
10
This program is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*****************************************************************************/
24
#include "statistics.h"
27
CStatistics::CStatistics()
35
m_waXValues.SetName("CStatistics::m_waXValues");
36
m_waYValues.SetName("CStatistics::m_waYValues");
40
CStatistics::~CStatistics()
65
void CStatistics::Init(int x, int y)
72
try { m_pMin = new double[x*y]; } catch(...) { m_pMin = NULL; }
73
if (m_pMin == NULL) NewException((double)x*y*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
75
try { m_pMax = new double[x*y]; } catch(...) { m_pMax = NULL; }
76
if (m_pMax == NULL) NewException((double)x*y*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
78
try { m_pAvg = new double[x*y]; } catch(...) { m_pAvg = NULL; }
79
if (m_pAvg == NULL) NewException((double)x*y*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
81
try { m_pCount = new double[x*y]; } catch(...) { m_pCount = NULL; }
82
if (m_pCount == NULL) NewException((double)x*y*sizeof(double),__FILE__,__LINE__,__PRETTY_FUNCTION__);
86
m_pMin[z] = 9999999999.0;
94
void CStatistics::Evaluate()
98
for (z=0;z<m_iSizeX*m_iSizeY;z++)
100
m_pAvg[z] /= m_pCount[z];
104
void CStatistics::Write(const char *pre, const char *s, const char *post)
116
a = OpenFileWrite(buf,true);
117
for (x=0;x<m_iSizeX;x++)
118
for (y=0;y<m_iSizeY;y++)
120
fprintf(a,"%8d; %8d; ",m_waXValues[x]+1,m_waYValues[y]+1);
121
if (m_pCount[y*m_iSizeX+x] == 0)
122
fprintf(a," - ; - ; - \n");
123
else fprintf(a,"%10.3f; %10.3f; %10.3f\n",m_pMin[y*m_iSizeX+x],m_pMax[y*m_iSizeX+x],m_pAvg[y*m_iSizeX+x]);