[Home] [News] [API] [Example usage] [FAQ] [Roadmap] [Download] [Contact]

Simple stats

   1: /***************************************************************************
   2:                           simpleStats.cpp  -  description
   3:                              -------------------
   4:     begin                : Sat Feb 16 2002
   5:     copyright            : (C) 2002 by Rudolph Pienaar
   6:     email                : pienaar@bme.ri.ccf.org
   7:  ***************************************************************************/
   9: 
  10: /***************************************************************************
  11:  *                                                                         *
  12:  *   This program is free software; you can redistribute it and/or modify  *
  13:  *   it under the terms of the GNU General Public License as published by  *
  14:  *   the Free Software Foundation; either version 2 of the License, or     *
  15:  *   (at your option) any later version.                                   *
  16:  *                                                                         *
  17:  ***************************************************************************/
  19: 
  20: using namespace std;
  21: #include <iostream> 
  22: 
  23: #include "../CMatrix/cmatrix.h" 
  24: 
  25: 
  26: int
  27: main(void) {
  28: 
  29:     CMatrix	M_D("8x8random.mat");
  30:     		// Create a matrix, M_D from textfile
  31:     		//	"8x8random.mat" - format of file
  32:     		//	not discussed here
  33: 
  34:     M_D.print("M_D");
  35: 
  36:     (M_D.sort(e_ascending, e_row)).print("M_D sorted: Ascending row-wise");
  37:     (M_D.sort(e_descending, e_row)).print("M_D sorted: Descending row-wise");
  38:     (M_D.sort(e_ascending, e_column)).print("M_D sorted: Ascending col-wise");
  39:     (M_D.sort(e_descending, e_column)).print("M_D sorted: Descending col-wise");
  40: 
  41:     M_D.print("M_D");
  42: 
  43:     cout << "Max element is: " << M_D.max() << endl;
  44:     cout << "Max element in row 0 is " << M_D.max(e_row, 0) << endl;
  45:     cout << "Max element in col 0 is " << M_D.max(e_column, 0) << endl;
  46:     (M_D.max(e_row)).print("Row dominant max col vector");
  47:     (M_D.max(e_column)).print("Col dominant max row vector");
  48:     cout << endl;
  49: 
  50:     cout << endl;
  51:     cout << "Min element is: " << M_D.min() << endl;
  52:     cout << "Min element in row 0 is " << M_D.min(e_row, 0) << endl;
  53:     cout << "Min element in col 0 is " << M_D.min(e_column, 0) << endl;
  54:     (M_D.min(e_row)).print("Row dominant min col vector");
  55:     (M_D.min(e_column)).print("Col dominant min row vector");
  56:     cout << endl;
  57: 
  58:     cout << endl;
  59:     cout << "mag is: " << M_D.mag() << endl;
  60:     cout << "mag of row 0 is " << M_D.mag(e_row, 0) << endl;
  61:     cout << "mag of col 0 is " << M_D.mag(e_column, 0) << endl;
  62:     (M_D.mag(e_row)).print("Row dominant mag col vector");
  63:     (M_D.mag(e_column)).print("Col dominant mag row vector");
  64:     cout << endl;
  65: 
  66:     cout << endl;
  67:     cout << "sum of matrix is: " << M_D.sum() << endl;
  68:     cout << "sum of row 0 is " << M_D.sum(e_row, 0) << endl;
  69:     cout << "sum of col 0 is " << M_D.sum(e_column, 0) << endl;
  70:     (M_D.sum(e_row)).print("Row dominant sum col vector");
  71:     (M_D.sum(e_column)).print("Col dominant sum row vector");
  72:     cout << endl;
  73: 
  74:     cout << endl;
  75:     cout << "mean of matrix is: " << M_D.mean() << endl;
  76:     cout << "mean of row 0 is " << M_D.mean(e_row, 0) << endl;
  77:     cout << "mean of col 0 is " << M_D.mean(e_column, 0) << endl;
  78:     (M_D.mean(e_row)).print("Row dominant mean col vector");
  79:     (M_D.mean(e_column)).print("Col dominant mean row vector");
  80:     cout << endl;
  81: 
  82:     cout << endl;
  83:     cout << "std of matrix is: " << M_D.std(true) << endl;
  84:     cout << "std of row 0 is " << M_D.std(e_row, 0, true) << endl;
  85:     cout << "std of col 0 is " << M_D.std(e_column, 0, true) << endl;
  86:     (M_D.std(e_row, true)).print("Row dominant std col vector");
  87:     (M_D.std(e_column, true)).print("Col dominant std row vector");
  88:     cout << endl;
  89: 
  90:     cout << endl;
  91:     (M_D.normalise(e_MAGNITUDE)).print("mag normalisation of matrix is: ");
  92:     (M_D.normalise(e_MAGNITUDE, e_row)).print("mag row normalisation is ");
  93:     (M_D.normalise(e_MAGNITUDE, e_column)).print("mag col normalisation is ");
  94:     cout << endl;
  95: 
  96:     cout << endl;
  97:     (M_D.normalise(e_MAXIMUM)).print("max normalisation of matrix is: ");
  98:     (M_D.normalise(e_MAXIMUM, e_row)).print("max row normalisation is ");
  99:     (M_D.normalise(e_MAXIMUM, e_column)).print("max col normalisation is ");
 100:     cout << endl;
 101: 
 102:     cout << endl;
 103:     (M_D.normalise(e_SUM)).print("sum normalisation of matrix is: ");
 104:     (M_D.normalise(e_SUM, e_row)).print("sum row normalisation is ");
 105:     (M_D.normalise(e_SUM, e_column)).print("sum col normalisation is ");
 106:     cout << endl;
 107: 
 108:     cout << endl;
 109:     (M_D.normalise(e_MEANSTD)).print("meanstd normalisation of matrix is: ");
 110:     (M_D.normalise(e_MEANSTD, e_row)).print("meanstd row normalisation is ");
 111:     (M_D.normalise(e_MEANSTD, e_column)).print("meanstd col normalisation is ");
 112:     cout << endl;
 113: 
 114: }
 115: 
 116: