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,380d5dcaa525139c,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.86.201 with SMTP id r9mr9866660wiz.4.1356837411684; Sat, 29 Dec 2012 19:16:51 -0800 (PST) Path: i11ni337243wiw.0!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!newsreader4.netcologne.de!news.netcologne.de!feeder.erje.net!eu.feeder.erje.net!newsfeed.straub-nv.de!reality.xs3.de!news.jacob-sparre.dk!hugin.jacob-sparre.dk!news.thorslund.org!pnx.dk!not-for-mail From: Gustaf Thorslund Newsgroups: comp.lang.ada Subject: X : Real_Vector := Solve(A => A, X => B); -- Why X as argument name? Date: Sun, 23 Dec 2012 23:28:13 +0100 Organization: gustaf.thorslund.org Message-ID: <871uegmmiq.fsf@katthult.thorslund.org> NNTP-Posting-Host: localhost Mime-Version: 1.0 X-Trace: katthult.thorslund.org 1356301693 3045 ::1 (23 Dec 2012 22:28:13 GMT) X-Complaints-To: usenet@thorslund.org NNTP-Posting-Date: Sun, 23 Dec 2012 22:28:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:/M5x1Nv6Gup44dcdASjvTZ37++k= Content-Type: text/plain; charset=us-ascii Date: 2012-12-23T23:28:13+01:00 List-Id: -- why_x.adb by confused Gustaf Thorslund with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays; with Ada.Text_IO; use Ada.Text_IO; procedure Why_X is -- Let's say we have an equation Ax = b according to the notation from -- http://en.wikipedia.org/wiki/Matrix_(mathematics)#Linear_equations -- where A and b are known while x is unknown. A : Real_Matrix(1..1, 1..1) := (others => (others => 2.0)); B : Real_Vector(1..1) := (others => 12.0); -- x is found using -- function Solve (A : Real_Matrix; X : Real_Vector) return -- Real_Vector; X : Real_Vector := Solve(A => A, X => B); -- Why X as argument name? begin for I in X'Range loop Put_Line(Float'Image(X(I))); end loop; end Why_X; -- Executing the program gives -- $ ./why_x -- 6.00000E+00 -- So we found the expected value of x. -- Was it a misstake to use X as argument name in Solve?