Version 1.1 of ais/ai-00296.txt

Unformatted version of ais/ai-00296.txt version 1.1
Other versions for file ais/ai-00296.txt

!standard G (00)          02-06-07 AI95-00296/00
!class amendment 02-06-07
!status received 02-06-07
!priority Medium
!difficulty Medium
!subject Vector and matrix operations
The vector and matric operations in ISO/IEC 13813 should be added to Ada.Numerics in Annex G.
ACATS test(s) need to be created.


Recommendation on ISO/IEC 13813 from the UK

The standard ISO/IEC 13813 entitled generic packages of real and complex type
declarations and basic operations for Ada (including vector and matrix types)
will soon be up for review. This note reviews the background to the development
of the standard and makes a recommendation that the standard be revised.


The Numerics Working Group of WG9 met many times during the period when Ada 95
was being designed and produced a number of standards. They were faced with the
problem of whether to produce standards based on Ada 83 (87 in ISO terms) or
whether to base them on Ada 95 or subsume them into Ada 95. One dilemma was of
course that although Ada 95 was on the way nevertheless Ada 83 was expected to
continue in use for many years.

The standards are
  11430: Generic package of elementary functions for Ada.
  11729: Generic package of primitive functions for Ada.
  13813: Generic packages of real and complex type declarations and basic
         operations for Ada (including vector and matrix types).
  13814: Generic package of complex elementary functions for Ada.

11430 and 11729 are mentioned for completeness. They were published in 1994.
They were based entirely on Ada 83 and their facilities are provided in the Ada
95 core language. The elementary functions, 11430, became the package
Ada.Numerics.Generic_Elementary_Functions and the primitive functions, 11729,
became the various attributes such as 'Floor and 'Ceiling, and 'Exponent and
'Fraction. These two standards were withdrawn recently and need no further

The other two standards, 13813 and 13814, were published in 1998 and will soon
be up for review at the end of their five year period. Three possible fates can
befall a standard when it is reviewed. It can be withdrawn, revised or

In the case of 13814, the functionality is all incorporated into the Numerics
Annex of Ada 95 as the package
Ada.Numerics.Generic_Complex_Elementary_Functions. There are a few changes in
presentation because the Ada 95 package uses the generic package parameter
feature which of course did not exist in Ada 83. Nevertheless there seems
little point in continuing with 13814 and so at the Leuven meeting of WG9 it
was agreed to recommend that it be withdrawn.

However, the situation regarding 13813 is not so clear. Some of its
functionality is included in Ada 95 but quite a lot is not. The topics covered
are (1) a complex types package including various complex arithmetic
operations, (2) a real arrays package covering both vectors and matrices, (3) a
complex arrays package covering  both vectors and matrices, (4) a complex
input-output package.

The complex types package (1) became the package
Ada.Numerics.Generic_Complex_Types and the input-output package (4) became
Ada.Text_IO.Complex_IO. However, the array packages, both real and complex,
were not incorporated into the Ada 95 standard.

At the Leuven meeting, it was agreed that 13813 should not be withdrawn without
further study. The UK was asked to study whether small or large changes are
required in 13813 and to report back. The Ada Rapporteur Group would then
decide whether the functionality should be included in a future revision or
amendment to Ada 95.

This is the report from the UK.


It is recommended that 13813 be revised so that it only contains the
functionality not included in Ada 95.

The revised standard should contain two generic packages namely
Ada.Numerics.Generic_Real_Arrays and Ada.Numerics.Generic_Complex_Arrays.

There should also be standard non-generic packages corresponding to the
predefined types such as Float in an analogous manner to the standard packages
such as Ada.Numerics.Complex_Types and Ada.Numerics.Long_Complex_Types for
Float and Long_Float respectively.

The text of the Ada specifications of the two generic packages should be
essentially as given in the nonnormative Annex G of the existing standard
13813. (This Annex illustrates how the existing standard packages might be
rewritten using Ada 95. There is an error regarding the formal package
parameters which has been corrected in the revised text.)

There is an important issue regarding what should happen if there is a mismatch
in the array lengths of the parameters in a number of the subprograms provided
by the packages. For example if

   function "+" (Left, Right: Real_Vector) return Real_Vector

be called with parameters such that Left'Length /= Right'Length.

The existing standard raises the exception Array_Index_Error which is declared
alone in a package Array_Exceptions. The nonnormative Annex G shows this
exception incorporated into the package Ada.Numerics thereby producing an
incompatibility with the existing definition of Ada.Numerics.

We considered four possibilities regarding this exception
  1) Add Array_Index_Error to Ada.Numerics as in Annex G.
  2) Place Array_Index_Error in a new child package such as Ada.Numerics.Arrays.
  3) Eliminate Array_Index_Error and raise Constraint_Error instead.
  4) State that the behaviour with mismatched arrays is implementation-defined.

We concluded that
  Option (1) is undesirable because of incompatibility.
  Option (2) is feasible but one ought then to place the generic packages
  themselves into this package so that they become
  Ada.Numerics.Arrays.Generic_Real_Arrays and
  Ada.Numerics.Arrays.Generic_Complex_Arrays. This nesting is considered
  Option(3) gives the same behaviour as similar mismatching on predefined
  operations and although losing some specificacity has practical simplicity.
  Option (4) is disliked since gratuitous implementation-defined
  behaviour should be avoided.

We therefore recommend Option (3) that Constraint_Error be raised on
mismatching of parameters.

If the Ada95 standard itself be revised at some later date then consideration
should be given to incorporating the functionality of the revised 13813 into
the Numerics Annex.

Proposed text

The proposed normative text of the revised standard is distributed separately
as N404, Working Draft, Revision of ISO/IEC 13813. Note that the non-normative
rationale section remains to be completed and that consequently the
bibliography might need alterations to match.


We acknowledge the valuable assistance of Donald Sando, the editor of the
original standard, in the preparation of this recommendation.


Questions? Ask the ACAA Technical Agent