libdspl-2.0
Библиотека алгоритмов цифровой обработки сигналов
verif_str_cmplx.c
1/*
2* Copyright (c) 2015-2022 Sergey Bakhurin
3* Digital Signal Processing Library [http://dsplib.org]
4*
5* This file is part of DSPL.
6*
7* is free software: you can redistribute it and/or modify
8* it under the terms of the GNU General Public License as published by
9* the Free Software Foundation, either version 3 of the License, or
10* (at your option) any later version.
11*
12* DSPL is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details.
16*
17* You should have received a copy of the GNU General Public License
18* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25#include "dspl.h"
26
27
28
29
30
31#ifdef DOXYGEN_ENGLISH
32
33#endif
34#ifdef DOXYGEN_RUSSIAN
35
36#endif
37void DSPL_API verif_str_cmplx(complex_t* yout, int nout,
38 char* str_msg, char* outfn, char* logfn)
39{
40 char str[VERIF_STR_BUF] = {0};
41 char msg[VERIF_STR_BUF] = {0};
42 complex_t *y = NULL;
43 double derr = 0.0;
44 int n,m, verr, type;
45
46 sprintf(str, "%s", str_msg);
47 while(strlen(str) < VERIF_STR_LEN)
48 str[strlen(str)] = VERIF_CHAR_POINT;
49
50 readbin(outfn, (void**)(&y), &n, &m, &type);
51
52 if(nout != n*m)
53 {
54 sprintf(msg, "FAILED (out size [%d] neq [%d])", n, nout);
55 strcat(str, msg);
56 addlog(str, logfn);
57 printf("%s\n", str);
58 return;
59 }
60
61 if(type!=DAT_COMPLEX)
62 {
63 sprintf(msg, "FAILED (type is complex)");
64 strcat(str, msg);
65 addlog(str, logfn);
66 printf("%s\n", str);
67 return;
68 }
69
70 verr = verif_cmplx(yout, y, nout, VERIF_LEVEL_DOUBLE, &derr);
71 if(verr == DSPL_VERIF_SUCCESS)
72 sprintf(msg, "ok (err = %12.4E)", derr);
73 else
74 sprintf(msg, "FAILED (err = %12.4E)", derr);
75 strcat(str, msg);
76 addlog(str, logfn);
77 printf("%s\n", str);
78}
79
80
81
int verif_cmplx(complex_t *x, complex_t *y, size_t n, double eps, double *err)
Верификация комплексных массивов
Definition: verif_cmplx.c:141
int readbin(char *fn, void **x, int *pn, int *pm, int *dtype)
Считать данные из бинарного файла
Definition: readbin.c:314
double complex_t[2]
Описание комплексного типа данных.
Definition: dspl.h:86