/usr/share/axiom-20170501/src/algebra/CPMATCH.spad is in axiom-source 20170501-3.
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 | )abbrev package CPMATCH ComplexPatternMatch
++ Author: Barry Trager
++ Date Created: 30 Nov 1995
++ Description:
++ This package supports matching patterns involving complex expressions
ComplexPatternMatch(R, S, CS) : SIG == CODE where
R : SetCategory
S : Join(PatternMatchable R, CommutativeRing)
CS : ComplexCategory S
PMRS ==> PatternMatchResult(R, CS)
PS ==> Polynomial S
SIG ==> with
if PS has PatternMatchable(R) then
patternMatch : (CS, Pattern R, PMRS) -> PMRS
++ patternMatch(cexpr, pat, res) matches the pattern pat to the
++ complex expression cexpr. res contains the variables of pat
++ which are already matched and their matches.
CODE ==> add
import PatternMatchPushDown(R, S, CS)
import PatternMatchResultFunctions2(R, PS, CS)
import PatternMatchResultFunctions2(R, CS, PS)
ivar : PS := "%i"::Symbol::PS
makeComplex(p:PS):CS ==
up := univariate p
degree up > 1 => error "not linear in %i"
icoef:=leadingCoefficient(up)
rcoef:=leadingCoefficient(reductum p)
complex(rcoef,icoef)
makePoly(cs:CS):PS == real(cs)*ivar + imag(cs)::PS
if PS has PatternMatchable(R) then
patternMatch(cs, pat, result) ==
zero? imag cs =>
patternMatch(real cs, pat, result)
map(makeComplex,
patternMatch(makePoly cs, pat, map(makePoly, result)))
|