[BACK]Return to generic_jacobian_matrices.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Polynomials

Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Polynomials/generic_jacobian_matrices.adb, Revision 1.1.1.1

1.1       maekawa     1: package body Generic_Jacobian_Matrices is
                      2:
                      3: -- CREATORS :
                      4:
                      5:   function Create ( p : Poly_Sys ) return Jaco_Mat is
                      6:
                      7:     res : Jaco_Mat(p'range,1..Number_of_Unknowns(p(p'first)));
                      8:
                      9:   begin
                     10:     for i in res'range(1) loop
                     11:       for j in res'range(2) loop
                     12:         res(i,j) := Diff(p(i),j);
                     13:       end loop;
                     14:     end loop;
                     15:     return res;
                     16:   end Create;
                     17:
                     18:   function Create ( j : Jaco_Mat ) return Eval_Jaco_Mat is
                     19:
                     20:     res : Eval_Jaco_Mat(j'range(1),j'range(2));
                     21:
                     22:   begin
                     23:     for k in j'range(1) loop
                     24:       for l in j'range(2) loop
                     25:         res(k,l) := Create(j(k,l));
                     26:       end loop;
                     27:     end loop;
                     28:     return res;
                     29:   end Create;
                     30:
                     31:   procedure Create ( p : Poly_Sys;
                     32:                      j : out Eval_Coeff_Jaco_Mat; m : out Mult_Factors ) is
                     33:
                     34:     nb : constant natural := Number_of_Unknowns(p(p'first));
                     35:     nbk : natural;
                     36:
                     37:   begin
                     38:     for k in p'range loop
                     39:       nbk := Number_of_Terms(p(k));
                     40:       for l in 1..nb loop
                     41:         declare
                     42:           mkl : Vector(1..nbk);
                     43:         begin
                     44:           Diff(p(k),l,j(k,l),mkl);
                     45:           m(k,l) := new Vectors.Vector'(mkl);
                     46:         end;
                     47:       end loop;
                     48:     end loop;
                     49:   end Create;
                     50:
                     51: -- EVALUATORS :
                     52:
                     53:   function Eval ( j : Jaco_Mat; x : Vector ) return Matrix is
                     54:
                     55:     m : Matrix(j'range(1),j'range(2));
                     56:
                     57:   begin
                     58:     for k in j'range(1) loop
                     59:       for l in j'range(2) loop
                     60:         m(k,l) := Eval(Poly(j(k,l)),x);
                     61:       end loop;
                     62:     end loop;
                     63:     return m;
                     64:   end Eval;
                     65:
                     66:   function Eval ( j : Eval_Jaco_Mat; x : Vector ) return Matrix is
                     67:
                     68:     m : Matrix(j'range(1),j'range(2));
                     69:
                     70:   begin
                     71:     for k in j'range(1) loop
                     72:       for l in j'range(2) loop
                     73:         m(k,l) := Eval(Eval_Poly(j(k,l)),x);
                     74:       end loop;
                     75:     end loop;
                     76:     return m;
                     77:   end Eval;
                     78:
                     79:   function Eval ( j : Eval_Coeff_Jaco_Mat; m : Mult_Factors;
                     80:                   c : VecVec; x : Vector ) return Matrix is
                     81:
                     82:     res : Matrix(j'range(1),j'range(2));
                     83:
                     84:   begin
                     85:     for k in j'range(1) loop
                     86:       declare
                     87:         cm : Vector(c(k)'range);
                     88:       begin
                     89:         for l in j'range(2) loop
                     90:           for i in cm'range loop
                     91:             cm(i) := m(k,l)(i)*c(k)(i);
                     92:           end loop;
                     93:           res(k,l) := Eval(Eval_Coeff_Poly(j(k,l)),cm,x);
                     94:         end loop;
                     95:       end;
                     96:     end loop;
                     97:     return res;
                     98:   end Eval;
                     99:
                    100: -- DESTRUCTORS :
                    101:
                    102:   procedure Clear ( j : in out Jaco_Mat ) is
                    103:   begin
                    104:     for k in j'range(1) loop
                    105:       for l in j'range(2) loop
                    106:         Clear(j(k,l));
                    107:       end loop;
                    108:     end loop;
                    109:   end Clear;
                    110:
                    111:   procedure Clear ( j : in out Eval_Jaco_Mat ) is
                    112:   begin
                    113:     for k in j'range(1) loop
                    114:       for l in j'range(2) loop
                    115:         Clear(j(k,l));
                    116:       end loop;
                    117:     end loop;
                    118:   end Clear;
                    119:
                    120:   procedure Clear ( j : in out Eval_Coeff_Jaco_Mat ) is
                    121:   begin
                    122:     for k in j'range(1) loop
                    123:       for l in j'range(2) loop
                    124:         Clear(j(k,l));
                    125:       end loop;
                    126:     end loop;
                    127:   end Clear;
                    128:
                    129:   procedure Clear ( m : in out Mult_Factors ) is
                    130:   begin
                    131:     for k in m'range(1) loop
                    132:       for l in m'range(2) loop
                    133:         Clear(m(k,l));
                    134:       end loop;
                    135:     end loop;
                    136:   end Clear;
                    137:
                    138: end Generic_Jacobian_Matrices;

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