A runtime-sized linear algebra vector of doubles. More...
Public Member Functions | |
DynamicVector () | |
default constructor - no allocation | |
DynamicVector (std::size_t n) | |
construct with (n) allocated elements | |
double | operator() (std::size_t i) const |
immutable index operator | |
double & | operator() (std::size_t i) |
mutable index operator | |
DynamicVector & | operator+= (DynamicVector const &b) |
Add a vector to this vector. | |
DynamicVector & | operator-= (DynamicVector const &b) |
Subtract a vector from this vector. | |
DynamicVector & | operator*= (double s) |
Multiply this vector by a scalar. | |
DynamicVector & | operator/= (double s) |
Divide this vector by a scalar. | |
double | operator* (DynamicVector const &b) const |
Get the vector dot product. | |
double | getLength () |
Get the vector magnitude. | |
void | zero () |
Initialize all elements to zero. |
A runtime-sized linear algebra vector of doubles.
This class is the runtime-sized equivalent of apf::Vector. It keeps all values in a single dynamically allocated array. Due to the use of dynamic allocation, users should avoid copying this class as much as possible. To help with this, we provide things like operator+= instead of operator+ to discourage users from creating temporary copies. The code for these methods is still inlined in an effort to keep your linear algebra running as fast as possible.
double apf::DynamicVector::operator() | ( | std::size_t | i | ) | const [inline] |
immutable index operator
note that we do inherit the square-bracket index operator from DynamicArray, but we use parentheses here to be consistent with apf::DynamicMatrix