]> git.donarmstrong.com Git - mothur.git/blob - sparsematrix.hpp
changing command name classify.shared to classifyrf.shared
[mothur.git] / sparsematrix.hpp
1 #ifndef SPARSEMATRIX_H
2 #define SPARSEMATRIX_H
3
4 #include "mothur.h"
5 #include "mothurout.h"
6
7
8 class ListVector;
9
10 /***********************************************************************/
11
12
13  struct PCell{
14         ull row;
15         ull column;
16         float dist;
17         PCell** vectorMap;
18         PCell() : row(0), column(0), dist(0), vectorMap(NULL) {};
19         PCell(ull r, ull c, float d) : row(r), column(c), dist(d), vectorMap(NULL) {};
20 };
21
22 /***********************************************************************/
23
24 typedef list<PCell>::iterator MatData;
25
26 class SparseMatrix {
27         
28 public:
29         SparseMatrix();
30         ~SparseMatrix(){  while(!mins.empty() && mins.back() == NULL){  mins.pop_back();        }  }
31         int getNNodes();
32         void print();                                   //Print the contents of the matrix
33         void print(ListVector*);                //Print the contents of the matrix
34         PCell* getSmallestCell();               //Return the cell with the smallest distance
35         float getSmallDist();
36         
37         MatData rmCell(MatData);
38         void addCell(PCell);
39         void clear();
40         MatData begin();
41         MatData end();
42
43 private:
44         PCell* smallCell;                               //The cell with the smallest distance
45         int numNodes;
46
47         list<PCell> matrix;
48         
49         vector<PCell*> mins;
50         float smallDist;
51         int minsIndex;
52         MothurOut* m;
53 };
54
55 /***********************************************************************/
56
57 #endif