1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#include <octave/oct.h>
#include <octave/xdiv.h>
#ifdef STANDALONE
ColumnVector Fmtt_implicit ( ColumnVector &x,
const ColumnVector &dx,
const Matrix &AA,
const ColumnVector &AAx,
const double &t,
const int &Nx,
const ColumnVector &openx)
{
#else // !STANDALONE
DEFUN_DLD (mtt_implicit, args, ,
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#include <octave/oct.h>
#include <octave/xdiv.h>
#ifdef STANDALONE
ColumnVector Fmtt_implicit ( ColumnVector &x,
ColumnVector &dx,
Matrix &AA,
const ColumnVector &AAx,
const double &t,
const int &Nx,
const ColumnVector &openx)
{
#else // !STANDALONE
DEFUN_DLD (mtt_implicit, args, ,
|
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
const ColumnVector AAx = args(3).vector_value ();
const double t = args(4).double_value ();
const int Nx = (int) (args(5).double_value ());
const ColumnVector openx = args(6).vector_value ();
#endif // OCTAVE_DEV
#endif // STANDALONE
register int i, n;
register int col_old, col_new;
register int row_old, row_new;
n = Nx;
for (i = 0; i < Nx; i++)
{
if (0 != openx (i))
{
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,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++;
}
}
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,0);
row_new++;
}
else
{
x (row_old) = 0.0;
}
}
#ifdef STANDALONE
return x;
#else // !STANDALONE
return octave_value (x);
#endif // STANDALONE
}
|
<
<
|
<
|
|
<
<
<
|
<
<
<
<
|
<
|
<
<
<
<
<
<
<
<
<
|
<
|
|
<
|
|
|
<
|
<
|
<
<
<
<
<
|
|
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
|
const ColumnVector AAx = args(3).vector_value ();
const double t = args(4).double_value ();
const int Nx = (int) (args(5).double_value ());
const ColumnVector openx = args(6).vector_value ();
#endif // OCTAVE_DEV
#endif // STANDALONE
register int row, col;
for (row = 0; row < Nx; row++)
{
if (0 != openx (row))
{
dx (row) = 0.0;
for (col = 0; col < Nx; col++)
{
AA (row,col) = AA (col,row) = 0.0;
}
}
}
x = static_cast<ColumnVector> (xleftdiv (AA, static_cast<Matrix>(AAx + dx * t)));
for (row = 0; row < Nx; row++)
{
if (0 != openx (row))
{
x (row) = 0.0;
}
}
#ifdef STANDALONE
return x;
#else // !STANDALONE
return octave_value (x);
#endif // STANDALONE
}
|