-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContingencyTbl.C
61 lines (44 loc) · 1.2 KB
/
ContingencyTbl.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/***********************************************************************
ContingencyTbl.C
BOOM : Bioinformatics Object Oriented Modules
Copyright (C)2012 William H. Majoros ([email protected]).
This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
License (GPL) version 3, as described at www.opensource.org.
***********************************************************************/
#include <iostream>
#include "ContingencyTbl.H"
using namespace std;
BOOM::ContingencyTbl::ContingencyTbl(int width,int height)
: BOOM::Array2D<int>(width,height),
rowTotals(height), columnTotals(width)
{
// ctor
}
int BOOM::ContingencyTbl::getColumnTotal(int column)
{
return columnTotals[column];
}
int BOOM::ContingencyTbl::getGrandTotal()
{
return grandTotal;
}
int BOOM::ContingencyTbl::getRowTotal(int row)
{
return rowTotals[row];
}
void BOOM::ContingencyTbl::computeTotals()
{
const int width=getFirstDim();
const int height=getSecondDim();
columnTotals.setAllTo(0);
rowTotals.setAllTo(0);
grandTotal=0;
for(int x=0 ; x<width ; ++x)
for(int y=0 ; y<height ; ++y)
{
int entry=(*this)[x][y];
grandTotal+=entry;
columnTotals[x]+=entry;
rowTotals[y]+=entry;
}
}