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
|
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\BasicOperatorXmpTitle}{BasicOperator}
\newcommand{\BasicOperatorXmpNumber}{9.3}
%
% =====================================================================
\begin{page}{BasicOperatorXmpPage}{9.3 BasicOperator}
% =====================================================================
\beginscroll
%
A basic operator is an object that can be symbolically
applied to a list of arguments from a set, the result being
a kernel over that set or an expression.
In addition to this section, please see \downlink{`Expression'}{ExpressionXmpPage}\ignore{Expression}
and \downlink{`Kernel'}{KernelXmpPage}\ignore{Kernel} for additional information and examples.
You create an object of type \axiomType{BasicOperator} by using the
\axiomFunFrom{operator}{BasicOperator} operation.
This first form of this operation has one argument and it
must be a symbol.
The symbol should be quoted in case the
name has been used as an identifier to which a value
has been assigned.
A frequent application of \axiomType{BasicOperator} is the
creation of an operator to represent the unknown function when
solving a differential equation.
\xtc{
Let \axiom{y} be the unknown function in terms of \axiom{x}.
}{
\spadpaste{y := operator 'y \bound{y}}
}
%
\xtc{
This is how you enter
the equation \axiom{y'' + y' + y = 0}.
}{
\spadpaste{deq := D(y x, x, 2) + D(y x, x) + y x = 0\bound{e1}\free{y}}
}
%
\xtc{
To solve the above equation, enter this.
}{
\spadpaste{solve(deq, y, x) \free{e1}\free{y}}
}
See \downlink{``\ugProblemDEQTitle''}{ugProblemDEQPage} in Section \ugProblemDEQNumber\ignore{ugProblemDEQ}
for this kind of use of \axiomType{BasicOperator}.
Use the single argument form of
\axiomFunFrom{operator}{BasicOperator} (as above) when you intend
to use the operator to create functional expressions with an
arbitrary number of arguments
\xtc{
{\it Nary} means an arbitrary number of arguments can be used
in the functional expressions.
}{
\spadpaste{nary? y \free{y}}
}
\xtc{
}{
\spadpaste{unary? y \free{y}}
}
Use the two-argument form when you want to restrict the number of
arguments in the functional expressions created with the operator.
\xtc{
This operator can only be used to create functional expressions
with one argument.
}{
\spadpaste{opOne := operator('opOne, 1) \bound{opOne}}
}
\xtc{
}{
\spadpaste{nary? opOne \free{opOne}}
}
\xtc{
}{
\spadpaste{unary? opOne \free{opOne}}
}
\xtc{
Use \axiomFunFrom{arity}{BasicOperator} to learn the number of
arguments that can be used.
It returns {\tt "false"} if the operator is nary.
}{
\spadpaste{arity opOne \free{opOne}}
}
\xtc{
Use \axiomFunFrom{name}{BasicOperator} to learn the name of an
operator.
}{
\spadpaste{name opOne \free{opOne}}
}
\xtc{
Use \axiomFunFrom{is?}{BasicOperator} to learn if an operator has a
particular name.
}{
\spadpaste{is?(opOne, 'z2) \free{opOne}}
}
\xtc{
You can also use a string as the name to be tested against.
}{
\spadpaste{is?(opOne, "opOne") \free{opOne}}
}
You can attached named properties to an operator.
These are rarely used at the top-level of the \Language{}
interactive environment but are used with \Language{}
library source code.
\xtc{
By default, an operator has no properties.
}{
\spadpaste{properties y \free{y}}
}
The interface for setting and getting properties is somewhat awkward
because the property values are stored as values of type
\axiomType{None}.
\xtc{
Attach a property by using \axiomFunFrom{setProperty}{BasicOperator}.
}{
\spadpaste{setProperty(y, "use", "unknown function" :: None ) \free{y}\bound{spy}}
}
\xtc{
}{
\spadpaste{properties y \free{y spy}}
}
\xtc{
We {\it know} the property value has type \axiomType{String}.
}{
\spadpaste{property(y, "use") :: None pretend String \free{y spy}}
}
\xtc{
Use \axiomFunFrom{deleteProperty!}{BasicOperator} to destructively
remove a property.
}{
\spadpaste{deleteProperty!(y, "use") \free{y spy}\bound{dpy}}
}
\xtc{
}{
\spadpaste{properties y \free{dpy}}
}
\endscroll
\autobuttons
\end{page}
%
|