Pascal-XSC |

Institut für Angewandte Mathematik, Forschungsschwerpunkt CAVN, Universität KarlsruheThe programming language PASCAL-XSC was developed to supply a powerful tool for the numerical solution of scientific problems based upon a properly defined and implemented computer arithmetic in the usual spaces of numerical computation. The main concepts of PASCAL-XSC are

Wissenschaftliches Rechnen/Softwaretechnologie, Universität Wuppertal

Interval arithmetic, complex arithmetic, complex interval arithmetic, and the corresponding vector and matrix arithmetics are provided. Application modules have been implemented in PASCAL-XSC for solving common numerical problems, such as

- Linear systems of equations
- Matrix inversion
- Nonlinear systems of equations
- Eigenvalues and eigenvectors
- Evaluation of arithmetic expressions
- Evaluation of polynomials and zeros of polynomials
- Numerical quadrature
- Initial and boundary value problems in ordinary differential equations
- Integral equations
- Automatic differentiation
- Optimization problems

In the subsequent paragraphs, the most important new concepts are considered briefly.

in Standard PASCAL, the addition of two polynomials is implemented as aconst maximum_degree = 20;

type polynomial = array [0..maximum_degree] of real;

Several calls ofprocedure add (a, b: polynomial; var c: polynomial); { Computes c = a + b for polynomials } var i: integer; begin for i:= 0 to maximum_degree do c[i]:= a[i] + b[i]; end;

In PASCAL-XSC, we define aadd (a,b,z); add (z,c,z); add (z,d,z);

Now, the expression z = a + b + c + d may be computed asfunction add (a, b: polynomial): polynomial; { Delivers the sum a + b for polynomials } var i: integer; begin for i:= 0 to maximum_degree do add[i]:= a[i] + b[i]; end;

Even clearer is thez:= add(a,add(b,add(c,d)))

Now, the expression may be written in the common mathematical notationoperator + (a, b: polynomial) result_polynomial : polynomial; { Delivers the sum a + b for polynomials } var i: integer; begin for i:= 0 to maximum_degree do result_polynomial[i]:= a[i] + b[i]; end;

A programmer may also define a new name as an operator. A priority is assigned in a preceding priority declaration.z:= a+b+c+d

As illustrated above, operators may also be overloaded.
Even the assignment operator `:=` may be overloaded so that the mathematical
notation may be used for assignments:

var c: complex; r: real; operator := (var c : complex; r: real); begin c.re := r; c.im := 0; end; ... r:= 1.5; c:= r; {complex number with real part 1.5 and imaginary part 0}

module poly; use {other modules} ... {local declarations} ... {global declarations} global type polynomial = ... ... global procedure read (... ... global procedure write (... ... global operator + (... ... global operator * (... ... begin {initialization part of the module} ... end. {module poly}

When declaring variables of this dynamic type, the index bounds have to be specified:type polynomial = dynamic array [*] of real;

where the values of the expressions for the index range are computed during program execution. To get access to the bounds of dynamic arrays which are specified only during execution of the program, the two functionsvar p, q : polynomial [0..2*n];

A PASCAL-XSC program using dynamic arrays for polynomials follows the templateoperator * (a, b: polynomial) product: polynomial[0..ubound(a)+ubound(b)]; { Delivers the product a * b of two polynomials a, b } var i, j : integer; result : polynomial[0..ubound(a)+ubound(b)]; begin for i:= 0 to ubound(a)+ubound(b) do result[i]:= 0; for i:= 0 to ubound(a) do for j:= 0 to ubound(b) do result[i+j]:= result[i+j] + a[i] * b[j]; product:= result; end;

The following example demonstrates that it is possible to access a row or a column of dynamic arrays as a single object. This is calledprogram dynatest (input, output); ... type polynomial = dynamic array [*] of real; ... var maximum_degree : integer; ... operator * (a, b:polynomial)... ... procedure write (var f : text; p: polynomial); ... procedure main (degree : integer); var p,q : polynomial[0..degree]; r : polynomial[0..2*degree]; begin ... r:= p * q; writeln ('p*q = ', r); ... end; begin {main program} read (maximum_degree); main (maximum_degree); end. {main program}

Current releases (Version 3.0 and higher) of PASCAL-XSC include the concept oftype vector = dynamic array [*] of real; type matrix = dynamic array [*] of vector; var v : vector[1..n]; m : matrix[1..n,1..n]; ... v := m[i]; { i-th row of m } m[*,j] := v; { j-th column of m }

For a detailed description of flexible arrays, see the references below.type vector = dynamic array [*] of real; procedure high_accuracy (basic_length: integer; result: real); var accurate : boolean; rvec : vector; k : integer; begin accurate := false; k := 0; repeat k:= k+1; allocate (rvec, 1..k*basic_length); ... { computations } accurate := ... free (rvec); { might be omitted } until accurate; result := ... end;

http://www2.math.uni-wuppertal.de/wrswt/xsc/pxsc_download.html

or

http://www.xsc.de