Class Vector

Class Documentation

class Vector

Class representing a mathematical vector.

Public Functions

explicit Vector(int n)

Constructs a new vector of the given size.

Vector(std::initializer_list<double> vectorData)

Constructs a new vector with the given data.

explicit Vector(std::vector<double> vectorData)

Constructs a new vector with the given data

Vector(const Vector &other)

Constructs a new vector that is a copy of the given vector

double &operator[](int i)

Operator to get a reference to the element at the specified index

Throws

std::invalid_argument – if the index does not exist

const double &operator[](int i) const

Operator to get a const reference to the element at the specified index

Throws

std::invalid_argument – if the index does not exist

int size() const

Returns the size of the vector

double norm()

Calculates the norm/magnitude of the vector

Vector normalize()

Calculates a new vector with the same direction as this vector, but a magnitude of 1

std::string toString()

Returns a string representation of the vector