CS488 PA3
Matrix.h
1
#ifndef edu_jmu_cs_Matrix_h
2
#define edu_jmu_cs_Matrix_h
3
4
#define TOLERANCE 0.0001
5
6
#include <cmath>
7
#include <initializer_list>
8
#include <math.h>
9
#include <stdexcept>
10
#include "../pa2/Vector.h"
11
using namespace
std
;
12
16
class
Matrix
{
17
protected
:
21
double
**
values
;
22
26
int
columns
;
27
31
int
rows
;
32
36
void
allocateMemory();
37
41
void
deallocateMemory();
42
50
void
setSize(
int
rows,
int
columns);
51
57
void
setValues(
double
value);
58
65
void
setValues(
const
double
* values);
66
73
void
setValues(
double
** values);
74
75
public
:
89
Matrix
(
int
rows,
int
columns);
90
100
Matrix
(
const
Matrix
& original);
101
110
explicit
Matrix
(
const
Vector& v);
111
115
~
Matrix
();
116
129
friend
double
cof(
const
Matrix
& A,
int
i,
int
j);
130
142
friend
double
det(
const
Matrix
& A);
143
152
double
get
(
int
r,
int
c)
const
;
153
159
int
getColumns()
const
;
160
166
int
getRows()
const
;
167
177
friend
Matrix
identity(
int
size);
178
189
friend
double
mminor(
const
Matrix
&A,
int
i,
int
j);
190
203
friend
Matrix
multiply(
const
Vector& a,
const
Vector& b);
204
225
double
&operator()(
int
r,
int
c);
226
246
Matrix
&operator=(std::initializer_list<double> values);
247
260
Matrix
&operator=(
const
Matrix
& other);
261
273
friend
Matrix
operator+(
const
Matrix
& A,
const
Matrix
& B);
274
286
friend
Matrix
operator-(
const
Matrix
& A,
const
Matrix
& B);
287
299
friend
Matrix
operator*(
const
Matrix
& A,
const
Matrix
& B);
300
315
friend
Vector operator*(
const
Vector& v,
const
Matrix
& M);
316
330
friend
Vector operator*(
const
Matrix
& M,
const
Vector& v);
331
342
friend
Matrix
operator*(
double
k,
const
Matrix
& A);
343
354
friend
Matrix
operator*(
const
Matrix
& A,
double
k);
355
365
friend
bool
operator==(
const
Matrix
& A,
const
Matrix
& B);
366
376
friend
bool
operator!=(
const
Matrix
& A,
const
Matrix
& B);
377
388
friend
Matrix
submatrix(
const
Matrix
& A,
int
i,
int
j);
389
399
friend
Matrix
trans(
const
Matrix
& A);
400
};
401
402
403
double
cof(
const
Matrix
& A,
int
i,
int
j);
404
double
det(
const
Matrix
& A);
405
Matrix
identity(
int
size);
406
double
mminor(
const
Matrix
&A,
int
i,
int
j);
407
Matrix
multiply(
const
Vector& a,
const
Vector& b);
408
Matrix
operator+(
const
Matrix
& A,
const
Matrix
& B);
409
Matrix
operator-(
const
Matrix
& A,
const
Matrix
& B);
410
Matrix
operator*(
const
Matrix
& A,
const
Matrix
& B);
411
Matrix
operator*(
double
k,
const
Matrix
& A);
412
Matrix
operator*(
const
Matrix
& A,
double
k);
413
Vector operator*(
const
Vector& v,
const
Matrix
& M);
414
Vector operator*(
const
Matrix
& M,
const
Vector& v);
415
bool
operator==(
const
Matrix
& A,
const
Matrix
& B);
416
bool
operator!=(
const
Matrix
& A,
const
Matrix
& B);
417
Matrix
submatrix(
const
Matrix
& A,
int
i,
int
j);
418
Matrix
trans(
const
Matrix
& A);
419
420
421
#endif
Matrix::rows
int rows
Definition:
Matrix.h:31
std
Matrix
Definition:
Matrix.h:16
Matrix::values
double ** values
Definition:
Matrix.h:21
Matrix::columns
int columns
Definition:
Matrix.h:26
Generated by
1.8.13