!standard G.3.1 07-06-21 AI05-0047-1/02 !standard G.3.2 !class binding interpretation 07-04-04 !status work item 07-04-04 !status received 07-04-04 !priority Medium !difficulty Easy !qualifier Clarification !subject Annoyances in the array packages !summary TBD !question I am using this AI to record a number of annoyances or bugs that I encountered during the implementation of the array packages. 1 - The multiplication of matrices is defined to "involve inner products" (G.3.1(56/2)). In strict mode, this requires that each component of the result comply with the requirements of G.3.1(83/2-84/2). Technically this is known as a "componentwise" error bound. An algorithm that gives a componentwise error bound is necessarily cubic (i.e., in O(N**3)). There exist however algorithms for multiplying matrices that are sub-cubic (e.g., Strassen's method) but these algorithms give normwise error bounds, meaning that the error on one component may spill over other components. Some variants of BLAS and other widely-used linear algebra libraries use fast matrix multiplication algorithms, so the accuracy requirements makes it impossible to implement Generic_Real_Arrays by interfacing to these libraries. 2 - The definition of Eigensystem does not impose any constraint on the length of the out parameters Values and Vectors. Instead it has the mysterious sentence "The index ranges of the parameter Vectors are those of A". It is written as if Eigensystem had a way to change the constraints of Vectors, which is evidently false. It would seem that it should require that Values'Length, Vectors'Length(1) and Vectors'Length(2) be all equal and equal to A'Length(1). 3 - For some matrices, the QR iteration used to compute the eigenvalues will just not converge (no deflation will happen). While it is always possible to let it run forever, it is typical in this case to give up after some number of iterations. The RM makes no provision for raising an exception. The values computed for (some of) the eigenvalues may be really bogus, so it would be better to raise an exception than to return garbage to the user. 4 - The index subtype for types Real_Vector and Real_Matrix is Integer. Presumably this was intended to provide maximum flexibility in selecting the index range. It has however unpleasant consequences. Consider: Identity: constant Real_Matrix := ((1.0, 0.0), (0.0, 1.0)); Anyone trying to evaluate Identity'First - 1 won't like the result. Why would anyone do that? Maybe to initialize a variable that will be used to iterate through the rows or column of the matrix. This is sure to bite many users, and using a slightly narrower index subtype would have been much wiser. 5 - G.3.2(75/2, 76/2) defines a function "abs" that returns the Hermitian L2-norm of a vector. However, the specification of this function is given as: function "abs" (Right : Complex_Vector) return Complex; The norm of a vector is always a (nonnegative) real number, so it doesn't make much sense to return a complex number here. This function should return a Real'Base. As a matter of fact it did in AI95-00418, but this AI was apparently incorrectly merged into the RM and Amendment. 6 - Section G.3.2 keeps talking about inner product, but never defines exactly what is meant by this term. This is significant because in a complex vector space the natural inner product is the Hermitian one, where the elements of the second vector are conjugated. It is unclear if the function "*" conjugates the elements of Right. ISO/IEC 13813 explicitly specified that "no complex conjugation is performed". While the "* operator defined by such a rule is not a true inner product, it is probably more appropriate in practice as it makes the conjugations explicit in the source: the user has to write X * Conjugate (Y) which mimics the mathematical notation where conjugation is always made explicit. At any rate, a clarification would be useful. !recommendation !wording !discussion !ACATS test !appendix ****************************************************************