Lapjv.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef LAPJV_H
  2. #define LAPJV_H
  3. #define LARGE 1000000
  4. #if !defined TRUE
  5. #define TRUE 1
  6. #endif
  7. #if !defined FALSE
  8. #define FALSE 0
  9. #endif
  10. #define NEW(x, t, n) if ((x = (t *)malloc(sizeof(t) * (n))) == 0) { return -1; }
  11. #define FREE(x) if (x != 0) { free(x); x = 0; }
  12. #define SWAP_INDICES(a, b) { int_t _temp_index = a; a = b; b = _temp_index; }
  13. #if 0
  14. #include <assert.h>
  15. #define ASSERT(cond) assert(cond)
  16. #define PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__)
  17. #define PRINT_COST_ARRAY(a, n) \
  18. while (1) { \
  19. printf(#a" = ["); \
  20. if ((n) > 0) { \
  21. printf("%f", (a)[0]); \
  22. for (uint_t j = 1; j < n; j++) { \
  23. printf(", %f", (a)[j]); \
  24. } \
  25. } \
  26. printf("]\n"); \
  27. break; \
  28. }
  29. #define PRINT_INDEX_ARRAY(a, n) \
  30. while (1) { \
  31. printf(#a" = ["); \
  32. if ((n) > 0) { \
  33. printf("%d", (a)[0]); \
  34. for (uint_t j = 1; j < n; j++) { \
  35. printf(", %d", (a)[j]); \
  36. } \
  37. } \
  38. printf("]\n"); \
  39. break; \
  40. }
  41. #else
  42. #define ASSERT(cond)
  43. #define PRINTF(fmt, ...)
  44. #define PRINT_COST_ARRAY(a, n)
  45. #define PRINT_INDEX_ARRAY(a, n)
  46. #endif
  47. typedef signed int int_t;
  48. typedef unsigned int uint_t;
  49. typedef double cost_t;
  50. typedef char boolean;
  51. typedef enum fp_t {
  52. FP_1 = 1, FP_2 = 2, FP_DYNAMIC = 3
  53. } fp_t;
  54. extern int_t lapjv_internal(
  55. const uint_t n, cost_t *cost[],
  56. int_t *x, int_t *y);
  57. #endif // LAPJV_H