% 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} %