From a555820564d9f2e95ca8c97871339d3a5a2081c3 Mon Sep 17 00:00:00 2001 From: Ankit Raj Date: Wed, 21 Jun 2017 10:26:59 +0530 Subject: Updated Scilab2C --- 2.3-1/src/c/signalProcessing/lev/sleva2.c | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 2.3-1/src/c/signalProcessing/lev/sleva2.c (limited to '2.3-1/src/c/signalProcessing/lev/sleva2.c') diff --git a/2.3-1/src/c/signalProcessing/lev/sleva2.c b/2.3-1/src/c/signalProcessing/lev/sleva2.c new file mode 100644 index 00000000..44d7974b --- /dev/null +++ b/2.3-1/src/c/signalProcessing/lev/sleva2.c @@ -0,0 +1,64 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008 - INRIA - Arnaud TORSET + * + * 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 + * + */ + + +/*Resolve the Yule-Walker equations: + + |r(0) r(1) ... r(N-1)|| a(1) | |sigma2| + |r(1) r(0) ... r(n-1)|| a(2) | | 0 | + | : : ... : || : |=| 0 | + | : : ... : || : | | 0 | + |r(N-1) r(N-2) ... r(0) ||a(N-1)| | 0 | + + using Levinson's algorithm. + r :Correlation coefficients + ar :Auto-Regressive model parameters + sigma2 :Scale constant + rc :Reflection coefficients +*/ + +#include +#include "lev.h" + +float sleva2(float* in,int size, float* ar){ + int i=0, j=0; + float accu=0; + float* ak1; + float sigma2; + + /* FIXME : malloc here */ + ak1=(float*)malloc((unsigned int)size*sizeof(float)); + + /* initialize levinson's algorithm */ + ar[0]=-in[1]/in[0]; + sigma2=(1-ar[0]*ar[0])*in[0]; + ak1[0]=0; + + /* iterative solution to yule-walker equations */ + for (i=1;i