~ubuntu-branches/ubuntu/trusty/gnuradio/trusty-updates

« back to all changes in this revision

Viewing changes to gnuradio-core/src/utils/partition-cascaded-decimating-filters.scm

  • Committer: Package Import Robot
  • Author(s): A. Maitland Bottoms
  • Date: 2012-02-26 21:26:16 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120226212616-vsfkbi1158xshdql
Tags: 3.5.1-1
* new upstream version, re-packaged from scratch with modern tools
    closes: #642716, #645332, #394849, #616832, #590048, #642580,
    #647018, #557050, #559640, #631863
* CMake build

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;; Estimate the total work (ntaps * sampling rate) for two cascaded
 
2
;; decimating low pass filters.
 
3
;;
 
4
;; The basic assumption is that the number of taps required in any 
 
5
;; section is inversely proportional to the normalized transition width
 
6
;; for that section.
 
7
;;
 
8
;; FS is the input sampling frequency
 
9
;; F1 is the cutoff frequency
 
10
;; F2 is the far edge of the transition band
 
11
;; DEC1 is the decimation factor for the first filter
 
12
;; DEC2 is the decimation factor for the 2nd filter
 
13
;;
 
14
;; The total decimation factor is DEC1 * DEC2.  Therefore,
 
15
;; the output rate of the filter is FS / (DEC1 * DEC2)
 
16
 
 
17
(require 'common-list-functions)
 
18
(require 'factor)
 
19
 
 
20
 
 
21
 
 
22
(define (work2 fs f1 f2 dec1 dec2)
 
23
  (+ (work1 fs f1 (/ fs (* 2 dec1)) dec1)
 
24
     (work1 (/ fs dec1) f1 f2 dec2)))
 
25
 
 
26
 
 
27
;; work for a single section
 
28
 
 
29
(define (work1 fs f1 f2 dec)
 
30
  (/ (* fs (/ fs (- f2 f1))) dec))
 
31
 
 
32
 
 
33
;; return the max integer dec such that fs/(2*dec) >= f2
 
34
 
 
35
(define (max-dec fs f2)
 
36
  (inexact->exact (floor (/ fs (* 2 f2)))))
 
37
 
 
38
 
 
39
;; `adjoin' returns the adjoint of the element OBJ and the list LST.
 
40
;;  That is, if OBJ is in LST, `adjoin' returns LST, otherwise, it returns
 
41
;;  `(cons OBJ LST)'.
 
42
 
 
43
(define (adjoin-equal obj lst)
 
44
  (if (member obj lst) lst (cons obj lst)))
 
45
 
 
46
 
 
47
;;; not quite right
 
48
 
 
49
(define (permute lst)
 
50
  (let ((result '()))
 
51
    (define (aux set head)
 
52
      (if (null? set)
 
53
          (set! result (cons head result))
 
54
          (for-each (lambda (x)
 
55
                      (aux (set-difference set (list x))
 
56
                           (cons x head)))
 
57
                    set)))
 
58
    (aux lst '())
 
59
    result))
 
60
 
 
61
;; `extract-nth' returns the Nth element of LST consed on to the
 
62
;; list resulting from splicing out the Nth element of LST.
 
63
;; Indexing is 0 based.
 
64
 
 
65
(define (extract-nth n lst)
 
66
  lst)
 
67
 
 
68
  
 
 
b'\\ No newline at end of file'