glplib.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* glplib.h (miscellaneous library routines) */
  2. /***********************************************************************
  3. * This code is part of GLPK (GNU Linear Programming Kit).
  4. *
  5. * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  6. * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
  7. * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  8. * E-mail: <mao@gnu.org>.
  9. *
  10. * GLPK is free software: you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * GLPK is distributed in the hope that it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  18. * License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  22. ***********************************************************************/
  23. #ifndef GLPLIB_H
  24. #define GLPLIB_H
  25. #define bigmul _glp_lib_bigmul
  26. void bigmul(int n, int m, unsigned short x[], unsigned short y[]);
  27. /* multiply unsigned integer numbers of arbitrary precision */
  28. #define bigdiv _glp_lib_bigdiv
  29. void bigdiv(int n, int m, unsigned short x[], unsigned short y[]);
  30. /* divide unsigned integer numbers of arbitrary precision */
  31. #ifndef GLP_LONG_DEFINED
  32. #define GLP_LONG_DEFINED
  33. typedef struct { int lo, hi; } glp_long;
  34. /* long integer data type */
  35. #endif
  36. typedef struct { glp_long quot, rem; } glp_ldiv;
  37. /* result of long integer division */
  38. #define xlset _glp_lib_xlset
  39. glp_long xlset(int x);
  40. /* expand integer to long integer */
  41. #define xlneg _glp_lib_xlneg
  42. glp_long xlneg(glp_long x);
  43. /* negate long integer */
  44. #define xladd _glp_lib_xladd
  45. glp_long xladd(glp_long x, glp_long y);
  46. /* add long integers */
  47. #define xlsub _glp_lib_xlsub
  48. glp_long xlsub(glp_long x, glp_long y);
  49. /* subtract long integers */
  50. #define xlcmp _glp_lib_xlcmp
  51. int xlcmp(glp_long x, glp_long y);
  52. /* compare long integers */
  53. #define xlmul _glp_lib_xlmul
  54. glp_long xlmul(glp_long x, glp_long y);
  55. /* multiply long integers */
  56. #define xldiv _glp_lib_xldiv
  57. glp_ldiv xldiv(glp_long x, glp_long y);
  58. /* divide long integers */
  59. #define xltod _glp_lib_xltod
  60. double xltod(glp_long x);
  61. /* convert long integer to double */
  62. #define xltoa _glp_lib_xltoa
  63. char *xltoa(glp_long x, char *s);
  64. /* convert long integer to character string */
  65. #define str2int _glp_lib_str2int
  66. int str2int(const char *str, int *val);
  67. /* convert character string to value of int type */
  68. #define str2num _glp_lib_str2num
  69. int str2num(const char *str, double *val);
  70. /* convert character string to value of double type */
  71. #define strspx _glp_lib_strspx
  72. char *strspx(char *str);
  73. /* remove all spaces from character string */
  74. #define strtrim _glp_lib_strtrim
  75. char *strtrim(char *str);
  76. /* remove trailing spaces from character string */
  77. #define strrev _glp_lib_strrev
  78. char *strrev(char *s);
  79. /* reverse character string */
  80. #define gcd _glp_lib_gcd
  81. int gcd(int x, int y);
  82. /* find greatest common divisor of two integers */
  83. #define gcdn _glp_lib_gcdn
  84. int gcdn(int n, int x[]);
  85. /* find greatest common divisor of n integers */
  86. #define lcm _glp_lib_lcm
  87. int lcm(int x, int y);
  88. /* find least common multiple of two integers */
  89. #define lcmn _glp_lib_lcmn
  90. int lcmn(int n, int x[]);
  91. /* find least common multiple of n integers */
  92. #define round2n _glp_lib_round2n
  93. double round2n(double x);
  94. /* round floating-point number to nearest power of two */
  95. #define fp2rat _glp_lib_fp2rat
  96. int fp2rat(double x, double eps, double *p, double *q);
  97. /* convert floating-point number to rational number */
  98. #define jday _glp_lib_jday
  99. int jday(int d, int m, int y);
  100. /* convert calendar date to Julian day number */
  101. #define jdate _glp_lib_jdate
  102. int jdate(int j, int *d, int *m, int *y);
  103. /* convert Julian day number to calendar date */
  104. #endif
  105. /* eof */