kopia lustrzana https://github.com/Dsplib/libdspl-2.0
Changes to be committed:
modified: .gitignore modified: dspl/src/inout.c modified: dspl/src/xcorr.c modified: include/dspl.c modified: include/dspl.h modified: lapack/lapack_complex.inc new file: verification/src/dspl_verif.h modified: verification/src/writebin_readbin_verification_complex.c modified: verification/src/writebin_readbin_verification_double.c modified: verification/verif.shpull/6/merge
rodzic
0b3d577085
commit
226b1ff7d5
|
@ -10,6 +10,7 @@
|
|||
*.html
|
||||
*.png
|
||||
*.def
|
||||
*.log
|
||||
|
||||
!header_ru.html
|
||||
!footer_ru.html
|
||||
|
|
|
@ -26,6 +26,35 @@
|
|||
#include "dspl.h"
|
||||
|
||||
|
||||
|
||||
#ifdef DOXYGEN_ENGLISH
|
||||
|
||||
#endif
|
||||
#ifdef DOXYGEN_RUSSIAN
|
||||
|
||||
#endif
|
||||
int DSPL_API addlog(char* str, char* fn)
|
||||
{
|
||||
FILE* pFile = NULL;
|
||||
if(!str)
|
||||
return ERROR_PTR;
|
||||
|
||||
pFile = fopen(fn, "a+");
|
||||
if(pFile == NULL)
|
||||
return ERROR_FOPEN;
|
||||
|
||||
fprintf(pFile, "%s\n", str);
|
||||
|
||||
fclose(pFile);
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef DOXYGEN_ENGLISH
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,15 +47,33 @@ int DSPL_API xcorr(double* x, int nx, double* y, int ny,
|
|||
fft_t fft = {0};
|
||||
int err;
|
||||
complex_t *cr = (complex_t*)malloc((2 * nr + 1) * sizeof(complex_t));
|
||||
if(!cr)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
complex_t *cx = (complex_t*)malloc( nx * sizeof(complex_t));
|
||||
if(!cx)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
complex_t *cy = (complex_t*)malloc( ny * sizeof(complex_t));
|
||||
if(!cy)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
|
||||
err = re2cmplx(x, nx, cx);
|
||||
if(err != RES_OK)
|
||||
goto exit_label;
|
||||
|
||||
err = re2cmplx(y, ny, cy);
|
||||
|
||||
if(err != RES_OK)
|
||||
goto exit_label;
|
||||
|
||||
err = xcorr_krn(cx, nx, cy, ny, &fft, flag, nr, cr, t);
|
||||
if(err != RES_OK)
|
||||
goto exit_label;
|
||||
|
@ -65,6 +83,11 @@ int DSPL_API xcorr(double* x, int nx, double* y, int ny,
|
|||
exit_label:
|
||||
if(cr)
|
||||
free(cr);
|
||||
if(cx)
|
||||
free(cx);
|
||||
if(cy)
|
||||
free(cy);
|
||||
|
||||
fft_free(&fft);
|
||||
return err;
|
||||
}
|
||||
|
@ -148,12 +171,46 @@ int xcorr_krn(complex_t* x, int nx, complex_t* y, int ny, fft_t* pfft,
|
|||
|
||||
/* memory allocation */
|
||||
px = (complex_t*)malloc(nfft * sizeof(complex_t));
|
||||
if(!px)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
|
||||
py = (complex_t*)malloc(nfft * sizeof(complex_t));
|
||||
if(!py)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
|
||||
pc = (complex_t*)malloc(nfft * sizeof(complex_t));
|
||||
|
||||
if(!pc)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
|
||||
pX = (complex_t*)malloc(nfft * sizeof(complex_t));
|
||||
if(!pX)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
|
||||
pY = (complex_t*)malloc(nfft * sizeof(complex_t));
|
||||
if(!pY)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
|
||||
pC = (complex_t*)malloc(nfft * sizeof(complex_t));
|
||||
if(!pC)
|
||||
{
|
||||
err = ERROR_MALLOC;
|
||||
goto exit_label;
|
||||
}
|
||||
|
||||
memset(px, 0, nfft * sizeof(complex_t));
|
||||
memset(py, 0, nfft * sizeof(complex_t));
|
||||
|
@ -204,8 +261,32 @@ exit_label:
|
|||
|
||||
|
||||
|
||||
#ifdef DOXYGEN_ENGLISH
|
||||
/*******************************************************************************
|
||||
Return FFT size for autocorrelation or cross correlation vector calculation
|
||||
|
||||
/*
|
||||
Cross-correlation vector size is
|
||||
N = 2 * nx - 1, if nx > ny;
|
||||
N = 2 * ny - 1, if nx <= ny.
|
||||
|
||||
If cross-correlation size N may not be efficient for FFT
|
||||
then we can add zeros to get high-performance FFT size.
|
||||
|
||||
For example if N = 1025, then we can add zeros to 2048-points FFT but this way
|
||||
seems not so good because too much zeros.
|
||||
|
||||
If we rewrite N = 2^L + D, then we can use
|
||||
|
||||
NFFT = 2^L + 2^(L - P), here P = 0,1,2 or 3.
|
||||
|
||||
So NFFT = 2^(L-P) * (2^P + 1). Then 2^(L-P) can use radix-2 FFT, and additional
|
||||
composite multiplication if P = 0,1,2 or 3 equals
|
||||
9, 5, 3 or 2, and we have high-performance FFT algorithms for its points.
|
||||
If P = 4 then composite multiplier is (2^P + 1) = 17, has no good FFT.
|
||||
*******************************************************************************/
|
||||
#endif
|
||||
#ifdef DOXYGEN_RUSSIAN
|
||||
/*******************************************************************************
|
||||
Возвращает размер FFT для расчета полного вектора автокорреляции
|
||||
или кросскорреляции.
|
||||
|
||||
|
@ -223,11 +304,12 @@ N = 2 * ny - 1, eсли nx <= ny.
|
|||
|
||||
NFFT = 2^L + 2^(L - P), где P = 0,1,2 или 3.
|
||||
|
||||
Тогда NFFT = 2^(L-P) * (2^P + 1). Тогда 2^(L-P) реалиуем как radix-2, а
|
||||
Тогда NFFT = 2^(L-P) * (2^P + 1). Тогда 2^(L-P) реализуем как radix-2, а
|
||||
дополнительный составной множитель при P = 0,1,2 или 3 равен соответсвенно
|
||||
9, 5, 3 или 2, а для этих длин существуют хорошие процедуры.
|
||||
При P = 4 составной множитель будет (2^P + 1) = 17, что не очень хорошо.
|
||||
*/
|
||||
*******************************************************************************/
|
||||
#endif
|
||||
int xcorr_fft_size(int nx, int ny, int* pnfft, int* pndata)
|
||||
{
|
||||
int nfft, nfft2, r2, dnfft;
|
||||
|
@ -236,9 +318,7 @@ int xcorr_fft_size(int nx, int ny, int* pnfft, int* pndata)
|
|||
return ERROR_SIZE;
|
||||
if(!pnfft || !pndata)
|
||||
return ERROR_PTR;
|
||||
|
||||
|
||||
|
||||
|
||||
if(nx > ny)
|
||||
{
|
||||
nfft = 2*nx - 1;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#ifndef BUILD_LIB
|
||||
|
||||
p_acos_cmplx acos_cmplx ;
|
||||
p_addlog addlog ;
|
||||
p_array_scale_lin array_scale_lin ;
|
||||
p_asin_cmplx asin_cmplx ;
|
||||
|
||||
|
@ -342,6 +343,7 @@ void* dspl_load()
|
|||
#endif /* LINUX_OS */
|
||||
|
||||
LOAD_FUNC(acos_cmplx);
|
||||
LOAD_FUNC(addlog);
|
||||
LOAD_FUNC(array_scale_lin);
|
||||
LOAD_FUNC(asin_cmplx);
|
||||
|
||||
|
|
|
@ -674,6 +674,9 @@ DECLARE_FUNC(int, acos_cmplx, complex_t*
|
|||
COMMA int
|
||||
COMMA complex_t*);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
DECLARE_FUNC(int, addlog, char* str
|
||||
COMMA char* fn);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
DECLARE_FUNC(int, array_scale_lin, double* x
|
||||
COMMA int n
|
||||
COMMA double xmin
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,9 @@
|
|||
#ifndef DSPL_VERIF_H
|
||||
#define DSPL_VERIF_H
|
||||
|
||||
#define VERIF_STR_LEN 48
|
||||
#define VERIF_CHAR_POINT 46
|
||||
#define VERIF_LEVEL_COMPLEX 1E-11
|
||||
#define VERIF_LEVEL_DOUBLE 1E-12
|
||||
|
||||
#endif
|
|
@ -3,6 +3,10 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "dspl.h"
|
||||
#include "dspl_verif.h"
|
||||
|
||||
#define ARRAY_MAX_SIZE 1000000
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -19,15 +23,15 @@ int main(int argc, char* argv[])
|
|||
hdspl = dspl_load(); /* Load DSPL function */
|
||||
|
||||
sprintf(str, "writebin and readbin for complex data:");
|
||||
while(strlen(str) < 48)
|
||||
str[strlen(str)] = 46;
|
||||
while(strlen(str) < VERIF_STR_LEN)
|
||||
str[strlen(str)] = VERIF_CHAR_POINT;
|
||||
|
||||
|
||||
err = random_init(&rnd, RAND_TYPE_MRG32K3A, NULL);
|
||||
if(err != RES_OK)
|
||||
goto exit_error_code;
|
||||
|
||||
err = randi(&nx, 1, 1, 1000000, &rnd);
|
||||
err = randi(&nx, 1, 1, ARRAY_MAX_SIZE, &rnd);
|
||||
if(err != RES_OK)
|
||||
goto exit_error_code;
|
||||
|
||||
|
@ -58,7 +62,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
/**************************** Verification *******************************/
|
||||
verr = verif_cmplx(pxd, pyd, ny, 1E-12, &derr);
|
||||
verr = verif_cmplx(pxd, pyd, ny, VERIF_LEVEL_COMPLEX, &derr);
|
||||
if(verr != DSPL_VERIF_SUCCESS)
|
||||
goto exit_error_verif;
|
||||
|
||||
|
@ -75,6 +79,8 @@ exit_error_verif:
|
|||
exit_label:
|
||||
/************************ write str to log file **************************/
|
||||
|
||||
printf("%s\n", str);
|
||||
addlog(str, "verification.log");
|
||||
|
||||
if(pxd)
|
||||
free(pxd);
|
||||
|
@ -84,7 +90,7 @@ exit_label:
|
|||
/* free dspl handle */
|
||||
dspl_free(hdspl);
|
||||
|
||||
printf("%s\n", str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,17 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "dspl.h"
|
||||
#include "dspl_verif.h"
|
||||
|
||||
#define ARRAY_MAX_SIZE 1000000
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
void* hdspl; /* DSPL handle */
|
||||
double *pxd = NULL;
|
||||
double *pyd = NULL;
|
||||
double* pxd = NULL;
|
||||
double* pyd = NULL;
|
||||
char str[512] = {0};
|
||||
|
||||
|
||||
int nx, ny, tx, err, verr;
|
||||
double derr;
|
||||
|
@ -17,13 +22,16 @@ int main(int argc, char* argv[])
|
|||
|
||||
hdspl = dspl_load(); /* Load DSPL function */
|
||||
|
||||
printf("writebin and readbin for double data:..........");
|
||||
sprintf(str, "writebin and readbin for double data:");
|
||||
while(strlen(str) < VERIF_STR_LEN)
|
||||
str[strlen(str)] = VERIF_CHAR_POINT;
|
||||
|
||||
|
||||
err = random_init(&rnd, RAND_TYPE_MRG32K3A, NULL);
|
||||
if(err != RES_OK)
|
||||
goto exit_error_code;
|
||||
|
||||
err = randi(&nx, 1, 1, 1000000, &rnd);
|
||||
err = randi(&nx, 1, 1, ARRAY_MAX_SIZE, &rnd);
|
||||
if(err != RES_OK)
|
||||
goto exit_error_code;
|
||||
|
||||
|
@ -48,20 +56,22 @@ int main(int argc, char* argv[])
|
|||
err = ERROR_DAT_TYPE;
|
||||
goto exit_error_code;
|
||||
}
|
||||
verr = verif(pxd, pyd, ny, 1E-12, &derr);
|
||||
verr = verif(pxd, pyd, ny, VERIF_LEVEL_DOUBLE, &derr);
|
||||
if(verr != DSPL_VERIF_SUCCESS)
|
||||
goto exit_error_verif;
|
||||
|
||||
printf("ok (err = %12.4E)", derr);
|
||||
sprintf(str, "%s ok (err = %12.4E)", str, derr);
|
||||
goto exit_label;
|
||||
|
||||
exit_error_code:
|
||||
printf("FAILED (with code = 0x%8x)", err);
|
||||
sprintf(str, "%s FAILED (with code = 0x%8x)", str, err);
|
||||
goto exit_label;
|
||||
exit_error_verif:
|
||||
printf("FAILED (err = %12.4E)", derr);
|
||||
sprintf(str, "%s FAILED (err = %12.4E)", str, derr);
|
||||
|
||||
exit_label:
|
||||
addlog(str, "verification.log");
|
||||
printf("%s\n", str);
|
||||
if(pxd)
|
||||
free(pxd);
|
||||
if(pyd)
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
mingw32-make
|
||||
|
||||
rm -f bin/verification.log
|
||||
|
||||
cd bin
|
||||
for file in *.exe
|
||||
do
|
||||
"./$file"
|
||||
done
|
||||
cd ../
|
||||
cp bin/verification.log verification.log
|
||||
rm -f bin/verification.log
|
||||
pause 5
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue