CS488 PA2
Vector.h
1
#ifndef edu_jmu_cs_Vector_h
2
#define edu_jmu_cs_Vector_h
3
4
#define TOLERANCE 0.0001
5
6
#include <cmath>
7
#include <initializer_list>
8
#include <math.h>
9
#include <stdexcept>
10
11
using namespace
std
;
12
13
18
class
Vector
{
19
protected
:
23
char
orientation
;
24
28
double
*
values
;
29
33
int
size
;
34
38
void
allocateMemory();
39
43
void
deallocateMemory();
44
52
void
setSize(
int
size,
char
orientation);
53
59
void
setValues(
double
value);
60
67
void
setValues(
const
double
* values);
68
69
70
public
:
81
explicit
Vector
(
int
size);
82
94
Vector
(
int
size,
char
orientation);
95
104
Vector
(
const
Vector
& original);
105
109
~
Vector
();
110
118
double
get
(
int
i)
const
;
119
125
char
getOrientation()
const
;
126
132
int
getSize()
const
;
133
140
friend
double
norm(
const
Vector
& a);
141
148
friend
Vector
normalized(
const
Vector
& a);
149
169
double
& operator()(
int
i);
170
192
Vector
& operator=(std::initializer_list<double> values);
193
208
Vector
& operator=(
const
Vector
& other);
209
221
friend
Vector
operator+(
const
Vector
& a,
const
Vector
& b);
222
236
friend
Vector
operator-(
const
Vector
& a,
const
Vector
& b);
237
248
friend
double
operator*(
const
Vector
& a,
const
Vector
& b);
249
260
friend
Vector
operator*(
double
k,
const
Vector
& a);
261
272
friend
Vector
operator*(
const
Vector
& a,
double
k);
273
285
friend
bool
operator==(
const
Vector
& a,
const
Vector
& b);
286
297
friend
bool
operator!=(
const
Vector
& a,
const
Vector
& b);
298
308
friend
Vector
trans(
const
Vector
& a);
309
310
314
const
static
char
COLUMN =
'C'
;
315
319
const
static
char
ROW =
'R'
;
320
};
321
322
323
double
norm(
const
Vector
& a);
324
Vector
normalized(
const
Vector
& a);
325
Vector
operator+(
const
Vector
& a,
const
Vector
& b);
326
Vector
operator-(
const
Vector
& a,
const
Vector
& b);
327
double
operator*(
const
Vector
& a,
const
Vector
& b);
328
Vector
operator*(
double
k,
const
Vector
& a);
329
Vector
operator*(
const
Vector
& a,
double
k);
330
bool
operator==(
const
Vector
& a,
const
Vector
& b);
331
bool
operator!=(
const
Vector
& a,
const
Vector
& b);
332
Vector
trans(
const
Vector
& a);
333
334
335
#endif
Vector
Definition:
Vector.h:18
std
Vector::size
int size
Definition:
Vector.h:33
Vector::values
double * values
Definition:
Vector.h:28
Vector::orientation
char orientation
Definition:
Vector.h:23
Generated by
1.8.13