1/*
2 * infinities - handle infinities symbolically, a little helper file
3 *
4 * Copyright (C) 2013 Christoph Zurnieden
5 *
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
9 *
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
13 * Public License for more details.
14 *
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL.  You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21
22static resource_debug_level;
23resource_debug_level = config("resource_debug", 0);
24
25
26define isinfinite(x)
27{
28    if (isstr(x)) {
29	if (strncmp(x, "cinf", 4) == 0
30	    || strncmp(x, "pinf", 4) == 0 || strncmp(x, "ninf", 4) == 0)
31	    return 1;
32    }
33    return 0;
34}
35
36define iscinf(x)
37{
38    if (isstr(x)) {
39	if (strncmp(x, "cinf", 4) == 0)
40	    return 1;
41    }
42    return 0;
43}
44
45define ispinf(x)
46{
47    if (isstr(x)) {
48	if (strncmp(x, "pinf", 4) == 0)
49	    return 1;
50    }
51    return 0;
52}
53
54define isninf(x)
55{
56    if (isstr(x)) {
57	if (strncmp(x, "ninf", 4) == 0)
58	    return 1;
59    }
60    return 0;
61}
62
63define cinf()
64{
65    return "cinf";
66}
67
68define ninf()
69{
70    return "ninf";
71}
72
73define pinf()
74{
75    return "pinf";
76}
77
78
79config("resource_debug", resource_debug_level),;
80if (config("resource_debug") & 3) {
81    print "isinfinite(x)";
82    print "iscinf(x)";
83    print "ispinf(x)";
84    print "isninf(x)";
85    print "cinf()";
86    print "ninf()";
87    print "pinf()";
88}
89