changeset 697:8434063ed162 feature/optim

1 objective optimization finished
author Ylva Rydin <ylva.rydin@telia.com>
date Fri, 06 Oct 2017 13:51:21 +0200
parents 7c16b5af8d98
children 0122cbe2e6d3
files +time/+expint/Magnus_mp.m +time/+expint/Magnus_mp.m~ +time/+expint/expm_Arnoldi.m
diffstat 3 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/+time/+expint/Magnus_mp.m	Thu Oct 05 18:04:23 2017 +0200
+++ b/+time/+expint/Magnus_mp.m	Fri Oct 06 13:51:21 2017 +0200
@@ -13,7 +13,7 @@
     case 'expm'
         v = expm(k*Omega)*v;
     case 'Arnoldi'
-        v = time.expint.expm_Arnoldi(-Omega,v,k,tol,100);
+        v = time.expint.expm_Arnoldi(-Omega,v,k,tol,1000);
     otherwise
         error('No such matrix exponential evaluation')
         
--- a/+time/+expint/Magnus_mp.m~	Thu Oct 05 18:04:23 2017 +0200
+++ b/+time/+expint/Magnus_mp.m~	Fri Oct 06 13:51:21 2017 +0200
@@ -4,14 +4,18 @@
 function v = Magnus_mp(v,D, t , k,matrixexp,tol)
 
 if isa(D,'function_handle')
- switch matrixexp
-     case 'expm'
-        v = expm(k*D(t +k/2))*v;
-     case 'Arnol'
-    v = time.expint.expm_Arnoldi(-D(t +k/2),v,k,toler,100);
+    Omega = D(t +k/2);
 else
-   %v = krylov(k*D,v);
-   % v = expm(k*D)*v;
+    Omega = D;
 end
 
+switch matrixexp
+    case 'expm'
+        v = expm(k*Omega)*v;
+    case 'Arnoldi'
+        [v, i] = time.expint.expm_Arnoldi(-Omega,v,k,tol,1000);
+    otherwise
+        error('No such matrix exponential evaluation')
+        
+end
 end
\ No newline at end of file
--- a/+time/+expint/expm_Arnoldi.m	Thu Oct 05 18:04:23 2017 +0200
+++ b/+time/+expint/expm_Arnoldi.m	Fri Oct 06 13:51:21 2017 +0200
@@ -1,5 +1,7 @@
 function y = expm_Arnoldi(A,v,t,toler,m)
-%
+
+global iter 
+
 % y = expm_Arnoldi(A,v,t,toler,m)
 %
 % computes $y = \exp(-t A) v$
@@ -26,8 +28,11 @@
 resnorm = inf;
 
 j=0;
+iter = 0;
+
 
 while resnorm > toler
+    iter = iter +1;
     j = j+1;
     w = A*V(:,j);
     for i=1:j