predftf

Capsim Block Documentation

Short Description

This star implements a multichannel input/output FIR predictor, which is adapted using the least squares Fast Transversal Filter algorithm.

Top
Parameters
Num Description Type Name Default Value
0 Name of ASCII input specification file file ifile_name prfile
1 Name of ASCII output specification file file ofile_name prfileo
2 Forgetting factor <= 1.0 float lambda 1.0
3 Initial value: forward prediction energy value float delta 1e-4
4 Number of samples to skip before starting adaptation int wait 0
5 Number of samples to adapt.Freeze after this number of iterations int adapt -1
Top
States
Num Type Name Initial Value Description
0 int counter
1 float* inpower
2 float* epower
3 int p
4 int q
5 FILE* fp
6 int* orders
7 int N
8 float* z
9 float* Z
10 float* F
11 float* B
12 float* C
13 float* Cp
14 float* W
15 float* Efi
16 float* Eb
17 float gamma
Top

Declarations


 

        int i,j,k,jj;
        float error[Mch];
        int index;              /* convenience counter */
        float estimate;
        float cb[Mch];          /* last p elements of Cp[ ] */
        float a[Mch];           /* auxilliary (temp) vector */
        float temp[Mch+1];      /* small working vector */
        float sum;              /* working accumulator */
        float ef[Mch];          /* forward est. error */
        float efp[Mch];         /* forward pred. error */
        float eb[Mch];          /* backward est. err. */
        float ebp[Mch];         /* b. prediction error */
        float gmp;              /* extended gain estimation error */



Top

