general.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #pragma once
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <math.h>
  14. #include <string.h>
  15. #include <assert.h>
  16. #include <util/exit.h>
  17. /* Applications that do not use the common library can define STANDALONE
  18. * to get definitions/definitions that are normally provided there.
  19. * In particular, note that Verbose is declared but undefined.
  20. */
  21. #ifndef STANDALONE
  22. #include "cgraph.h"
  23. #include "globals.h"
  24. #include "arith.h"
  25. #endif /* STANDALONE */
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #ifdef STANDALONE
  30. #define MAX(a,b) ((a)>(b)?(a):b)
  31. #define MIN(a,b) ((a)<(b)?(a):b)
  32. #define POINTS(inch) 72*(inch)
  33. #ifdef GVDLL
  34. __declspec(dllimport) extern unsigned char Verbose;
  35. #else
  36. extern unsigned char Verbose;
  37. #endif
  38. #endif /* STANDALONE */
  39. #ifdef DEBUG
  40. extern double _statistics[10];
  41. #endif
  42. extern int irand(int n);
  43. extern double drand(void);
  44. extern int *random_permutation(int n);/* random permutation of 0 to n-1 */
  45. double* vector_subtract_to(int n, double *x, double *y);/* y = x-y */
  46. double vector_product(int n, double *x, double *y);
  47. double* vector_saxpy(int n, double *x, double *y, double beta); /* y = x+beta*y */
  48. double* vector_saxpy2(int n, double *x, double *y, double beta);/* x = x+beta*y */
  49. /* take m elements v[p[i]]],i=1,...,m and oput in u. u will be assigned if *u = NULL */
  50. void vector_float_take(int n, float *v, int m, int *p, float **u);
  51. /* give the position of the smallest, second smallest etc in vector v.
  52. results in p. If *p == NULL, p is assigned.
  53. */
  54. void vector_ordering(int n, double *v, int **p);
  55. void vector_sort_int(int n, int *v);
  56. #define MACHINEACC 1.0e-16
  57. #define SQRT_MACHINEACC 1.0e-8
  58. #define MINDIST 1.e-15
  59. enum {UNMATCHED = -1};
  60. double distance(double *x, int dim, int i, int j);
  61. double distance_cropped(double *x, int dim, int i, int j);
  62. double point_distance(double *p1, double *p2, int dim);
  63. char *strip_dir(char *s);
  64. #ifdef __cplusplus
  65. }
  66. #endif