This file is indexed.

/usr/share/calc/surd.cal is in apcalc-common 2.12.5.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*
 * surd - calculate using quadratic surds of the form: a + b * sqrt(D).
 *
 * Copyright (C) 1999  David I. Bell
 *
 * Calc is open software; you can redistribute it and/or modify it under
 * the terms of the version 2.1 of the GNU Lesser General Public License
 * as published by the Free Software Foundation.
 *
 * Calc is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU Lesser General
 * Public License for more details.
 *
 * A copy of version 2.1 of the GNU Lesser General Public License is
 * distributed with calc under the filename COPYING-LGPL.  You should have
 * received a copy with calc; if not, write to Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @(#) $Revision: 30.1 $
 * @(#) $Id: surd.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
 * @(#) $Source: /usr/local/src/bin/calc/cal/RCS/surd.cal,v $
 *
 * Under source code control:	1990/02/15 01:50:38
 * File existed as early as:	before 1990
 *
 * Share and enjoy!  :-)	http://www.isthe.com/chongo/tech/comp/calc/
 */


obj surd {a, b};		/* definition of the surd object */

global surd_type = -1;		/* type of surd (value of D) */
static obj surd surd__;		/* example surd for testing against */


define surd(a,b)
{
	local x;

	obj surd x;
	x.a = a;
	x.b = b;
	return x;
}


define surd_print(a)
{
	print "surd(" : a.a : ", " : a.b : ")" :;
}


define surd_conj(a)
{
	local	x;

	obj surd x;
	x.a = a.a;
	x.b = -a.b;
	return x;
}


define surd_norm(a)
{
	return a.a^2 + abs(surd_type) * a.b^2;
}


define surd_value(a, xepsilon)
{
	local	epsilon;

	epsilon = xepsilon;
	if (isnull(epsilon))
		epsilon = epsilon();
	return a.a + a.b * sqrt(surd_type, epsilon);
}

define surd_add(a, b)
{
	local obj surd	x;

	if (!istype(b, x)) {
		x.a = a.a + b;
		x.b = a.b;
		return x;
	}
	if (!istype(a, x)) {
		x.a = a + b.a;
		x.b = b.b;
		return x;
	}
	x.a = a.a + b.a;
	x.b = a.b + b.b;
	if (x.b)
		return x;
	return x.a;
}


define surd_sub(a, b)
{
	local obj surd	x;

	if (!istype(b, x)) {
		x.a = a.a - b;
		x.b = a.b;
		return x;
	}
	if (!istype(a, x)) {
		x.a = a - b.a;
		x.b = -b.b;
		return x;
	}
	x.a = a.a - b.a;
	x.b = a.b - b.b;
	if (x.b)
		return x;
	return x.a;
}


define surd_inc(a)
{
	local	x;

	x = a;
	x.a++;
	return x;
}


define surd_dec(a)
{
	local	x;

	x = a;
	x.a--;
	return x;
}


define surd_neg(a)
{
	local obj surd	x;

	x.a = -a.a;
	x.b = -a.b;
	return x;
}


define surd_mul(a, b)
{
	local obj surd	x;

	if (!istype(b, x)) {
		x.a = a.a * b;
		x.b = a.b * b;
	} else if (!istype(a, x)) {
		x.a = b.a * a;
		x.b = b.b * a;
	} else {
		x.a = a.a * b.a + surd_type * a.b * b.b;
		x.b = a.a * b.b + a.b * b.a;
	}
	if (x.b)
		return x;
	return x.a;
}


define surd_square(a)
{
	local obj surd	x;

	x.a = a.a^2 + a.b^2 * surd_type;
	x.b = a.a * a.b * 2;
	if (x.b)
		return x;
	return x.a;
}


define surd_scale(a, b)
{
	local obj surd	x;

	x.a = scale(a.a, b);
	x.b = scale(a.b, b);
	return x;
}


define surd_shift(a, b)
{
	local obj surd	x;

	x.a = a.a << b;
	x.b = a.b << b;
	if (x.b)
		return x;
	return x.a;
}


define surd_div(a, b)
{
	local x, y;

	if ((a == 0) && b)
		return 0;
	obj surd x;
	if (!istype(b, x)) {
		x.a = a.a / b;
		x.b = a.b / b;
		return x;
	}
	y = b;
	y.b = -b.b;
	return (a * y) / (b.a^2 - surd_type * b.b^2);
}


define surd_inv(a)
{
	return 1 / a;
}


define surd_sgn(a)
{
	if (surd_type < 0)
		quit "Taking sign of complex surd";
	if (a.a == 0)
		return sgn(a.b);
	if (a.b == 0)
		return sgn(a.a);
	if ((a.a > 0) && (a.b > 0))
		return 1;
	if ((a.a < 0) && (a.b < 0))
		return -1;
	return sgn(a.a^2 - a.b^2 * surd_type) * sgn(a.a);
}


define surd_cmp(a, b)
{
	if (!istype(a, surd__))
		return ((b.b != 0) || (a != b.a));
	if (!istype(b, surd__))
		return ((a.b != 0) || (b != a.a));
	return ((a.a != b.a) || (a.b != b.b));
}


define surd_rel(a, b)
{
	local x, y;

	if (surd_type < 0)
		quit "Relative comparison of complex surds";
	if (!istype(a, surd__)) {
		x = a - b.a;
		y = -b.b;
	} else if (!istype(b, surd__)) {
		x = a.a - b;
		y = a.b;
	} else {
		x = a.a - b.a;
		y = a.b - b.b;
	}
	if (y == 0)
		return sgn(x);
	if (x == 0)
		return sgn(y);
	if ((x < 0) && (y < 0))
		return -1;
	if ((x > 0) && (y > 0))
		return 1;
	return sgn(x^2 - y^2 * surd_type) * sgn(x);
}

if (config("resource_debug") & 3) {
    print "obj surd {a, b} defined";
    print "surd_type defined";
    print "set surd_type as needed";
}