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