Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Conor Joseph Mccoid
UNIGE
Commits
dfee15ac
Commit
dfee15ac
authored
Dec 01, 2021
by
Conor McCoid
Browse files
Extrap: test of v2 as underdetermined system solve
parent
6f691b6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Research/Extrapolation methods/Code/EX_extrap_linearFPI_v1_20211022.m
View file @
dfee15ac
% Example - Extrapolation: fixed point iteration on linear function
% solve the equation x = Ax + b for random A and b
d
=
100
;
n
=
2
*
d
;
d
=
5
;
n
=
2
*
d
;
A
=
rand
(
d
);
A
=
A
/
norm
(
A
);
b
=
rand
(
d
,
1
);
x_true
=
-
(
A
-
eye
(
d
))
\
b
;
...
...
@@ -12,8 +12,8 @@ end
F
=
X
(:,
2
:
end
)
-
X
(:,
1
:
n
);
[
x_v1
,
r_v1
]
=
ALGO_extrap_MPE_v1_20211022
(
F
,
X
(:,
1
:
n
));
%
[x_v2,r_v2] = ALGO_extrap_MPE_v2_20211029(F,X(:,1:n));
[
x_v2
,
r_v2
]
=
ALGO_extrap_MPE_v3_20211119
(
F
,
X
(:,
1
:
n
));
[
x_v2
,
r_v2
]
=
ALGO_extrap_MPE_v2_20211029
(
F
,
X
(:,
1
:
n
));
%
[x_v2,r_v2] = ALGO_extrap_MPE_v3_20211119(F,X(:,1:n));
x
=
x_v1
(:,
end
);
Error_abs
=
norm
(
x
-
x_true
)
Error_rel
=
Error_abs
/
norm
(
x_true
)
...
...
@@ -25,14 +25,14 @@ Error_v2 = vecnorm(x_v2 - x_true);
[
x_GMRES
,
~
,
~
,
~
,
res_GMRES
]
=
gmres
(
A
-
eye
(
d
),
-
b
,
d
,
eps
,
d
,
eye
(
d
),
eye
(
d
),
X
(:,
1
));
figure
(
1
)
semilogy
(
1
:
n
,
Error_v1
,
'b*--'
,
1
:
d
+
1
,
Error_v2
,
'k.--'
)
semilogy
(
1
:
n
,
Error_v1
,
'b*--'
,
1
:
length
(
Error_v2
)
,
Error_v2
,
'k.--'
)
xlabel
(
'Iteration'
)
ylabel
(
'Error in solution'
)
title
(
'Error vs iteration'
)
legend
(
'MPE w/ Arnoldi'
,
'MPE w/ HH,Givens'
)
figure
(
2
)
semilogy
(
1
:
n
,
res_MPE_v1
,
'b*--'
,
1
:
d
+
1
,
r_v2
,
'k.--'
,
1
:
length
(
res_GMRES
),
res_GMRES
,
'ro'
)
semilogy
(
1
:
n
,
res_MPE_v1
,
'b*--'
,
1
:
length
(
r_v2
)
,
r_v2
,
'k.--'
,
1
:
length
(
res_GMRES
),
res_GMRES
,
'ro'
)
xlabel
(
'Iteration'
)
ylabel
(
'Residual'
)
title
(
'Residual vs iteration'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment