From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4246083efae0e43b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: aschwarz@acm.org (skidmarks) Newsgroups: comp.lang.ada Subject: Re: Singular Value Decomposition (SVD) Ada Algorithm Date: 1 Nov 2004 08:17:36 -0800 Organization: http://groups.google.com Message-ID: <35f054ea.0411010817.52bbf8fc@posting.google.com> References: <35f054ea.0410290918.5f7f7d0@posting.google.com> <34defe4d.0410300854.5c038648@posting.google.com> <35f054ea.0410302259.7510a56e@posting.google.com> <34defe4d.0410311001.36e3680@posting.google.com> NNTP-Posting-Host: 199.46.200.230 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1099325856 8273 127.0.0.1 (1 Nov 2004 16:17:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 1 Nov 2004 16:17:36 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:5955 Date: 2004-11-01T08:17:36-08:00 List-Id: > <...> I developed a > > doubly-linked list. List management is a normal package body. The > > generic package provides space, in the generic body, and interfaces to > > the non-generic list manager. The effect is to have a no-cost generic > > package interfacing with a shared non-generic package. > > I'm not sure I followed that claim; you might consider posting an > example (folks here are pretty constructive, so you won't get > pilloried :) Sorry. To be brief: 1. Optimization of data via generics was avoided. All data is 32-bits. The rationale is: a. If size optimized and packed, more instructions are required during operation for (un)packing operations, which increases total size, and with more instructions there is decreased performance. (The size is relative and depends on use. Performance is bad.) b. If size optimized and unpacked, then depending on the CPU, slack bytes are added which increases the size. c. By making all sizes the same, the issue becomes movement into and out of the fixed size datum field. 2. The List Manager handles all list operations, insertion, deletion, data changes, and is invariant to any application. 3. The generics: a. Handles transmission of data to/from cell datum fields. b. Creates a free list (an array of cells) in the generic body. c. At instantiation, populate the free list. d. Provide an interface to the List Manager and some application niceties not supported by the List Manager. At the end, the generic functions are all pragma inline and reference the List Manager. Data specific issues are addressed in the generic package which converts data from the user type to the List Manager type via an Unchecked_Conversion, which I assume requires the generation of no code for data which have the same size. The application then does (something like): (Ada like not like Ada): package List is new Generic (data_type); begin Cell := List.Push(local data); Cell := List.Delete(Cell); List.etc end <>; A List Manager equivalent function is: function Push( List, Cell ) return Cell_Adr_Ptr; and the Generic functions which make this happen is: function Push( Data ) return Cell_Adr_Ptr is begin return List_Manager.Push( List, Set_Data( Unchecked_Conversion(Data), NUCELL)); end Push; pragma inline ( Push ); where: NUCELL creates a new cell from the available space list Set_Data puts a datum into a cell List is known only to the generic (the list is created in the generic body. And sorry, this is way too long winded. The final result is that there is a division of responsibility which (I believe) provides an adequate level of encapsulation and information hiding while giving some application level conveniences. The generic acts as a no-cost intermediate level (no code or very little code) to the general purpose list manager functions. There is always room for comment and architectural changes. A dialog will always be appreciated. art