#include <VectorN.h>
Inheritance diagram for Physsim::VectorN:

Public Member Functions | |
| VectorN () | |
| Default constructor - constructs an empty vector. | |
| VectorN (unsigned N) | |
| Constructs an uninitialized N-dimensional vector. | |
| VectorN (const VectorN &source) | |
| Copy constructor. | |
| VectorN (unsigned N, const boost::shared_array< Real > array) | |
| Constructs a N-dimensional vector from the given array. | |
| virtual Real | dot (const VectorN &v) const |
| void | normalize () |
| unsigned | size () const |
| Real | norm () const |
| Real | len_sq () const |
| boost::shared_ptr< MatrixN > | outer_prod (const VectorN &v) const |
| void | augment (const VectorN &v) |
| Augments this vector with another. | |
| void | resize (unsigned N, bool preserve=false) |
| Resizes this vector, optionally preserving its existing elements. | |
| void | set_zero () |
| Sets all components of this vector to 0. | |
| void | set_one () |
| Sets all components of this vector to 1. | |
| VectorN | get_sub_vec (unsigned start_idx, unsigned end_idx) const |
| Gets the specified sub-vector. | |
| void | set_sub_vec (unsigned start_idx, const VectorN &v) |
| Sets the specified sub-vector. | |
| bool | is_finite () const |
| Returns true if all components of this vector are not infinite and not NaN, and false otherwise. | |
| void | operator= (const VectorN *source) |
| Copies another vector. | |
| virtual void | operator= (const VectorN &source) |
| VectorN | operator+ (const VectorN &v) const |
| Adds this vector to another. | |
| void | operator+= (const VectorN &v) |
| Adds another vector to this one in place. | |
| VectorN | operator- (const VectorN &v) const |
| Subtracts another vector from this. | |
| void | operator-= (const VectorN &v) |
| Subtracts another vector from this one in place. | |
| VectorN | operator * (Real scalar) const |
| Multiplies this vector by a scalar. | |
| void | operator *= (Real scalar) |
| Multiplies this vector in place by a scalar. | |
| VectorN | operator/ (Real scalar) const |
| Divides this vector by a scalar (same as vector * 1/scalar). | |
| void | operator/= (Real scalar) |
| VectorN | operator- () const |
| Real & | operator[] (const unsigned i) |
| Real | operator[] (const unsigned i) const |
| boost::shared_array< Real > & | data () |
|
const boost::shared_array< Real > & | data () const |
| bool | operator< (const VectorN &v) const |
| Compares two vectors lexographically. | |
| bool | operator== (const VectorN &v) const |
| Compares two vectors. | |
| bool | epsilon_equals (const VectorN &v, Real epsilon) const |
| Compares this with another vector using a tolerance epsilon. | |
Static Public Member Functions | |
| static Real | dot (const VectorN &v1, const VectorN &v2) |
| Computes the dot-product between two vectors. | |
| static VectorN | normalize (const VectorN &v) |
| Returns the normalized vector (l2 norm). | |
| static Real | norm (const VectorN &v) |
| Computes the l2-norm of a vector. | |
| static VectorN | one (unsigned N) |
| Returns a N-dimensional one vector. | |
| static boost::shared_ptr< MatrixN > | outer_prod (const VectorN &v1, const VectorN &v2) |
| Computes the outerproduct of two vectors. | |
| static VectorN | zero (unsigned n) |
| Returns a N-dimensional zero vector. | |
| static bool | epsilon_equals (const VectorN &v1, const VectorN &v2, Real epsilon) |
| Compares two vectors using a tolerance epsilon. | |
Protected Attributes | |
| boost::shared_array< Real > | _data |
| unsigned | _len |
| VectorN::VectorN | ( | unsigned | N, | |
| const boost::shared_array< Real > | array | |||
| ) |
Constructs a N-dimensional vector from the given array.
| array | a N-dimensional (or larger) array |
Computes the dot-product between two vectors.
Note: if the dimensions are unequal, an assertion will fail.
Computes the outerproduct of two vectors.
If v1 is m-dimensional and v2 is n-dimensional, the outer product is m x n dimensional.
| VectorN VectorN::get_sub_vec | ( | unsigned | start_idx, | |
| unsigned | end_idx | |||
| ) | const |
Gets the specified sub-vector.
| start_idx | the starting index (inclusive) | |
| end_idx | the ending index (inclusive) |
| void VectorN::set_sub_vec | ( | unsigned | start_idx, | |
| const VectorN & | v | |||
| ) |
Sets the specified sub-vector.
| start_idx | the starting index (inclusive) | |
| v | a (end_idx - start_idx + 1)-dimensional vector |
Subtracts another vector from this.
Operation order: this - v
| bool VectorN::operator== | ( | const VectorN & | v | ) | const |
Compares two vectors.
1.5.1