JDFTx  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
scalar.h File Reference

Complex numbers with CPU and GPU operators. More...

#include <cmath>
#include <cstdlib>
#include <vector>


struct  array< T, N >
struct  complex
 Complex number (need to define our own because we need operators for gpu code as well) More...


#define __hostanddev__   inline


template<class T >
ceildiv (T num, T den)
 Ceiling of a positive integer division, templated over int types.
template<class T >
floorMultiple (T num, T den)
 Return largest multiple of den smaller than num, templated over int types.
__hostanddev__ double real (const complex &c)
 real part
__hostanddev__ double imag (const complex &c)
 imaginary part
__hostanddev__ double norm (const complex &c)
 absolute value squared
__hostanddev__ double abs (const complex &c)
 absolute value
__hostanddev__ double arg (const complex &c)
 argument (phase angle)
__hostanddev__ complex conj (const complex &c)
 complex conjugate
__hostanddev__ double conj (const double &c)
 identity operation provided to ease templating over complex and double
__hostanddev__ complex operator+ (double r, const complex &c)
__hostanddev__ complex operator- (double r, const complex &c)
__hostanddev__ complex operator* (double r, const complex &c)
__hostanddev__ complex cis (double x)
 Compute cis(x) = exp(iota x) = cos(x) + iota sin(x)

Detailed Description

Complex numbers with CPU and GPU operators.