Mvector, mathematical vectors
This class represents an n-dimensional vector
R. Brown, 1/2011
Mvector
float* arr
int len
arr
Mvector
int length
Mvector
Mvector is initialized with
an array of length length zeroes.
Mvector
Mvector is initialized with
an array of length default_len zeroes.
Mvector
const Mvector & mvec
Mvector
object to be copied
Mvector is initialized with
an array of length mvec.len with elements copied from mvec.arr[].
~Mvector
Mvector is deallocated.
Mvector & operator=
const Mvec & mvec
Mvector object
to be copied
Mvector is replaced by a
copy of mvec.
Mvector, after replacement.
int len
len.
float & operator[]
int index
index < len
index is
out of range.
vec[] with index index.
Mvector operator*
float val
Mvector mv is allocated with length
len, and each element of mv is assigned the
product of val with the element of this
Mvector having the same index.
mv.
Mvector operator*
const Mvector & vec
Mvector value,
where vec.len == len of this
Mvector instance.
mvec differs from
len, then the program crashes. Otherwise, a new
Mvector object mv is allocated with length
len, and each element of mv is assigned the
product of the elements of arr[] and
vec.arr[] having the same index.
mv.
Mvector operator+
const Mvector & vec
Mvector value,
where vec.len == len of this
Mvector instance.
mvec differs from
len, then the program crashes. Otherwise, a new
Mvector object mv is allocated with length
len, and each element of mv is assigned the
sum of the elements of arr[] and
vec.arr[] having the same index.
mv.