Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
general.h
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#pragma once
12
13#include <stdlib.h>
14#include <stdio.h>
15#include <math.h>
16#include <string.h>
17#include <assert.h>
18#include <cgraph/exit.h>
19/* Applications that do not use the common library can define STANDALONE
20 * to get definitions/definitions that are normally provided there.
21 * In particular, note that Verbose is declared but undefined.
22 */
23#ifndef STANDALONE
24#include "cgraph.h"
25#include "globals.h"
26#include "arith.h"
27#endif /* STANDALONE */
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#define set_flag(a, flag) ((a)=((a)|(flag)))
34#define test_flag(a, flag) ((a)&(flag))
35#define clear_flag(a, flag) ((a) &=(~(flag)))
36
37#ifdef STANDALONE
38
39#define MAX(a,b) ((a)>(b)?(a):b)
40#define MIN(a,b) ((a)<(b)?(a):b)
41
42#define POINTS(inch) 72*(inch)
43
44#ifdef GVDLL
45__declspec(dllimport) extern unsigned char Verbose;
46#else
47extern unsigned char Verbose;
48#endif
49
50#endif /* STANDALONE */
51
52#ifdef DEBUG
53extern double _statistics[10];
54#endif
55
56
57extern int irand(int n);
58extern double drand(void);
59extern int *random_permutation(int n);/* random permutation of 0 to n-1 */
60
61
62double* vector_subtract_to(int n, double *x, double *y);/* y = x-y */
63
64double vector_product(int n, double *x, double *y);
65
66double* vector_saxpy(int n, double *x, double *y, double beta); /* y = x+beta*y */
67
68
69double* vector_saxpy2(int n, double *x, double *y, double beta);/* x = x+beta*y */
70
71/* take m elements v[p[i]]],i=1,...,m and oput in u. u will be assigned if *u = NULL */
72void vector_float_take(int n, float *v, int m, int *p, float **u);
73
74/* give the position of the smallest, second smallest etc in vector v.
75 results in p. If *p == NULL, p is assigned.
76*/
77void vector_ordering(int n, double *v, int **p);
78void vector_sort_int(int n, int *v);
79
80#define MACHINEACC 1.0e-16
81#define SQRT_MACHINEACC 1.0e-8
82
83#define MINDIST 1.e-15
84
85enum {UNMATCHED = -1};
86
87
88double distance(double *x, int dim, int i, int j);
89double distance_cropped(double *x, int dim, int i, int j);
90
91double point_distance(double *p1, double *p2, int dim);
92
93char *strip_dir(char *s);
94
95#ifdef __cplusplus
96}
97#endif
abstract graph C library, Cgraph API
int * random_permutation(int n)
Definition general.c:33
double * vector_saxpy(int n, double *x, double *y, double beta)
Definition general.c:64
double drand(void)
Definition general.c:22
double * vector_saxpy2(int n, double *x, double *y, double beta)
Definition general.c:71
char * strip_dir(char *s)
Definition general.c:161
@ UNMATCHED
Definition general.h:85
void vector_ordering(int n, double *v, int **p)
Definition general.c:115
double distance(double *x, int dim, int i, int j)
Definition general.c:145
double vector_product(int n, double *x, double *y)
Definition general.c:57
void vector_float_take(int n, float *v, int m, int *p, float **u)
Definition general.c:78
void vector_sort_int(int n, int *v)
Definition general.c:136
int irand(int n)
Definition general.c:26
double * vector_subtract_to(int n, double *x, double *y)
Definition general.c:51
double distance_cropped(double *x, int dim, int i, int j)
Definition general.c:140
double point_distance(double *p1, double *p2, int dim)
Definition general.c:153
static int Verbose
Definition gml2gv.c:22
Definition grammar.c:93