** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: plotfile.cpp,v 1.2 2000/12/20 14:39:09 kevin Exp $
+** $Id: plotfile.cpp,v 1.3 2000/12/20 20:08:48 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
\r
}\r
\r
+bool\r
+PlotFile::getMinMax (int iStartingCol, double& dMin, double& dMax) const\r
+{\r
+ if (iStartingCol >= m_iNumColumns) {\r
+ sys_error (ERR_WARNING, "iStartingCol >= iNumColumns");\r
+ return false;\r
+ }\r
+\r
+ int iOffset = iStartingCol * m_iNumRecords;\r
+ dMin = m_vecCurves[ 0 + iOffset ];\r
+ dMax = dMin;\r
+\r
+ for (int iCol = iStartingCol; iCol < m_iNumColumns; iCol++) {\r
+ int iOffset = iCol * m_iNumRecords;\r
+ for (int iRec = 0; iRec < m_iNumRecords; iRec++) {\r
+ double dVal = m_vecCurves[ iRec + iOffset ];\r
+ if (dVal < dMin)\r
+ dMin = dVal;\r
+ else if (dVal > dMax)\r
+ dMax = dVal;\r
+ }\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+bool \r
+PlotFile::statistics (int iStartingCol, double& min, double& max, double& mean, double& mode, double& median, double &stddev) const\r
+{\r
+ if (iStartingCol >= m_iNumColumns) {\r
+ sys_error (ERR_WARNING, "iStartingCol >= iNumColumns");\r
+ return false;\r
+ }\r
+\r
+ int iOffset = iStartingCol * m_iNumRecords;\r
+ int iNPoints = (m_iNumColumns - iStartingCol) * m_iNumRecords;\r
+ std::vector<double> vec (iNPoints);\r
+\r
+ for (int iCol = iStartingCol; iCol < m_iNumColumns; iCol++) {\r
+ int iOffset = iCol * m_iNumRecords;\r
+ for (int iRec = 0; iRec < m_iNumRecords; iRec++)\r
+ vec.push_back( m_vecCurves[ iRec + iOffset ] );\r
+ }\r
+\r
+ vectorNumericStatistics (vec, min, max, mean, mode, median, stddev);\r
+\r
+ return true;\r
+}\r
+\r
bool
PlotFile::fileWrite (const char* const filename)
{