Site Menu Project Specification Implementation Recommendations Reference Needs Updating Work in Progress Wastebasket Wiki Manual |
LONGCOMPLEXDEFINITION MODULE LONGCOMPLEX [CTYPE]; (* Double Precision Complex Numbers *) FROM FileIO IMPORT File; (* required for IO *) (* LONGCOMPLEX type *) TYPE LONGCOMPLEX = RECORD re, im : LONGREAL; END; (* LONGCOMPLEX *) (* C-Type bindings to operators, pervasives and primitives: *) (* Monadic arithmetic operations *) PROCEDURE [ABS] abs ( z : LONGCOMPLEX ) : LONGCOMPLEX; (* Returns the absolute value of LONGCOMPLEX value z. This function is bound to pervasive function ABS for type LONGCOMPLEX. *) PROCEDURE [NEG] neg ( z : LONGCOMPLEX ) : LONGCOMPLEX; (* Returns the sign reversed value of LONGCOMPLEX value z. This function is bound to the unary minus operator for type LONGCOMPLEX. *) (* Dyadic arithmetic operations *) PROCEDURE [+] add ( z1, z2 : LONGCOMPLEX ) : LONGCOMPLEX; (* Adds LONGCOMPLEX values z1 and z2 and returns the result. This function is bound to the + operator for type LONGCOMPLEX. *) PROCEDURE [-] sub ( z1, z2 : LONGCOMPLEX ) : LONGCOMPLEX; (* Subtracts LONGCOMPLEX value z2 from z1 and returns the result. This function is bound to the - operator for type LONGCOMPLEX. *) PROCEDURE [*] multiply ( z1, z2 : LONGCOMPLEX ) : LONGCOMPLEX; (* Multiplies LONGCOMPLEX values z1 and z2 and returns the result. This function it bound to the * operator for type LONGCOMPLEX. *) PROCEDURE [/] divide ( z1, z2 : LONGCOMPLEX ) : LONGCOMPLEX; (* Divives LONGCOMPLEX value z1 by z2 and returns the result. This function is bound to the / operator for type LONGCOMPLEX. *) (* Relational operations *) PROCEDURE [=] isEqual ( z1, z2 : LONGCOMPLEX ) : BOOLEAN; (* Returns TRUE if LONGCOMPLEX values z1 and z2 are equal, otherwise FALSE. This function is bound to operators = and # for type LONGCOMPLEX. *) (* IO operations *) PROCEDURE Read( infile : File; VAR z : LONGCOMPLEX ); (* Reads the textual representation of a LONGCOMPLEX value from stream infile - any leading whitespace is skipped - any remaining characters that are part of the numeral being read are removed from infile - the numeric value of the numeral string read is assigned to the variable passed in for z - the file status is set to any of: success, outOfRange, wrongFormat, endOfLine, or endOfInput. This procedure is substituted for invocations of READ with a LONGCOMPLEX argument. *) PROCEDURE Write( outfile : File; CONST z : LONGCOMPLEX ); (* Writes the textual representation of value z to stream outfile. This pro- cedure is substituted for invocations of WRITE with a LONGCOMPLEX argument.*) PROCEDURE WriteF ( outfile : File; CONST fmtStr : ARRAY OF CHAR; items : VARIADIC OF CONST LONGCOMPLEX ); (* Writes a formatted textual representation of one or more LONGCOMPLEX values to output stream outfile. The output format is determined by fmtStr. This procedure is substituted for invocations of WRITEF with one or more LONGCOMPLEX arguments. *) END LONGCOMPLEX. |