-
Notifications
You must be signed in to change notification settings - Fork 0
/
simplexTable.h
53 lines (40 loc) · 1.39 KB
/
simplexTable.h
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
#pragma once
#include <vector>
#include <iostream>
#include <string>
#include "fraction.h"
using namespace std;
class VarName
{
public:
bool basis;
unsigned int number;
VarName(bool basis, unsigned int number);
char getCharacter() const;
string toString() const;
string toLaTeX() const;
};
class SimplexTable
{
public:
SimplexTable(unsigned int columns, unsigned int rows);
unsigned int getColumnAmount() const;
unsigned int getRowAmount() const;
Fraction getCell(unsigned int column, unsigned int row) const;
void setCell(unsigned int column, unsigned int row, const Fraction& val);
void setRow(unsigned int row, const vector<Fraction>& rowVals);
void setColumn(unsigned int column, const vector<Fraction>& columnVals);
void print() const;
void printLaTeX() const;
friend ostream& operator<<(ostream& os, const SimplexTable& table);
void reduce();
void pivot(unsigned int column, unsigned int row);
private:
vector<vector<Fraction>> table;
vector<VarName> columnNames;
vector<VarName> rowNames;
unsigned int getColumnPrintLength(unsigned int column) const;
unsigned int getRowPrintLength() const;
unsigned int getColumnStartChar(unsigned int column) const;
void printHLine(ostream& os) const;
};