Initialization Code



 

        if(NO_OUTPUT_BUFFERS() < 1) {
                fprintf(stderr,"pred: no output data channels\n");
                return(1);
        }
        if(NO_INPUT_BUFFERS() < NO_OUTPUT_BUFFERS() +1) {
                fprintf(stderr,"pred: not enough input buffers\n");
                return(2);
        }
        if((fp = fopen(ifile_name, "r")) == NULL) {
                fprintf(stderr,"pred: can't find filter specification file\n");
                return(3);
        }
        fscanf(fp, "%d", &q);
        fscanf(fp, "%d", &p);
        if(p > Mch || q > Mch) {
                fprintf(stderr,"pred: more than %d i/o channels\n",Mch);
                return(4);
        }
        if( q != NO_OUTPUT_BUFFERS() ||
            p != NO_INPUT_BUFFERS() - q ) {
                fprintf(stderr,
                "pred: spec file %s does not agree with topology\n",
                        ifile_name);
                return(5);
        }
        if(   (orders = (int*)calloc(p,sizeof(int))) == NULL
           || (z = (float*)calloc(p,sizeof(float))) == NULL
           || (inpower = (float*)calloc(p,sizeof(float))) == NULL
           || (epower = (float*)calloc(q,sizeof(float))) == NULL
           || (Efi = (float*)calloc(p*p,sizeof(float))) == NULL
           || (Eb = (float*)calloc(p*p,sizeof(float))) == NULL) {
                fprintf(stderr,"pred: can't allocate space\n");
                return(6);
        }
        N = 0;
        for(j=0; j
    
Top

Main Code



 


#if 0
if(MIN_AVAIL() == 0) return(0);
#endif
for(jj = MIN_AVAIL(); jj>0; jj--) {

if(wait > 0) {
        wait--;
        for(k=0; k W(n-1)  (15) */
        for(i=0; i0; i--)
        Z[i] = Z[i-1];
index = 0;
for(j=0; j 0) adapt--;

}
return(0);





Top

Wrapup Code



 

for(j=0; j
    
Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP Corporation

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/**********************************************************************
                predftf()
***********************************************************************
This star implements a multichannel input/output FIR predictor, which is
adapted using the least squares Fast Transversal Filter algorithm.
It can be used as an equalizer, FSE, DFE, or echo canceller.
An arbitrary number p input channels are transversal filtered
to produce an arbitrary number q output estimate signals.
Note: each output buffer connected to this star implies a separate
output channel, and identically numbered error input channel.
Input signal channels are then connected to higher numbered buffers.
It is assumed that the estimate error is computed externally.
Do NOT implement an external (causality) unit-delay from
output estimate to input error; this delay is handled automatically.
Param.  1 - Name of ASCII input specification file.  Filter orders
                and initial tap values are given.  default => prfile
The proper specification file format is:
  (int) # output channels, q
  (int) # input channels, p
  (int) order of in ch.#1  . . .  (int) order of in ch.#p
  (float) ch.#1, tap 1 . . .  (float) ch.#1, tap last
      .                                                {output ch.1}
      .
  (float) ch.#p, tap 1 . . .  (float) ch.#p, tap last
   .
   .
   .
  (float) ch.#1, tap 1 . . .  (float) ch.#1, tap last
      .                                                {output ch.q}
      .
  (float) ch.#p, tap 1 . . .  (float) ch.#p, tap last
Param.  2 - Name of output file, for final adapted filter values.
          default => prfileo.  The file is written in proper
          input-file format.  This file can then be used to initialize
          the filter for the next run, if desired.
It is assumed that each output prediction filter will create one
estimate output for EACH input sample/error sample pair.
Any decimation, etc. must occur externally.
Param.  3 - (float) lambda.  data forgetting factor.  default => 1.0
          Lambda = 1.0 implies no long term adaptation occurs.
        4 - (float) delta.  initial value, forward prediction energy.
          default => 1e-4
        5 - (int) wait.  number of samples to skip before starting
          adaptation.  The predictor still inputs samples, and
          outputs a zero estimate.  default => 0
        6 - (int) adapt.  number of samples to adapt filter.  After
          this number, filter taps are fixed, and estimates are still
          produced.  default => -1  (implies always adapt)

predftf


This star implements a multichannel input/output FIR predictor, which is
adapted using the least squares Fast Transversal Filter algorithm.
It can be used as an equalizer, FSE, DFE, or echo canceller.
An arbitrary number p input channels are transversal filtered
to produce an arbitrary number q output estimate signals.
Note: each output buffer connected to this star implies a separate
output channel, and identically numbered error input channel.
Input signal channels are then connected to higher numbered buffers.
It is assumed that the estimate error is computed externally.
Do NOT implement an external (causality) unit-delay from
output estimate to input error; this delay is handled automatically.
Param.  1 - Name of ASCII input specification file.  Filter orders
                and initial tap values are given.  default => prfile
The proper specification file format is:
  (int) # output channels, q
  (int) # input channels, p
  (int) order of in ch.#1  . . .  (int) order of in ch.#p
  (float) ch.#1, tap 1 . . .  (float) ch.#1, tap last
      .                                                {output ch.1}
      .
  (float) ch.#p, tap 1 . . .  (float) ch.#p, tap last
   .
   .
   .
  (float) ch.#1, tap 1 . . .  (float) ch.#1, tap last
      .                                                {output ch.q}
      .
  (float) ch.#p, tap 1 . . .  (float) ch.#p, tap last
Param.  2 - Name of output file, for final adapted filter values.
          default => prfileo.  The file is written in proper
          input-file format.  This file can then be used to initialize
          the filter for the next run, if desired.
It is assumed that each output prediction filter will create one
estimate output for EACH input sample/error sample pair.
Any decimation, etc. must occur externally.
Param.  3 - (float) lambda.  data forgetting factor.  default => 1.0
          Lambda = 1.0 implies no long term adaptation occurs.
        4 - (float) delta.  initial value, forward prediction energy.
          default => 1e-4
        5 - (int) wait.  number of samples to skip before starting
          adaptation.  The predictor still inputs samples, and
          outputs a zero estimate.  default => 0
        6 - (int) adapt.  number of samples to adapt filter.  After
          this number, filter taps are fixed, and estimates are still
          produced.  default => -1  (implies always adapt)


Programmer: L.J. Faber
Date: April 1988
Modified: May 1988  add multichannel output
Modified: June 1988  estimate-referenced prediction energy
Modified: Aug 1988  est. input power.  new parameter delta.
Modified: Sept 1988  add parameters 5,6 and associated.

*/