Up | Next | Tail |
The declaration realvalued may be used to restrict variables to the real numbers. The syntax is:
realvalued v1,...vn;
For such variables the operator impart gives the result zero. Thus, with
realvalued x,y;
the expression impart(x+sin(y)) is evaluated as zero. You may also declare an operator as real valued with the meaning, that this operator maps real arguments always to real values. Example:
operator h; realvalued h,x; impart h(x); 0 impart h(w); impart(h(w))
Such declarations are not needed for the standard elementary functions.
To remove the propery from a variable or an operator use the declaration notrealvalued with the syntax:
notrealvalued v1,...vn;
The boolean operator realvaluedp allows you to check if a variable, an operator, or an operator expression is known as real valued. Thus,
realvalued x; write if realvaluedp(sin x) then "yes" else "no"; write if realvaluedp(sin z) then "yes" else "no";
would print first yes and then no. For general expressions test the impart for checking the value range:
realvalued x,y; w:=(x+i*y); w1:=conj w; impart(w*w1); 0 impart(w*w); 2*x*y
Up | Next | Front |