PSCF v1.3
|
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. | |
Vec (const Vec< D, T > &v) | |
Copy constructor. | |
Vec (T const *v) | |
Constructor from a C-array. | |
Vec (T s) | |
Constructor, initialize all elements to a common scalar value. | |
Assignment and Initialization | |
Vec< D, T > & | operator= (const Vec< D, T > &v) |
Copy assignment. | |
Vec< D, T > & | operator= (T s) |
Assignment all elements to the same scalar T value. | |
Vec< D, T > & | setToZero () |
Set all elements to zero. | |
Arithmetic Assignment | |
void | operator+= (const Vec< D, T > &dv) |
Add vector dv to this vector. | |
void | operator-= (const Vec< D, T > &dv) |
Subtract vector dv from this vector. | |
void | operator+= (T s) |
Add a common scalar to all components. | |
void | operator-= (T s) |
Subtract a common scalar from all components. | |
void | operator*= (T s) |
Multiply this vector by scalar s. | |
Array Subscript | |
const T & | operator[] (int i) const |
Return one Cartesian element by value. | |
T & | operator[] (int i) |
Return one element of the vector by references. |
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. | |
Vec< D, T > & | subtract (const Vec< D, T > &v1, const Vec< D, T > &v2) |
Subtract vector v2 from v1. | |
Vec< D, T > & | multiply (const Vec< D, T > &v, T s) |
Multiply a vector v by a scalar s. | |
Vec< D, T > & | negate (const Vec< D, T > &v) |
Return negative of vector v. | |
Vec< D, T > & | negate () |
Negate all elements of this vector. | |
template<class Archive> | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize to/from an archive. |
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 |
Default constructor.
Definition at line 317 of file Vec.h.
Referenced by add(), multiply(), negate(), negate(), operator+=(), operator-=(), operator=(), operator=(), setToZero(), subtract(), and Vec().
|
inlineexplicit |
|
inlineexplicit |
Set all elements to zero.
Definition at line 381 of file Vec.h.
References Util::setToZero(), and Vec().
Referenced by Pscf::Prdc::FilmFieldGenMaskBase< D >::needsUpdate().
|
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.
References Vec().
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.
References Vec().
Referenced by Pscf::Prdc::UnitCellBase< D >::ksq().
Return negative of vector v.
Upon return, *this = -v;
v | vector input |
Definition at line 520 of file Vec.h.
References Vec().
Referenced by Pscf::Rpc::FourthOrderParameter< D >::computePrefactor(), Pscf::Rpg::FourthOrderParameter< D >::computePrefactor(), Pscf::Prdc::Basis< D >::isValid(), and Pscf::Prdc::readBasisData().
|
inline |