-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix.h
More file actions
67 lines (48 loc) · 1.23 KB
/
Matrix.h
File metadata and controls
67 lines (48 loc) · 1.23 KB
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
62
63
64
65
66
67
#ifndef MATRIX_H_
#define MATRIX_H_
#include <iostream>
using namespace std;
class Matrix {
public:
Matrix(unsigned int row, unsigned int col, double fill) {
rows = row;
cols = col;
double fills = fill;
box = new double *[rows];
for (int i = 0; i < rows; i++) {
box[i] = new double[cols];
for (int j = 0; j < cols; j++) {
box[i][j] = fills;
}
}
}
//Accessors
//not const because I will be resizing them for extra credit
unsigned int num_rows() {
return rows;
}
unsigned int num_cols() {
return cols;
}
bool get(unsigned int row, unsigned int col, double container) {
if ((row >= 0 && row < rows) && (col >= 0 && col < cols)) {
container = box[row][col];
return true;
}
return false;
}
//Modifiers
bool set(unsigned int row, unsigned int col, double value) {
if ((row >= 0 && row < rows) && (col >= 0 && col < cols)) {
box[row][col] = value;
return true;
}
return false;
}
private:
unsigned int rows;
unsigned int cols;
//double fills;
double **box;
};
#endif