Overview
Comment:Simplified.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: e472b719de496628ccec2808efb8f4048cd7ae48b98fed2e69bbcd72c400fe44
User & Date: geraint@users.sourceforge.net on 2001-02-18 00:08:21
Other Links: branch diff | manifest | tags
Context
2001-02-18
00:10:30
Print message. check-in: d206e09bb9 user: geraint@users.sourceforge.net tags: origin/master, trunk
00:08:21
Simplified. check-in: e472b719de user: geraint@users.sourceforge.net tags: origin/master, trunk
2001-02-17
03:48:17
Use assignment LHS to gather tmp variable names.
Prevents collection of long expressions, eg: tmp34*(tmp75
check-in: eca5067ba8 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/lib/cc/mtt_implicit.cc from [daf2306c04] to [039828956b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
1


2






















































3
4
5
6
7
8
9

-
-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







#include <octave/oct.h>
#include "useful-functions.hh"

#include <octave/xdiv.h>
static inline int
result_ok (int info, double rcond, int warn = 1)
{
  assert (info != -1);

  if (info == -2)
    {
      if (warn)
	warning ("matrix singular to machine precision, rcond = %g", rcond);
      else
	error ("matrix singular to machine precision, rcond = %g", rcond);

      return 0;
    }
  else
    return 1;
}
bool
mx_leftdiv_conform (const Matrix& a, const ColumnVector& b)
{
  int a_nr = a.rows ();
  int b_nr = b.length ();

  if (a_nr != b_nr)
    {
      int a_nc = a.cols ();
      int b_nc = 1;

      gripe_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc);
      return false;
    }

  return true;
}

// need to update xdiv.cc ?
inline ColumnVector
ldiv (const Matrix &a, const ColumnVector &b)
{
  if (! mx_leftdiv_conform (a, b))
    return ColumnVector ();

  int info;
  if (a.rows () == a.columns ())
    {
      double rcond = 0.0;
      ColumnVector result = a.solve (b, info, rcond);
      if (result_ok (info, rcond))
	return result;
    }

  int rank;
  return a.lssolve (b, info, rank);
}

#ifdef STANDALONE
ColumnVector Fmtt_implicit (      ColumnVector	&x,
			    const ColumnVector	&dx,
			    const Matrix	&AA,
			    const ColumnVector	&AAx,
			    const double	&t,
98
99
100
101
102
103
104
105
106
107
108




109
110
111
112
113
114
115


116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

132
133
134
135
136
137
138

139
140
141
142
143
144
145
42
43
44
45
46
47
48




49
50
51
52
53
54
55
56
57


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72



73
74
75
76
77
78
79

80
81
82
83
84
85
86
87







-
-
-
-
+
+
+
+





-
-
+
+













-
-
-
+






-
+







    {
      if (0 != openx (i))
	{
	  n--;
	}
    }

  static ColumnVector	tmp_dx	(n);
  static ColumnVector	tmp_x	(n);
  static ColumnVector	tmp_AAx	(n);
  static Matrix	tmp_AA	(n, n);
  static Matrix	tmp_dx	(n,1);
  static Matrix	tmp_x	(n,1);
  static Matrix	tmp_AAx	(n,1);
  static Matrix	tmp_AA	(n,n);

  for (row_new = row_old = 0; row_old < Nx; row_old++)
    {
      if (0 == openx (row_old))
	{
	  tmp_dx  (row_new)	= dx  (row_old);
	  tmp_AAx (row_new)	= AAx (row_old);
	  tmp_dx  (row_new,0)	= dx  (row_old);
	  tmp_AAx (row_new,0)	= AAx (row_old);
	  for (col_new = col_old = 0; col_old < Nx; col_old++)
	    {
	      if (0 == openx (col_old))
		{
		  // xxx: this can be improved by symmetry
		  tmp_AA (row_new,col_new) = AA (row_old,col_old);
		  col_new++;
		}
	    }
	  row_new++;
	}
    }

  // can't get ldiv to work - doesn't like ColVector
  // tmp_x = tmp_AA.pseudo_inverse () * tmp_AAx + t * tmp_dx;
  tmp_x = ldiv (tmp_AA, (tmp_AAx + t * tmp_dx));
  tmp_x = xleftdiv (tmp_AA, (tmp_AAx + tmp_dx * t));
  
  row_new = 0;
  for (row_old = 0; row_old < Nx; row_old++)
    {
      if (0 == openx (row_old))
	{
	  x (row_old) = tmp_x (row_new);
	  x (row_old) = tmp_x (row_new,0);
	  row_new++;
	}
      else
	{
	  x (row_old) = 0.0;
	}
    }


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