Definition
An instance of data type vector is a vector of variables of type double.
#include < LEDA/numbers/vector.h >
Creation
vector | v | creates an instance v of type vector; v is initialized to the zero-dimensional vector. |
vector | v(int d) | creates an instance v of type vector; v is initialized to the zero vector of dimension d. |
vector | v(double a, double b) | creates an instance v of type vector; v is initialized to the two-dimensional vector (a, b). |
vector | v(double a, double b, double c) | |
creates an instance v of type vector; v is initialized to the three-dimensional vector (a, b, c). | ||
vector | v(const vector& w, int prec) | |
creates an instance v of type vector; v is initialized to a copy of w. The second argument is for compatibility with rat_vector. |
Operations
Additional Operations for vectors in two and three-dimensional space
Implementation
Vectors are implemented by arrays of real numbers. All operations on a vector v take time O(v.dim()), except for dim and [ ] which take constant time. The space requirement is O(v.dim()).
Be aware that the operations on vectors and matrices incur rounding errors and hence are not completely reliable. For example, if M is a matrix, b is a vector, and x is computed by x = M.solve(b) it is not necessarily true that the test b == M * x evaluates to true. The types integer_vector and integer_matrix provide exact linear algebra.