ivutils
|
N-dimensional vector of the type T and some useful operations. More...
#include <vector_3c.h>
Public Types | |
typedef vec_prod_traits< T, N >::type | vec_product_t |
vector product type | |
Public Member Functions | |
Vector_Nt (const T &a=0) | |
makes all components equal to a | |
template<class A > | |
Vector_Nt (const A *beg) | |
construct from array | |
template<class A > | |
Vector_Nt (const Vector_Nt< A, N > &vect) | |
construct from another vector | |
template<class A , int N1> | |
Vector_Nt (const Vector_Nt< A, N1 > &vect) | |
construct from another vector with different N | |
template<typename... Ts> | |
Vector_Nt (const T &first, Ts... args) | |
Constructor from any number of arguments. | |
template<class inp_iterator > | |
void | copy_to (inp_iterator beg) const |
Copies vector to iterator. | |
bool | operator== (const Vector_Nt &vect) const |
Comparison. | |
bool | operator< (const Vector_Nt &vect) const |
Comparison in the order of components. | |
T | operator* (const Vector_Nt &vect) const |
Scalar product. | |
Vector_Nt | operator* (const T &coeff) const |
Multiplies by coefficient. | |
template<class Vec > | |
Vector_Nt | scale (const Vec &s) const |
Multiplies by vector component-by-component. | |
template<class Vec > | |
Vector_Nt | descale (const Vec &s) const |
Divides by vector component-by-component. | |
Vector_Nt | operator/ (const T &coeff) const |
Divides by coefficient. | |
Vector_Nt | operator- () const |
Vector product (N=3 only) | |
T | norm2 () const |
Norm squared. | |
T | norm () const |
Norm. | |
T | normalize (const T &newnorm=1.) |
Returns norm and normalizes vector on newnorm. | |
Vector_Nt | unit (const T &l=1) const |
T | inormalize (T newnorm=1., T infty=std::numeric_limits< T >::max()) |
Normalizes a vector that may have infinite components. | |
Vector_Nt | prj (int i) const |
return a vector projection on a given axis | |
Vector_Nt | prj (const Vector_Nt &k) const |
return a vector projection on a given vector (k*v)*k | |
Vector_Nt | rcell1 (const Vector_Nt &cell, int flags=0xffff) const |
nearest image distance within rectangular cell (FOR DISTANCE MEASUREMENTS) assumes that each coordinate absolute value is in the range [0,cell[i]) returned vector is in the range [-cell[i]/2,cell[i]/2) flags indicate the periodicity in specific directions: 0x1 for X, 0x2 for Y, 0x4 for Z | |
Vector_Nt | rcell (const Vector_Nt &cell, int flags=0xffff) const |
reduction to elementary cell [0, cell[i]) (FOR REDUCTION TO ELEMENTARY CELL) flags indicate the periodicity in specific directions: 0x1 for X, 0x2 for Y, 0x4 for Z | |
Vector_Nt | rpcell (const Vector_Nt &p1, const Vector_Nt &cell, int flags=0xfff) const |
the same as rcell, but start point of zero cell is p1 | |
T | maxcoord (int *ind=nullptr) const |
returns maximal vector component and its index | |
T | mincoord (int *ind=nullptr) const |
returns minimal vector component and its index | |
T | maxabscoord (int *ind=nullptr) const |
returns the coord having maximal absolute value | |
T | minabscoord (int *ind=nullptr) const |
returns the coord having minimal absolute value | |
bool | infinite (T infty=std::numeric_limits< T >::max()) const |
returns true if the vector has infinite components | |
void | snap_to_zero (const T &level=VEC_ZERO) |
makes small components (those having absolute value less than level) exactly zero | |
T & | operator[] (int i) |
obtains element value | |
Vector_Nt (const T &a=0) | |
makes all components equal to a | |
template<class A > | |
Vector_Nt (const A *beg) | |
construct from input iterator (or array) | |
template<class T2 , size_t M, class storage2_t > | |
Vector_Nt (const Vector_Nt< T2, M, storage2_t > &vect) | |
Construct from another vector, if dimension is not preset, inherits vect dimension. | |
template<class T2 , size_t M, class storage2_t > | |
Vector_Nt & | operator= (const Vector_Nt< T2, M, storage2_t > &vect) |
Copy from another vector. | |
template<class A > | |
void | copy_to (A *beg) const |
Copies vector to iterator. | |
T & | operator[] (int i) const |
obtains element value | |
template<size_t M, class storage2_t > | |
bool | operator== (const Vector_Nt< T, M, storage2_t > &vect) const |
comparison. | |
template<size_t M, class storage2_t > | |
T | operator* (const Vector_Nt< T, M, storage2_t > &vect) const |
Scalar product. | |
Vector_Nt | operator* (const T &coeff) const |
Multiplies on coefficient. | |
template<class Vec > | |
Vector_Nt | scale (const Vec &s) const |
Multiplies on vector by components. | |
Vector_Nt | operator/ (const T &coeff) const |
Divides on coefficient. | |
template<size_t M, class storage2_t > | |
Vector_Nt | operator% (const Vector_Nt< T, M, storage2_t > &vect) const |
Vector product (dim()=3 only) | |
Vector_Nt | operator- () const |
Multiplies on -1. | |
T | norm2 () const |
Norm squared. | |
T | norm () const |
Norm. | |
T | normalize (T newnorm=1.) |
Returns norm and normalizes vector on newnorm. | |
T | inormalize (T newnorm=1., T infty=VEC_INFTY) |
Normalizes a vector that may have infinite components. | |
Vector_Nt | prj (size_t i) const |
return a vector projection on a given axis | |
Vector_Nt | prj (const Vector_Nt &k) const |
return a vector projection on a given vector (k*v)*k | |
Vector_Nt | unit (T l=1) const |
return a vector of length l parallel to this | |
template<size_t M, class storage2_t > | |
Vector_Nt | rcell1 (const Vector_Nt< T, M, storage2_t > &cell, int flags=0xffff) const |
nearest image distance within rectangular cell (FOR DISTANCE MEASUREMENTS) assumes that each coordinate absolute value is in the range [0,cell[i]) returned vector is in the range [-cell[i]/2,cell[i]/2) flags indicate the periodicity in specific directions: 0x1 for X, 0x2 for Y, 0x4 for Z Note that cell dimension is not checked. | |
template<size_t M, class storage2_t > | |
Vector_Nt | rcell (const Vector_Nt< T, M, storage2_t > &cell, int flags=0xffff) const |
reduction to elementary cell [0, cell[i]) (FOR REDUCTION TO ELEMENTARY CELL) flags indicate the periodicity in specific directions: 0x1 for X, 0x2 for Y, 0x4 for Z Note that cell dimension is not checked. | |
template<size_t M, class storage2_t , size_t P, class storage3_t > | |
Vector_Nt | rpcell (const Vector_Nt< T, M, storage2_t > &p1, const Vector_Nt< T, P, storage3_t > &cell, int flags=0xfff) const |
the same as rcell, but start point of zero cell is p1 Note that p1, cell dimensions are not checked. | |
T | maxcoord (int *ind=nullptr) const |
returns maximal vector component and its index | |
T | mincoord (int *ind=nullptr) const |
returns minimal vector component and its index | |
T | maxabscoord (int *ind=nullptr) const |
returns the coord having maximal absolute value | |
T | minabscoord (int *ind=nullptr) const |
returns the coord having minimal absolute value | |
bool | infinite (T infty=VEC_INFTY) const |
returns true if the vector has infinite components | |
N-dimensional vector of the type T and some useful operations.
General N-dimensional vector of type T and some useful operations.
Storage class for a vector should follow storage_prototype. Note that for binary operators on vectors with variable dimension storages the result dimension is inherited from the argument with the minimal dimension.
|
inline |
Constructor from any number of arguments.
The aruments are converted to T and assigned to the corresponding dimension. If there are less than N arguments, the value of the last one will be used to assign to the missing dimensions.
|
inline |
Vector product (N=3 only)
Multiplies on -1
|
inline |
Comparison in the order of components.
If the difference is less than VEC_ZERO_EPS then components are assumed to be equal
|
inline |
Copy from another vector.
If dimensions are different, copies min(dim1,dim2) number of elements only.
|
inline |
Comparison.
If the difference is less than VEC_ZERO_EPS then components are assumed to be equal
|
inline |
comparison.
If the difference is less than MULT_EPSILON * std::numeric_limits<T>::epsilon() then components are assumed to be equal
|
inline |