H2Lib  3.0
Macros | Typedefs | Functions | Variables
basic.h File Reference
#include <stdlib.h>
#include <assert.h>
#include <stdarg.h>
#include <cairo/cairo.h>
#include "settings.h"

Go to the source code of this file.

Macros

#define M_PI   3.141592653589793238462643383
 Mathematical constant $\pi$.
 
#define NORM_STEPS   20
 Number of power iteration steps used to approximate the spectral norm.
 
#define NC_DEFLATE_LEVEL   9
 Deflation level for NetCDF compression. More...
 
#define H2_MACH_EPS   1e-13
 "Machine accuracy" for some algorithms
 
#define h2_malloc(sz)   malloc(sz)
 Wrapper for either aligned or not align memory allocation function. More...
 
#define h2_free(p)   free(p)
 Wrapper for either aligned or not align memory free function. More...
 
#define ROUNDUP(x, N)   ((((x) + (N) - 1) / (N)) * (N))
 Round up some value x to the nearest multiple of N. More...
 
#define REAL(x)   creal(x)
 Get the real part $a$ of a field element $x=a+ib$.
 
#define IMAG(x)   cimag(x)
 Get the imaginary part $b$ of a field element $x=a+ib$.
 
#define CONJ(x)   conj(x)
 Compute the complex conjugate $\bar x$ of a field element $x$.
 
#define ABSSQR(x)   _h2_abssqr(x)
 Compute the square of the absolute value $|x|^2$ of a field element $x$.
 
#define ABS(x)   REAL_SQRT(ABSSQR(x))
 Compute the absolute value $|x|$ of a field element $x$.
 
#define SIGN1(x)   _h2_sgn1(x)
 Compute the sign $\mathop{\rm sgn}(x)$ of a field element $x$ with the convention $\mathop{\rm sgn}(0)=1$.
 
#define FIELD_RAND()   _h2_fieldrand()
 Compute a (pseudo-)random field element.
 
#define REAL_ABS(x)   fabs(x)
 Compute the absolute value $|x|$ of a real number $x$.
 
#define REAL_SQR(x)   _h2_real_sqr(x)
 Compute the square $x^2$ of a real number $x$.
 
#define REAL_SIN(x)   sin(x)
 Compute the sine $\sin(x)$ of a real number $x$.
 
#define REAL_COS(x)   cos(x)
 Compute the cosine $\cos(x)$ of a real number $x$.
 
#define REAL_ASIN(x)   asin(x)
 Compute the arcsine $\asin(x)$ of a real number $x$.
 
#define REAL_ACOS(x)   acos(x)
 Compute the arccosine $\acos(x)$ of a real number $x$.
 
#define REAL_TAN(x)   tan(x)
 Compute the tangent $\tan(x)$ of a real number $x$.
 
#define REAL_SQRT(x)   sqrt(x)
 Compute the square root $\sqrt{x}$ of a non-negative real nunber $x$.
 
#define REAL_RSQRT(x)   _h2_rsqrt(x)
 Compute the reciprocal square root $1.0/\sqrt{x}$ of a non-negative real nunber $x$.
 
#define REAL_POW(x, y)   pow(x, y)
 Compute the $y$-th power $x^y$ of a real number $x$.
 
#define REAL_LOG(x)   log(x)
 Compute the natural logarithm $\ln(x)$ of a positive real number $x$.
 
#define REAL_EXP(x)   exp(x)
 Compute the exponetial function $\exp(x)$ of a real number $x$.
 
#define REAL_RAND()   _h2_realrand()
 Compute a (pseudo-)random real number.
 
#define DOT2(x, y)   (CONJ((x)[0]) * (y)[0] + CONJ((x)[1]) * (y)[1])
 Compute dot product of vectors of dimension 2, i.e. $ \bar x_1 y_1 + \bar x_2 y_2 $.
 
#define DOT3(x, y)   (CONJ((x)[0]) * (y)[0] + CONJ((x)[1]) * (y)[1] + CONJ((x)[2]) * (y)[2])
 Compute dot product of vectors of dimension 3, i.e. $ \bar x_1 y_1 + \bar x_2 y_2 + \bar x_3 y_3 $.
 
#define NORMSQR2(x, y)   (ABSSQR(x) + ABSSQR(y))
 Compute squared 2-norm of a vector of dimension 2, i.e. $ \lvert x \rvert^2 + \lvert y \rvert^2 $.
 
#define NORMSQR3(x, y, z)   (ABSSQR(x) + ABSSQR(y) + ABSSQR(z))
 Compute squared 2-norm of a vector of dimension 3, i.e. $ \lvert x \rvert^2 + \lvert y \rvert^2 + \lvert z \rvert^2 $.
 
#define NORM2(x, y)   REAL_SQRT(ABSSQR(x) + ABSSQR(y))
 Compute 2-norm of a vector of dimension 2, i.e. $ \sqrt{\lvert x \rvert^2 + \lvert y \rvert^2} $.
 
#define NORM3(x, y, z)   REAL_SQRT(ABSSQR(x) + ABSSQR(y) + ABSSQR(z))
 Compute 2-norm of a vector of dimension 3, i.e. $ \sqrt{\lvert x \rvert^2 + \lvert y \rvert^2 + \lvert z \rvert^2} $.
 
