forked from fricas/fricas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
op.spad
658 lines (603 loc) · 26.5 KB
/
op.spad
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
)abbrev domain BOP BasicOperator
++ Basic system operators
++ Author: Manuel Bronstein
++ Date Created: 22 March 1988
++ Description:
++ A basic operator is an object that can be applied to a list of
++ arguments from a set, the result being a kernel over that set.
++ Keywords: operator, kernel.
BasicOperator() : Exports == Implementation where
O ==> OutputForm
P ==> AssociationList(Symbol, None)
L ==> List Record(key : Symbol, entry : None)
SEX ==> InputForm
Exports ==> OrderedSet with
name : % -> Symbol
++ name(op) returns the name of op.
properties : % -> P
++ properties(op) returns the list of all the properties
++ currently attached to op.
copy : % -> %
++ copy(op) returns a copy of op.
operator : Symbol -> %
++ operator(f) makes f into an operator with arbitrary arity.
operator : (Symbol, NonNegativeInteger) -> %
++ operator(f, n) makes f into an n-ary operator.
arity : % -> Union(NonNegativeInteger, "failed")
++ arity(op) returns n if op is n-ary, and
++ "failed" if op has arbitrary arity.
nullary? : % -> Boolean
++ nullary?(op) tests if op is nullary.
unary? : % -> Boolean
++ unary?(op) tests if op is unary.
nary? : % -> Boolean
++ nary?(op) tests if op has arbitrary arity.
weight : % -> NonNegativeInteger
++ weight(op) returns the weight attached to op.
weight : (%, NonNegativeInteger) -> %
++ weight(op, n) attaches the weight n to op.
equality : (%, (%, %) -> Boolean) -> %
++ equality(op, foo?) attaches foo? as the "%equal?" property
++ to op. If op1 and op2 have the same name, and one of them
++ has an "%equal?" property f, then \spad{f(op1, op2)} is called to
++ decide whether op1 and op2 should be considered equal.
comparison : (%, (%, %) -> Boolean) -> %
++ comparison(op, foo?) attaches foo? as the "%less?" property
++ to op. If op1 and op2 have the same name, and one of them
++ has a "%less?" property f, then \spad{f(op1, op2)} is called to
++ decide whether \spad{op1 < op2}.
display : % -> Union(List O -> O, "failed")
++ display(op) returns the "%display" property of op if
++ it has one attached, and "failed" otherwise.
display : (%, List O -> O) -> %
++ display(op, foo) attaches foo as the "%display" property
++ of op. If op has a "%display" property f, then \spad{op(a1,...,an)}
++ gets converted to OutputForm as \spad{f(a1, ..., an)}.
display : (%, O -> O) -> %
++ display(op, foo) attaches foo as the "%display" property
++ of op. If op has a "%display" property f, then \spad{op(a)}
++ gets converted to OutputForm as \spad{f(a)}.
++ Argument op must be unary.
input : (%, List SEX -> SEX) -> %
++ input(op, foo) attaches foo as the "%input" property
++ of op. If op has a "%input" property f, then \spad{op(a1,...,an)}
++ gets converted to InputForm as \spad{f(a1, ..., an)}.
input : % -> Union(List SEX -> SEX, "failed")
++ input(op) returns the "%input" property of op if
++ it has one attached, "failed" otherwise.
is? : (%, Symbol) -> Boolean
++ is?(op, s) tests if the name of op is s.
has? : (%, Symbol) -> Boolean
++ has?(op, s) tests if property s is attached to op.
assert : (%, Symbol) -> %
++ assert(op, s) attaches property s to op.
++ Argument op is modified "in place", i.e. no copy is made.
deleteProperty! : (%, Symbol) -> %
++ deleteProperty!(op, s) unattaches property s from op.
++ Argument op is modified "in place", i.e. no copy is made.
property : (%, Symbol) -> Union(None, "failed")
++ property(op, s) returns the value of property s if
++ it is attached to op, and "failed" otherwise.
setProperty : (%, Symbol, None) -> %
++ setProperty(op, s, v) attaches property s to op,
++ and sets its value to v.
++ Argument op is modified "in place", i.e. no copy is made.
setProperties : (%, P) -> %
++ setProperties(op, l) sets the property list of op to l.
++ Argument op is modified "in place", i.e. no copy is made.
Implementation ==> add
-- if narg < 0 then the operator has variable arity.
Rep := Record(opname : Symbol, narg : SingleInteger, props : P)
import from P
import from SingleInteger
import from NonNegativeInteger
import from Set(Symbol)
-- some internal properties
LESS? := "%less?"::Symbol
EQUAL? := "%equal?"::Symbol
WEIGHT := '%weight
DISPLAY := '%display
SEXPR := '%input
oper : (Symbol, SingleInteger, P) -> %
is?(op, s) == name(op) = s
name op == op.opname
properties op == op.props
setProperties(op, l) == (op.props := l; op)
operator s == oper(s, -1::SingleInteger, table())
operator(s, n) == oper(s, n::Integer::SingleInteger, table())
property(op, name) == search(name, op.props)
assert(op, s) == setProperty(op, s, NIL$Lisp)
has?(op, name) == key?(name, op.props)
oper(se, n, prop) == [se, n, prop]
weight(op, n) == setProperty(op, WEIGHT, n pretend None)
nullary? op == zero?(op.narg)
unary? op == ((op.narg) = 1)
nary? op == negative?(op.narg)
equality(op, func) == setProperty(op, EQUAL?, func pretend None)
comparison(op, func) == setProperty(op, LESS?, func pretend None)
display(op : %, f : O -> O) == display(op, (l1 : List(O)) : O +-> f first l1)
deleteProperty!(op, name) == (remove!(name, properties op); op)
setProperty(op, name, valu) == (op.props.name := valu; op)
coerce(op : %) : OutputForm == name(op)::OutputForm
input(op : %, f : List SEX -> SEX) == setProperty(op, SEXPR, f pretend None)
display(op : %, f : List O -> O) == setProperty(op, DISPLAY, f pretend None)
display op ==
(u := property(op, DISPLAY)) case "failed" => "failed"
(u@None) pretend (List O -> O)
input op ==
(u := property(op, SEXPR)) case "failed" => "failed"
(u@None) pretend (List SEX -> SEX)
arity op ==
negative?(n := op.narg) => "failed"
convert(n)@Integer :: NonNegativeInteger
copy op ==
oper(name op, op.narg,
table([[r.key, r.entry] for r in entries(properties op)@L]$L))
-- property EQUAL? contains a function f: (BOP, BOP) -> Boolean
-- such that f(o1, o2) is true iff o1 = o2
op1 = op2 ==
(EQ$Lisp)(op1, op2) => true
name(op1) ~= name(op2) => false
op1.narg ~= op2.narg => false
set(keys properties op1) ~=$Set(Symbol) set(keys properties op2) => false
(func := property(op1, EQUAL?)) case None =>
((func@None) pretend ((%, %) -> Boolean)) (op1, op2)
true
-- property WEIGHT allows one to change the ordering around
-- by default, every operator has weight 1
weight op ==
(w := property(op, WEIGHT)) case "failed" => 1
(w@None) pretend NonNegativeInteger
-- property LESS? contains a function f: (BOP, BOP) -> Boolean
-- such that f(o1, o2) is true iff o1 < o2
op1 < op2 ==
(w1 := weight op1) ~= (w2 := weight op2) => w1 < w2
op1.narg ~= op2.narg => op1.narg < op2.narg
name(op1) ~= name(op2) => name(op1) < name(op2)
n1 := #(k1 := set(keys(properties op1))$Set(Symbol))
n2 := #(k2 := set(keys(properties op2))$Set(Symbol))
n1 ~= n2 => n1 < n2
not zero?(n1 := #(d1 := difference(k1, k2))) =>
n1 ~= (n2 := #(d2 := difference(k2, k1))) => n1 < n2
inspect(d1) < inspect(d2)
(func := property(op1, LESS?)) case None =>
((func@None) pretend ((%, %) -> Boolean)) (op1, op2)
(func := property(op1, EQUAL?)) case None =>
not(((func@None) pretend ((%, %) -> Boolean)) (op1, op2))
false
)abbrev package BOP1 BasicOperatorFunctions1
++ Tools to set/get common properties of operators
++ Author: Manuel Bronstein
++ Date Created: 28 Mar 1988
++ Description:
++ This package exports functions to set some commonly used properties
++ of operators, including properties which contain functions.
++ Keywords: operator.
BasicOperatorFunctions1(A : SetCategory) : Exports == Implementation where
OP ==> BasicOperator
Exports ==> with
evaluate : (OP, List A) -> Union(A, "failed")
++ evaluate(op, [a1,...,an]) checks if op has an "%eval"
++ property f. If it has, then \spad{f(a1, ..., an)} is returned, and
++ "failed" otherwise.
evaluate : (OP, List A -> A) -> OP
++ evaluate(op, foo) attaches foo as the "%eval" property
++ of op. If op has an "%eval" property f, then applying op
++ to \spad{(a1, ..., an)} returns the result of \spad{f(a1, ..., an)}.
evaluate : (OP, A -> A) -> OP
++ evaluate(op, foo) attaches foo as the "%eval" property
++ of op. If op has an "%eval" property f, then applying op
++ to a returns the result of \spad{f(a)}. Argument op must be unary.
evaluate : OP -> Union(List A -> A, "failed")
++ evaluate(op) returns the value of the "%eval" property of
++ op if it has one, and "failed" otherwise.
derivative : (OP, List (List A -> A)) -> OP
++ derivative(op, [foo1, ..., foon]) attaches [foo1, ..., foon] as
++ the "%diff" property of op. If op has an "%diff" property
++ \spad{[f1, ..., fn]} then applying a derivation D to \spad{op(a1, ..., an)}
++ returns \spad{f1(a1, ..., an) * D(a1) + ... + fn(a1, ..., an) * D(an)}.
derivative : (OP, A -> A) -> OP
++ derivative(op, foo) attaches foo as the "%diff" property
++ of op. If op has an "%diff" property f, then applying a
++ derivation D to op(a) returns \spad{f(a) * D(a)}. Argument op must be unary.
derivative : OP -> Union(List(List A -> A), "failed")
++ derivative(op) returns the value of the "%diff" property of
++ op if it has one, and "failed" otherwise.
constantOperator : A -> OP
++ constantOperator(a) returns a nullary operator op
++ such that \spad{op()} always evaluate to \spad{a}.
constantOpIfCan : OP -> Union(A, "failed")
++ constantOpIfCan(op) returns \spad{a} if op is the constant
++ nullary operator always returning \spad{a}, "failed" otherwise.
Implementation ==> add
EVAL := '%eval
CONST := '%constant
DIFF := '%diff
evaluate(op : OP, func : A -> A) == evaluate(op, (l1 : List(A)) : A +-> func first l1)
evaluate op ==
(func := property(op, EVAL)) case "failed" => "failed"
(func@None) pretend (List A -> A)
evaluate(op : OP, args : List A) ==
(func := property(op, EVAL)) case "failed" => "failed"
((func@None) pretend (List A -> A)) args
evaluate(op : OP, func : List A -> A) ==
setProperty(op, EVAL, func pretend None)
derivative op ==
(func := property(op, DIFF)) case "failed" => "failed"
((func@None) pretend List(List A -> A))
derivative(op : OP, grad : List(List A -> A)) ==
setProperty(op, DIFF, grad pretend None)
derivative(op : OP, f : A -> A) ==
unary? op or nary? op =>
derivative(op, [(l1 : List(A)) : A +-> f first l1]$List(List A -> A))
error "Operator is not unary"
cdisp : (OutputForm, List OutputForm) -> OutputForm
csex : (InputForm, List InputForm) -> InputForm
eqconst? : (OP, OP) -> Boolean
constOp : A -> OP
cdisp(a, l) == a
csex(a, l) == a
eqconst?(a, b) ==
(va := property(a, CONST)) case "failed" => not has?(b, CONST)
((vb := property(b, CONST)) case None) and
((va@None) pretend A) = ((vb@None) pretend A)
opconst : OP
if A has Comparable then
ltconst? : (OP, OP) -> Boolean
ltconst?(a, b) ==
(va := property(a, CONST)) case "failed" => has?(b, CONST)
((vb := property(b, CONST)) case None) and
smaller?((va@None) pretend A, (vb@None) pretend A)
opconst :=
comparison(equality(operator('constant, 0), eqconst?), ltconst?)
else
opconst := equality(operator('constant, 0), eqconst?)
constOp a ==
setProperty(display(copy opconst,
(l1 : List(OutputForm)) : OutputForm +-> cdisp(a::OutputForm, l1)),
CONST, a pretend None)
constantOpIfCan op ==
is?(op, 'constant) and
((u := property(op, CONST)) case None) => (u@None) pretend A
"failed"
if A has ConvertibleTo InputForm then
constantOperator a == input(constOp a, (l1 : List(InputForm)) : InputForm +-> csex(convert a, l1))
else
constantOperator a == constOp a
)abbrev package COMMONOP CommonOperators
++ Provides commonly used operators
++ Author: Manuel Bronstein
++ Date Created: 25 Mar 1988
++ Description:
++ This package exports the elementary operators, with some semantics
++ already attached to them. The semantics that is attached here is not
++ dependent on the set in which the operators will be applied.
++ Keywords: operator.
CommonOperators() : Exports == Implementation where
OP ==> BasicOperator
O ==> OutputForm
POWER ==> '%power
ALGOP ==> '%alg
EVEN ==> 'even
ODD ==> 'odd
DUMMYVAR ==> '%dummyVar
Exports ==> with
operator : Symbol -> OP
++ operator(s) returns an operator with name s, with the
++ appropriate semantics if s is known. If s is not known,
++ the result has no semantics.
Implementation ==> add
dpi : List O -> O
dbeta : List O -> O
dgamma : List O -> O
dquote : List O -> O
dexp : O -> O
dfact : O -> O
startUp : Boolean -> Void
setDummyVar : (OP, NonNegativeInteger) -> OP
brandNew? : Boolean := true
opalg := operator('rootOf, 2)$OP
oproot := operator('nthRoot, 2)
oppi := operator('pi, 0)
oplog := operator('log, 1)
opexp := operator('exp, 1)
opabs := operator('abs, 1)
opsin := operator('sin, 1)
opcos := operator('cos, 1)
optan := operator('tan, 1)
opcot := operator('cot, 1)
opsec := operator('sec, 1)
opcsc := operator('csc, 1)
opasin := operator('asin, 1)
opacos := operator('acos, 1)
opatan := operator('atan, 1)
opacot := operator('acot, 1)
opasec := operator('asec, 1)
opacsc := operator('acsc, 1)
opsinh := operator('sinh, 1)
opcosh := operator('cosh, 1)
optanh := operator('tanh, 1)
opcoth := operator('coth, 1)
opsech := operator('sech, 1)
opcsch := operator('csch, 1)
opasinh := operator('asinh, 1)
opacosh := operator('acosh, 1)
opatanh := operator('atanh, 1)
opacoth := operator('acoth, 1)
opasech := operator('asech, 1)
opacsch := operator('acsch, 1)
opbox := operator('%box, 1)$OP
oppren := operator('%paren, 1)$OP
opquote := operator('%quote)$OP
opdiff := operator('%diff, 3)
opsi := operator('Si, 1)
opci := operator('Ci, 1)
opshi := operator('Shi, 1)
opchi := operator('Chi, 1)
opei := operator('Ei, 1)
opli := operator('li, 1)
operf := operator('erf, 1)
operfi := operator('erfi, 1)
opli2 := operator('dilog, 1)
opfis := operator('fresnelS, 1)
opfic := operator('fresnelC, 1)
opGamma := operator('Gamma, 1)
opGamma2 := operator('Gamma2, 2)
opBeta := operator('Beta, 2)
opBeta3 := operator('Beta3, 3)
opdigamma := operator('digamma, 1)
oppolygamma := operator('polygamma, 2)
opBesselJ := operator('besselJ, 2)
opBesselY := operator('besselY, 2)
opBesselI := operator('besselI, 2)
opBesselK := operator('besselK, 2)
opAiryAi := operator('airyAi, 1)
opAiryAiPrime := operator('airyAiPrime, 1)
opAiryBi := operator('airyBi , 1)
opAiryBiPrime := operator('airyBiPrime, 1)
opLambertW := operator('lambertW, 1)
opPolylog := operator('polylog, 2)
opWeierstrassP := operator('weierstrassP, 3)
opWeierstrassPPrime := operator('weierstrassPPrime, 3)
opWeierstrassSigma := operator('weierstrassSigma, 3)
opWeierstrassZeta := operator('weierstrassZeta, 3)
-- arbitrary arity
opHypergeometricF := operator('hypergeometricF)$BasicOperator
opMeijerG := operator('meijerG)$BasicOperator
opWhittakerM := operator('whittakerM, 3)$OP
opWhittakerW := operator('whittakerW, 3)$OP
opAngerJ := operator('angerJ, 2)$OP
opWeberE := operator('weberE, 2)$OP
opStruveH := operator('struveH, 2)$OP
opStruveL := operator('struveL, 2)$OP
opHankelH1 := operator('hankelH1, 2)$OP
opHankelH2 := operator('hankelH2, 2)$OP
opLommelS1 := operator('lommelS1, 3)$OP
opLommelS2 := operator('lommelS2, 3)$OP
opKummerM := operator('kummerM, 3)$OP
opKummerU := operator('kummerU, 3)$OP
opLegendreP := operator('legendreP, 3)$OP
opLegendreQ := operator('legendreQ, 3)$OP
opKelvinBei := operator('kelvinBei, 2)$OP
opKelvinBer := operator('kelvinBer, 2)$OP
opKelvinKei := operator('kelvinKei, 2)$OP
opKelvinKer := operator('kelvinKer, 2)$OP
opEllipticK := operator('ellipticK, 1)$OP
opEllipticE := operator('ellipticE, 1)$OP
opEllipticE2 := operator('ellipticE2, 2)$OP
opEllipticF := operator('ellipticF, 2)$OP
opEllipticPi := operator('ellipticPi, 3)$OP
opJacobiSn := operator('jacobiSn, 2)$OP
opJacobiCn := operator('jacobiCn, 2)$OP
opJacobiDn := operator('jacobiDn, 2)$OP
opJacobiZeta := operator('jacobiZeta, 2)$OP
opJacobiTheta := operator('jacobiTheta, 2)$OP
opWeierstrassPInverse := operator('weierstrassPInverse, 3)$OP
opLerchPhi := operator('lerchPhi, 3)$OP
opRiemannZeta := operator('riemannZeta, 1)$OP
-- orthogonal polynomials
opCharlierC := operator('charlierC, 3)$OP
opHermiteH := operator('hermiteH, 2)$OP
opJacobiP := operator('jacobiP, 4)$OP
opLaguerreL := operator('laguerreL, 3)$OP
opMeixnerM := operator('meixnerM, 4)$OP
op_log_gamma := operator('%logGamma, 1)$OP
op_eis := operator('%eis, 1)$OP
op_erfs := operator('%erfs, 1)$OP
op_erfis := operator('%erfis, 1)$OP
opint := operator('integral, 3)
-- arbitrary arity
opiint := operator('%iint)$BasicOperator
opdint := operator('%defint, 5)
opfact := operator('factorial, 1)
opperm := operator('permutation, 2)
opbinom := operator('binomial, 2)
oppow := operator(POWER, 2)
opsum := operator('summation, 3)
opdsum := operator('%defsum, 5)
opprod := operator('product, 3)
opdprod := operator('%defprod, 5)
oprootsum := operator('%root_sum, 3)
opfloor := operator('floor, 1)
opceil := operator('ceil, 1)
op_fractionPart := operator('fractionPart, 1)
opreal := operator('real, 1)
opimag := operator('imag, 1)
opconjugate := operator('conjugate, 1)
oparg := operator('arg, 1)
opsign := operator('sign, 1)
op_unitStep := operator('unitStep, 1)
op_diracDelta := operator('diracDelta, 1)
-- arbitrary arity
opmax := operator('max)$BasicOperator
opmin := operator('min)$BasicOperator
algop := [oproot, opalg]$List(OP)
rtrigop := [opsin, opcos, optan, opcot, opsec, opcsc,
opasin, opacos, opatan, opacot, opasec, opacsc]
htrigop := [opsinh, opcosh, optanh, opcoth, opsech, opcsch,
opasinh, opacosh, opatanh, opacoth, opasech, opacsch]
trigop := concat(rtrigop, htrigop)
elemop := concat(trigop, [oppi, oplog, opexp])
primop := [opei, opli, opsi, opci, opshi, opchi, operf, operfi, opli2,
opint, opdint, opfis, opfic, opiint]
combop := [opfact, opperm, opbinom, oppow,
opsum, opdsum, opprod, opdprod]
specop := [opGamma, opGamma2, opBeta, opBeta3, opdigamma, oppolygamma,
opfloor, opceil, opreal, opimag, opsign, opabs, opmax, opmin,
op_fractionPart, op_unitStep,
op_diracDelta, oparg, opconjugate, op_log_gamma,
op_eis, op_erfs, op_erfis,
opBesselJ, opBesselY, opBesselI, opBesselK, opAiryAi, opAiryBi,
opAiryAiPrime, opAiryBiPrime, opLambertW, opPolylog,
opWeierstrassP, opWeierstrassPPrime, opWeierstrassZeta,
opWeierstrassSigma, opHypergeometricF, opMeijerG, _
opWhittakerM, _
opWhittakerW, _
opAngerJ, _
opWeberE, _
opStruveH, _
opStruveL, _
opHankelH1, _
opHankelH2, _
opLommelS1, _
opLommelS2, _
opKummerM, _
opKummerU, _
opLegendreP, _
opLegendreQ, _
opKelvinBei, _
opKelvinBer, _
opKelvinKei, _
opKelvinKer, _
opEllipticK, _
opEllipticE, _
opEllipticE2, _
opEllipticF, _
opEllipticPi, _
opJacobiSn, _
opJacobiCn, _
opJacobiDn, _
opJacobiZeta, _
opJacobiTheta, _
opLerchPhi, _
opRiemannZeta, _
opCharlierC, _
opHermiteH, _
opJacobiP, _
opLaguerreL, _
opMeixnerM, _
opWeierstrassPInverse _
]
anyop := [oppren, opdiff, opbox, opquote]
allop := concat(concat(concat(concat(concat(
algop, elemop), primop), combop), specop), anyop)
-- odd and even single argument operators, must be maintained current!
evenop := [opcos, opsec, opcosh, opsech, opabs, op_diracDelta]
oddop := [opsin, opcsc, optan, opcot, opasin, opacsc, opatan,
opsinh, opcsch, optanh, opcoth, opasinh, opacsch, opatanh,
opacoth, opsi, opshi, operf, operfi, opfis, opfic,
opsign, opreal, opimag]
-- operators whose second argument is a dummy variable
dummyvarop1 := [opdiff, opalg, opint, oprootsum, opsum, opprod]
-- operators whose second and third arguments are dummy variables
dummyvarop2 := [opdint, opdsum, opdprod]
operator s ==
if brandNew? then startUp false
for op in allop repeat
is?(op, s) => return copy op
operator(s)$OP
dpi l == '%pi::O
dfact x == postfix("!"::Symbol::O, (ATOM(x)$Lisp => x; paren x))
dquote l == prefix(quote(first(l)::O), rest l)
dgamma l == prefix('Gamma::O, l)
dbeta(l) == prefix('Beta::O, l)
dEllipticE2(l : List O) : O == prefix('ellipticE::O, l)
setDummyVar(op, n) == setProperty(op, DUMMYVAR, n pretend None)
dexp x ==
e := '%e::O
x = 1::O => e
e ^ x
inputdefsum(a: List InputForm): InputForm ==
seg: InputForm := convert([convert('SEGMENT)$InputForm, a.4, a.5])$InputForm
eq: InputForm := convert([convert('equation)$InputForm, a.2, seg])
convert([convert('sum)$InputForm, a.1, eq])
inputdefprod(a: List InputForm): InputForm ==
seg: InputForm := convert([convert('SEGMENT)$InputForm, a.4, a.5])$InputForm
eq: InputForm := convert([convert('equation)$InputForm, a.2, seg])
convert([convert('product)$InputForm, a.1, eq])
startUp b ==
brandNew? := b
display(oppren, paren)
display(opbox, commaSeparate)
display(oppi, dpi)
display(opexp, dexp)
display(opBeta3, dbeta)
setProperty(opBeta3, 'disp_name, ('Beta::O) pretend None)
display(opGamma2, dgamma)
setProperty(opGamma2, 'disp_name, ('Gamma::O) pretend None)
display(opEllipticE2, dEllipticE2)
display(opfact, dfact)
display(opquote, dquote)
display(opperm, (z1 : List O) : O +-> supersub('A::O, z1))
display(opbinom, (z1 : List O) : O +-> binomial(first z1, second z1))
display(oppow, (z1 : List O) : O +-> first(z1) ^ second(z1))
display(opsum, (z1 : List O) : O +-> sum(first z1, second z1, third z1))
display(opprod, (z1 : List O) : O +-> prod(first z1, second z1, third z1))
display(opint, (z1 : List O) : O +-> int(first z1 * hconcat('d::O, second z1),
empty(), third z1))
input(oppren, (z1 : List InputForm) : InputForm +-> convert concat(convert("("::Symbol)@InputForm,
concat(z1, convert(")"::Symbol)@InputForm)))
input(oppow, (z1 : List InputForm) : InputForm +-> convert concat(convert("^"::Symbol)@InputForm, z1))
input(oproot,
(z1 : List InputForm) : InputForm +-> convert [convert("^"::Symbol)@InputForm, first z1, 1 / second z1])
input(opdsum, inputdefsum)
input(opdprod, inputdefprod)
for op in algop repeat assert(op, ALGOP)
for op in rtrigop repeat assert(op, 'rtrig)
for op in htrigop repeat assert(op, 'htrig)
for op in trigop repeat assert(op, 'trig)
for op in elemop repeat assert(op, 'elem)
for op in primop repeat assert(op, 'prim)
for op in combop repeat assert(op, 'comb)
for op in specop repeat assert(op, 'special)
for op in anyop repeat assert(op, 'any)
for op in evenop repeat assert(op, EVEN)
for op in oddop repeat assert(op, ODD)
for op in dummyvarop1 repeat setDummyVar(op, 1)
for op in dummyvarop2 repeat setDummyVar(op, 2)
assert(oppren, 'linear)
void
--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
--All rights reserved.
--
--Redistribution and use in source and binary forms, with or without
--modification, are permitted provided that the following conditions are
--met:
--
-- - Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
--
-- - Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in
-- the documentation and/or other materials provided with the
-- distribution.
--
-- - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-- names of its contributors may be used to endorse or promote products
-- derived from this software without specific prior written permission.
--
--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
--IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
--TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
--PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
--OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
--EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
--PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
--PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
--LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
--NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-- SPAD files for the functional world should be compiled in the
-- following order:
--
-- OP kl expr function