JDFTx  1.7.0
vector3.h File Reference

3-vector with CPU and GPU operators More...

#include <core/scalar.h>
#include <cstdio>

Classes

class  vector3< scalar >
 Generic 3-vector. More...
 

Macros

#define LOOP3(code)   { for(int k=0; k<3; k++) { code } }
 

Functions

template<typename scalar >
__hostanddev__ vector3< scalar > operator+ (scalar s, const vector3< scalar > &a)
 
__hostanddev__ vector3< int > operator+ (int s, const vector3< int > &a)
 
__hostanddev__ vector3< int > operator+ (const vector3< int > &a, int s)
 
template<typename scalar >
__hostanddev__ vector3< scalar > operator+ (const vector3< scalar > &a, int s)
 
template<typename scalar >
__hostanddev__ vector3< scalar > operator+ (int s, const vector3< scalar > &a)
 
__hostanddev__ vector3 operator+ (vector3<> a, vector3< int > b)
 
__hostanddev__ vector3 operator+ (vector3< int > a, vector3<> b)
 
template<typename scalar >
__hostanddev__ vector3< scalar > & operator*= (vector3< scalar > &a, scalar s)
 
template<typename scalar >
__hostanddev__ vector3< scalar > & operator*= (vector3< scalar > &a, double s)
 
template<typename scalar >
__hostanddev__ vector3< scalar > & operator*= (vector3< scalar > &a, int s)
 
__hostanddev__ vector3operator*= (vector3<> &a, double s)
 
__hostanddev__ vector3operator*= (vector3<> &a, int s)
 
__hostanddev__ vector3< int > & operator*= (vector3< int > &a, int s)
 
template<typename scalar >
__hostanddev__ vector3< scalar > operator* (scalar s, const vector3< scalar > &a)
 
template<typename scalar >
__hostanddev__ vector3< scalar > operator* (const vector3< scalar > &a, scalar s)
 
template<typename scalar >
__hostanddev__ vector3< scalar > operator* (double s, const vector3< scalar > &a)
 
template<typename scalar >
__hostanddev__ vector3< scalar > operator* (const vector3< scalar > &a, double s)
 
template<typename scalar >
__hostanddev__ vector3< scalar > operator* (int s, const vector3< scalar > &a)
 
template<typename scalar >
__hostanddev__ vector3< scalar > operator* (const vector3< scalar > &a, int s)
 
__hostanddev__ vector3 operator* (double s, const vector3<> &a)
 
__hostanddev__ vector3 operator* (const vector3<> &a, double s)
 
__hostanddev__ vector3 operator* (double s, const vector3< int > &a)
 
__hostanddev__ vector3 operator* (const vector3< int > &a, double s)
 
__hostanddev__ vector3< complexoperator* (complex s, const vector3<> &a)
 
__hostanddev__ vector3< complexoperator* (const vector3<> &a, complex s)
 
__hostanddev__ vector3< complexoperator* (complex s, const vector3< int > &a)
 
__hostanddev__ vector3< complexoperator* (const vector3< int > &a, complex s)
 
template<typename scalar >
__hostanddev__ scalar dot (const vector3< scalar > &a, const vector3< scalar > &b)
 
template<typename scalar >
__hostanddev__ scalar dot (const vector3< double > &a, const vector3< scalar > &b)
 
template<typename scalar >
__hostanddev__ scalar dot (const vector3< int > &a, const vector3< scalar > &b)
 
template<typename scalar >
__hostanddev__ scalar dot (const vector3< scalar > &a, const vector3< double > &b)
 
template<typename scalar >
__hostanddev__ scalar dot (const vector3< scalar > &a, const vector3< int > &b)
 
__hostanddev__ double dot (const vector3< double > &a, const vector3< double > &b)
 
__hostanddev__ double dot (const vector3< int > &a, const vector3< double > &b)
 
__hostanddev__ double dot (const vector3< double > &a, const vector3< int > &b)
 
__hostanddev__ int dot (const vector3< int > &a, const vector3< int > &b)
 
template<typename scalar >
__hostanddev__ vector3< scalar > cross (const vector3< scalar > &a, const vector3< scalar > &b)
 cross product
 
template<typename scalar >
__hostanddev__ scalar box (const vector3< scalar > &a, const vector3< scalar > &b, const vector3< scalar > &c)
 box product / triple product
 
__hostanddev__ vector3< double > normalize (const vector3<> &v)
 normalise vector
 
__hostanddev__ vector3< int > round (const vector3<> &v, double *err=0)
 Round vector3<> to vector3<int> (and optionally retrieve error)
 
__hostanddev__ double circDistanceSquared (const vector3<> &a, const vector3<> &b)
 
template<typename T >
gcd (T x, T y)
 GCD of integers, templated over integer types.
 
template<typename T >
vector3< T > gcdReduce (const vector3< T > &d)
 Reduce an integer vector by its gcd.
 
template<typename scalar >
__hostanddev__ vector3< scalar > loadVector (const vector3< const scalar * > &vArr, int i)
 Load vector from a constant vector field.
 
template<typename scalar >
__hostanddev__ vector3< scalar > loadVector (const vector3< scalar * > &vArr, int i)
 Load vector from a vector field.
 
template<typename scalar >
__hostanddev__ void storeVector (const vector3< scalar > &v, vector3< scalar * > &vArr, int i)
 Store vector to a vector field.
 
template<typename scalar >
__hostanddev__ void accumVector (const vector3< scalar > &v, vector3< scalar * > &vArr, int i)
 Accumulate vector onto a vector field.
 

Detailed Description

3-vector with CPU and GPU operators