1module cde_jetspace; % CDE package, routines for the definition of jetspace
2
3% Redistribution and use in source and binary forms, with or without
4% modification, are permitted provided that the following conditions are met:
5%
6%    * Redistributions of source code must retain the relevant copyright
7%      notice, this list of conditions and the following disclaimer.
8%    * Redistributions in binary form must reproduce the above copyright
9%      notice, this list of conditions and the following disclaimer in the
10%      documentation and/or other materials provided with the distribution.
11%
12% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
16% CONTRIBUTORS
17% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23% POSSIBILITY OF SUCH DAMAGE.
24%
25
26% % *****************************************************************
27% Author and maintainer: Raffaele Vitolo
28% Dipartimento di Matematica, Universita' del Salento (Lecce, Italy)
29% email: raffaele.vitolo@unisalento.it
30% web: http://poincare.unisalento.it/vitolo
31% ===============================================================
32
33
34%-----------------------------------------------------------------------------%
35% Jetspace coordinates
36%-----------------------------------------------------------------------------%
37
38% Here we introduce all jet coordinates up to the order specified
39% in the parameter total_order.
40
41% Coordinates are introduced in two formats,
42% which have the same name with termination `_mind' or `_id'
43% depending on if coordinates are of the form
44% {u,{1,2,0}} (multiindex notation)
45% or u_x1y2z0 (identifier notation).
46% The two formats are necessary for all computations which depend
47% on the numeric value of the multiindex.
48
49% We also define odd coordinates, to be used on tangent or cotangent coverings.
50% Odd coordinates have the identifier notation and the ext notation,
51% to be used in internal computations.
52
53% We also define a number of useful procedures to be used throughout
54% the program.
55
56symbolic procedure jet_fiber_dim(jorder);
57% Compute the number of derivatives of order exactly equal to 'jorder'
58% for a jet space with n_ivar indep. vars and n_dvar dep. vars
59begin scalar n_ivar,n_dvar;
60   n_dvar:=length(dep_var!*);
61   n_ivar:=length(indep_var!*);
62   if eqn(jorder,0) then return n_dvar else return
63     n_dvar*(factorial(n_ivar+jorder-1))/
64     (factorial(jorder)*factorial(n_ivar-1))
65end;
66
67symbolic operator jet_fiber_dim;
68
69symbolic procedure jet_dim(jorder);
70% Compute the sum of the number of independent variables plus the number
71% of all derivative coordinates from the order 0 up to order 'jorder'
72% for a jet space with n_ivar indep. vars and n_dvar dep. vars
73begin scalar n_ivar,n_dvar;
74   n_dvar:=length(dep_var!*);
75   n_ivar:=length(indep_var!*);
76   if eqn(jorder,0) then return n_ivar + n_dvar else return
77     n_ivar +
78     n_dvar*(factorial(n_ivar+jorder))/(factorial(n_ivar)*factorial(jorder));
79end;
80
81symbolic operator jet_dim;
82
83symbolic procedure length_multiindex lm;
84   % Finds the length of a multiindex
85   for each el in lm sum el;
86
87symbolic procedure factorial_multiindex lm;
88   % Finds the factorial of a multiindex
89   for each el in lm product factorial(el);
90
91symbolic procedure generate_multiindex m;
92   % for a given multiindex m generates all multiindexes
93   % strictly containing m with length = length m + 1
94   % new multiindex appear in the following order:
95   % each index is incremented starting from left to right
96   % with respect to the order of independent variables.
97   for i:=1:n_indep_var collect cde_replace_nth(m,i,nth(m,i)+1);
98
99symbolic procedure generate_prolongation_table(m,total_order);
100   % for a given multiindex m generates a table of the form
101   % {mind,list_of_first_prol}
102   % where |m| <= total_order
103   begin scalar temp_m_list,temp_table_rows,all_table_rows;
104      temp_m_list:=copy list(m);
105      while length_multiindex(car temp_m_list)<total_order do
106      <<
107	 temp_table_rows:=for each el in temp_m_list collect
108	    list(el,generate_multiindex(el));
109	 temp_m_list:=cde_mkset(
110          for each ell in temp_table_rows join cadr ell
111         );
112         all_table_rows:=append(all_table_rows,temp_table_rows);
113      >>;
114      temp_m_list:=for each elll in temp_m_list collect list(elll,nil);
115      return append(all_table_rows,temp_m_list)
116   end;
117
118symbolic procedure join_dvar_mind(dvar,tm);
119   % From a list of dependent variables and a table of multiindexes
120   % produces a list with all derivative coordinates in multiindex notation
121   % the list is ordered according with the length of multiindexes and dvar
122   for each el in tm join
123      for each ell in dvar collect list(ell,car el);
124
125symbolic procedure mind_to_eid der;
126   % converts a derivative coordinate from the multiindex notation
127   % to the external identifier notation - ex.: u_t2x
128   begin scalar mip,tempind;
129      mip:=for i:=1:n_indep_var join
130      <<
131         tempind:=nth(cadr der,i);
132         if tempind=0 then nil
133            else if tempind=1 then list(nth(indep_var!*,i))
134            else list(tempind,nth(indep_var!*,i))
135      >>;
136      return
137         if not(mip) then car der else cde_list2id(car der . ('_ . mip))
138   end;
139
140symbolic procedure idtomind(par,der_id);
141   % given a derivative coordinate in identifier notation, finds the
142   % corresponding multiindex notation. Works for even (par=0) and odd (par=1)
143   % jetspace coordinates.
144   if par=0 then cdr assoc(der_id,i2m_jetspace!*)
145    else cdr assoc(der_id,i2m_jetspace_odd!*);
146
147symbolic procedure order_of_der_mind(der_mind);
148   % finds the order of a given (odd) jetspace coordinate
149   % in multiindex notation
150   length_multiindex(cadr der_mind);
151
152symbolic procedure order_of_der(par,der_id);
153   % finds the order of a given (odd) jetspace coordinate
154   if par=0 then cdr assoc(der_id,i2o_jetspace!*)
155    else cdr assoc(der_id,i2o_jetspace_odd!*);
156
157symbolic operator order_of_der;
158
159symbolic procedure select_all_ders(par,var,l_vars);
160  % Select inside l_vars the derivative variables of var.
161  % l_vars must be an all-even or all-odd coordinate list!
162  begin
163    scalar tempoddvars;
164    for each el in l_vars do
165      if eq(car idtomind(par,el),var) then tempoddvars:=el . tempoddvars;
166    return tempoddvars
167  end;
168
169symbolic procedure selectvars0(par,orderofder,sdepvars,svars);
170  % The symbolic version of selectvars
171  begin scalar fdo;
172    for each el in svars do
173      if and(member(car idtomind(par,el),sdepvars),
174	eqn(order_of_der(par,el),orderofder)) then
175	  fdo:=el . fdo;
176    return reverse(fdo)
177  end;
178
179symbolic procedure selectvars(par,orderofder,depvars,vars);
180  % From a set of (even or odd) parametric derivatives `vars' collects
181  % derivative coordinates of some given dependent variables `depvars'
182  % and of order equal to `orderofder'
183  cons('list,selectvars0(par,orderofder,cdr depvars,cdr vars));
184
185symbolic operator selectvars;
186
187symbolic procedure cde_jetspace();
188   begin
189      n_indep_var:=length(indep_var!*);
190      if n_indep_var equal 0 then rederr "Error: missing dependent variables";
191      % produces a list of all multiindexes obtained from the zero multiindex
192      % and fulfilling the condition length<=total_order
193      % then generates all derivative coordinates in multiindex notation
194      all_mind_table!*:=
195       	generate_prolongation_table(cde_mkzero(length(indep_var!*)),
196	  total_order);
197      all_der_mind!*:=join_dvar_mind(dep_var!*,all_mind_table!*);
198      all_odd_mind!*:=join_dvar_mind(odd_var!*,all_mind_table!*);
199      all_mind!*:=for each el in all_mind_table!* collect car el;
200      % produces lists with all derivative coordinates
201      % of dependent and odd coordinates in identifier notation
202      all_der_id!*:=for each el in all_der_mind!* collect mind_to_eid(el);
203      all_der_id:='list . all_der_id!*;
204      all_odd_id!*:=for each el in all_odd_mind!* collect mind_to_eid(el);
205      all_odd_id:='list . all_odd_id!*;
206      % the number of all ext variables
207      n_all_ext:=length(all_odd_id!*);
208      % makes association lists which are used for conversion
209      % from identifiers to multiindexes.
210      i2m_jetspace!*:=pair(all_der_id!*,all_der_mind!*);
211      i2m_jetspace_odd!*:=pair(all_odd_id!*,all_odd_mind!*);
212      % makes association lists which are used
213      % for the computation of the order of a multiindex or
214      % a derivative coordinate
215%      m2o_jetspace!*:=pair(all_mind!*,
216%       for each el in all_mind!* collect length_multiindex(el)
217%      );
218      i2o_jetspace!*:=pair(all_der_id!*,
219       for each el in all_der_mind!* collect order_of_der_mind(el)
220      );
221      i2o_jetspace_odd!*:=pair(all_odd_id!*,
222       for each el in all_odd_mind!* collect order_of_der_mind(el)
223      );
224   end;
225
226endmodule;
227
228end;