Overview
Comment:Added affine form.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 17fd0d589b23ecbc4aa3339fdc9b21cfb8cb5821c0fb6c87307790eae3c37182
User & Date: gawthrop@users.sourceforge.net on 1998-04-07 08:12:12
Other Links: branch diff | manifest | tags
Context
1998-04-07
08:30:20
Initial revision check-in: c4c5a450a2 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:12:12
Added affine form. check-in: 17fd0d589b user: gawthrop@users.sourceforge.net tags: origin/master, trunk
05:45:12
Reverted to an older version due to untraceable bug in new version check-in: e4d0928b1a user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/ode2obs_r from [18594f298c] to [8b50fa41a2].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27







+
+
+







# Copyright (c) P.J.Gawthrop 1991, 1992, 1994, 1995, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1998/04/07 05:45:12  peterg
## Reverted to an older version due to untraceable bug in new version
##
## Revision 1.3  1996/08/25 10:07:05  peter
## Remove a du state ment causaing touble
##      - but needs more work.
##
## Revision 1.2  1996/08/25 08:38:14  peter
## Error handling added.
##
51
52
53
54
55
56
57

58
59
60
61
62
63
64
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68







+







MTTGPCNy := 2;
MTTGPCNu := 0;

%%in "$1_sympar.r";
in "$1_ode.r";
%%in "$1_simp.r";

% Read the obs form parameters.
in "$1_obspar.r";

%Create the U vector of input derivatives.
MTTNuu := (MTTGPCNu+1)*MTTNu;
MTTNuu1 := MTTGPCNu*MTTNu;


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

















105
106
107
108
109
110
111
88
89
90
91
92
93
94














95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118







-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  MTTYY(i,1) := MTTY(i,1);
END;

l := MTTNy;
FOR i := 1:MTTGPCNy DO
    FOR j := 1:MTTNy DO
    BEGIN
    l := l+1;
    MTTYY(l,1) := 0;
    FOR k := 1:MTTNx DO %Derivatives wrt x
    BEGIN
      xk := MTTX(k,1);
      MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l-MTTNy,1), xk, 1)*MTTdX(k,1);
    END;
    IF MTTGPCNu>0 THEN
    FOR k := 1:MTTGPCNu DO %Derivatives wrt u
    BEGIN
      uk := MTTUU(1,k);
      MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l,1), uk, 1)*MTTUU(1,k+1);
    END;
  END;
      l := l+1;
      MTTYY(l,1) := 0;
      FOR k := 1:MTTNx DO %Derivatives wrt x
      BEGIN
        xk := MTTX(k,1);
        MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l-MTTNy,1), xk, 1)*MTTdX(k,1);
      END;
      IF MTTGPCNu>0 THEN
      FOR k := 1:MTTGPCNu DO %Non-zero derivatives of u
      BEGIN
        FOR kk := 1:MTTNu DO
        BEGIN
          uk := MTTUU(kk,k);
          MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l,1), uk, 1)*MTTUU(1,k+1);
        END;
      END;
    END;
END;

%%Create O_x - derivative of YY wrt x
%Matrix MTTO_x(MTTNyy,MTTNx);
%FOR j := 1:MTTNx DO
%  BEGIN
%  xj := MTTX(j,1);
157
158
159
160
161
162
163



164






165
166
167
168














169
170
171

172




173















174
175
176
177
178
179
180
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180




181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226







+
+
+

+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+



+

+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







%      jk := j+(k-1)*MTTNu;
%      MTTO_ux(i,jk) := df(MTTO_u(i,j), xk);
%      END;
%    END;
%  END;


% Try and split the obs function into affine form (O(x,u) = o(x) + h(x)u)
affine := 1;
MTTNuu := (MTTGPCNu+1)*MTTNu;

IF affine=1 THEN
BEGIN
  MATRIX MTTObs_o(MTTNyy,1);
  MATRIX MTTObs_h(MTTNyy,MTTNuu);
  FOR i := 1:MTTNyy DO
  BEGIN
mtt_matrix := MTTYY$
mtt_matrix_n := MTTNy*MTTGPCNy;
mtt_matrix_m := 1;
mtt_matrix_name := "MTTYY"$
    MTTObs_o(i,1) := MTTYY(i,1);
    FOR j := 1:MTTNuu DO
    BEGIN
      %Expand as polynomial in uj
      coeffs := coeff(MTTObs_o(i,1), MTTu(j,1));
      MTTObs_o(i,1) := first(coeffs);
      IF length(coeffs)>1 THEN
        MTTObs_h(i,j) := second(coeffs);
      IF length(coeffs)>2 THEN affine := 0;
    END;
  END;
END;



%%Create the _obs.r file
OUT "$1_obs.r";
affine := affine;

mtt_matrix := MTTYY$
mtt_matrix_n := MTTNyy$
mtt_matrix_m := 1$
mtt_matrix_name := "MTTYY"$
reduce_matrix();

IF affine=1 THEN
BEGIN
  mtt_matrix := MTTObs_o$
  mtt_matrix_n := MTTNyy$
  mtt_matrix_m := 1$
  mtt_matrix_name := "MTTObs_o"$
  reduce_matrix();

  mtt_matrix := MTTObs_h$
  mtt_matrix_n := MTTNyy$
  mtt_matrix_m := MTTNuu$
  mtt_matrix_name := "MTTObs_h"$
  reduce_matrix();
END;

%MTTO_x := MTTO_x;
%MTTO_u := MTTO_u;
%MTTO_uu := MTTO_uu;
%MTTO_ux := MTTO_ux;

write ";END;";


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]