Prev: Size of Vector limited to 1024 MB of Heap Size
Next: How to implement a server socket compatible to telnet?
From: Jeffrey R. Carter on 7 Aug 2008 15:13 amado.alves(a)gmail.com wrote: > > And Ada got in the way: slicing restricted to one-dimensional arrays! Compared to other languages that have no slicing at all? -- Jeff Carter "To Err is human, to really screw up, you need C++!" St�phane Richard 63
From: amado.alves on 8 Aug 2008 05:59 > > And Ada got in the way: slicing restricted to one-dimensional arrays! > > Compared to other languages that have no slicing at all? There are languages better than Ada at array indexing, including slicing. If there aren't, there should be! A bidimensional array like the standard Real_Matrix should be compatible with a unidimensional array like Real_Vector. One row (or one column) of a matrix is a vector. In fact aggregate notation reflects this Matrix := ( (a, b, c) , (d, e, f) , (g, h, i) ); Vector := (x, y, x); but then the obvious are illegal: Vector := Matrix (1); -- (a, b, c) or Band_Matrix := Matrix (1 .. 2); -- ( (a, b, c) , -- (d, e, f) ) A good language should even permit Vertical_Band_Matrix := Matrix (Matrix'Range, 1 .. 2); -- ( (a, b) , (d, e) , -- (g, h) ) or Block := Matrix (1 .. 2, 1 .. 2); -- ( (a, b) , -- (d, e) )
From: Dmitry A. Kazakov on 8 Aug 2008 06:38 On Fri, 8 Aug 2008 02:59:56 -0700 (PDT), amado.alves(a)gmail.com wrote: >>> And Ada got in the way: slicing restricted to one-dimensional arrays! >> >> Compared to other languages that have no slicing at all? > > There are languages better than Ada at array indexing, including > slicing. If there aren't, there should be! > > A bidimensional array like the standard Real_Matrix should be > compatible with a unidimensional array like Real_Vector. > One row (or one column) of a matrix is a vector. > In fact aggregate notation reflects this > > Matrix := ( (a, b, c) , > (d, e, f) , > (g, h, i) ); > > Vector := (x, y, x); > > but then the obvious are illegal: > > Vector := Matrix (1); -- (a, b, c) > > or > > Band_Matrix := Matrix (1 .. 2); -- ( (a, b, c) , > -- (d, e, f) ) > > A good language should even permit > > Vertical_Band_Matrix := Matrix (Matrix'Range, 1 .. 2); -- ( (a, b) , > (d, e) , > -- (g, h) ) > or > > Block := Matrix (1 .. 2, 1 .. 2); -- ( (a, b) , > -- (d, e) ) A good language should support keyed notation of array indices: Vector := Matrix (Column => 1); -- (a, d, g) type Matrix is array (Row, Column : Positive range <>) of Float; It also should provide index types: type Square is index (Row, Column : Positive range <>); type Matrix is array (Square) of Float; and type Matrix is array (Row, Column : Positive range <>) of Float; subtype Square is Matrix'Index; and iteration for I in M'Index loop -- Zeroes all matrix M (I) := 0.0; end loop; and enumeration case A'Index is when (1,1) | (2,2) => ... when others => ... end case; and array aggregates ((1,1)=>0.0, (1,2)=>...); -- Flat notation The value of an index type is a tuple. Elements of the tuple are ranges and individual indices. All operations you mentioned above are compositions of the corresponding slicing of the index type and then indexing the array by the index. The result of indexing depends on the index type: A (1, 2) -- Element, dimension 0 A (1..1, 2) -- Vector, dimension 1 A (1..1, 2..2) -- Matrix, dimension 2 There also has to be range types and range values. Last but not least, a good language should allow reasonable array renaming with bounds slicing. Array renaming in Ada is bogus. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
From: Georg Bauhaus on 8 Aug 2008 07:35 amado.alves(a)gmail.com schrieb: >>> And Ada got in the way: slicing restricted to one-dimensional arrays! >> Compared to other languages that have no slicing at all? > > There are languages better than Ada at array indexing, including > slicing. If there aren't, there should be! Ada is a systems programming language. As such, it is targetting digital computers. In cases where Ada can be used for some mathematical tasks, it is still a systems programming language. You could just ask for a type system that allows assignment to diagonals of matrices, upper triangles, switch from row order to column order right in the type system and so on. (And, I guess, per DK, have these type based mechanisms be construction facilities for the programmer, with default implementations only). Ada is about computers that have word/byte adressable storage cells that happen to be able to store bit combinations. Ada is not about cells of mathematical abstractions. Overlap is accidental. If you do already have some theory for your graphs, and presuming you need a working program for large matrices, I'd suggest that you seriously consider prototyping your algorithms using one of the fine PLs that do have the required mathematical stuff built in. (The various APLs, some of which are specializing or certain large data sets, come to mind; Mathematica, and so on.) You can always concentrate on an specially efficient Ada implementation later. Ada is a systems programming language for digital computer systems performing close-to-the-hardware tasks, not mathematics. -- Georg Bauhaus Y A Time Drain http://www.9toX.de
From: Jean-Pierre Rosen on 8 Aug 2008 07:29
amado.alves(a)gmail.com a �crit : >>> And Ada got in the way: slicing restricted to one-dimensional arrays! >> Compared to other languages that have no slicing at all? > > There are languages better than Ada at array indexing, including > slicing. If there aren't, there should be! > AFAIK, Fortran90 has very sophisticated slicing of arrays. The only thing I heard about it, is that it was so complicated to define and use that it was a major reason why there are so few Fortran90 compilers... Language design is about balancing features, usefulness, and implementability. -- --------------------------------------------------------- J-P. Rosen (rosen(a)adalog.fr) Visit Adalog's web site at http://www.adalog.fr |