comp.lang.ada
 help / color / mirror / Atom feed
* X : Real_Vector := Solve(A => A, X => B); -- Why X as argument name?
@ 2012-12-23 22:28 Gustaf Thorslund
  2012-12-24  8:33 ` Niklas Holsti
  2012-12-24 20:10 ` jpwoodruff
  0 siblings, 2 replies; 7+ messages in thread
From: Gustaf Thorslund @ 2012-12-23 22:28 UTC (permalink / 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?



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-12-24 21:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-23 22:28 X : Real_Vector := Solve(A => A, X => B); -- Why X as argument name? Gustaf Thorslund
2012-12-24  8:33 ` 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

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