GCOP  1.0
Namespaces | Defines | Functions
utils.h File Reference
#include <cstdlib>
#include <cmath>
#include <sys/time.h>
#include <cstring>
#include <iostream>
#include <stdio.h>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  gcop

Defines

#define EPS   (1e-10)
#define ISZERO(x)   (fabs(x)<EPS)
#define TIME_CMP(a, b)   (a.tv_sec != b.tv_sec || a.tv_usec != b.tv_usec)
#define SQR(a)   ((a)*(a))
#define SIGN(a)   ((a) < 0 ? -1 : 1)
#define DIST(a, b)   (sqrt(((a)[0]-(b)[0])*((a)[0]-(b)[0])+((a)[1]-(b)[1])*((a)[1]-(b)[1])))
#define NORM(a)   (sqrt((a)[0]*(a)[0]+(a)[1]*(a)[1]))
#define MINUS(c, a, b)   (c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];
#define PLUS(c, a, b)   (c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];
#define DOT(a, b)   ((a)[0]*(b)[0]+(a)[1]*(b)[1])
#define MULT(a, b, n)   (a)[0]=(b)[0]*(n);(a)[1]=(b)[1]*(n);
#define DIV(a, b, n)   (a)[0]=(b)[0]/(n);(a)[1]=(b)[1]/(n);
#define DET(a, b)   ((a)[0]*(b)[1]-(a)[1]*(b)[0])
#define NEG(a, b)   (a)[0]=-(b)[0];(a)[1]=-(b)[1];
#define SET(a, b)   (a)[0]=(b)[0];(a)[1]=(b)[1];
#define CLEAR(a)   (a)[0]=0;(a)[1]=0;
#define DIST3(a, b)   (sqrt(SQR((a)[0]-(b)[0])+SQR((a)[1]-(b)[1])+SQR((a)[2]-(b)[2])))
#define NORM3(a)   (sqrt((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2]))
#define MINUS3(c, a, b)   (c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];
#define PLUS3(c, a, b)   (c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];
#define AVE3(c, a, b)   (c)[0]=((a)[0]+(b)[0])/2;(c)[1]=((a)[1]+(b)[1])/2;(c)[2]=((a)[2]+(b)[2])/2;
#define DOT3(a, b)   ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
#define MULT3(a, b, n)   (a)[0]=(b)[0]*(n);(a)[1]=(b)[1]*(n);(a)[2]=(b)[2]*(n);
#define DIV3(a, b, n)   (a)[0]=(b)[0]/(n);(a)[1]=(b)[1]/(n);(a)[2]=(b)[2]/(n);
#define NEG3(a, b)   (a)[0]=-(b)[0];(a)[1]=-(b)[1];(a)[2]=-(b)[2];
#define SET3(a, b)   (a)[0]=(b)[0];(a)[1]=(b)[1];(a)[2]=(b)[2];
#define CLEAR3(a)   (a)[0]=0;(a)[1]=0;(a)[2]=0;
#define CROSS(c, a, b)   (c)[0]=(a)[1]*(b)[2]-(a)[2]*(b)[1]; (c)[1]=-(a)[0]*(b)[2]+(a)[2]*(b)[0]; (c)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0];
#define NORM4(a)   (sqrt((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2]+(a)[3]*(a)[3]))
#define MINUS4(c, a, b)   (c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];(c)[3]=(a)[3]-(b)[3];
#define PLUS4(c, a, b)   (c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];(c)[3]=(a)[3]+(b)[3];
#define MULT4(a, b, n)   (a)[0]=(b)[0]*(n);(a)[1]=(b)[1]*(n);(a)[2]=(b)[2]*(n);(a)[3]=(b)[3]*(n);
#define DIV4(a, b, n)   (a)[0]=(b)[0]/(n);(a)[1]=(b)[1]/(n);(a)[2]=(b)[2]/(n);(a)[3]=(b)[3]/(n);
#define SET4(a, b)   (a)[0]=(b)[0];(a)[1]=(b)[1];(a)[2]=(b)[2];(a)[3]=(b)[3];
#define CLEAR4(a)   (a)[0]=0;(a)[1]=0;(a)[2]=0;(a)[3]=0;
#define DIST4(a, b)   (sqrt(SQR((a)[0]-(b)[0])+SQR((a)[1]-(b)[1])+SQR((a)[2]-(b)[2])+SQR((a)[3]-(b)[3])))

Functions

void gcop::timer_start (struct timeval &timer)
long gcop::timer_us (struct timeval &timer)
double gcop::normal_dist (double mu, double sigma, double x)
double gcop::random_normal ()
void gcop::mult (double *c, const double *a, const double *b, int m, int n, int p, bool rm=true)
void gcop::mult (double *c, const double *a, int an, const int *ai, const int *aj, const double *b, int m, int n, int p)
double gcop::dangle (double a1, double a2)
void gcop::save_map (const char *map, int width, int height, const char *filename)
char * gcop::load_map (int *width, int *height, const char *filename)
void gcop::rot (double m[9], const double o[3])
void gcop::hermite2 (double c1[2], double c2[2], double c3[2], const double xi[2], const double vi[2], const double xf[2])
void gcop::hermite3 (double c1[3], double c2[3], double c3[3], const double xi[3], const double vi[3], const double xf[3])
double gcop::normal (double mu, double sigma, double x)
double gcop::normal (int d, const double *mu, const double *sigma, const double *x)
double gcop::normal2 (const double mu[2], const double sigma[2], const double x[2])
double gcop::randn ()
double gcop::ncdf (double x)

