The HilbertMatrix Maplet application provides a graphical interface to the LinearAlgebra[HilbertMatrix] function.

Given an offset , the Hilbert matrix is a matrix with entries . The default value is . The only outputoption that can be used in this case is to set the matrix to readonly. By using user input, this procedure returns the calling sequence required to generate the desired Hilbert matrix or evaluates the result.

Thus, the Maplet application requests:

1. The row dimension.

2. The column dimension.

3. The offset.

4. Whether the matrix is read-only.

5. Whether the result is to be evaluated (or the calling sequence is to be returned).

Example Code

>

restart:

Invoke the Maplets Elements subpackage.

>

with(Maplets[Elements]):

This example displays a Maplet application that queries the user for the inputs required, and then processes the results.

The variable continue is used to determine whether a previous section failed as a result of errors in user input or a Cancel click in either Maplet application.

Once the result from the Maplet application has been returned, check if the user clicked Cancel (by checking for a result) or OK.If the user selected OK, attempt to parse the results. As well, if the results do not parse, query the user for a correction by using the Maplets[Examples][GetInput] routine.The values of the check boxes should always parse because each result is the string or .

Next, the parsed values should be checked to verify that they are of the correct type.

>

if continue then if not type( [r], ['nonnegint'] ) then continue := false; error "the 1st entry `%1` is not of type `%2`", result[1], 'nonnegint'; end if; if not type( [c], ['nonnegint'] ) then continue := false; error "the 2nd entry `%1` is not of type `%2`", result[2], 'nonnegint'; end if; if not type( [s], ['algebraic'] ) then continue := false; error "the 3rd entry `%1` is not of type `%2`", result[3], 'algebraic'; end if;end if;

Finally, we set the options, and assign the answer depending on whether the user requested an evaluation.For this example, since answer is global, it evaluates fully. The extra level of unevaluation quotes is not necessary inside a procedure.