cxcorr

Capsim Block Documentation

Short Description

This star correlates the input samples with the sequence given in a file.

Top
Input Connections
Port Type Name
0 complex x
Top
Output Connections
Port Type Name
0 complex y
Top
Parameters
Num Description Type Name Default Value
0 File name containing sequence to correlate file filename
1 Number of samples in sequence int N
Top
States
Num Type Name Initial Value Description
0 complex* x_P
1 complex* h_P
2 int Ndiv2
Top

Declarations


 

   	int i;
   	int j;
	complex tmp1,tmp2;
        complex  sum;
        complex tmp;
	FILE *fopen();
	FILE *imp_F;



Top

Initialization Code



 

        Ndiv2=N/2;
	/*
	 * Allocate memory and return pointers for tapped delay line x_P and
	 * array containing impulse response samples, h_P.
	 *
	 */
	if( (x_P = (complex*)calloc(N,sizeof(complex))) == NULL ||
	    (h_P = (complex*)calloc(N,sizeof(complex))) == NULL ) {
	   	fprintf(stderr,"cxcorr: can't allocate work space\n");
		return(4);
	}
	/*
	 * open file containing impulse response samples. Check
	 * to see if it exists.
	 *
	 */
        if( (imp_F = fopen(filename,"r")) == NULL) {
		fprintf(stderr,"cxcorr could not be opened file was %s \n",
				filename);
		return(4);
	}
	/*
	 * Read in the impulse response samples into the array
	 * and initialize the tapped delay line to zero.
	 *
	 */
	for (i=0; i
    
Top

Main Code



 




	while(IT_IN(0)){
		/*
		 * Shift input sample into tapped delay line
		 */
		tmp2=x(0);
		for(i=0; i
    
Top

Wrapup Code



 

	free(x_P); free(h_P); 




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



 

/* cxcorr.s */
/***********************************************************************
                             cxcorr()
************************************************************************
This star correlates the input samples with the sequence given in a file.
Param:	1 - (file) File with the sequence to correlate
	2 - (int) N  number of samples in the sequence.

cxcorr


This star correlates the input samples with the sequence given in a file.
Param:	1 - (file) File with the sequence to correlate
	2 - (int) N  number of samples in the sequence.


Date:  September 23, 1988 
Programmer: Adali Tulay
Modified: August 27, 2001 for complex correlation, Sasan Ardalan

*/