random.c

来自「在TI的CCS环境下用C语言编写的lms算法,已经通过测试」· C语言 代码 · 共 42 行

C
42
字号
/*
	random.c - Zero-mean random noise 
*/  

#define USE_DATA 0

#if USE_DATA  /* Use random data file as input */   
#pragma CODE_SECTION(random, "lms_code"); 
#pragma DATA_SECTION(randdata, "lms_data"); 
#pragma DATA_SECTION(i, "lms_cinit"); 
 
#include "randdata.dat"

static unsigned int i=0;

void random(int *x, unsigned int N)
{       
    unsigned int t;

    for (t=N; t>0; t--) 
    {
       *x++ = randdata[i];
       i++;
       if (i == 10000)
         i=0;                
    }                                       
}

#else   /* Use random function for input */

#include <math.h>

#pragma CODE_SECTION(random, "lms_code"); 
        
void random(int *x, unsigned int N)
{
    unsigned int t;
    for (t=N; t>0; t--)
       *x++ = rand()-0x4000;
}
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?