libdspl-2.0
Библиотека алгоритмов цифровой обработки сигналов
polyval_cmplx.c
1 /*
2 * Copyright (c) 2015-2024 Sergey Bakhurin
3 * Digital Signal Processing Library [http://dsplib.org]
4 *
5 * This file is part of libdspl-2.0.
6 *
7 * is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser 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 Lesser General Public License
18 * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include <stdlib.h>
22 #include <string.h>
23 #include <math.h>
24 #include "dspl.h"
25 
26 
27 
28 
29 
30 #ifdef DOXYGEN_ENGLISH
31 
32 #endif
33 #ifdef DOXYGEN_RUSSIAN
34 
79 #endif
80 int DSPL_API polyval_cmplx(complex_t* a, int ord,
81  complex_t* x, int n, complex_t* y)
82 {
83  int k, m;
84  complex_t t;
85 
86  if(!a || !x || !y)
87  return ERROR_PTR;
88  if(ord<0)
89  return ERROR_POLY_ORD;
90  if(n<1)
91  return ERROR_SIZE;
92 
93  for(k = 0; k < n; k++)
94  {
95  RE(y[k]) = RE(a[ord]);
96  IM(y[k]) = IM(a[ord]);
97  for(m = ord-1; m>-1; m--)
98  {
99  RE(t) = CMRE(y[k], x[k]);
100  IM(t) = CMIM(y[k], x[k]);
101  RE(y[k]) = RE(t) + RE(a[m]);
102  IM(y[k]) = IM(t) + IM(a[m]);
103  }
104  }
105  return RES_OK;
106 }
107 
#define ERROR_POLY_ORD
Неверно задан порядок полинома. Порядок полинома должен быть положительным целым числом.
Definition: dspl.h:609
#define RE(x)
Макрос определяющий реальную часть комплексного числа.
Definition: dspl.h:420
#define ERROR_PTR
Ошибка указателя. Данная ошибка означает, что один из обязательных указателей (память под который дол...
Definition: dspl.h:610
int polyval_cmplx(complex_t *a, int ord, complex_t *x, int n, complex_t *y)
Расчет комплексного полинома
Definition: polyval_cmplx.c:80
#define ERROR_SIZE
Ошибка при передаче размера массива. Данная ошибка возникает когда помимо указателя на массив входных...
Definition: dspl.h:618
double complex_t[2]
Описание комплексного типа данных.
Definition: dspl.h:86
#define RES_OK
Функция завершилась корректно. Ошибки отсутствуют.
Definition: dspl.h:558
#define IM(x)
Макрос определяющий мнимую часть комплексного числа.
Definition: dspl.h:478