Define Documentation

#define AVE3 (   c,
  a,
 
)    (c)[0]=((a)[0]+(b)[0])/2;(c)[1]=((a)[1]+(b)[1])/2;(c)[2]=((a)[2]+(b)[2])/2;
#define CLEAR (   a)    (a)[0]=0;(a)[1]=0;
#define CLEAR3 (   a)    (a)[0]=0;(a)[1]=0;(a)[2]=0;
#define CLEAR4 (   a)    (a)[0]=0;(a)[1]=0;(a)[2]=0;(a)[3]=0;
#define CROSS (   c,
  a,
 
)    (c)[0]=(a)[1]*(b)[2]-(a)[2]*(b)[1]; (c)[1]=-(a)[0]*(b)[2]+(a)[2]*(b)[0]; (c)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0];
#define DET (   a,
 
)    ((a)[0]*(b)[1]-(a)[1]*(b)[0])
#define DIST (   a,
 
)    (sqrt(((a)[0]-(b)[0])*((a)[0]-(b)[0])+((a)[1]-(b)[1])*((a)[1]-(b)[1])))
#define DIST3 (   a,
 
)    (sqrt(SQR((a)[0]-(b)[0])+SQR((a)[1]-(b)[1])+SQR((a)[2]-(b)[2])))
#define DIST4 (   a,
 
)    (sqrt(SQR((a)[0]-(b)[0])+SQR((a)[1]-(b)[1])+SQR((a)[2]-(b)[2])+SQR((a)[3]-(b)[3])))
#define DIV (   a,
  b,
 
)    (a)[0]=(b)[0]/(n);(a)[1]=(b)[1]/(n);
#define DIV3 (   a,
  b,
 
)    (a)[0]=(b)[0]/(n);(a)[1]=(b)[1]/(n);(a)[2]=(b)[2]/(n);
#define DIV4 (   a,
  b,
 
)    (a)[0]=(b)[0]/(n);(a)[1]=(b)[1]/(n);(a)[2]=(b)[2]/(n);(a)[3]=(b)[3]/(n);
#define DOT (   a,
 
)    ((a)[0]*(b)[0]+(a)[1]*(b)[1])
#define DOT3 (   a,
 
)    ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])

Referenced by gcop::Viewer::DrawArrow().

#define EPS   (1e-10)
#define ISZERO (   x)    (fabs(x)<EPS)
#define MINUS (   c,
  a,
 
)    (c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];

Referenced by gcop::hermite2().

#define MINUS3 (   c,
  a,
 
)    (c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];
#define MINUS4 (   c,
  a,
 
)    (c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];(c)[3]=(a)[3]-(b)[3];
#define MULT (   a,
  b,
 
)    (a)[0]=(b)[0]*(n);(a)[1]=(b)[1]*(n);

Referenced by gcop::hermite2().

#define MULT3 (   a,
  b,
 
)    (a)[0]=(b)[0]*(n);(a)[1]=(b)[1]*(n);(a)[2]=(b)[2]*(n);
#define MULT4 (   a,
  b,
 
)    (a)[0]=(b)[0]*(n);(a)[1]=(b)[1]*(n);(a)[2]=(b)[2]*(n);(a)[3]=(b)[3]*(n);
#define NEG (   a,
 
)    (a)[0]=-(b)[0];(a)[1]=-(b)[1];
#define NEG3 (   a,
 
)    (a)[0]=-(b)[0];(a)[1]=-(b)[1];(a)[2]=-(b)[2];
#define NORM (   a)    (sqrt((a)[0]*(a)[0]+(a)[1]*(a)[1]))

Referenced by gcop::hermite2().

#define NORM3 (   a)    (sqrt((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2]))
#define NORM4 (   a)    (sqrt((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2]+(a)[3]*(a)[3]))
#define PLUS (   c,
  a,
 
)    (c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];
#define PLUS3 (   c,
  a,
 
)    (c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];
#define PLUS4 (   c,
  a,
 
)    (c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];(c)[3]=(a)[3]+(b)[3];
#define SET (   a,
 
)    (a)[0]=(b)[0];(a)[1]=(b)[1];
#define SET3 (   a,
 
)    (a)[0]=(b)[0];(a)[1]=(b)[1];(a)[2]=(b)[2];

Referenced by gcop::Dem::GetNormal().

#define SET4 (   a,
 
)    (a)[0]=(b)[0];(a)[1]=(b)[1];(a)[2]=(b)[2];(a)[3]=(b)[3];
#define SIGN (   a)    ((a) < 0 ? -1 : 1)
#define SQR (   a)    ((a)*(a))
#define TIME_CMP (   a,
 
)    (a.tv_sec != b.tv_sec || a.tv_usec != b.tv_usec)