CS488 PA1
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
Vector Class Reference

#include <Vector.h>

Public Member Functions

 Vector (int size)
 
 Vector (int size, char orientation)
 
 Vector (const Vector &original)
 
 ~Vector ()
 
double get (int i) const
 
char getOrientation () const
 
int getSize () const
 
void set (int i, double value)
 
void setValues (double value)
 

Static Public Attributes

static const char COLUMN = 'C'
 
static const char ROW = 'R'
 

Private Member Functions

void allocateMemory ()
 
void deallocateMemory ()
 
void setSize (int size, char orientation)
 

Private Attributes

char orientation
 
double * values
 
int size
 

Detailed Description

The Vector class is an encapsulation of both n-dimensional points and n-dimensional directions.

Constructor & Destructor Documentation

◆ Vector() [1/3]

Vector::Vector ( int  size)
explicit

Construct a column vector of given size.

Example of use:

Vector y(3);
Parameters
sizeThe size of the Vector

◆ Vector() [2/3]

Vector::Vector ( int  size,
char  orientation 
)

Construct a column or row vector of given size.

Example of use:

Parameters
sizeThe size of the Vector
orientationThe orientation (either COLUMN or ROW)

◆ Vector() [3/3]

Vector::Vector ( const Vector original)

A copy constructor.

Note: A copy constructor is critical because without one we can't pass a Vector by value (since when one passes by value a copy is made).

Parameters
originalThe Vector to copy

◆ ~Vector()

Vector::~Vector ( )

Destructor.

Member Function Documentation

◆ allocateMemory()

void Vector::allocateMemory ( )
private

Allocate memory for this Vector.

◆ deallocateMemory()

void Vector::deallocateMemory ( )
private

Deallocate the memory used by this Vector.

◆ get()

double Vector::get ( int  i) const

Get a particular element of this Vector.

Parameters
iThe index of the element
Returns
The value of the element at the given index

◆ getOrientation()

char Vector::getOrientation ( ) const

Get the orientation of this Vector.

Returns
The orientation (COLUMN or ROW)

◆ getSize()

int Vector::getSize ( ) const

Get the size of this Vector.

Returns
The number of elements in this Vector

◆ set()

void Vector::set ( int  i,
double  value 
)

Set a particular element of this Vector.

Parameters
iThe index of the element to assign
valueThe value to assign

◆ setSize()

void Vector::setSize ( int  size,
char  orientation 
)
private

Set the size (and orientation) of this Vector. Note: This method should only be called by constructors.

Parameters
sizeThe size (default is 1);
orientationThe orientation (default is COLUMN)

◆ setValues()

void Vector::setValues ( double  value)

Set all the elements of this Vector to a given value.

Parameters
valueThe value

Member Data Documentation

◆ COLUMN

const char Vector::COLUMN = 'C'
static

A constant that denotes a column Vector.

◆ orientation

char Vector::orientation
private

The orientation (either ROW or COLUMN) of this Vector.

◆ ROW

const char Vector::ROW = 'R'
static

A constant that denotes a row Vector.

◆ size

int Vector::size
private

The number of elements in this Vector (which are numbered from 0 to size-1).

◆ values

double* Vector::values
private

A pointer to the (0-based) array of values in this Vector.


The documentation for this class was generated from the following files: