[BACK]Return to multprec_complex_solutions.ads CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Homotopy

Annotation of OpenXM_contrib/PHC/Ada/Homotopy/multprec_complex_solutions.ads, Revision 1.1.1.1

1.1       maekawa     1: with Standard_Complex_Numbers;
                      2: with Standard_Complex_Solutions;
                      3: with Multprec_Floating_Numbers;          use Multprec_Floating_Numbers;
                      4: with Generic_Lists;
                      5: with Multprec_Complex_Numbers;           use Multprec_Complex_Numbers;
                      6: with Multprec_Complex_Vectors;           use Multprec_Complex_Vectors;
                      7:
                      8: package Multprec_Complex_Solutions is
                      9:
                     10: -- DESCRIPTION :
                     11: --   This package provides an abstraction of a list and an array
                     12: --   of solutions as vectors of multi-precision complex numbers.
                     13:
                     14: -- DATA STRUCTURES :
                     15:
                     16:   type Solution ( n : natural ) is record
                     17:     t : Standard_Complex_Numbers.Complex_Number;
                     18:                                 -- continuation parameter t
                     19:     m : natural;                -- multiplicity of the solution
                     20:     v : Vector(1..n);           -- the solution
                     21:     err : Floating_Number;      -- error = |correction| from Newton
                     22:     rco : Floating_Number;      -- inverse of condition number
                     23:     res : Floating_Number;      -- norm of residual vector
                     24:   end record;
                     25:
                     26:   type Link_to_Solution is access Solution;
                     27:
                     28:   package List_of_Solutions is new Generic_Lists(Link_to_Solution);
                     29:   type Solution_List is new List_of_Solutions.List;
                     30:
                     31:   type Solution_Array is array ( positive range <> ) of Link_to_Solution;
                     32:
                     33: -- CREATORS :
                     34:
                     35:   function Create ( sl : Solution_List ) return Solution_Array;
                     36:   function Create ( sa : Solution_Array ) return Solution_List;
                     37:
                     38:   -- DESCRIPTION :
                     39:   --   Allows the transition from a list to an array and vice versa.
                     40:
                     41:   function Create ( s : Standard_Complex_Solutions.Solution )
                     42:                   return Multprec_Complex_Solutions.Solution;
                     43:
                     44:   -- DESCRIPTION :
                     45:   --   Converts the solution as a standard complex vector into a
                     46:   --   representation that uses multi-precision numbers.
                     47:
                     48:   function Create ( l : Standard_Complex_Solutions.Solution_List )
                     49:                   return Multprec_Complex_Solutions.Solution_List;
                     50:
                     51:   -- DESCRIPTION :
                     52:   --   Converts the list of solutions as standard vectors into a
                     53:   --   representation that uses multi-precision numbers.
                     54:
                     55: -- COMPARISON and COPYING :
                     56:
                     57:   function Equal ( s1,s2 : Solution; tol : Floating_Number ) return boolean;
                     58:
                     59:   -- DESCRIPTION :
                     60:   --   Returns true if for each component
                     61:   --   |s1.v(i)-s2.v(i)|/|s1.v(i)| < tol, for i in s1.v'range.
                     62:
                     63:   function Equal ( s1,s2 : Solution_List; tol : Floating_Number )
                     64:                  return boolean;
                     65:   function Equal ( s1,s2 : Solution_Array; tol : Floating_Number )
                     66:                  return boolean;
                     67:
                     68:   -- DESCRIPTION :
                     69:   --   Returns true if both lists of arrays are equal to each other, upon
                     70:   --   the given tolerance for the relative error.
                     71:
                     72:   procedure Equals ( sols : in out Solution_List; flag : in natural;
                     73:                      tol : in Floating_Number; same : out boolean );
                     74:   -- DESCRIPTION :
                     75:   --   The solutions that are equal to each other are marked with a flag.
                     76:
                     77:   procedure Equals ( sa : in Solution_Array; x : in Vector; i : in natural;
                     78:                      tol : in Floating_Number; j : in out natural );
                     79:   -- DESCRIPTION :
                     80:   --   Compares the first i-1 vectors in sa with x.
                     81:
                     82:   -- ON ENTRY :
                     83:   --   sa        a solution array, containing at least i-1 elements;
                     84:   --   x         a vector;
                     85:   --   i         an index, normally the entry of x in sa;
                     86:   --   tol       tolerance for relative error on two vectors;
                     87:   --   j         must be equal to sa'first.
                     88:
                     89:   -- ON RETURN :
                     90:   --   j         the entry for which sa(j) equals x.
                     91:
                     92:   procedure Copy ( s1 : in Solution; s2 : in out Solution );
                     93:
                     94:   -- DESCRIPTION :
                     95:   --   Makes a deep copy of the solution s1 into the solution s2.
                     96:
                     97:   procedure Copy ( s1 : in Solution_List; s2 : in out Solution_List );
                     98:   procedure Copy ( s1 : in Solution_Array; s2 : in out Solution_Array );
                     99:
                    100:   -- DESCRIPTION :
                    101:   --   Makes a deep copy of the list or the array of solutions.
                    102:
                    103: -- SELECTORS :
                    104:
                    105:   function Number ( sols : Solution_List; flag : natural ) return natural;
                    106:
                    107:   -- DESCRIPTION :
                    108:   --   Returns the number of solutions in the list with a multiplicity
                    109:   --   equal to flag.
                    110:
                    111:   function Is_In ( sols : Solution_List; s : Solution; tol : Floating_Number )
                    112:                 return boolean;
                    113:   function Is_In ( sa : Solution_Array; s : Solution; tol : Floating_Number )
                    114:                 return boolean;
                    115:
                    116:   -- DESCRIPTION :
                    117:   --   Returns true if the solution s belongs to the list or to the array.
                    118:
                    119:   function Get ( sols : Solution_List; pos : positive ) return Solution;
                    120:
                    121:   -- DESCRIPTION :
                    122:   --   Returns the solution at the given position.
                    123:
                    124:   -- REQUIRED : pos <= Length_Of(sols).
                    125:
                    126: -- CONSTRUCTORS :
                    127:
                    128:   procedure Append ( first,last : in out Solution_List; s : in Solution );
                    129:
                    130:   -- DESCRIPTION :
                    131:   --   The solution sol is appended to the list first;
                    132:   --   last is a pointer to the last element of the list first.
                    133:
                    134:   procedure Add ( sols : in out Solution_List; s : in Solution );
                    135:
                    136:   -- DESCRIPTION :
                    137:   --   The solution sol is appended to the list sols.
                    138:
                    139:   procedure Add ( sols : in out Solution_List; s : in Solution;
                    140:                   tol : in Floating_Number; other : out natural );
                    141:
                    142:   -- DESCRIPTION :
                    143:   --   Append the solution to the list, if it does not already belong to it.
                    144:
                    145: -- MODIFIERS :
                    146:
                    147:   procedure Set_Size ( s : in out Solution; size : in natural );
                    148:   procedure Set_Size ( ls : in out Link_to_Solution; size : in natural );
                    149:   procedure Set_Size ( sols : in out Solution_List; size : in natural );
                    150:
                    151:   -- DESCRIPTION :
                    152:   --   Adjustment of the size of the numbers to the given size.
                    153:
                    154:   procedure Change ( sols : in out Solution_List; pos : in positive;
                    155:                      s : in Solution; tol : in Floating_Number;
                    156:                      other : out natural );
                    157:
                    158:   -- DESCRIPTION :
                    159:   --   Changes the solution at the given position into s, if the solution
                    160:   --   does not already occur.
                    161:
                    162:   -- REQUIRED : pos <= Length_Of(sols).
                    163:
                    164:   procedure Set_Continuation_Parameter
                    165:                 ( sols : in out Solution_List;
                    166:                   t : in Standard_Complex_Numbers.Complex_Number );
                    167:
                    168:   -- DESCRIPTION :
                    169:   --   All solutions in the list will be given the continuation parameter t.
                    170:
                    171:   procedure Change_Multiplicity
                    172:                 ( sols : in out Solution_List; pos : in positive;
                    173:                   m : in natural );
                    174:
                    175:   -- DESCRIPTION :
                    176:   --   Changes the multiplicity of the solution with the given position
                    177:   --   into m.
                    178:
                    179:   -- REQUIRED : pos <= Length_Of(sols).
                    180:
                    181:   procedure Remove ( sols : in out Solution_List; pos : in positive );
                    182:
                    183:   -- DESCRIPTION :
                    184:   --   Removes the solution with given position from the list.
                    185:
                    186:   -- REQUIRED : pos <= Length_Of(sols).
                    187:
                    188:   generic
                    189:     with function To_Be_Removed ( flag : in natural ) return boolean;
                    190:   procedure Delete ( sols : in out Solution_List );
                    191:
                    192:   -- DESCRIPTION :
                    193:   --   Removes all solutions in s for which To_Be_Removed(s.m) holds.
                    194:
                    195:   procedure Remove_All ( sols : in out Solution_List; flag : in natural );
                    196:
                    197:   -- DESCRIPTION :
                    198:   --   All solutions with a multiplicity equal to flag are removed.
                    199:
                    200: -- DESTRUCTORS :
                    201:
                    202:   procedure Clear ( sa : in out Solution_Array );
                    203:   procedure Clear ( s : in out Solution );
                    204:   procedure Clear ( ls : in out Link_to_Solution );
                    205:   procedure Shallow_Clear ( sl : in out Solution_List );
                    206:   procedure    Deep_Clear ( sl : in out Solution_List );
                    207:
                    208:   -- DESCRIPTION :
                    209:   --   Deallocation of the occupied memory space.
                    210:   --   A shallow clear only deallocates the pointers,
                    211:   --   so that the data may still be accessible by sharing,
                    212:   --   whereas a deep clear also makes the data inaccessible.
                    213:
                    214: end Multprec_Complex_Solutions;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>