ECOCPAK v0.9
ClassData.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2011 the authors listed below
00002 // http://ecocpak.sourceforge.net
00003 // 
00004 // Authors:
00005 // - Dimitrios Bouzas (bouzas at ieee dot org)
00006 // - Nikolaos Arvanitopoulos (niarvani at ieee dot org)
00007 // - Anastasios Tefas (tefas at aiia dot csd dot auth dot gr)
00008 // 
00009 // This file is part of the ECOC PAK C++ library. It is 
00010 // provided without any warranty of fitness for any purpose.
00011 //
00012 // You can redistribute this file and/or modify it under 
00013 // the terms of the GNU Lesser General Public License (LGPL) 
00014 // as published by the Free Software Foundation, either 
00015 // version 3 of the License or (at your option) any later 
00016 // version.
00017 // (see http://www.opensource.org/licenses for more info)
00018 
00019 
00022 
00023 
00024 
00025 #ifndef _CLASSDATA_H_
00026 #define _CLASSDATA_H_
00027 
00028 
00029 
00030 #include <armadillo>
00031 using namespace arma;
00032 
00033 
00034 
00050 class ClassData 
00051   {
00052   public:
00053 
00054   // --- Ctors & Dtor --- //
00055   
00056   // Copy constructor -- overloaded
00057   ClassData(const ClassData&);
00058 
00059   // User defined constructor -- overloaded
00060   ClassData(const mat&, const u32);
00061   
00062   // User defined constructor -- overloaded
00063   ClassData(const mat&, const u32, bool, int);
00064 
00065   // Destructor
00066   ~ClassData();
00067 
00068   // Static variable globalIndex holds the number of ClassData objects
00069   // created so far
00070   static unsigned int globalIndex;
00071 
00072   // --- Accessors  --- //
00073 
00074   // returns class samples matrix
00075   mat Data() const;
00076 
00077   // returns class label
00078   u32 ClassLabel() const;
00079 
00080   // returns class index
00081   u32 ClassIndex() const;
00082 
00083   // returns number of class samples
00084   u32 Samples() const;
00085 
00086   // returns attributes variable
00087   u32 Attributes() const;
00088 
00089   // --- Mutators --- //
00090 
00091   // sets data member variable
00092   ClassData& setData(const mat&);
00093 
00094   // sets classLabel member variable
00095   ClassData& setClassLabel(const u32);
00096 
00097   // sets classIndex member variable
00098   ClassData& setClassIndex(const u32);
00099 
00100   private:
00101   
00105   mat data;
00106 
00108   u32 classLabel;
00109 
00111   u32 samples;
00112 
00115   u32 attributes;
00116 
00121   u32 classIndex;
00122   };
00123 
00124 
00125 
00131 u32 ClassData::globalIndex = 0;
00132 
00133 
00134 
00145 ClassData::ClassData
00146   (
00147   const mat& d, 
00148   const u32 l, 
00149   const bool sub, 
00150   const int ts
00151   )
00152   {
00153   // assign new information to the class attributes
00154   data = d;
00155   samples = d.n_rows;
00156   attributes = d.n_cols;
00157   classLabel = l;
00158 
00159   // if the global index is to be increased
00160   if(sub && samples >= ts) 
00161     {
00162     globalIndex++;
00163     classIndex = globalIndex;
00164     } 
00165   else 
00166     {
00167     classIndex = -2;
00168     }
00169 
00170   }
00171 
00172 
00173 
00180 ClassData::ClassData
00181   (
00182   const mat& d, 
00183   const u32 l 
00184   )
00185   {
00186   // assign new information to class attributes
00187   data = d;
00188   samples = d.n_rows;
00189   attributes = d.n_cols;
00190   classLabel = l;
00191   
00192   // increase global index and update class index
00193   globalIndex++;
00194   classIndex = globalIndex;
00195   }
00196 
00197 
00198 
00204 ClassData::ClassData
00205   (
00206   const ClassData& c
00207   )
00208   {
00209   // assign new information of classData c to the attribute of this class
00210   data = c.Data();
00211   samples = c.Samples();
00212   attributes = c.Attributes();
00213   classLabel = c.ClassLabel();
00214   classIndex = c.ClassIndex();
00215   }
00216 
00217 
00218 
00221 ClassData::~ClassData()
00222   {
00223   
00224   }
00225 
00226 
00227 
00237 inline 
00238 mat 
00239 ClassData::Data() const
00240   {
00241   return data;
00242   }
00243 
00244 
00245 
00254 inline 
00255 u32 
00256 ClassData::ClassLabel() const
00257   {
00258   return classLabel;
00259   }
00260 
00261 
00262 
00271 inline
00272 u32 
00273 ClassData::ClassIndex() const
00274   {
00275   return classIndex;
00276   }
00277 
00278 
00279 
00288 inline 
00289 u32 
00290 ClassData::Samples() const
00291   {
00292   return samples;
00293   }
00294 
00295 
00296 
00305 inline 
00306 u32 
00307 ClassData::Attributes() const
00308   {
00309   return attributes;
00310   }
00311 
00312 
00313 
00322 inline 
00323 ClassData& 
00324 ClassData::setData
00325   (
00326   const mat& d
00327   )
00328   {
00329   data = d;
00330   return *this;
00331   }
00332 
00333 
00334 
00343 inline 
00344 ClassData&
00345 ClassData::setClassLabel
00346   (
00347   const u32 l
00348   )
00349   {
00350   classLabel = l;
00351   return *this;
00352   }
00353 
00354 
00355 
00364 inline 
00365 ClassData& 
00366 ClassData::setClassIndex
00367   (
00368   const u32 i
00369   )
00370   {
00371   classIndex = i;
00372   return *this;
00373   }
00374 
00375 
00376 
00377 #endif
00378 
00379 
00380 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerator Defines