Meta Byte Track
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lapjv.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 { FP_1 = 1, FP_2 = 2, FP_DYNAMIC = 3 } fp_t;
  52. extern int_t lapjv_internal(
  53. const uint_t n, cost_t *cost[],
  54. int_t *x, int_t *y);
  55. #endif // LAPJV_H