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: a07f3367d7,bf03d731a6ef511f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!news2.arglkargh.de!news.tornevall.net!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Copying rows in a two dimensional array. Date: Sun, 31 Jan 2010 21:42:28 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <4b6637a1$0$4586$4d3efbfe@news.sover.net> NNTP-Posting-Host: 1b42cef8d1508194c4902a4e5cc4a667 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: 04f220009ace2086633ad63d22385067 X-Complaints-To: abuse@tornevall.net X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: <4b6637a1$0$4586$4d3efbfe@news.sover.net> X-Validate-Post: http://news.tornevall.net/validate.php?trace=04f220009ace2086633ad63d22385067 X-SpeedUI: 1738 X-Complaints-Italiano: Parlo la lingua non � italiano User-Agent: Thunderbird 2.0.0.23 (X11/20090817) X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: g2news1.google.com comp.lang.ada:8843 Date: 2010-01-31T21:42:28-07:00 List-Id: Peter C. Chapin wrote: > > type Matrix is array(Positive range <>, Positive range <>) of Floating_Type; > > I need to exchange two rows in this array. What I'd like to do is something > along these lines: > > Temp_Array := A(I, 1 .. Size); > A(I, 1 .. Size) := A(K, 1 .. Size); > A(K, 1 .. Size) := Temp_Array; > > The compiler (GNAT GPL 2009) has a problem with this syntax and, after looking > into it some, I think that's because slicing only works for one dimensional > arrays. Fair enough. That's correct: slicing is only defined for one-D arrays. > So I thought, "Perhaps A needs to be an array of arrays." > > type Matrix is array(Positive range <>) of WHAT_EXACTLY? Row_Vector? > Apparently the component type of an array needs to be fully constrained (which > again makes sense) yet I don't know the size I'll want to use at the point > where this type is declared. Correct again: array components must be definite. I'm not aware of a solution other than the brute force approach. -- Jeff Carter "Gentlemen, you can't fight in here. This is the War Room!" Dr. Strangelove 30