#define REAL_DOT2(x, y)   ((x)[0] * (y)[0] + (x)[1] * (y)[1])
 Compute dot product of vectors of reals with dimension 2, i.e. $ x_1 y_1 + x_2 y_2 $.
 
#define REAL_DOT3(x, y)   ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2])
 Compute dot product of vectors of reals with dimension 3, i.e. $ x_1 y_1 + x_2 y_2 + x_3 y_3 $.
 
#define REAL_NORMSQR2(x, y)   (REAL_SQR(x) + REAL_SQR(y))
 Compute squared 2-norm of a vector of reals with dimension 2, i.e. $ x^2 + y^2 $.
 
#define REAL_NORMSQR3(x, y, z)   (REAL_SQR(x) + REAL_SQR(y) + REAL_SQR(z))
 Compute squared 2-norm of a vector of reals with dimension 3, i.e. $ x^2 + y^2 +z^2 $.
 
#define REAL_NORM2(x, y)   REAL_SQRT(REAL_SQR(x) + REAL_SQR(y))
 Compute 2-norm of a vector of reals with dimension 2, i.e. $ \sqrt{x^2 + y^2} $.
 
#define REAL_NORM3(x, y, z)   REAL_SQRT(REAL_SQR(x) + REAL_SQR(y) + REAL_SQR(z))
 Compute 2-norm of a vector of reals with dimension 3, i.e. $ \sqrt{x^2 + y^2 + z^2} $.
 
#define REAL_MAX(x, y)   _h2_realmax(x, y)
 Compute the maximum $\max\{x,y\}$ of two real numbers $x$ and $y$.
 
#define REAL_MAX3(x, y, z)   _h2_realmax3(x, y, z)
 Compute the maximum $\max\{x,y,z\}$ of three real numbers $x,y$ and $z$.
 
#define REAL_MIN(x, y)   _h2_realmin(x, y)
 Compute the minimum $\min\{x,y\}$ of two real numbers $x$ and $y$.
 
#define REAL_MIN3(x, y, z)   _h2_realmin3(x, y, z)
 Compute the minimum $\min\{x,y,z\}$ of three real numbers $x,y$ and $z$.
 
#define UINT_MAX(x, y)   _h2_uintmax(x, y)
 Compute the maximum $\max\{x,y\}$ of two unsigned integers $x$ and $y$.
 
#define UINT_MAX3(x, y, z)   _h2_uintmax3(x, y, z)
 Compute the maximum $\max\{x,y,z\}$ of three unsigned integers $x,y$ and $z$.
 
#define UINT_MIN(x, y)   _h2_uintmin(x, y)
 Compute the minimum $\min\{x,y,z\}$ of two unsigned integers $x,y$ and $z$.
 
#define UINT_MIN3(x, y, z)   _h2_uintmin3(x, y, z)
 Compute the minimum $\min\{x,y,z\}$ of three unsigned integers $x,y$ and $z$.
 
#define allocmem(sz)   _h2_allocmem(sz,__FILE__,__LINE__)
 Allocate heap storage. More...
 
#define allocuint(sz)   _h2_allocuint(sz,__FILE__,__LINE__)
 Allocate heap storage of type uint. More...
 
#define allocreal(sz)   _h2_allocreal(sz,__FILE__,__LINE__)
 Allocate heap storage of type real. More...
 
#define allocfield(sz)   _h2_allocfield(sz,__FILE__,__LINE__)
 Allocate heap storage of type field. More...
 
#define allocmatrix(rows, cols)   _h2_allocmatrix(rows,cols,__FILE__,__LINE__)
 Allocate heap storage for a matrix. More...
 
#define heapsort(n, leq, swap, data)   _h2_heapsort(n,leq,swap,data)
 Heapsort algorithm. More...
 

Typedefs

typedef struct _stopwatch stopwatch
 Stop watch for run-time measurements.
 
typedef stopwatchpstopwatch
 Pointer to a stopwatch object.
 

Functions

void init_h2lib (int *argc, char ***argv)
 Initialize the library. More...
 
void uninit_h2lib ()
 Uninitialize the library. More...
 
size_t get_current_memory ()
 Current amount of allocated memory (bytes) More...
 
void freemem (void *ptr)
 Release allocated storage. More...
 
pstopwatch new_stopwatch ()
 Create a stopwatch object. More...
 
void del_stopwatch (pstopwatch sw)
 Delete a stopwatch object. More...
 
void start_stopwatch (pstopwatch sw)
 Start a stopwatch. More...
 
real stop_stopwatch (pstopwatch sw)
 Stop a stopwatch. More...
 
cairo_t * new_cairopdf (const char *filename, double width, double height)
 Create a PDF canvas for Cairo drawing. More...
 
cairo_t * new_cairopng (uint width, uint height)
 Create a PNG canvas for Cairo drawing. More...
 
bool write_cairopng (cairo_t *cr, const char *filename)
 Write Cairo image to PNG file. More...
 

Variables

int max_pardepth
 Reasonable cut-off depth for parallelization.
 

Detailed Description

Author
Steffen Börm