Site Menu Project Specification Implementation Recommendations Reference Needs Updating Work in Progress Wastebasket Wiki Manual |
Type LONGCOMPLEXWiP.TypeLONGCOMPLEX HistoryHide minor edits - Show changes to output 2010-04-09 19:03
by -
Changed line 11 from:
LONGCOMPLEX = to:
LONGCOMPLEX = RECORD ("C-Type") Deleted lines 14-36:
(* unbound accessors for convenience *) PROCEDURE Re ( z : LONGCOMPLEX ) : LONGREAL; (* returns the real part of a complex number *) PROCEDURE Im ( z : LONGCOMPLEX ) : LONGREAL; (* returns the imaginary part of a complex number *) (* bound accessor and mutator *) PROCEDURE [.] component ( n : CARDINAL; z : LONGCOMPLEX ) : LONGREAL; (* Returns the value of the n-th component of complex number z *) PROCEDURE [!] setComponent ( n : CARDINAL; VAR z : LONGCOMPLEX; r : LONGREAL ); (* Overwrites the value of the n-th component of complex number z with r *) (* literal assignment *) CONST [{}] allowValueConstructors = TRUE; 2010-04-08 16:04
by -
Changed lines 17-21 from:
(* PROCEDURE Cmplx ( re, im : LONGREAL ) : LONGCOMPLEX; (* constructs a complex number from an ordered pair to:
(* unbound accessors for convenience *) Added lines 24-32:
(* bound accessor and mutator *) PROCEDURE [.] component ( n : CARDINAL; z : LONGCOMPLEX ) : LONGREAL; (* Returns the value of the n-th component of complex number z *) PROCEDURE [!] setComponent ( n : CARDINAL; VAR z : LONGCOMPLEX; r : LONGREAL ); (* Overwrites the value of the n-th component of complex number z with r *) 2010-04-06 17:06
by -
Deleted lines 16-20:
CONST [TYPE] semanticModel = 'C'; (* obsolete *) Changed line 19 from:
PROCEDURE Cmplx ( to:
PROCEDURE Cmplx ( re, im : LONGREAL ) : LONGCOMPLEX; Changed lines 31-33 from:
CONST [{}] allowValueConstructors = TRUE; CONST [:=] allowValueConstructors = TRUE; (* but this needs more checks *) to:
CONST [{}] allowValueConstructors = TRUE; 2010-04-05 12:19
by -
Changed lines 11-12 from:
LONGCOMPLEX = OPAQUE RECORD to:
LONGCOMPLEX = OPAQUE RECORD ("C-Type") re, (* real part *) Changed line 19 from:
CONST [TYPE] semanticModel = 'C'; to:
CONST [TYPE] semanticModel = 'C'; (* obsolete *) 2010-04-04 10:16
by -
Changed line 27 from:
PROCEDURE Re ( z : to:
PROCEDURE Re ( z : LONGCOMPLEX ) : LONGREAL; Changed line 30 from:
PROCEDURE Im ( z : to:
PROCEDURE Im ( z : LONGCOMPLEX ) : LONGREAL; 2010-04-04 10:15
by -
Changed lines 33-65 from:
(* Complex Numbers *) FROM FileIO IMPORT File; (* required for IO *) (* COMPLEX type *) TYPE COMPLEX = OPAQUE RECORD re : REAL; (* real part *) im : REAL; (* imaginary part *) END; (* number type *) CONST [TYPE] semanticModel = 'C'; (* constructor and accessors *) PROCEDURE Cmplx ( real, imag : REAL ) : COMPLEX; (* constructs a complex number from an ordered pair *) PROCEDURE Re ( z : COMPLEX ) : REAL; (* returns the real part of a complex number *) PROCEDURE Im ( z : COMPLEX ) : REAL; (* returns the imaginary part of a complex number *) to:
Deleted lines 39-79:
(* monadic arithmetic operations *) PROCEDURE [ABS] abs ( z : COMPLEX ) : COMPLEX; PROCEDURE [NEG] neg ( z : COMPLEX ) : COMPLEX; (* dyadic arithmetic operations *) PROCEDURE [+] add ( z1, z2 : COMPLEX ) : COMPLEX; PROCEDURE [-] sub ( z1, z2 : COMPLEX ) : COMPLEX; PROCEDURE [*] multiply ( z1, z2 : COMPLEX ) : COMPLEX; PROCEDURE [/] divide ( z1, z2 : COMPLEX ) : COMPLEX; (* relational operations *) PROCEDURE [=] isEqual ( z1, z2 : COMPLEX ) : BOOLEAN; (* IO operations, bound to READ, WRITE and WRITEF *) PROCEDURE Read( infile : File; VAR z : COMPLEX ); (* Reads the textual representation of a COMPLEX value in simple format from input 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 *) PROCEDURE Write( outfile : File; z : COMPLEX ); (* Writes the textual representation of COMPLEX value z in simple format to output stream outfile *) PROCEDURE WriteF( outfile : File; fmtStr : ARRAY OF CHAR; items : CARDINAL; VARIADIC v[items] OF z : COMPLEX ); (* Writes a formatted textual representation of one or more COMPLEX values to output stream outfile. The value of parameter items is calculated and inserted automatically. The output format is determined by fmtStr. *) END COMPLEX.@] 2010-04-04 10:02
by -
Added lines 33-112:
[@DEFINITION MODULE COMPLEX; (* Complex Numbers *) FROM FileIO IMPORT File; (* required for IO *) (* COMPLEX type *) TYPE COMPLEX = OPAQUE RECORD re : REAL; (* real part *) im : REAL; (* imaginary part *) END; (* number type *) CONST [TYPE] semanticModel = 'C'; (* constructor and accessors *) PROCEDURE Cmplx ( real, imag : REAL ) : COMPLEX; (* constructs a complex number from an ordered pair *) PROCEDURE Re ( z : COMPLEX ) : REAL; (* returns the real part of a complex number *) PROCEDURE Im ( z : COMPLEX ) : REAL; (* returns the imaginary part of a complex number *) (* literal assignment *) CONST [{}] allowValueConstructors = TRUE; (* either this or ... *) CONST [:=] allowValueConstructors = TRUE; (* but this needs more checks *) (* monadic arithmetic operations *) PROCEDURE [ABS] abs ( z : COMPLEX ) : COMPLEX; PROCEDURE [NEG] neg ( z : COMPLEX ) : COMPLEX; (* dyadic arithmetic operations *) PROCEDURE [+] add ( z1, z2 : COMPLEX ) : COMPLEX; PROCEDURE [-] sub ( z1, z2 : COMPLEX ) : COMPLEX; PROCEDURE [*] multiply ( z1, z2 : COMPLEX ) : COMPLEX; PROCEDURE [/] divide ( z1, z2 : COMPLEX ) : COMPLEX; (* relational operations *) PROCEDURE [=] isEqual ( z1, z2 : COMPLEX ) : BOOLEAN; (* IO operations, bound to READ, WRITE and WRITEF *) PROCEDURE Read( infile : File; VAR z : COMPLEX ); (* Reads the textual representation of a COMPLEX value in simple format from input 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 *) PROCEDURE Write( outfile : File; z : COMPLEX ); (* Writes the textual representation of COMPLEX value z in simple format to output stream outfile *) PROCEDURE WriteF( outfile : File; fmtStr : ARRAY OF CHAR; items : CARDINAL; VARIADIC v[items] OF z : COMPLEX ); (* Writes a formatted textual representation of one or more COMPLEX values to output stream outfile. The value of parameter items is calculated and inserted automatically. The output format is determined by fmtStr. *) END COMPLEX.@] 2010-04-04 09:33
by -
Changed lines 3-6 from:
(* FROM FileIO IMPORT to:
(* Double Precision Complex Numbers *) FROM FileIO IMPORT File; (* required for IO *) (* LONGCOMPLEX type *) Changed lines 12-13 from:
re : LONGREAL; to:
re : LONGREAL; (* real part *) im : LONGREAL; (* imaginary part *) Changed lines 24-27 from:
PROCEDURE Cmplx ( real, imag : (* constructs a complex from an ordered pair *) PROCEDURE Re ( z : to:
PROCEDURE Cmplx ( real, imag : LONGREAL ) : LONGCOMPLEX; (* constructs a complex number from an ordered pair *) PROCEDURE Re ( z : COMPLEX ) : LONGREAL; Changed line 30 from:
PROCEDURE Im ( z : to:
PROCEDURE Im ( z : COMPLEX ) : LONGREAL; Changed lines 56-61 from:
(* IO operations *) PROCEDURE (* [READ] *) to:
(* IO operations, bound to READ, WRITE and WRITEF *) PROCEDURE Read( infile : File; VAR z : LONGCOMPLEX ); Changed lines 64-87 from:
- the file status is set to any of PROCEDURE (* Writes the textual representation of PROCEDURE (* [WRITEF] *) WriteF( outfile : File; z : LONGCOMPLEX; n : CARDINAL); (* Writes the textual representation of z in scientific format showing n places after the decimal point to output stream outfile without padding. *) PROCEDURE (* [WRITEF] *) WriteFixed( (* Writes the textual representation of z in simple format with the decimal point at position i and showing n places after the decimal point to output stream outfile. (* unbound IO operations *) PROCEDURE WriteEng( outfile : File; z : LONGCOMPLEX; n, m, exp : CARDINAL ); (* Writes the textual representation of z in engineering format showing n places before and m places after the decimal point with exponent exp to output stream outfile without padding. Parameters m and exp are rounded to the nearest value of three. *) PROCEDURE WriteLedger( outfile : File; z : LONGCOMPLEX; i, n : CARDINAL ); (* Writes the textual representation of z in ledger format with the sign at position 0, the decimal point at position i and showing n places after the decimal point to output stream outfile to:
- the file status is set to any of success, outOfRange, wrongFormat, endOfLine, or endOfInput *) PROCEDURE Write( outfile : File; z : LONGCOMPLEX ); (* Writes the textual representation of LONGCOMPLEX value z in simple format to output stream outfile *) PROCEDURE WriteF( outfile : File; fmtStr : ARRAY OF CHAR; items : CARDINAL; VARIADIC v[items] OF z : LONGCOMPLEX ); (* Writes a formatted textual representation of one or more LONGCOMPLEX values to output stream outfile. The value of parameter items is calculated and inserted automatically. The output format is determined by fmtStr. *) 2010-04-04 09:30
by -
Added lines 13-18:
(* number type *) CONST [TYPE] semanticModel = 'C'; Changed lines 31-32 from:
(* to:
(* monadic arithmetic operations *) Changed line 38 from:
(* to:
(* dyadic arithmetic operations *) 2010-01-17 12:48
by -
Added lines 1-82:
[@DEFINITION MODULE LONGCOMPLEX; (* Complex Numbers *) FROM FileIO IMPORT File; TYPE LONGCOMPLEX = OPAQUE RECORD re : LONGREAL; im : LONGREAL; END; (* constructor and accessors *) PROCEDURE Cmplx ( real, imag : REAL ) : LONGCOMPLEX; (* constructs a complex from an ordered pair *) PROCEDURE Re ( z : LONGCOMPLEX ) : LONGREAL; (* returns the real part of a complex number *) PROCEDURE Im ( z : LONGCOMPLEX ) : LONGREAL; (* returns the imaginary part of a complex number *) (* unary arithmetic operations *) PROCEDURE [ABS] abs ( z : LONGCOMPLEX ) : LONGCOMPLEX; PROCEDURE [NEG] neg ( z : LONGCOMPLEX ) : LONGCOMPLEX; (* binary arithmetic operations *) PROCEDURE [+] add ( z1, z2 : LONGCOMPLEX ) : LONGCOMPLEX; PROCEDURE [-] sub ( z1, z2 : LONGCOMPLEX ) : LONGCOMPLEX; PROCEDURE [*] multiply ( z1, z2 : LONGCOMPLEX ) : LONGCOMPLEX; PROCEDURE [/] divide ( z1, z2 : LONGCOMPLEX ) : LONGCOMPLEX; (* relational operations *) PROCEDURE [=] isEqual ( z1, z2 : LONGCOMPLEX ) : BOOLEAN; PROCEDURE [#] isNotEqual ( z1, z2 : LONGCOMPLEX ) : BOOLEAN; (* IO operations *) PROCEDURE (* [READ] *) Read( infile : File; VAR z : LONGCOMPLEX ); (* Reads the textual representation of a LONGCOMPLEX value in simple format from input 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 allRight, outOfRange, wrongFormat, endOfLine, or endOfInput *) PROCEDURE (* [WRITE] *) Write( outfile : File; z : LONGCOMPLEX ); (* Writes the textual representation of z in scientific format showing nine places after the decimal point to output stream outfile without padding. *) PROCEDURE (* [WRITEF] *) WriteF( outfile : File; z : LONGCOMPLEX; n : CARDINAL); (* Writes the textual representation of z in scientific format showing n places after the decimal point to output stream outfile without padding. *) PROCEDURE (* [WRITEF] *) WriteFixed( outfile : File; z : LONGCOMPLEX; i, n : CARDINAL ); (* Writes the textual representation of z in simple format with the decimal point at position i and showing n places after the decimal point to output stream outfile. (* unbound IO operations *) PROCEDURE WriteEng( outfile : File; z : LONGCOMPLEX; n, m, exp : CARDINAL ); (* Writes the textual representation of z in engineering format showing n places before and m places after the decimal point with exponent exp to output stream outfile without padding. Parameters m and exp are rounded to the nearest value of three. *) PROCEDURE WriteLedger( outfile : File; z : LONGCOMPLEX; i, n : CARDINAL ); (* Writes the textual representation of z in ledger format with the sign at position 0, the decimal point at position i and showing n places after the decimal point to output stream outfile. *) END LONGCOMPLEX.@] |