CS488 PA4
Public Member Functions | Friends | List of all members
Vector Class Reference

#include <Vector.h>

Inherits Matrix.

Public Member Functions

 Vector ()
 
 Vector (int size)
 
 Vector (const Vector &original)
 
Vectoroperator= (std::initializer_list< double > m)
 
Vectoroperator= (const Matrix &other)
 
- Public Member Functions inherited from Matrix
 Matrix ()
 
 Matrix (int rows, int columns)
 
 Matrix (const Matrix &original)
 
 ~Matrix ()
 
double get (int r, int c) const
 
double get (int i) const
 
Matrix getColumn (int c) const
 
int getColumns () const
 
int getRows () const
 
double & operator() (int r, int c)
 
double & operator() (int i)
 
Matrixoperator= (std::initializer_list< double > values)
 
Matrixoperator= (const Matrix &other)
 

Friends

double norm (const Matrix &a)
 
Matrix normalized (const Matrix &a)
 

Additional Inherited Members

- Protected Member Functions inherited from Matrix
void allocateMemory (int rows, int columns)
 
void deallocateMemory ()
 
void setValues (double value)
 
void setValues (const Matrix &other)
 
void setValues (const double *values)
 
void setValues (double **values)
 
- Protected Attributes inherited from Matrix
double ** values
 
int columns
 
int rows
 

Detailed Description

An encapsulation of a column Vector (that is a specialization of a Matrix for convenience).

Constructor & Destructor Documentation

◆ Vector() [1/3]

Vector::Vector ( )

Construct a 2x1 Vector.

◆ Vector() [2/3]

Vector::Vector ( int  size)
explicit

Construct a size x 1 Vector.

Parameters
sizeThe number of rows

◆ Vector() [3/3]

Vector::Vector ( const Vector original)

Copy constructor.

Parameters
originalThe Vector to copy

Member Function Documentation

◆ operator=() [1/2]

Vector & Vector::operator= ( std::initializer_list< double >  m)

Assign an initializer_list to this Vector.

Parameters
mThe initializer_list containing the values
Exceptions
length_errorif the list is the wrong size
Returns
The Vector referred to by this

◆ operator=() [2/2]

Vector & Vector::operator= ( const Matrix other)

Assign an (appropriately sized) Matrix to this Vector.

Note: This method is not void so that one can write x = y = z (which first assigns z to y and then assigns the result of that assignment to x). It returns the result by reference because there is no concern that this will not refer to something.

Parameters
otherThe Matrix to copy
Exceptions
length_errorif the sizes don't conform
Returns
The Vector referred to by this

Friends And Related Function Documentation

◆ norm

double norm ( const Matrix a)
friend

Calculate the Euclidean norm of a Vector (really a 1-dimensional Matrix).

Parameters
aThe Vector
Returns
\( || \mathbf{a} || \)

◆ normalized

Matrix normalized ( const Matrix a)
friend

Calculate the normalized version of a Vector (really a 1-dimensional Matrix).

Parameters
aThe Vector
Returns
\( \mathbf{a} / ||\mathbf{a}|| \)

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