Vector
Array<double>
Array<double>)
n.
Array<double>)
Vector(number_of_elements)
e.g. Vector x(3); or y = Vector(n);.
Vector(existing_vector_to_copy)
e.g. Vector y; cin >> y; Vector x(y);
This should be faster than initialising a new vector and then copying another.
Create(number_of_elements)
e.g. Vector x; x.Create(7);
Array class inherits from Classio
and provides Read and Write operations
which allow the << and >>
operators to be used, in which case the number of elements is read from and
written to the I/O stream.
Array also provides
Read_elements and Write_elements methods
to read and write the element list only, without the number of elements.)
e.g.
Vector x; cin >> x; cout << x << endl; x.Write_elements(cout);
=
e.g. Vector x,y; cin >> x; y = x;
Vector subvector(
const int i0, // first index of subvector
const int i1 // last index of subvector
) const
e.g. Vector y = x.subvector(0,4);
friend double inner_product(const Vector& a, const Vector& b)
friend double dot(const Vector& a, const Vector& b)
friend double operator*(const Vector& a, const Vector& b)
e.g.
Vector x,y; cin >> x >> y; double a = inner_product(x,y), b = dot(x,y), c = x * y; // a = b = c
friend double norm(const Vector& a)
e.g.
vector a; cin >> a; double anorm = norm(a);
friend double length(const Vector& a)
e.g.
Vector a; cin >> a; double alen = length(a);
friend void normalise(Vector& a)
e.g.
vector a; cin >> a; normalise(a); cout << a;
friend Vector operator+(const Vector& a, const Vector& b)
friend Vector operator-(const Vector& a, const Vector& b)
friend Vector operator-(const Vector& a)
friend Vector operator*(const Vector& a, const int s)
friend Vector operator*(const int s, const Vector& a)
friend Vector operator*(const Vector& a, const double s)
friend Vector operator*(const double s, const Vector& a)
friend Vector operator/(const Vector& a, const int s)
friend Vector operator/(const Vector& a, const double s)
Vector_fixed_dimension
vector
Vector_fixed_dimension is exactly the same as a
vector, except that the Read and Write
methods are redefined to omit the number of elements.
(This means that the number of elements must be set before
a Vector_fixed_dimension is read.)
This class is the base for vectors of a specific dimension.
Vector4d
Vector_fixed_dimension
Vector3d
Vector_fixed_dimension
friend Vector3d cross_product(const Vector3d& a, const Vector3d& b)
friend Vector3d operator^(const Vector3d& a, const Vector3d& b)
friend double vector_triple_product(const Vector3d& a, const Vector3d& b,
const Vector3d& c)
friend Vector3d rotate(
const Vector3d& a, // initial vector
const Vector3d& axis, // axis vector (rotation is right-hand screw)
const double phi // rotation angle in radians
)
friend Vector3d rotate_about(
const Vector3d& a, // initial vector
const Vector3d& axis, // axis vector (rotation is right-hand screw)
const Vector3d& p, // point through which axis passes
const double phi // rotation angle in radians
)
Vector2d
Vector_fixed_dimension
friend double operator^(const Vector2d& a, const Vector2d& b)
friend Vector2d rotate(
const Vector2d& a, // initial vector
const double phi // rotation angle in radians (anticlockwise)
)
friend Vector2d rotate_about(
const Vector2d& a, // initial vector
const Vector2d& p, // point through which axis passes
const double phi // rotation angle in radians (anticlockwise)
)
Real_vector
Arithmetic_matrix<double>