2020-09-04 11:43:44 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include "dspl.h"
|
2020-09-17 07:53:32 +00:00
|
|
|
|
#include "dspl_verif.h"
|
|
|
|
|
|
|
|
|
|
#define ARRAY_MAX_SIZE 1000000
|
|
|
|
|
|
2020-09-04 11:43:44 +00:00
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
void* hdspl; /* DSPL handle */
|
|
|
|
|
complex_t *pxd = NULL;
|
|
|
|
|
complex_t *pyd = NULL;
|
2020-09-05 15:22:03 +00:00
|
|
|
|
char str[512] = {0};
|
2020-09-04 11:43:44 +00:00
|
|
|
|
|
|
|
|
|
int nx, ny, tx, err, verr;
|
|
|
|
|
double derr;
|
|
|
|
|
|
|
|
|
|
random_t rnd = {0}; /* random structure */
|
|
|
|
|
|
|
|
|
|
hdspl = dspl_load(); /* Load DSPL function */
|
|
|
|
|
|
2020-09-05 15:22:03 +00:00
|
|
|
|
sprintf(str, "writebin and readbin for complex data:");
|
2020-09-17 07:53:32 +00:00
|
|
|
|
while(strlen(str) < VERIF_STR_LEN)
|
|
|
|
|
str[strlen(str)] = VERIF_CHAR_POINT;
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
2020-09-04 11:43:44 +00:00
|
|
|
|
|
|
|
|
|
err = random_init(&rnd, RAND_TYPE_MRG32K3A, NULL);
|
|
|
|
|
if(err != RES_OK)
|
|
|
|
|
goto exit_error_code;
|
|
|
|
|
|
2020-09-17 07:53:32 +00:00
|
|
|
|
err = randi(&nx, 1, 1, ARRAY_MAX_SIZE, &rnd);
|
2020-09-04 11:43:44 +00:00
|
|
|
|
if(err != RES_OK)
|
|
|
|
|
goto exit_error_code;
|
|
|
|
|
|
|
|
|
|
pxd = (complex_t*) malloc(nx * sizeof(complex_t));
|
|
|
|
|
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
|
|
|
|
/****************** verifiсation function start **************************/
|
2020-09-04 11:43:44 +00:00
|
|
|
|
err = randn((double*)pxd, 2*nx, 1.0, 10.0, &rnd);
|
|
|
|
|
if(err != RES_OK)
|
|
|
|
|
goto exit_error_code;
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
|
|
|
|
/************ Write input verification data to the file ******************/
|
2020-09-04 11:43:44 +00:00
|
|
|
|
err = writebin((void*)pxd, nx, DAT_COMPLEX, "dat/x.dat");
|
|
|
|
|
if(err != RES_OK)
|
|
|
|
|
goto exit_error_code;
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
|
|
|
|
/************ RUN external verificator (octave or python) ****************/
|
2020-09-04 11:43:44 +00:00
|
|
|
|
err = system("octave octave/writebin_readbin_verification.m");
|
|
|
|
|
|
2020-09-05 15:22:03 +00:00
|
|
|
|
/***************** Read external verificator output **********************/
|
2020-09-04 11:43:44 +00:00
|
|
|
|
err = readbin("dat/y.dat", (void**)(&pyd), &ny, &tx);
|
|
|
|
|
if(err != RES_OK)
|
|
|
|
|
goto exit_error_code;
|
|
|
|
|
if(tx!=DAT_COMPLEX)
|
|
|
|
|
{
|
|
|
|
|
err = ERROR_DAT_TYPE;
|
|
|
|
|
goto exit_error_code;
|
|
|
|
|
}
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
|
|
|
|
/**************************** Verification *******************************/
|
2020-09-17 07:53:32 +00:00
|
|
|
|
verr = verif_cmplx(pxd, pyd, ny, VERIF_LEVEL_COMPLEX, &derr);
|
2020-09-04 11:43:44 +00:00
|
|
|
|
if(verr != DSPL_VERIF_SUCCESS)
|
|
|
|
|
goto exit_error_verif;
|
|
|
|
|
|
2020-09-05 15:22:03 +00:00
|
|
|
|
sprintf(str, "%s ok (err = %12.4E)", str, derr);
|
2020-09-04 11:43:44 +00:00
|
|
|
|
goto exit_label;
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
2020-09-04 11:43:44 +00:00
|
|
|
|
exit_error_code:
|
2020-09-05 15:22:03 +00:00
|
|
|
|
sprintf(str, "%s FAILED (with code = 0x%8x)", str, err);
|
2020-09-04 11:43:44 +00:00
|
|
|
|
goto exit_label;
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
2020-09-04 11:43:44 +00:00
|
|
|
|
exit_error_verif:
|
2020-09-05 15:22:03 +00:00
|
|
|
|
sprintf(str, "%s FAILED (err = %12.4E)", str, derr);
|
|
|
|
|
|
2020-09-04 11:43:44 +00:00
|
|
|
|
exit_label:
|
2020-09-05 15:22:03 +00:00
|
|
|
|
/************************ write str to log file **************************/
|
|
|
|
|
|
2020-09-17 07:53:32 +00:00
|
|
|
|
printf("%s\n", str);
|
|
|
|
|
addlog(str, "verification.log");
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
2020-09-04 11:43:44 +00:00
|
|
|
|
if(pxd)
|
|
|
|
|
free(pxd);
|
|
|
|
|
if(pyd)
|
|
|
|
|
free(pyd);
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
2020-09-04 11:43:44 +00:00
|
|
|
|
/* free dspl handle */
|
|
|
|
|
dspl_free(hdspl);
|
2020-09-05 15:22:03 +00:00
|
|
|
|
|
2020-09-17 07:53:32 +00:00
|
|
|
|
|
2020-09-04 11:43:44 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|