comp.lang.ada
 help / color / mirror / Atom feed
From: Gustaf Thorslund <gustaf@thorslund.org>
Subject: X : Real_Vector := Solve(A => A, X => B); -- Why X as argument name?
Date: Sun, 23 Dec 2012 23:28:13 +0100
Date: 2012-12-23T23:28:13+01:00	[thread overview]
Message-ID: <871uegmmiq.fsf@katthult.thorslund.org> (raw)

-- 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?



             reply	other threads:[~2012-12-23 22:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-23 22:28 Gustaf Thorslund [this message]
2012-12-24  8:33 ` X : Real_Vector := Solve(A => A, X => B); -- Why X as argument name? Niklas Holsti
2012-12-24 11:50   ` Simon Wright
2012-12-24 12:58     ` Niklas Holsti
2012-12-24 21:25     ` Gustaf Thorslund
2012-12-24 20:42   ` Gustaf Thorslund
2012-12-24 20:10 ` jpwoodruff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox