From 159d2f9c60c520498c035db0e8aacb048afc012f Mon Sep 17 00:00:00 2001 From: Steven Van Vaerenbergh Date: Fri, 8 Jun 2018 10:48:23 +0200 Subject: [PATCH 1/6] minor edits --- README.md | 4 +++- lib/util/kernel.m | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0dca9d6..bce8c43 100644 --- a/README.md +++ b/README.md @@ -110,10 +110,12 @@ If you use this toolbox in your research please cite ["A Comparative Study of Ke @inproceedings{vanvaerenbergh2013comparative, author = {Van Vaerenbergh, Steven and Santamar{\'i}a, Ignacio}, - booktitle = {2013 IEEE Digital Signal Processing (DSP) Workshop and IEEE Signal Processing Education (SPE)}, + booktitle = {2013 IEEE Digital Signal Processing and Signal Processing Education Meeting (DSP/SPE)}, title = {A Comparative Study of Kernel Adaptive Filtering Algorithms}, doi = {10.1109/DSP-SPE.2013.6642587}, + pages = {181--186}, year = {2013}, + month = aug, note = {Software available at \url{https://github.com/steven2358/kafbox/}} } diff --git a/lib/util/kernel.m b/lib/util/kernel.m index b565559..c78d560 100644 --- a/lib/util/kernel.m +++ b/lib/util/kernel.m @@ -9,7 +9,7 @@ N2 = size(X2,1); switch ktype - case 'gauss' % RBF kernel + case {'gauss','rbf'} % RBF kernel norms1 = sum(X1.^2,2); norms2 = sum(X2.^2,2); From 4e1166b5820a0a494954effbbad96b70ad9ee40d Mon Sep 17 00:00:00 2001 From: Steven Van Vaerenbergh Date: Thu, 27 Jun 2019 13:22:35 +0200 Subject: [PATCH 2/6] add kernel_adaptive_filter superclass --- lib/L2_s.m | 2 +- lib/exkrls.m | 2 +- lib/fbklms.m | 2 +- lib/fbkrls.m | 2 +- lib/kafbox_template.m | 2 +- lib/kalman.m | 2 +- lib/kap.m | 2 +- lib/kapsm.m | 2 +- lib/klms.m | 2 +- lib/klms_csal1.m | 2 +- lib/klms_csl1.m | 2 +- lib/knlms.m | 2 +- lib/krls.m | 2 +- lib/krlst.m | 2 +- lib/lkapa.m | 2 +- lib/lms.m | 2 +- lib/memory_cell.m | 2 +- lib/mknlms_cs.m | 2 +- lib/mxklms.m | 2 +- lib/nlkapa.m | 2 +- lib/nlms.m | 2 +- lib/norma.m | 2 +- lib/phypass.m | 2 +- lib/problms.m | 2 +- lib/qklms.m | 2 +- lib/qklms_fb.m | 2 +- lib/rffklms.m | 2 +- lib/rls.m | 2 +- lib/swkrls.m | 2 +- lib/util/kernel_adaptive_filter.m | 8 ++++++++ 30 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 lib/util/kernel_adaptive_filter.m diff --git a/lib/L2_s.m b/lib/L2_s.m index 14a29d9..20cd17d 100644 --- a/lib/L2_s.m +++ b/lib/L2_s.m @@ -9,7 +9,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef L2_s < handle +classdef L2_s < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters eta = .5; % step size diff --git a/lib/exkrls.m b/lib/exkrls.m index ed349fe..3cdcc68 100644 --- a/lib/exkrls.m +++ b/lib/exkrls.m @@ -11,7 +11,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef exkrls < handle +classdef exkrls < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') alphaf = .999; % state forgetting factor, "alpha" in publication diff --git a/lib/fbklms.m b/lib/fbklms.m index 007d05a..e6edec6 100644 --- a/lib/fbklms.m +++ b/lib/fbklms.m @@ -9,7 +9,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef fbklms < handle +classdef fbklms < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters nu = .05; % growth criterion threshold diff --git a/lib/fbkrls.m b/lib/fbkrls.m index b4d3c52..c20e40f 100644 --- a/lib/fbkrls.m +++ b/lib/fbkrls.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef fbkrls < handle +classdef fbkrls < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') M = 100; % dictionary size diff --git a/lib/kafbox_template.m b/lib/kafbox_template.m index 8a068c3..d5c7b02 100644 --- a/lib/kafbox_template.m +++ b/lib/kafbox_template.m @@ -9,7 +9,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef kafbox_template < handle +classdef kafbox_template < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters param1 = 1; diff --git a/lib/kalman.m b/lib/kalman.m index 6b6143d..84f8de1 100644 --- a/lib/kalman.m +++ b/lib/kalman.m @@ -12,7 +12,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef kalman < handle +classdef kalman < matlab.mixin.Copyable properties (GetAccess = 'public', SetAccess = 'private') % parameters F; % state transition matrix diff --git a/lib/kap.m b/lib/kap.m index 40b3b62..091430f 100644 --- a/lib/kap.m +++ b/lib/kap.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef kap < handle +classdef kap < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') mu0 = .95; % coherence criterion threshold diff --git a/lib/kapsm.m b/lib/kapsm.m index a47ad17..a77c80b 100644 --- a/lib/kapsm.m +++ b/lib/kapsm.m @@ -11,7 +11,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef kapsm < handle +classdef kapsm < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters M = 200; % dictionary size diff --git a/lib/klms.m b/lib/klms.m index aead126..e8d5653 100644 --- a/lib/klms.m +++ b/lib/klms.m @@ -9,7 +9,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef klms < handle +classdef klms < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') eta = .5; % learning rate diff --git a/lib/klms_csal1.m b/lib/klms_csal1.m index b2a1ca4..099ad1a 100644 --- a/lib/klms_csal1.m +++ b/lib/klms_csal1.m @@ -12,7 +12,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef klms_csal1 < handle +classdef klms_csal1 < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters eta = .1; % step-size diff --git a/lib/klms_csl1.m b/lib/klms_csl1.m index 7e1e010..3adc101 100644 --- a/lib/klms_csl1.m +++ b/lib/klms_csl1.m @@ -12,7 +12,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef klms_csl1 < handle +classdef klms_csl1 < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters eta = .1; % step-size diff --git a/lib/knlms.m b/lib/knlms.m index ff6290d..2043aac 100644 --- a/lib/knlms.m +++ b/lib/knlms.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef knlms < handle +classdef knlms < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters eta = .5; % step size diff --git a/lib/krls.m b/lib/krls.m index 74e4397..a5bbf07 100644 --- a/lib/krls.m +++ b/lib/krls.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef krls < handle +classdef krls < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') nu = 1E-4; % ALD threshold diff --git a/lib/krlst.m b/lib/krlst.m index 2f131db..4e179d7 100644 --- a/lib/krlst.m +++ b/lib/krlst.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef krlst < handle +classdef krlst < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') lambda = .999; % forgetting factor diff --git a/lib/lkapa.m b/lib/lkapa.m index ca199cc..db72211 100644 --- a/lib/lkapa.m +++ b/lib/lkapa.m @@ -11,7 +11,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef lkapa < handle +classdef lkapa < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters eta = .05; % learning rate diff --git a/lib/lms.m b/lib/lms.m index 851154b..b27b2a9 100644 --- a/lib/lms.m +++ b/lib/lms.m @@ -6,7 +6,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef lms < handle +classdef lms < matlab.mixin.Copyable properties (GetAccess = 'public', SetAccess = 'private') mu = 0.001; % learning rate diff --git a/lib/memory_cell.m b/lib/memory_cell.m index 8e10f54..5e6f66e 100644 --- a/lib/memory_cell.m +++ b/lib/memory_cell.m @@ -3,7 +3,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef memory_cell < handle +classdef memory_cell < matlab.mixin.Copyable properties (GetAccess = 'public', SetAccess = 'private') % variables y_mem; diff --git a/lib/mknlms_cs.m b/lib/mknlms_cs.m index 5bb3476..c8e15f4 100644 --- a/lib/mknlms_cs.m +++ b/lib/mknlms_cs.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef mknlms_cs < handle +classdef mknlms_cs < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters delta = .95; % coherence criterion threshold diff --git a/lib/mxklms.m b/lib/mxklms.m index f2d6879..e044cad 100644 --- a/lib/mxklms.m +++ b/lib/mxklms.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef mxklms < handle +classdef mxklms < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters mu = 2; % learning rate for gradient descent update of v diff --git a/lib/nlkapa.m b/lib/nlkapa.m index dbae149..358529c 100644 --- a/lib/nlkapa.m +++ b/lib/nlkapa.m @@ -11,7 +11,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef nlkapa < handle +classdef nlkapa < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters eta = .05; % learning rate diff --git a/lib/nlms.m b/lib/nlms.m index 4d50eb8..be8ac0e 100644 --- a/lib/nlms.m +++ b/lib/nlms.m @@ -6,7 +6,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef nlms < handle +classdef nlms < matlab.mixin.Copyable properties (GetAccess = 'public', SetAccess = 'private') mu = .9; % step size diff --git a/lib/norma.m b/lib/norma.m index 8f2b96c..55cea57 100644 --- a/lib/norma.m +++ b/lib/norma.m @@ -9,7 +9,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef norma < handle +classdef norma < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') tau = 500; % memory size (terms retained in truncation) diff --git a/lib/phypass.m b/lib/phypass.m index d3a1a5d..8d1d57f 100644 --- a/lib/phypass.m +++ b/lib/phypass.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef phypass < handle +classdef phypass < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') mu = 0.5; % step size diff --git a/lib/problms.m b/lib/problms.m index a39a216..325c8af 100644 --- a/lib/problms.m +++ b/lib/problms.m @@ -8,7 +8,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef problms < handle +classdef problms < matlab.mixin.Copyable properties (GetAccess = 'public', SetAccess = 'private') sigma2_n = 1E-6; % variance of observation noise diff --git a/lib/qklms.m b/lib/qklms.m index 1d04876..59bf37d 100644 --- a/lib/qklms.m +++ b/lib/qklms.m @@ -8,7 +8,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef qklms < handle +classdef qklms < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') eta = .9; % learning rate diff --git a/lib/qklms_fb.m b/lib/qklms_fb.m index 17e752f..32b7da3 100644 --- a/lib/qklms_fb.m +++ b/lib/qklms_fb.m @@ -10,7 +10,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef qklms_fb < handle +classdef qklms_fb < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') eta = .9; % learning rate diff --git a/lib/rffklms.m b/lib/rffklms.m index f31446b..d14d08e 100644 --- a/lib/rffklms.m +++ b/lib/rffklms.m @@ -8,7 +8,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef rffklms < handle +classdef rffklms < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters seed = 1; diff --git a/lib/rls.m b/lib/rls.m index dcd3351..37dbdc5 100644 --- a/lib/rls.m +++ b/lib/rls.m @@ -6,7 +6,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef rls < handle +classdef rls < matlab.mixin.Copyable properties (GetAccess = 'public', SetAccess = 'private') lambda = .99; % forgetting factor diff --git a/lib/swkrls.m b/lib/swkrls.m index 7b29988..8ff303a 100644 --- a/lib/swkrls.m +++ b/lib/swkrls.m @@ -9,7 +9,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef swkrls < handle +classdef swkrls < kernel_adaptive_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters M = 250; % dictionary size diff --git a/lib/util/kernel_adaptive_filter.m b/lib/util/kernel_adaptive_filter.m new file mode 100644 index 0000000..3698214 --- /dev/null +++ b/lib/util/kernel_adaptive_filter.m @@ -0,0 +1,8 @@ +% Superclass for kernel adaptive filters. +% +% This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. +% https://github.com/steven2358/kafbox/ + +classdef kernel_adaptive_filter < matlab.mixin.Copyable + +end From b119d9a2753359e75c1e879f7d8a64b45aa94545 Mon Sep 17 00:00:00 2001 From: Steven Van Vaerenbergh Date: Thu, 27 Jun 2019 13:22:45 +0200 Subject: [PATCH 3/6] bug fix --- lib/L2_s.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/L2_s.m b/lib/L2_s.m index 20cd17d..a5f22ef 100644 --- a/lib/L2_s.m +++ b/lib/L2_s.m @@ -111,7 +111,7 @@ function train(kaf,x,y) kaf.kernelpars(qq)]; kaf.typevector = [kaf.typevector(2:end);... qq]; - kaf.Gram = multikernel(kaf.dict,... + kaf.Gram = kaf.multikernel(kaf.dict,... kaf.dict,kaf.kerneltype,kaf.largest,... kaf.paravector,kaf.paravector); break; From 39e0acfdd23ae684309032c64ddfdd7a4a3631df Mon Sep 17 00:00:00 2001 From: Steven Van Vaerenbergh Date: Tue, 7 Jan 2020 17:17:58 +0100 Subject: [PATCH 4/6] add base_estimator --- install.m | 1 - lib/base/base_estimator.m | 35 +++++++++++++++++++++++++++++++ lib/{util => base}/kernel.m | 0 lib/base/kernel_adaptive_filter.m | 8 +++++++ lib/base/linear_filter.m | 8 +++++++ lib/kalman.m | 2 +- lib/lms.m | 2 +- lib/memory_cell.m | 2 +- lib/nlms.m | 2 +- lib/problms.m | 2 +- lib/rls.m | 2 +- 11 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 lib/base/base_estimator.m rename lib/{util => base}/kernel.m (100%) create mode 100644 lib/base/kernel_adaptive_filter.m create mode 100644 lib/base/linear_filter.m diff --git a/install.m b/install.m index ba573fc..99b8b1b 100644 --- a/install.m +++ b/install.m @@ -7,7 +7,6 @@ % addpath(fullfile(pwd,'demo')); % add demo folder without subfolders - fprintf('done.\n') disp('Type "savepath" if you wish to store the changes.') % savepath; diff --git a/lib/base/base_estimator.m b/lib/base/base_estimator.m new file mode 100644 index 0000000..811ffc6 --- /dev/null +++ b/lib/base/base_estimator.m @@ -0,0 +1,35 @@ +% Base class for all estimators in KAFBOX. +% +% This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. +% https://github.com/steven2358/kafbox/ + +classdef base_estimator < matlab.mixin.Copyable + methods + % get parameter names for the estimator + function names = get_param_names(obj) + names = fieldnames(obj); + end + + % get parameters + function params = get_params(obj) + params = struct; + for fn = fieldnames(obj)', + params.(fn{1}) = obj.(fn{1}); + end + end + + % set parameters + function set_params(obj,params) + if (nargin > 0) % copy valid parameters + for fn = fieldnames(params)', + if ismember(fn{1},fieldnames(obj)), + values = params.(fn{1}); + obj.(fn{1}) = values; + else + warning('Unknown parameter: %s.',fn{1}); + end + end + end + end + end +end diff --git a/lib/util/kernel.m b/lib/base/kernel.m similarity index 100% rename from lib/util/kernel.m rename to lib/base/kernel.m diff --git a/lib/base/kernel_adaptive_filter.m b/lib/base/kernel_adaptive_filter.m new file mode 100644 index 0000000..32559c4 --- /dev/null +++ b/lib/base/kernel_adaptive_filter.m @@ -0,0 +1,8 @@ +% Superclass for kernel adaptive filters. +% +% This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. +% https://github.com/steven2358/kafbox/ + +classdef kernel_adaptive_filter < base_estimator + +end diff --git a/lib/base/linear_filter.m b/lib/base/linear_filter.m new file mode 100644 index 0000000..e53f1e3 --- /dev/null +++ b/lib/base/linear_filter.m @@ -0,0 +1,8 @@ +% Superclass for linear filters. +% +% This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. +% https://github.com/steven2358/kafbox/ + +classdef linear_filter < base_estimator + +end diff --git a/lib/kalman.m b/lib/kalman.m index 84f8de1..b35025c 100644 --- a/lib/kalman.m +++ b/lib/kalman.m @@ -12,7 +12,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef kalman < matlab.mixin.Copyable +classdef kalman < linear_filter properties (GetAccess = 'public', SetAccess = 'private') % parameters F; % state transition matrix diff --git a/lib/lms.m b/lib/lms.m index b27b2a9..3675b19 100644 --- a/lib/lms.m +++ b/lib/lms.m @@ -6,7 +6,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef lms < matlab.mixin.Copyable +classdef lms < linear_filter properties (GetAccess = 'public', SetAccess = 'private') mu = 0.001; % learning rate diff --git a/lib/memory_cell.m b/lib/memory_cell.m index 5e6f66e..ea92cd7 100644 --- a/lib/memory_cell.m +++ b/lib/memory_cell.m @@ -3,7 +3,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef memory_cell < matlab.mixin.Copyable +classdef memory_cell < base_estimator properties (GetAccess = 'public', SetAccess = 'private') % variables y_mem; diff --git a/lib/nlms.m b/lib/nlms.m index be8ac0e..3032345 100644 --- a/lib/nlms.m +++ b/lib/nlms.m @@ -6,7 +6,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef nlms < matlab.mixin.Copyable +classdef nlms < linear_filter properties (GetAccess = 'public', SetAccess = 'private') mu = .9; % step size diff --git a/lib/problms.m b/lib/problms.m index 325c8af..342e4a5 100644 --- a/lib/problms.m +++ b/lib/problms.m @@ -8,7 +8,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef problms < matlab.mixin.Copyable +classdef problms < linear_filter properties (GetAccess = 'public', SetAccess = 'private') sigma2_n = 1E-6; % variance of observation noise diff --git a/lib/rls.m b/lib/rls.m index 37dbdc5..b2d6a01 100644 --- a/lib/rls.m +++ b/lib/rls.m @@ -6,7 +6,7 @@ % This file is part of the Kernel Adaptive Filtering Toolbox for Matlab. % https://github.com/steven2358/kafbox/ -classdef rls < matlab.mixin.Copyable +classdef rls < linear_filter properties (GetAccess = 'public', SetAccess = 'private') lambda = .99; % forgetting factor From bf91ba5fc3f2a54f495be167872bd7dbb7cdf322 Mon Sep 17 00:00:00 2001 From: Steven Van Vaerenbergh Date: Tue, 7 Jan 2020 17:51:07 +0100 Subject: [PATCH 5/6] bug fix (for new matlab) --- demo/demo_profiler_prediction_lorenz.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/demo_profiler_prediction_lorenz.m b/demo/demo_profiler_prediction_lorenz.m index 1ef1c9a..e745c35 100644 --- a/demo/demo_profiler_prediction_lorenz.m +++ b/demo/demo_profiler_prediction_lorenz.m @@ -68,7 +68,7 @@ % output_dir = output_dir_default; % fprintf('Using default folder "%s" for storing results.\n', output_dir_default); % end -output_dir = fullfile(mfilename('fullpath'),'..','results'); +output_dir = fullfile(fileparts(mfilename('fullpath')),'results'); t1 = tic; [data,algorithms,results] = kafbox_profiler(data,sim_opts,algorithms,output_dir); From 2592548de3d2f58d295cdc938c83801c0d23ef01 Mon Sep 17 00:00:00 2001 From: Steven Van Vaerenbergh Date: Tue, 7 Jan 2020 17:53:48 +0100 Subject: [PATCH 6/6] fix warnings --- demo/demo_parameter_estimation_lorenz.m | 2 +- demo/demo_prediction.m | 2 +- demo/demo_prediction_kstep.m | 2 +- demo/demo_prediction_kstep_split.m | 2 +- demo/demo_prediction_mackey_glass.m | 6 +++--- demo/demo_reconverge_all.m | 10 +++++----- demo/demo_regression_2d.m | 4 ++-- demo/demo_sample_run.m | 4 ++-- demo/demo_sinc.m | 4 ++-- demo/demo_sinc_all.m | 8 ++++---- demo/demo_template_prediction.m | 2 +- demo/demo_template_system_identification.m | 2 +- demo/krlst_split.m | 8 ++++---- demo/literature/liu2010kernel/fig2_12.m | 6 +++--- demo/literature/richard2009online/fig1.m | 4 ++-- demo/literature/richard2009online/fig2.m | 4 ++-- .../richard2009online/generate_doddbench.m | 2 +- .../richard2009online/generate_richardbench.m | 2 +- demo/literature/vanvaerenbergh2006sliding/fig2.m | 4 ++-- demo/literature/vanvaerenbergh2012kernel/fig3.m | 6 +++--- demo/literature/yukawa2012multikernel/fig1a.m | 6 +++--- demo/run_all_demos.m | 2 +- lib/L2_s.m | 4 ++-- lib/base/base_estimator.m | 6 +++--- lib/base/kernel.m | 2 +- lib/exkrls.m | 4 ++-- lib/fbklms.m | 8 ++++---- lib/fbkrls.m | 4 ++-- lib/kafbox_template.m | 4 ++-- lib/kalman.m | 4 ++-- lib/kap.m | 6 +++--- lib/kapsm.m | 8 ++++---- lib/klms.m | 6 +++--- lib/klms_csal1.m | 6 +++--- lib/klms_csl1.m | 6 +++--- lib/knlms.m | 6 +++--- lib/krls.m | 8 ++++---- lib/krlst.m | 8 ++++---- lib/lkapa.m | 6 +++--- lib/lms.m | 6 +++--- lib/mknlms_cs.m | 10 +++++----- lib/mxklms.m | 10 +++++----- lib/nlkapa.m | 6 +++--- lib/nlms.m | 6 +++--- lib/norma.m | 4 ++-- lib/phypass.m | 12 ++++++------ lib/problms.m | 6 +++--- lib/profiler/exkrls_profiler.m | 2 +- lib/profiler/fbkrls_profiler.m | 2 +- lib/profiler/kafbox_profiler.m | 10 +++++----- lib/profiler/kafbox_profiler_msecurves.m | 6 +++--- lib/profiler/kafbox_profiler_plotresults.m | 12 ++++++------ lib/profiler/kafbox_profiler_simulation.m | 6 +++--- lib/profiler/kafbox_profiler_storet.m | 10 +++++----- lib/profiler/kap_profiler.m | 2 +- lib/profiler/klms_profiler.m | 2 +- lib/profiler/knlms_profiler.m | 2 +- lib/profiler/krls_profiler.m | 2 +- lib/profiler/norma_profiler.m | 2 +- lib/profiler/qklms_profiler.m | 2 +- lib/profiler/struct2str.m | 2 +- lib/profiler/swkrls_profiler.m | 2 +- lib/qklms.m | 6 +++--- lib/qklms_fb.m | 6 +++--- lib/rffklms.m | 4 ++-- lib/rls.m | 6 +++--- lib/swkrls.m | 4 ++-- lib/test/unit_test.m | 8 ++++---- lib/test/unit_test_profiler.m | 6 +++--- lib/util/kafbox_predictionloop.m | 10 +++++----- lib/util/kafbox_quickrun.m | 6 +++--- 71 files changed, 184 insertions(+), 184 deletions(-) diff --git a/demo/demo_parameter_estimation_lorenz.m b/demo/demo_parameter_estimation_lorenz.m index 47911f5..1368c4f 100644 --- a/demo/demo_parameter_estimation_lorenz.m +++ b/demo/demo_parameter_estimation_lorenz.m @@ -37,7 +37,7 @@ kaf = krlst(struct('lambda',lambda_est,'M',100,'sn2',reg_est,... 'kerneltype','gauss','kernelpar',sigma_est)); -for i=1:N, +for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end % progress indicator, 10 dots Y_est(i) = kaf.evaluate(X(i,:)); % predict the next output diff --git a/demo/demo_prediction.m b/demo/demo_prediction.m index e25a7e2..21ba647 100644 --- a/demo/demo_prediction.m +++ b/demo/demo_prediction.m @@ -12,7 +12,7 @@ %% RUN ALGORITHM N = size(X,1); Y_est = zeros(N,1); -for i=1:N, +for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end % progress indicator, 10 dots Y_est(i) = kaf.evaluate(X(i,:)); % predict the next output kaf.train(X(i,:),Y(i)); % train with one input-output pair diff --git a/demo/demo_prediction_kstep.m b/demo/demo_prediction_kstep.m index dd20528..bbef6de 100644 --- a/demo/demo_prediction_kstep.m +++ b/demo/demo_prediction_kstep.m @@ -18,7 +18,7 @@ %% RUN ALGORITHM N = size(X,1); Y_est = zeros(N,1); -for i=k:N, +for i=k:N if ~mod(i,floor(N/10)), fprintf('.'); end % progress indicator, 10 dots Y_est(i) = kaf.evaluate(X(i,:)); % predict the next output diff --git a/demo/demo_prediction_kstep_split.m b/demo/demo_prediction_kstep_split.m index da315f1..b2fc560 100644 --- a/demo/demo_prediction_kstep_split.m +++ b/demo/demo_prediction_kstep_split.m @@ -34,7 +34,7 @@ Y_test = Y(N_train+1:N_train+N_test); Y_test_MSE = zeros(N_train,1); -for i=1:N_train, +for i=1:N_train % train on data set 1 if ~mod(i,floor(N_train/10)), fprintf('.'); end % progress indicator, 10 dots kaf.train(X(i,:),Y(i)); % train with one input-output pair diff --git a/demo/demo_prediction_mackey_glass.m b/demo/demo_prediction_mackey_glass.m index ef834e6..da5c7c2 100644 --- a/demo/demo_prediction_mackey_glass.m +++ b/demo/demo_prediction_mackey_glass.m @@ -40,11 +40,11 @@ MSE = zeros(n_train,n_algos); y_est_final = zeros(n_test,n_algos); titles = cell(n_algos,1); -for j=1:n_algos, +for j=1:n_algos kaf = algos{j}; titles{j} = upper(class(kaf)); % store algorithm name fprintf('Training %s',titles{j}) - for i=1:n_train, + for i=1:n_train if ~mod(i,floor(n_train/10)), fprintf('.'); end % progress indicator kaf.train(X_train(i,:),y_train(i)); % train with one input-output pair @@ -69,7 +69,7 @@ plot(y_test,'LineWidth',2); titles2 = {'original'}; line_styles = {'--','-.'}; -for j=1:n_algos, +for j=1:n_algos plot(y_est_final(:,j),'LineWidth',2,'LineStyle',line_styles{j}); end titles2(2:n_algos+1) = titles; diff --git a/demo/demo_reconverge_all.m b/demo/demo_reconverge_all.m index 6d3fca2..57c0cc5 100644 --- a/demo/demo_reconverge_all.m +++ b/demo/demo_reconverge_all.m @@ -19,7 +19,7 @@ %% PROGRAM w = who; -for i=1:length(w), % copy all parameters to option structure +for i=1:length(w) % copy all parameters to option structure eval(sprintf('opt.%s = %s;',w{i},w{i})) end @@ -30,8 +30,8 @@ fdir = fileparts(which('kafbox_template.m')); files = dir(fullfile(fdir,'*.m')); [~,algorithms] = cellfun(@fileparts, {files.name}, 'UniformOutput',0); -for i=length(algorithms):-1:1, - if ~exist(algorithms{i},'class'), +for i=length(algorithms):-1:1 + if ~exist(algorithms{i},'class') algorithms(i) = []; % remove files that do not represent classes end end @@ -49,7 +49,7 @@ titles{algo_ind} = strrep(upper(algorithm),'_','\_'); kaf = feval(algorithm); - for i=1:N, + for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end y_est = kaf.evaluate(X_test); @@ -81,7 +81,7 @@ num_in_league = (rm==0)*5 + rm; % plot the results for the num_in_league worst results league_inds = num_alg-remaining+num_in_league:-1:num_alg-remaining+1; - for i=league_inds, + for i=league_inds plot(10*log10(MSE(:,ind(i))),'LineWidth',1) end title(sprintf('League %d',fig_ind)) diff --git a/demo/demo_regression_2d.m b/demo/demo_regression_2d.m index b51a7c1..a608df0 100644 --- a/demo/demo_regression_2d.m +++ b/demo/demo_regression_2d.m @@ -13,7 +13,7 @@ %% PROGRAM -kaf = feval(algorithm, opts); +kaf = feval(algorithm, opts); %#ok % generate some data c = 5; @@ -22,7 +22,7 @@ y = sin(3*x(:,1)).*cos(x(:,1)+x(:,2)); fprintf('Training') -for i=1:N, +for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end kaf.train(x(i,:),y(i)); % y_test = kaf.evaluate(x(i+1,:)); diff --git a/demo/demo_sample_run.m b/demo/demo_sample_run.m index 1075132..8b409f1 100644 --- a/demo/demo_sample_run.m +++ b/demo/demo_sample_run.m @@ -47,7 +47,7 @@ fprintf('Running KRLS-T\n'); t1 = tic; -for i=1:n, +for i=1:n if ~mod(i,floor(n/10)), fprintf('.'); end Qold = kaf.Q; kaf.train(x(i),y(i)); @@ -108,7 +108,7 @@ end if savefig - if ~exist('fig','file') + if ~exist('fig','file') %#ok mkdir('fig'); end % write individual png diff --git a/demo/demo_sinc.m b/demo/demo_sinc.m index 0ef1017..709960b 100644 --- a/demo/demo_sinc.m +++ b/demo/demo_sinc.m @@ -25,9 +25,9 @@ %% RUN ALGORITHM fprintf('%s: ',upper(algorithm)); Y_est = zeros(N_test,1); -kaf = feval(algorithm); +kaf = feval(algorithm); %#ok t1 = tic; -for i=1:N, +for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end kaf.train(x(i),y(i)); end diff --git a/demo/demo_sinc_all.m b/demo/demo_sinc_all.m index cf87e7c..6e90f06 100644 --- a/demo/demo_sinc_all.m +++ b/demo/demo_sinc_all.m @@ -27,8 +27,8 @@ fdir = fileparts(which('kafbox_template.m')); files = dir(fullfile(fdir,'*.m')); [~,algorithms] = cellfun(@fileparts, {files.name}, 'UniformOutput',0); -for i=length(algorithms):-1:1, - if ~exist(algorithms{i},'class'), +for i=length(algorithms):-1:1 + if ~exist(algorithms{i},'class') algorithms(i) = []; % remove files that do not represent classes end end @@ -46,7 +46,7 @@ titles{algo_ind} = strrep(upper(algorithm),'_','\_'); kaf = feval(algorithm); - for i=1:N, + for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end kaf.train(x(i),y(i)); end @@ -73,7 +73,7 @@ num_in_league = (rm==0)*5 + rm; % plot the results for the num_in_league worst results league_inds = num_alg-remaining+num_in_league:-1:num_alg-remaining+1; - for i=league_inds, + for i=league_inds plot(x_test,Y_est(:,ind(i)),'LineWidth',2) end title(sprintf('League %d',fig_ind)) diff --git a/demo/demo_template_prediction.m b/demo/demo_template_prediction.m index 70ad707..812e394 100644 --- a/demo/demo_template_prediction.m +++ b/demo/demo_template_prediction.m @@ -69,7 +69,7 @@ fprintf('Running prediction algorithm %s',upper(class(kaf))) Y_est = zeros(N,1); -for i=1:N, +for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end Y_est(i) = kaf.evaluate(X(i,:)); % make prediction diff --git a/demo/demo_template_system_identification.m b/demo/demo_template_system_identification.m index 039542d..be2f2b8 100644 --- a/demo/demo_template_system_identification.m +++ b/demo/demo_template_system_identification.m @@ -26,7 +26,7 @@ fprintf('Running system identification algorithm') Y_est = zeros(N,1); -for i=1:N, +for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end Y_est(i) = kaf.evaluate(X(i,:)); % make prediction diff --git a/demo/krlst_split.m b/demo/krlst_split.m index 5e1c2dc..90f8d1b 100644 --- a/demo/krlst_split.m +++ b/demo/krlst_split.m @@ -39,8 +39,8 @@ function kaf = krlst_split(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -124,7 +124,7 @@ function train(kaf,x,y) % train the algorithm function kaf = prune(kaf,Qold,gamma2) m = size(kaf.Sigma,1); - if gamma2 end @@ -136,7 +136,7 @@ function train(kaf,x,y) % train the algorithm [~, r] = min(criterion); % remove element r, which incurs in the minimum error smaller = 1:m; smaller(r) = []; - if r == m, % if we must remove the element we just added, perform reduced update instead + if r == m % if we must remove the element we just added, perform reduced update instead kaf.Q = Qold; kaf.reduced = true; else diff --git a/demo/literature/liu2010kernel/fig2_12.m b/demo/literature/liu2010kernel/fig2_12.m index 0a1b899..7a588da 100644 --- a/demo/literature/liu2010kernel/fig2_12.m +++ b/demo/literature/liu2010kernel/fig2_12.m @@ -20,7 +20,7 @@ N_tr = 1000; % number of training data N_te = 50; % number of testing data -setups{1} = lms(struct('mu',.01)); +setups{1} = lms(struct('mu',.01)); %#ok setups{2} = klms(struct('eta',0.2,'M',N_tr,'kerneltype','gauss','kernelpar',1)); %% PREPARE DATA @@ -36,7 +36,7 @@ y = z - 0.9*z.^2 + ns; % output of nonlinear channel X_all = zeros(N_tr+N_te,embedding); % time-embedding -for k=1:embedding, +for k=1:embedding X_all(:,k) = y(k:N_tr+N_te+k-1); end @@ -52,7 +52,7 @@ MSE = zeros(N_tr,num_setup); -for setup_ind = 1:num_setup, +for setup_ind = 1:num_setup kaf = setups{setup_ind}; for n=1:N_tr diff --git a/demo/literature/richard2009online/fig1.m b/demo/literature/richard2009online/fig1.m index 13675a7..0cfb225 100644 --- a/demo/literature/richard2009online/fig1.m +++ b/demo/literature/richard2009online/fig1.m @@ -35,13 +35,13 @@ MSE = zeros(N,num_setup); titles = cell(num_setup,1); -for sim_ind = 1:numsim, +for sim_ind = 1:numsim fprintf('SIM %d:\n',sim_ind) % Generate the data [X,y,yref] = generate_doddbench(N); - for setup_ind = 1:num_setup, + for setup_ind = 1:num_setup kaf = setups{setup_ind}; titles{setup_ind} = upper(class(kaf)); diff --git a/demo/literature/richard2009online/fig2.m b/demo/literature/richard2009online/fig2.m index d072875..9f027dc 100644 --- a/demo/literature/richard2009online/fig2.m +++ b/demo/literature/richard2009online/fig2.m @@ -37,13 +37,13 @@ MSE = zeros(N,num_setup); titles = cell(num_setup,1); -for sim_ind = 1:numsim, +for sim_ind = 1:numsim fprintf('SIM %d:\n',sim_ind) % Generate the data [X,y,yref] = generate_richardbench(N); - for setup_ind = 1:num_setup, + for setup_ind = 1:num_setup kaf = setups{setup_ind}; titles{setup_ind} = upper(class(kaf)); diff --git a/demo/literature/richard2009online/generate_doddbench.m b/demo/literature/richard2009online/generate_doddbench.m index f4944d1..f88b3cb 100644 --- a/demo/literature/richard2009online/generate_doddbench.m +++ b/demo/literature/richard2009online/generate_doddbench.m @@ -20,7 +20,7 @@ dref = zeros(1,N+2); dref(1:2)=[0.1 0.1]; -for t=3:N+2, +for t=3:N+2 dref(t) = (0.8-0.5*exp(-dref(t-1)^2))*dref(t-1) - ... (0.3+0.9*exp(-dref(t-1)^2))*dref(t-2)+0.1*sin(pi*dref(t-1)); end diff --git a/demo/literature/richard2009online/generate_richardbench.m b/demo/literature/richard2009online/generate_richardbench.m index 60f5e06..894a9b7 100644 --- a/demo/literature/richard2009online/generate_richardbench.m +++ b/demo/literature/richard2009online/generate_richardbench.m @@ -21,7 +21,7 @@ u = 0.25*randn(N+1,1); dref = zeros(1,N+1); -for t=2:N+1, +for t=2:N+1 v(t) = 1.1*exp(-abs(v(t-1)))+u(t); dref(t) = v(t)^2; end diff --git a/demo/literature/vanvaerenbergh2006sliding/fig2.m b/demo/literature/vanvaerenbergh2006sliding/fig2.m index a886af2..d106a9a 100644 --- a/demo/literature/vanvaerenbergh2006sliding/fig2.m +++ b/demo/literature/vanvaerenbergh2006sliding/fig2.m @@ -41,7 +41,7 @@ num_alg = length(setups); MSE = zeros(N,num_alg); MSE_final = zeros(1,num_alg); -for sim_ind = 1:num_sim, +for sim_ind = 1:num_sim % generate data [X,y,y_ref,X_test,y_test] = generate_channel_switch(opt); @@ -54,7 +54,7 @@ fprintf('%9s M=%3d: ',upper(class(kaf)),kaf.M); mse = zeros(N,1); - for i=1:N, + for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end y_est = kaf.evaluate(X_test); diff --git a/demo/literature/vanvaerenbergh2012kernel/fig3.m b/demo/literature/vanvaerenbergh2012kernel/fig3.m index 0e8e311..d878ade 100644 --- a/demo/literature/vanvaerenbergh2012kernel/fig3.m +++ b/demo/literature/vanvaerenbergh2012kernel/fig3.m @@ -41,7 +41,7 @@ % generate Gaussian input data s s = rand(N+N_test,1); s_mem = zeros(N+N_test,embedding); -for i = 1:embedding, +for i = 1:embedding s_mem(i:N+N_test,i) = s(1:N+N_test-i+1); % time-embedding end s = s_mem(1:N+N_test,:); % input data, stored in columns @@ -78,9 +78,9 @@ titles{setup_ind} = upper(class(kaf)); fprintf('%s\t',titles{setup_ind}); - for n=1:N, + for n=1:N if ~mod(n,round(N/10)), fprintf('.'); end - if n<=Nswitch, + if n<=Nswitch Y_test = Y_test1; else Y_test = Y_test2; diff --git a/demo/literature/yukawa2012multikernel/fig1a.m b/demo/literature/yukawa2012multikernel/fig1a.m index b0e17c9..5adbd70 100644 --- a/demo/literature/yukawa2012multikernel/fig1a.m +++ b/demo/literature/yukawa2012multikernel/fig1a.m @@ -28,7 +28,7 @@ % mk_kernelpars = [.2 .5 1 2 5 10 20 50]; % alternative values % remark 1 from paper determines mu0 -setups{1} = lms(struct('mu',.01)); +setups{1} = lms(struct('mu',.01)); %#ok setups{2} = knlms(struct('mu0',mk_thresh^(.2/min(mk_kernelpars)),'eta',0.2,'eps',3E-2,'kerneltype','gauss','kernelpar',1/sqrt(.2))); setups{3} = knlms(struct('mu0',mk_thresh^(.5/min(mk_kernelpars)),'eta',0.2,'eps',3E-2,'kerneltype','gauss','kernelpar',1/sqrt(.5))); setups{4} = mknlms_cs(struct('delta',mk_thresh,'eta',0.2,'rho',6E-2,'kerneltype','gauss','kernelpars',1./sqrt(mk_kernelpars))); @@ -47,7 +47,7 @@ y = z - 0.9*z.^2 + ns; % output of nonlinear channel X_all = zeros(N_tr+N_te,embedding); % time-embedding -for k=1:embedding, +for k=1:embedding X_all(:,k) = y(k:N_tr+N_te+k-1); end @@ -63,7 +63,7 @@ num_setup = length(setups); MSE = zeros(N_tr,num_setup); -for setup_ind = 1:num_setup, +for setup_ind = 1:num_setup kaf = setups{setup_ind}; for n=1:N_tr diff --git a/demo/run_all_demos.m b/demo/run_all_demos.m index 7ce9791..959b7c5 100644 --- a/demo/run_all_demos.m +++ b/demo/run_all_demos.m @@ -17,7 +17,7 @@ % get list of literature scripts folders_literature = dir(fullfile(fdir,'literature','*2*')); -for i=1:length(folders_literature); +for i=1:length(folders_literature) folder_i = fullfile(fdir,'literature',folders_literature(i).name); files_i = dir(fullfile(folder_i,'fig*.m')); folders_i = repmat({folder_i},length(files_i),1); diff --git a/lib/L2_s.m b/lib/L2_s.m index a5f22ef..10eb44b 100644 --- a/lib/L2_s.m +++ b/lib/L2_s.m @@ -37,8 +37,8 @@ methods function kaf = L2_s(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end diff --git a/lib/base/base_estimator.m b/lib/base/base_estimator.m index 811ffc6..224bebe 100644 --- a/lib/base/base_estimator.m +++ b/lib/base/base_estimator.m @@ -13,7 +13,7 @@ % get parameters function params = get_params(obj) params = struct; - for fn = fieldnames(obj)', + for fn = fieldnames(obj)' params.(fn{1}) = obj.(fn{1}); end end @@ -21,8 +21,8 @@ % set parameters function set_params(obj,params) if (nargin > 0) % copy valid parameters - for fn = fieldnames(params)', - if ismember(fn{1},fieldnames(obj)), + for fn = fieldnames(params)' + if ismember(fn{1},fieldnames(obj)) values = params.(fn{1}); obj.(fn{1}) = values; else diff --git a/lib/base/kernel.m b/lib/base/kernel.m index c78d560..8de4baf 100644 --- a/lib/base/kernel.m +++ b/lib/base/kernel.m @@ -49,7 +49,7 @@ case 'linear' % linear kernel K = X1*X2'; - case 'sum', + case 'sum' a = kpar.a; ktype1 = kpar.ktype1; kpar1 = kpar.kpar1; diff --git a/lib/exkrls.m b/lib/exkrls.m index 3cdcc68..62315db 100644 --- a/lib/exkrls.m +++ b/lib/exkrls.m @@ -35,7 +35,7 @@ function kaf = exkrls(parameters) % constructor allpars = {'alphaf','lambda','beta','q','kerneltype','kernelpar','M'}; if (nargin > 0) - for j=1:length(allpars), + for j=1:length(allpars) p = allpars{j}; if isfield(parameters,p), kaf.(p) = parameters.(p); end end @@ -62,7 +62,7 @@ function train(kaf,x,y) % train the algorithm kaf.Q = kaf.alphaf^2/((kaf.beta*kaf.lambda+ktt)*(kaf.alphaf^2+kaf.beta*kaf.lambda*kaf.q)); kaf.dict = x; else - if (size(kaf.dict,1) 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -63,12 +63,12 @@ function train(kaf,x,y) % train the algorithm % growth criterion kx = kt(end); dependency = kx - k./kaf.diagkdict; - if min(dependency) >= kaf.nu, % expand dictionary + if min(dependency) >= kaf.nu % expand dictionary kaf.dict = [kaf.dict; x]; kaf.diagkdict = [kaf.diagkdict; kx]; kaf.alpha = [kaf.alpha; kaf.eta*e/(k'*k)]; - if length(kaf.alpha) > kaf.M, % prune dictionary + if length(kaf.alpha) > kaf.M % prune dictionary [~, id] = min(abs(kaf.alpha)); kaf.dict(id,:) = []; kaf.diagkdict(id) = []; diff --git a/lib/fbkrls.m b/lib/fbkrls.m index c20e40f..ba4ce02 100644 --- a/lib/fbkrls.m +++ b/lib/fbkrls.m @@ -29,8 +29,8 @@ methods function kaf = fbkrls(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end diff --git a/lib/kafbox_template.m b/lib/kafbox_template.m index d5c7b02..15e7790 100644 --- a/lib/kafbox_template.m +++ b/lib/kafbox_template.m @@ -26,8 +26,8 @@ methods function kaf = kafbox_template(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end diff --git a/lib/kalman.m b/lib/kalman.m index b35025c..418902d 100644 --- a/lib/kalman.m +++ b/lib/kalman.m @@ -30,8 +30,8 @@ methods function obj = kalman(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(obj)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(obj)) obj.(fn{1}) = parameters.(fn{1}); end end diff --git a/lib/kap.m b/lib/kap.m index 091430f..c933735 100644 --- a/lib/kap.m +++ b/lib/kap.m @@ -32,8 +32,8 @@ methods function kaf = kap(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -67,7 +67,7 @@ function train(kaf,x,y) % train the algorithm k = kernel(kaf.dict,x,kaf.kerneltype,kaf.kernelpar); kx = kernel(x,x,kaf.kerneltype,kaf.kernelpar); C = k./(sqrt(kx)*kaf.modict); % coherence - if (max(C) <= kaf.mu0), % coherence criterion + if (max(C) <= kaf.mu0) % coherence criterion kaf.dict = [kaf.dict; x]; % order increase kaf.alpha = [kaf.alpha; 0]; % order increase end diff --git a/lib/kapsm.m b/lib/kapsm.m index a77c80b..1225ea1 100644 --- a/lib/kapsm.m +++ b/lib/kapsm.m @@ -35,8 +35,8 @@ methods function kaf = kapsm(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -100,7 +100,7 @@ function train(kaf,x,y) % train the algorithm end % sliding-window pruning - if length(kaf.alpha)>kaf.M, + if length(kaf.alpha)>kaf.M k = kernel(kaf.dict,kaf.dict(1,:),... kaf.kerneltype,kaf.kernelpar); kaf.norm_f = sqrt(kaf.norm_f.^2 + kaf.alpha(1)^2*k(1) - ... @@ -123,7 +123,7 @@ function train(kaf,x,y) % train the algorithm case 'huber' sigma = loss_param; loss = zeros(length(ksi),1); - for i=1:length(ksi), + for i=1:length(ksi) if abs(ksi(i)) <= sigma loss(i) = ksi(i)^2/(2*sigma); else diff --git a/lib/klms.m b/lib/klms.m index e8d5653..d93aa37 100644 --- a/lib/klms.m +++ b/lib/klms.m @@ -26,8 +26,8 @@ methods function kaf = klms(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -44,7 +44,7 @@ end function train(kaf,x,y) % train the algorithm - if (size(kaf.dict,1) 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -63,7 +63,7 @@ function train(kaf,x,y) % train the algorithm kx = kernel(x,x,kaf.kerneltype,kaf.kernelpar); C = kd./(sqrt(kx)*kaf.modict); % coherence - if (max(C) <= kaf.mu0), % coherence criterion + if (max(C) <= kaf.mu0) % coherence criterion kaf.dict = [kaf.dict; x]; % order increase kaf.modict = [kaf.modict; sqrt(kx)]; kaf.alpha = [kaf.alpha; 0]; % order increase diff --git a/lib/klms_csl1.m b/lib/klms_csl1.m index 3adc101..195e1c5 100644 --- a/lib/klms_csl1.m +++ b/lib/klms_csl1.m @@ -31,8 +31,8 @@ methods function kaf = klms_csl1(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -59,7 +59,7 @@ function train(kaf,x,y) % train the algorithm kx = kernel(x,x,kaf.kerneltype,kaf.kernelpar); C = kd./(sqrt(kx)*kaf.modict); % coherence - if (max(C) <= kaf.mu0), % coherence criterion + if (max(C) <= kaf.mu0) % coherence criterion kaf.dict = [kaf.dict; x]; % order increase kaf.modict = [kaf.modict; sqrt(kx)]; kaf.alpha = [kaf.alpha; 0]; % order increase diff --git a/lib/knlms.m b/lib/knlms.m index 2043aac..3fd7fa1 100644 --- a/lib/knlms.m +++ b/lib/knlms.m @@ -29,8 +29,8 @@ methods function kaf = knlms(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -56,7 +56,7 @@ function train(kaf,x,y) % train the algorithm k = kernel(kaf.dict,x,kaf.kerneltype,kaf.kernelpar); kx = kernel(x,x,kaf.kerneltype,kaf.kernelpar); C = k./(sqrt(kx)*kaf.modict); % coherence - if (max(C) <= kaf.mu0), % coherence criterion + if (max(C) <= kaf.mu0) % coherence criterion kaf.dict = [kaf.dict; x]; % order increase kaf.modict = [kaf.modict; sqrt(kx)]; kaf.alpha = [kaf.alpha; 0]; % reserve spot diff --git a/lib/krls.m b/lib/krls.m index a5bbf07..66c04c6 100644 --- a/lib/krls.m +++ b/lib/krls.m @@ -30,8 +30,8 @@ function kaf = krls(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -51,7 +51,7 @@ function train(kaf,x,y) % train the algorithm k = kernel([kaf.dict; x],x,kaf.kerneltype,kaf.kernelpar); kt = k(1:end-1); ktt = k(end); - if numel(kt)==0, % initialize + if numel(kt)==0 % initialize kaf.Kinv = 1/ktt; kaf.alpha = y/ktt; kaf.P = 1; @@ -60,7 +60,7 @@ function train(kaf,x,y) % train the algorithm at = kaf.Kinv*kt; % coefficients of best linear combination delta = ktt - kt'*at; % residual of linear approximation - if (delta>kaf.nu && size(kaf.dict,1)kaf.nu && size(kaf.dict,1) 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -114,7 +114,7 @@ function train(kaf,x,y) % train the algorithm kaf.prune = false; % delete a basis if necessary if (m>kaf.M || gamma2 end @@ -126,7 +126,7 @@ function train(kaf,x,y) % train the algorithm [~, r] = min(criterion); % remove element r, which incurs in the minimum error smaller = 1:m; smaller(r) = []; - if r == m, % if we must remove the element we just added, perform reduced update instead + if r == m % if we must remove the element we just added, perform reduced update instead kaf.Q = Qold; kaf.reduced = true; else diff --git a/lib/lkapa.m b/lib/lkapa.m index db72211..cb97560 100644 --- a/lib/lkapa.m +++ b/lib/lkapa.m @@ -32,8 +32,8 @@ methods function kaf = lkapa(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -56,7 +56,7 @@ function train(kaf,x,y) % train the algorithm kaf.xmem = x; kaf.ymem = y; else - if size(kaf.dict,1) < kaf.M, + if size(kaf.dict,1) < kaf.M if size(kaf.xmem,1) 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(obj)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(obj)) obj.(fn{1}) = parameters.(fn{1}); end end @@ -36,7 +36,7 @@ end function train(obj,x,y) % train the algorithm - if numel(obj.w)==0, % initialize + if numel(obj.w)==0 % initialize obj.w = zeros(length(x),1); end diff --git a/lib/mknlms_cs.m b/lib/mknlms_cs.m index c8e15f4..bf587a8 100644 --- a/lib/mknlms_cs.m +++ b/lib/mknlms_cs.m @@ -28,8 +28,8 @@ function kaf = mknlms_cs(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -53,7 +53,7 @@ function train(kaf,x,y) % train the algorithm kaf.alpha = zeros(1,M); % row with coefficients for all kernels else K = multikernel_dict(kaf,x); - if (max(K(:)) <= kaf.delta), % coherence criterion + if (max(K(:)) <= kaf.delta) % coherence criterion kaf.dict = [kaf.dict; x]; % order increase kaf.alpha = [kaf.alpha; zeros(1,M)]; % order increase end @@ -78,11 +78,11 @@ function train(kaf,x,y) % train the algorithm d2 = mat1 + mat2 - 2*X*kaf.dict'; % distance matrix Kalpha = -1./(2*kaf.kernelpars.^2); - for m=1:M, + for m=1:M K(:,:,m) = exp(d2*Kalpha(m)); end otherwise % default case - for m=1:M, + for m=1:M k = kernel(X,kaf.dict,kaf.kerneltype,kaf.kernelpars(m)); K(:,:,m) = k; end diff --git a/lib/mxklms.m b/lib/mxklms.m index e044cad..4165910 100644 --- a/lib/mxklms.m +++ b/lib/mxklms.m @@ -30,8 +30,8 @@ methods function kaf = mxklms(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -50,7 +50,7 @@ end function train(kaf,x,y) % train the algorithm - if (size(kaf.dict,1) 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -57,7 +57,7 @@ function train(kaf,x,y) % train the algorithm kaf.xmem = x; kaf.ymem = y; else - if size(kaf.dict,1) < kaf.M, + if size(kaf.dict,1) < kaf.M if size(kaf.xmem,1) 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(obj)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(obj)) obj.(fn{1}) = parameters.(fn{1}); end end @@ -37,7 +37,7 @@ end function train(obj,x,y) % train the algorithm - if numel(obj.w)==0, % initialize + if numel(obj.w)==0 % initialize obj.w = zeros(length(x),1); end diff --git a/lib/norma.m b/lib/norma.m index 55cea57..b5b7590 100644 --- a/lib/norma.m +++ b/lib/norma.m @@ -28,8 +28,8 @@ methods function kaf = norma(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end diff --git a/lib/phypass.m b/lib/phypass.m index 8d1d57f..3ee3f98 100644 --- a/lib/phypass.m +++ b/lib/phypass.m @@ -32,8 +32,8 @@ methods function kaf = phypass(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -76,7 +76,7 @@ function train(kaf,x,y) % train the algorithm Kmemdict = kernel(kaf.mem,kaf.dict,kaf.kerneltype,kaf.kernelpar); Kdict = kernel(kaf.dict,kaf.dict,kaf.kerneltype,kaf.kernelpar); - for k=1:num, + for k=1:num d_check = Kmemdict(k,:); % kernel between k'th memory element and full dictionary [mm,ii] = sort(d_check,'descend'); %#ok dict_id(:,k) = ii(1:num_d); % memory indexes @@ -95,7 +95,7 @@ function train(kaf,x,y) % train the algorithm denominator = zeros(num,1); beta = zeros(num,1); - for k=1:num, + for k=1:num numerator(k) = Kmemdict(k,:)*kaf.alpha; denominator(k) = Kmemdict(k,dict_id(:,k))*alpha_new(:,k); beta(k) = (kaf.d(k) - numerator(k))/(denominator(k)); % progress of the projection onto hyperplanes @@ -104,11 +104,11 @@ function train(kaf,x,y) % train the algorithm end G = zeros(num,num); - for k = 1:num, + for k = 1:num Grow = alpha_new(:,k)'*Kdict(dict_id(:,k),dict_id); sti = 1; ndi = num_d; - for l = 1:num, + for l = 1:num G(k,l) = Grow(1,sti:ndi)*alpha_new(:,l); sti = ndi + 1; ndi = ndi + num_d; diff --git a/lib/problms.m b/lib/problms.m index 342e4a5..6f58e6b 100644 --- a/lib/problms.m +++ b/lib/problms.m @@ -24,8 +24,8 @@ methods function obj = problms(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(obj)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(obj)) obj.(fn{1}) = parameters.(fn{1}); end end @@ -42,7 +42,7 @@ function train(obj,x,y) % train the algorithm m = length(x); - if numel(obj.w)==0, % initialize + if numel(obj.w)==0 % initialize obj.w = zeros(m,1); end diff --git a/lib/profiler/exkrls_profiler.m b/lib/profiler/exkrls_profiler.m index 2dc3a1e..b09b27b 100644 --- a/lib/profiler/exkrls_profiler.m +++ b/lib/profiler/exkrls_profiler.m @@ -19,7 +19,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing + if kaf.prev_dict_size < m % growing m1 = m; m2 = m - 1; floptions = struct(... diff --git a/lib/profiler/fbkrls_profiler.m b/lib/profiler/fbkrls_profiler.m index 0acd505..4fa98eb 100644 --- a/lib/profiler/fbkrls_profiler.m +++ b/lib/profiler/fbkrls_profiler.m @@ -19,7 +19,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing + if kaf.prev_dict_size < m % growing m1 = m; m2 = m - 1; m4 = m; diff --git a/lib/profiler/kafbox_profiler.m b/lib/profiler/kafbox_profiler.m index b1e998e..4a3d58f 100644 --- a/lib/profiler/kafbox_profiler.m +++ b/lib/profiler/kafbox_profiler.m @@ -9,22 +9,22 @@ num_algo = length(algorithms); numsim = 1; -if isfield(sim_opts,'numsim'), +if isfield(sim_opts,'numsim') numsim = sim_opts.numsim; end % pre-allocate structure results = cell(num_algo,1); -for algo_ind = 1:num_algo, +for algo_ind = 1:num_algo num_config = length(algorithms{algo_ind}.options.sweep_val); algo_results = cell(num_config,1); - for config_ind = 1:num_config, + for config_ind = 1:num_config algo_results{config_ind} = cell(numsim,1); end results{algo_ind} = algo_results; end -for sim_ind = 1:numsim, % process simulations +for sim_ind = 1:numsim % process simulations fprintf('SIM %2d\n',sim_ind); for algo_ind = 1:num_algo % process algorithms @@ -34,7 +34,7 @@ sweep_val = algo.options.sweep_val; num_config = length(sweep_val); % number of iterations in sweep - for config_ind = 1:num_config, % process configurations + for config_ind = 1:num_config % process configurations algo_config = algo; fprintf('%9s %10s: ',algo_config.name,... struct2str(struct(sweep_par,sweep_val(config_ind)))); diff --git a/lib/profiler/kafbox_profiler_msecurves.m b/lib/profiler/kafbox_profiler_msecurves.m index ff88a5b..3c0247c 100644 --- a/lib/profiler/kafbox_profiler_msecurves.m +++ b/lib/profiler/kafbox_profiler_msecurves.m @@ -17,13 +17,13 @@ num_setups = length(results); MSE_avg_setups = cell(num_setups,1); -for setup_ind = 1:num_setups, +for setup_ind = 1:num_setups setup_results = results{setup_ind}; num_configs = length(setup_results); MSE_avg_configs = cell(num_configs,1); - for config_ind = 1:num_configs, + for config_ind = 1:num_configs config_results = setup_results{config_ind}; if isfield(config_results{1},'NMSE') @@ -34,7 +34,7 @@ MSE = zeros(N,1); num_sim = length(config_results); - for sim_ind = 1:num_sim, + for sim_ind = 1:num_sim simresults = config_results{sim_ind}; if isfield(simresults,'NMSE') % temporary diff --git a/lib/profiler/kafbox_profiler_plotresults.m b/lib/profiler/kafbox_profiler_plotresults.m index 7fe8a66..9c1545d 100644 --- a/lib/profiler/kafbox_profiler_plotresults.m +++ b/lib/profiler/kafbox_profiler_plotresults.m @@ -64,7 +64,7 @@ numsim = length(config_results); flops = 0; bytes = 0; - for sim_ind = 1:numsim, + for sim_ind = 1:numsim sim_results = config_results{sim_ind}; bytes = max(bytes,sim_results.bytes); flops = max(flops,sim_results.flops); @@ -77,7 +77,7 @@ r.ssmse = ss; clear target_mse - for i=1:2, + for i=1:2 switch pmeasures{i} case 'ssplus' target_mse = ss + opt; @@ -132,11 +132,11 @@ xlabel(labels{1}); ylabel(labels{2}); -if logaxis(1), +if logaxis(1) xtl = get(gca,'XTickLabel'); set(gca,'XTickLabel',str2log10(xtl)); end -if logaxis(2), +if logaxis(2) ytl = get(gca,'YTickLabel'); set(gca,'YTickLabel',str2log10(ytl)); end @@ -185,7 +185,7 @@ function str = print_formatted_value(s,v) -if (v-round(v))^2<1E-8, +if (v-round(v))^2<1E-8 str = sprintf('%s = %d',s,v); else str = sprintf('%s = %.2f',s,v); @@ -194,7 +194,7 @@ % add log10 to string numbers function b = str2log10(a) b = cell(length(a),1); -for i=1:length(a), +for i=1:length(a) if isa(a,'cell') el = a{i}; else diff --git a/lib/profiler/kafbox_profiler_simulation.m b/lib/profiler/kafbox_profiler_simulation.m index 2885dee..a0930fd 100644 --- a/lib/profiler/kafbox_profiler_simulation.m +++ b/lib/profiler/kafbox_profiler_simulation.m @@ -23,7 +23,7 @@ % check if results for this simulation have been stored before simresults = kafbox_profiler_storet(simdata,algo_config,output_dir); -if isempty(simresults), % perform simulation +if isempty(simresults) % perform simulation [X,Y,X_test,Y_test] = kafbox_data(simdata); % load data @@ -48,7 +48,7 @@ y_test_ind(data.N_switch:end) = 2; end - for i=1:N, + for i=1:N Y_est = kaf.evaluate(X(i,:)); % predict kaf.train_profiled(X(i,:),Y(i)); % train @@ -72,7 +72,7 @@ Y_est = kaf.evaluate(X_test); % test on multiple data end erm_val = mean((Y_test(:,y_test_ind(i)) - Y_est).^2); - if strcmp(erm,'NMSE'), + if strcmp(erm,'NMSE') erm_val = erm_val/var_test; %#ok end eval(sprintf('%s(i) = erm_val;',erm)) diff --git a/lib/profiler/kafbox_profiler_storet.m b/lib/profiler/kafbox_profiler_storet.m index fb70713..8a03f41 100644 --- a/lib/profiler/kafbox_profiler_storet.m +++ b/lib/profiler/kafbox_profiler_storet.m @@ -28,14 +28,14 @@ % all relevant values in one array my_config = config.options; fn = fieldnames(data); -for i = 1:length(fn), +for i = 1:length(fn) if ~strcmp(fn{i},'name') my_config.(sprintf('data_%s',fn{i})) = data.(fn{i}); end end skiplist = {'sweep_par','sweep_val','data_numsim'}; -for i = 1:length(skiplist), +for i = 1:length(skiplist) if isfield(my_config,skiplist{i}) my_config = rmfield(my_config,skiplist{i}); end @@ -71,9 +71,9 @@ str = struct2str(my_config); -for i=1:length(configs), +for i=1:length(configs) stri = configs{i}.cstr; - if strcmp(str,stri), + if strcmp(str,stri) id = configs{i}.id; r = load_results(results_path,id); return @@ -82,7 +82,7 @@ r = []; -function save_results(results,results_path,id) %#ok +function save_results(results,results_path,id) fname = sprintf('%s/%s',results_path,id); save(fname,'results'); diff --git a/lib/profiler/kap_profiler.m b/lib/profiler/kap_profiler.m index 95852c3..7c8eada 100644 --- a/lib/profiler/kap_profiler.m +++ b/lib/profiler/kap_profiler.m @@ -20,7 +20,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing + if kaf.prev_dict_size < m % growing m1 = m - 1; m2 = m - 1; else diff --git a/lib/profiler/klms_profiler.m b/lib/profiler/klms_profiler.m index 9063833..26adeb7 100644 --- a/lib/profiler/klms_profiler.m +++ b/lib/profiler/klms_profiler.m @@ -19,7 +19,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing + if kaf.prev_dict_size < m % growing m1 = m - 1; floptions = struct(... 'sum', m1 - 1, ... diff --git a/lib/profiler/knlms_profiler.m b/lib/profiler/knlms_profiler.m index ebd21bb..ee83e27 100644 --- a/lib/profiler/knlms_profiler.m +++ b/lib/profiler/knlms_profiler.m @@ -20,7 +20,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing + if kaf.prev_dict_size < m % growing m1 = m - 1; n2 = 1; else diff --git a/lib/profiler/krls_profiler.m b/lib/profiler/krls_profiler.m index 07b1701..9f76091 100644 --- a/lib/profiler/krls_profiler.m +++ b/lib/profiler/krls_profiler.m @@ -20,7 +20,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing + if kaf.prev_dict_size < m % growing m1 = m; m2 = m - 1; m3 = m - 1; diff --git a/lib/profiler/norma_profiler.m b/lib/profiler/norma_profiler.m index 52deccb..bca24ed 100644 --- a/lib/profiler/norma_profiler.m +++ b/lib/profiler/norma_profiler.m @@ -21,7 +21,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing (no pruning) + if kaf.prev_dict_size < m % growing (no pruning) m1 = m-1; else m1 = m; diff --git a/lib/profiler/qklms_profiler.m b/lib/profiler/qklms_profiler.m index e53781d..969a91f 100644 --- a/lib/profiler/qklms_profiler.m +++ b/lib/profiler/qklms_profiler.m @@ -20,7 +20,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing + if kaf.prev_dict_size < m % growing m1 = m-1; n4 = 1; n5 = 1; diff --git a/lib/profiler/struct2str.m b/lib/profiler/struct2str.m index e23ca9b..23dde38 100644 --- a/lib/profiler/struct2str.m +++ b/lib/profiler/struct2str.m @@ -13,7 +13,7 @@ str = sprintf('%s %s=%d',str,fn,fv); else found = 0; - for j=0:10, + for j=0:10 if (round(10^j*fv)==10^j*fv) && ~found str = sprintf(sprintf('%%s %%s=%%.%df',j),str,fn,fv); found = 1; diff --git a/lib/profiler/swkrls_profiler.m b/lib/profiler/swkrls_profiler.m index 3ed46ff..7ab682b 100644 --- a/lib/profiler/swkrls_profiler.m +++ b/lib/profiler/swkrls_profiler.m @@ -19,7 +19,7 @@ function flops = lastflops(kaf) % flops for last iteration m = size(kaf.dict,1); - if kaf.prev_dict_size < m, % growing + if kaf.prev_dict_size < m % growing m1 = m; m2 = m - 1; floptions = struct(... diff --git a/lib/qklms.m b/lib/qklms.m index 59bf37d..5fa4ba2 100644 --- a/lib/qklms.m +++ b/lib/qklms.m @@ -25,8 +25,8 @@ methods function kaf = qklms(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -52,7 +52,7 @@ function train(kaf,x,y) % train the algorithm else % find distance to closest dictionary element [d2,j] = min(sum((kaf.dict - repmat(x,m,1)).^2,2)); end - if d2 <= kaf.epsu^2, % reduced coefficient update + if d2 <= kaf.epsu^2 % reduced coefficient update kaf.alpha(j) = kaf.alpha(j) + kaf.eta*err; else kaf.dict = [kaf.dict; x]; % add base to dictionary diff --git a/lib/qklms_fb.m b/lib/qklms_fb.m index 32b7da3..7bc582c 100644 --- a/lib/qklms_fb.m +++ b/lib/qklms_fb.m @@ -32,8 +32,8 @@ methods function kaf = qklms_fb(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end @@ -62,7 +62,7 @@ function train(kaf,x,y) % train the algorithm c1 = pi*kaf.kernelpar^2/2; % pre-calculate - if d2 <= kaf.epsu^2, % new basis under quantization threshold + if d2 <= kaf.epsu^2 % new basis under quantization threshold kaf.alpha(j) = kaf.alpha(j) + kaf.eta*err; % update significance for quantizing y to j-th centre (16) diff --git a/lib/rffklms.m b/lib/rffklms.m index d14d08e..adf6495 100644 --- a/lib/rffklms.m +++ b/lib/rffklms.m @@ -27,8 +27,8 @@ methods function kaf = rffklms(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end diff --git a/lib/rls.m b/lib/rls.m index b2d6a01..f043d18 100644 --- a/lib/rls.m +++ b/lib/rls.m @@ -22,8 +22,8 @@ function obj = rls(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(obj)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(obj)) obj.(fn{1}) = parameters.(fn{1}); end end @@ -39,7 +39,7 @@ end function train(obj,x,y) % train the algorithm - if numel(obj.w)==0, % initialize + if numel(obj.w)==0 % initialize m = length(x); obj.w = zeros(m,1); obj.P = obj.c\eye(m); diff --git a/lib/swkrls.m b/lib/swkrls.m index 8ff303a..2cf2477 100644 --- a/lib/swkrls.m +++ b/lib/swkrls.m @@ -28,8 +28,8 @@ methods function kaf = swkrls(parameters) % constructor if (nargin > 0) % copy valid parameters - for fn = fieldnames(parameters)', - if ismember(fn,fieldnames(kaf)), + for fn = fieldnames(parameters)' + if ismember(fn,fieldnames(kaf)) kaf.(fn{1}) = parameters.(fn{1}); end end diff --git a/lib/test/unit_test.m b/lib/test/unit_test.m index 3a72f28..50b2347 100644 --- a/lib/test/unit_test.m +++ b/lib/test/unit_test.m @@ -33,7 +33,7 @@ end % check for invalid names -for a=algorithms, +for a=algorithms unexisting = isempty(find(ismember(allfiles,a{1}),1)); if unexisting error('Algorithm not found: %s.',a{1}); @@ -101,7 +101,7 @@ fprintf('\n') fprintf('1 training step................\n') - for i=1, + for i=1 try kaf.train(x(i,:),y(i)); catch err @@ -116,7 +116,7 @@ end fprintf('Training with repeated data....') - for i=1:10, + for i=1:10 if ~mod(i,floor(N/10)), fprintf('.'); end kaf.train(x(1,:),y(1)); % y_test = kaf.evaluate(x(i+1,:)); @@ -124,7 +124,7 @@ fprintf('\n') fprintf('Long training........') - for i=1:N, + for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end kaf.train(x(i,:),y(i)); % y_test = kaf.evaluate(x(i+1,:)); diff --git a/lib/test/unit_test_profiler.m b/lib/test/unit_test_profiler.m index c656590..b29397b 100644 --- a/lib/test/unit_test_profiler.m +++ b/lib/test/unit_test_profiler.m @@ -38,7 +38,7 @@ function unit_test_profiler(varargin) end % check for invalid names -for a=algorithms, +for a=algorithms unexisting = isempty(find(ismember(allfiles,a{1}),1)); if unexisting error('Algorithm not found: %s.',a{1}); @@ -98,7 +98,7 @@ function unit_test_profiler(varargin) y = sin(3*x(:,1)).*cos(x(:,1)+x(:,2)); fprintf('1 training step................\n') - for i=1, + for i=1 try kaf.train_profiled(x(i,:),y(i)); catch err @@ -118,7 +118,7 @@ function unit_test_profiler(varargin) fprintf('Profiled training....') flops_all = zeros(N,1); bytes_all = zeros(N,1); - for i=1:N, + for i=1:N if ~mod(i,floor(N/10)), fprintf('.'); end kaf.train_profiled(x(i,:),y(i)); diff --git a/lib/util/kafbox_predictionloop.m b/lib/util/kafbox_predictionloop.m index 814fa23..68452d9 100644 --- a/lib/util/kafbox_predictionloop.m +++ b/lib/util/kafbox_predictionloop.m @@ -6,15 +6,15 @@ function [e,kaf] = kafbox_predictionloop(kaf,X,y,vb) -if nargin<4, +if nargin<4 vb = 1; end N = size(X,1); e = zeros(N,1); -for n=1:N, - if ~mod(n,floor(N/10)) && vb, +for n=1:N + if ~mod(n,floor(N/10)) && vb fprintf('.'); % progress indicator (10 dots) end @@ -23,6 +23,6 @@ kaf.train(X(n,:),y(n)); % train with one input-output pair end -if vb, +if vb fprintf('\n'); -end; +end diff --git a/lib/util/kafbox_quickrun.m b/lib/util/kafbox_quickrun.m index ba72eaf..e2d89ea 100644 --- a/lib/util/kafbox_quickrun.m +++ b/lib/util/kafbox_quickrun.m @@ -8,7 +8,7 @@ function kafbox_quickrun(kafname,datasetname,kafopt,dataopt) rng(1) t1 = tic; -if nargin > 2, +if nargin > 2 kaf = feval(kafname,kafopt); else kaf = feval(kafname); @@ -23,8 +23,8 @@ function kafbox_quickrun(kafname,datasetname,kafopt,dataopt) N_switch = 500; MSE = zeros(N,1); -for n=1:N, - if ~mod(n,floor(N/10)), +for n=1:N + if ~mod(n,floor(N/10)) fprintf('.'); % progress indicator (10 dots) end