File: remezb.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (66 lines) | stat: -rw-r--r-- 1,654 bytes parent folder | download | duplicates (2)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function [an]=remezb(nc,fg,ds,wt)
//<an>=remezb(nc,fg,ds,wt)
//Minimax approximation of a frequency domain
//magnitude response.  The approximation takes
//the form
//
//          h = sum[a(n)cos(wn)]
//
//for n=0,1,...,nc.  An FIR, linear-phase filter
//can be obtained from the the output of the macro
//by using the following Scilab commands
//
//          hn(1:nc-1)=an(nc:-1:2)/2;
//          hn(nc)=an(1);
//          hn(nc+1:2*nc-1)=an(2:nc)/2;
//
//  nc :Number of cosine functions
//  fg :Grid of frequency points in [0,.5)
//  ds :Desired magnitude on grid fg
//  wt :Weighting function on error on grid fg
//  an :Cosine filter coefficients
//!
// author: C. Bunks  date: 24 August 1988
// Copyright INRIA

//get frequency grid size
 
   ngrid=maxi(size(fg));
 
//check for errors in input
 
   f0=fg(1);
   f1=fg(ngrid);
   if f0<0 then
      error('values of fg must be in [0,.5] --- program stopped'),
   end,
   if f0>.5 then
      error('values of fg must be in [0,.5] --- program stopped'),
   end,
   if f1<0 then
      error('values of fg must be in [0,.5] --- program stopped'),
   end,
   if f1>.5 then
      error('values of fg must be in [0,.5] --- program stopped'),
   end,
   dsize=maxi(size(ds));
   wsize=maxi(size(wt));
   if dsize<>ngrid then
      error('fg and ds vectors are not the same length --- program stopped'),
   end,
   if wsize<>ngrid then
      error('fg and wt vectors are not the same length --- program stopped'),
   end,
 
//set up the initial guess for the extremal frequencies
 
   iext=round(1:ngrid/nc:ngrid);
   iext(nc+1)=ngrid;
   iext(nc+2)=ngrid;
 
//call remez.f
 
   an=remez(iext,ds,fg,wt);