PSCF v1.1
|
A Vec<D, T><D,T> is a D-component vector with elements of type T. More...
#include <Vec.h>
Public Member Functions | |
Constructors | |
Vec () | |
Default constructor. More... | |
Vec (const Vec< D, T > &v) | |
Copy constructor. More... | |
Vec (T const *v) | |
Constructor from a C-array. More... | |
Vec (T s) | |
Constructor, initialize all elements to a common scalar value. More... | |
Assignment and Initialization | |
Vec< D, T > & | operator= (const Vec< D, T > &v) |
Copy assignment. More... | |
Vec< D, T > & | operator= (T s) |
Assignment all elements to the same scalar T value. More... | |
Vec< D, T > & | setToZero () |
Set all elements to zero. More... | |
Arithmetic Assignment | |
void | operator+= (const Vec< D, T > &dv) |
Add vector dv to this vector. More... | |
void | operator-= (const Vec< D, T > &dv) |
Subtract vector dv from this vector. More... | |
void | operator+= (T s) |
Add a common scalar to all components. More... | |
void | operator-= (T s) |
Subtract a common scalar from all components. More... | |
void | operator*= (T s) |
Multiply this vector by scalar s. More... | |
Array Subscript | |
const T & | operator[] (int i) const |
Return one Cartesian element by value. More... | |
T & | operator[] (int i) |
Return one element of the vector by references. More... | |
Vec<D, T> valued functions (assigned to invoking object) | |
Vec< D, T > & | add (const Vec< D, T > &v1, const Vec< D, T > &v2) |
Add vectors v1 and v2. More... | |
Vec< D, T > & | subtract (const Vec< D, T > &v1, const Vec< D, T > &v2) |
Subtract vector v2 from v1. More... | |
Vec< D, T > & | multiply (const Vec< D, T > &v, T s) |
Multiply a vector v by a scalar s. More... | |
Vec< D, T > & | negate (const Vec< D, T > &v) |
Return negative of vector v. More... | |
Vec< D, T > & | negate () |
Negate all elements of this vector. More... | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize to/from an archive. More... | |
A Vec<D, T><D,T> is a D-component vector with elements of type T.
The elements of a Vec<D, T> can be accessed using subscript operator, as for a built in array.
The arithmetic assignment operators +=, -=, and *= are overloaded to allow vector-vector addition and subtraction and vector-scalar multiplication.
All other unary and binary mathematical operations are implemented as methods or free functions. Operations that yield a Vec<D, T>, such as addition, are implemented by methods that assign the result to the invoking Vec object, and return this object by reference. For example,
This syntax for functions that yield a vector makes the allocation of a temporary Vec<D, T> object explicit, by requiring that the invoking function be a member of an object that will hold the result.
For efficiency, all member functions are declared inline.
|
inline |
|
inlineexplicit |
|
inlineexplicit |
Set all elements to zero.
Definition at line 381 of file Vec.h.
References Util::setToZero().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Add vectors v1 and v2.
Upon return, *this = v1 + v2.
v1 | vector (input) |
v2 | vector (input) |
Definition at line 473 of file Vec.h.
Referenced by Pscf::operator+().
|
inline |
Multiply a vector v by a scalar s.
Upon return, *this = v*s.
v | vector input |
s | scalar input |
Definition at line 505 of file Vec.h.
Referenced by Pscf::UnitCellBase< D >::ksq().
|
inline |
Return negative of vector v.
Upon return, *this = -v;
v | vector input |
Definition at line 520 of file Vec.h.
Referenced by Pscf::Basis< D >::isValid(), Pscf::Pspc::FieldIo< D >::readFieldsBasis(), and Pscf::Pspg::FieldIo< D >::readFieldsBasis().
|
inline |