-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrls.sci
43 lines (39 loc) · 2.06 KB
/
rls.sci
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
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) Scilab Enterprises - 20xx-2012 - Kartik PATEL <[email protected]>
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function alg = rls(forgetfactor, varargin)
// alg = rls(forgetfactor, invcorr0)
// This function creates an AdaptiveAlgorithm Object for a Recursive Least Square Algorithm
// to use it with `lineareq` or `dfe` to create an equalizer object.
// NOTE: For now, the object is expressed as a structure type.
//
// Input Arguments:
// forgetfactor : Any non-negative real number. It is forgetfactor parameter for RLS algorithm.
// invcorr0 : Real number between 0 to 1. It sets initialisation parameter for inverse correlation matrix. (Default = 1)
// Output:
// alg : Adaptive Alagorithm Object based on Input parameters. Implemented as a Structure type.
if argn(2) > 2 then
error(msprintf(gettext("Invalid number of input argument\n")));
end
// Condition check on stepsize
if forgetfactor ~= conj(forgetfactor) then //Not real forgetfactor
error(msprintf(gettext("Input forgetfactor must be real number between 0 and 1.")));
end
if forgetfactor < 0 | forgetfactor > 1 then //Invalid forgetfactor
error(msprintf(gettext("Input stepsize must be non-negative real number")));
end
//Condition check on invcorr0 if provided
if argn(2) == 2 then
invcorr0 = varargin(1);
else
invcorr0 = 1; //Default value of invcorr0 to a scalar
end
// Input checks end
alg = struct('AlgType', 'RLS', 'ForgetFactor', forgetfactor, 'InvCorrInit', invcorr0);
// NOTE: The output must be AdaptiveAlgorithm Object. But currently, it is implemented as a Structure type.
endfunction