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