updated some functions and added makefile in release

Changes to be committed:
new file:   _release/.gitignore
new file:   _release/Makefile
modified:   _release/dspl.h
new file:   _release/test.c
modified:   dspl/Makefile
modified:   dspl/src/array.c
modified:   dspl/src/fft.c
modified:   dspl/src/fft_subkernel.c
modified:   include/dspl.c
modified:   include/dspl.h
pull/6/head
Dsplib 2020-11-23 10:59:47 +03:00
rodzic d5586dfb9e
commit 8067d440b4
10 zmienionych plików z 300 dodań i 9 usunięć

4
_release/.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1,4 @@
*.o
*.so
*.dll
*.exe

37
_release/Makefile 100644
Wyświetl plik

@ -0,0 +1,37 @@
CC = gcc
# Define OS
ifeq ($(OS),Windows_NT)
DSPL_LIBNAME = libdspl.dll
DEF_OS = WIN_OS
LFLAGS = -lm
else
UNAME_S := $(shell uname -s)
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_S),Linux)
DSPL_LIBNAME = libdspl.so
DEF_OS = LINUX_OS
LFLAGS = -lm -ldl
else ifeq ($(UNAME_S),Darwin)
DSPL_LIBNAME = libdspl.so
DEF_OS = LINUX_OS
LFLAGS = -lm -ldl
endif
endif
# C-compiler flags
CFLAGS = -c -O3 -D$(DEF_OS)
OBJFILES = test.o dspl.o
all: test.exe clean
test.exe: $(OBJFILES)
$(CC) $(OBJFILES) -o $@ $(LFLAGS)
%.o:%.c
$(CC) $(CFLAGS) $< -o $@ $(LFLAGS)
clean:
rm -f *.o

Wyświetl plik

@ -118,7 +118,32 @@ Memory must be allocated by \ref fft_create function. \n\n
Pointer to the vector of intermediate results. \n
The size of the vector is `[n x 1]`. \n
The memory must be allocated with the \ref fft_create function. \n\n
The structure is populated with the \ref fft_create function once
\param w32
Static twiddle factors vector for 32-points FFT. \n \n
\param w64
Static twiddle factors vector for 32-points FFT. \n \n
\param w128
Static twiddle factors vector for 32-points FFT. \n \n
\param w256
Static twiddle factors vector for 32-points FFT. \n \n
\param w512
Static twiddle factors vector for 32-points FFT. \n \n
\param w1024
Dynamic twiddle factors vector for 32-points FFT. \n \n
\param w2048
Dynamic twiddle factors vector for 32-points FFT. \n \n
\param w4096
Dynamic twiddle factors vector for 32-points FFT. \n \n
The structure is calculated with the \ref fft_create function once
before using the FFT algorithm. \n
A pointer to an object of this structure may be
reused when calling FFT functions. \n
@ -186,6 +211,32 @@ then the structure arrays will be automatically recreated for the length `n`.
Указатель на вектор промежуточных вычислений алгоритма БПФ. \n
Размер вектора `[n x 1]`. \n
Память должна быть выделена функцией \ref fft_create. \n \n
\param w32
Статический вектор поворотных коэффициентов 32-точечного БПФ. \n \n
\param w64
Статический вектор поворотных коэффициентов 64-точечного БПФ. \n \n
\param w128
Статический вектор поворотных коэффициентов 128-точечного БПФ. \n \n
\param w256
Статический вектор поворотных коэффициентов 256-точечного БПФ. \n \n
\param w512
Статический вектор поворотных коэффициентов 512-точечного БПФ. \n \n
\param w1024
Статический вектор поворотных коэффициентов 1024-точечного БПФ. \n \n
\param w2048
Статический вектор поворотных коэффициентов 2048-точечного БПФ. \n \n
\param w4096
Статический вектор поворотных коэффициентов 4096-точечного БПФ. \n \n
Структура заполняется функцией \ref fft_create один раз
до использования алгоритма БПФ. \n
Указатель на объект данной структуры может быть
@ -229,6 +280,7 @@ typedef struct
complex_t* t0;
complex_t* t1;
/* radix-2 twiddle factors vectors */
complex_t w32[ 32];
complex_t w64[ 64];
complex_t w128[128];

30
_release/test.c 100644
Wyświetl plik

@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
#include "dspl.h"
int main(int argc, char* argv[])
{
/* libdspl handle */
void* hdspl;
/* Load libdspl functions */
hdspl = dspl_load();
/* Check libdspl handle. */
/* If hdspl == NULL means problem with libdspl loading */
if(!hdspl)
{
printf("libdspl loading error!\n");
return -1;
}
/* Print libdspl info */
dspl_info();
/* free dspl handle */
dspl_free(hdspl);
return 0;
}

Wyświetl plik

@ -22,7 +22,7 @@ $(RELEASE_DIR)/$(LIB_NAME): $(DSPL_OBJ_FILES) $(BLAS_LIB_NAME) $(LAPACK_DOUBLE_
#Compile libdspl obj files from c sources
$(DSPL_OBJ_DIR)/%.o:$(DSPL_SRC_DIR)/%.c
$(CC) $(CFLAGS) $< -o $@ -lm
$(CC) $(CFLAGS) $< -o $@ -lm
#Copy libdspl.dll to the examples "bin" folder
$(EXAMPLE_BIN_DIR)/$(LIB_NAME):$(RELEASE_DIR)/$(LIB_NAME)

Wyświetl plik

@ -611,6 +611,38 @@ int DSPL_API decimate_cmplx(complex_t* x, int n, int d, complex_t* y, int* cnt)
int DSPL_API find_nearest(double* x, int n, double val, int *idx, double* dist)
{
double mind, dv;
int iv, i;
if(!x)
return ERROR_PTR;
if(n < 1)
return ERROR_SIZE;
mind = fabs(x[0] - val);
iv = 0;
for(i = 1; i < n; i++)
{
dv = fabs(x[i] - val);
if( dv < mind)
{
mind = dv;
iv = i;
}
}
if(idx)
*idx = iv;
if(dist)
*dist = fabs(x[iv] - val);
return RES_OK;
}
#ifdef DOXYGEN_ENGLISH
/*! ****************************************************************************
@ -1308,5 +1340,69 @@ int DSPL_API ones(double* x, int n)
return ERROR_SIZE;
for(i = 0; i < n; i++)
x[i] = 1.0;
return RES_OK;
return RES_OK;
}
#ifdef DOXYGEN_ENGLISH
/*! ****************************************************************************
\ingroup ARRAY_GROUP
\fn int sum(double* x, int n, double* s)
\author Sergey Bakhurin www.dsplib.org
***************************************************************************** */
#endif
#ifdef DOXYGEN_RUSSIAN
/*! ****************************************************************************
\ingroup ARRAY_GROUP
\fn int sum(double* x, int n, double* s)
\author Бахурин Сергей www.dsplib.org
***************************************************************************** */
#endif
int DSPL_API sum(double* x, int n, double* s)
{
int i;
double z = 0.0;
if(!x || !s)
return ERROR_PTR;
if(n<1)
return ERROR_SIZE;
for(i = 0; i < n; i++)
z += x[i];
*s = z;
return RES_OK;
}
#ifdef DOXYGEN_ENGLISH
/*! ****************************************************************************
\ingroup ARRAY_GROUP
\fn int sum(double* x, int n, double* s)
\author Sergey Bakhurin www.dsplib.org
***************************************************************************** */
#endif
#ifdef DOXYGEN_RUSSIAN
/*! ****************************************************************************
\ingroup ARRAY_GROUP
\fn int sum(double* x, int n, double* s)
\author Бахурин Сергей www.dsplib.org
***************************************************************************** */
#endif
int DSPL_API sum_sqr(double* x, int n, double* s)
{
int i;
double z = 0.0;
if(!x || !s)
return ERROR_PTR;
if(n<1)
return ERROR_SIZE;
for(i = 0; i < n; i++)
z += x[i]*x[i];
*s = z;
return RES_OK;
}

Wyświetl plik

@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
#include <float.h>
#include "dspl.h"
#include "dspl_internal.h"
@ -788,6 +789,7 @@ label_size:
matrix_transpose_cmplx(t0, n1, n2, t1);
for(k = 0; k < n1; k++)
{
fft_krn(t1+k*n2, t0+k*n2, p, n2, addr+n);
@ -1210,9 +1212,20 @@ int DSPL_API fft_mag(double* x, int n, fft_t* pfft,
double* mag, double* freq)
{
int k, err;
err = fft_abs(x, n, pfft, fs, flag, mag, freq);
fft_t *cfft = NULL;
if(pfft)
cfft = pfft;
else
{
cfft = (fft_t*) malloc(sizeof(fft_t));
memset(cfft, 0, sizeof(fft_t));
}
err = fft_abs(x, n, cfft, fs, flag, mag, freq);
if(err != RES_OK)
return err;
goto error_proc;
if(mag)
{
if(flag & DSPL_FLAG_LOGMAG)
@ -1222,7 +1235,9 @@ int DSPL_API fft_mag(double* x, int n, fft_t* pfft,
for(k = 0; k < n; k++)
mag[k] *= mag[k];
}
error_proc:
if(cfft && cfft != pfft)
free(cfft);
return err;
}
@ -1243,9 +1258,20 @@ int DSPL_API fft_mag_cmplx(complex_t* x, int n, fft_t* pfft,
double* mag, double* freq)
{
int k, err;
err = fft_abs_cmplx(x, n, pfft, fs, flag, mag, freq);
fft_t *cfft = NULL;
if(pfft)
cfft = pfft;
else
{
cfft = (fft_t*) malloc(sizeof(fft_t));
memset(cfft, 0, sizeof(fft_t));
}
err = fft_abs_cmplx(x, n, cfft, fs, flag, mag, freq);
if(err != RES_OK)
return err;
goto error_proc;
if(mag)
{
if(flag & DSPL_FLAG_LOGMAG)
@ -1255,7 +1281,9 @@ int DSPL_API fft_mag_cmplx(complex_t* x, int n, fft_t* pfft,
for(k = 0; k < n; k++)
mag[k] *= mag[k];
}
error_proc:
if(cfft && cfft != pfft)
free(cfft);
return err;
}

Wyświetl plik

@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "dspl.h"
#include "dspl_internal.h"

Wyświetl plik

@ -98,6 +98,7 @@ p_filter_iir filter_iir ;
p_filter_ws1 filter_ws1 ;
p_filter_zp2ab filter_zp2ab ;
p_find_max_abs find_max_abs ;
p_find_nearest find_nearest ;
p_fir_linphase fir_linphase ;
p_flipip flipip ;
p_flipip_cmplx flipip_cmplx ;
@ -181,6 +182,8 @@ p_sine_int sine_int ;
p_sqrt_cmplx sqrt_cmplx ;
p_std std ;
p_std_cmplx std_cmplx ;
p_sum sum ;
p_sum_sqr sum_sqr ;
p_trapint trapint ;
p_trapint_cmplx trapint_cmplx ;
@ -312,6 +315,7 @@ void* dspl_load()
LOAD_FUNC(filter_ws1);
LOAD_FUNC(filter_zp2ab);
LOAD_FUNC(find_max_abs);
LOAD_FUNC(find_nearest);
LOAD_FUNC(fir_linphase);
LOAD_FUNC(flipip);
LOAD_FUNC(flipip_cmplx);
@ -395,6 +399,8 @@ void* dspl_load()
LOAD_FUNC(sqrt_cmplx);
LOAD_FUNC(std);
LOAD_FUNC(std_cmplx);
LOAD_FUNC(sum);
LOAD_FUNC(sum_sqr);
LOAD_FUNC(trapint);
LOAD_FUNC(trapint_cmplx);

Wyświetl plik

@ -119,7 +119,29 @@ Pointer to the vector of intermediate results. \n
The size of the vector is `[n x 1]`. \n
The memory must be allocated with the \ref fft_create function. \n\n
\param w32
Static twiddle factors vector for 32-points FFT. \n \n
\param w64
Static twiddle factors vector for 32-points FFT. \n \n
\param w128
Static twiddle factors vector for 32-points FFT. \n \n
\param w256
Static twiddle factors vector for 32-points FFT. \n \n
\param w512
Static twiddle factors vector for 32-points FFT. \n \n
\param w1024
Dynamic twiddle factors vector for 32-points FFT. \n \n
\param w2048
Dynamic twiddle factors vector for 32-points FFT. \n \n
\param w4096
Dynamic twiddle factors vector for 32-points FFT. \n \n
The structure is calculated with the \ref fft_create function once
before using the FFT algorithm. \n
@ -258,6 +280,7 @@ typedef struct
complex_t* t0;
complex_t* t1;
/* radix-2 twiddle factors vectors */
complex_t w32[ 32];
complex_t w64[ 64];
complex_t w128[128];
@ -1045,6 +1068,12 @@ DECLARE_FUNC(int, find_max_abs, double* a
COMMA double* m
COMMA int* ind);
/*----------------------------------------------------------------------------*/
DECLARE_FUNC(int, find_nearest, double* x
COMMA int n
COMMA double val
COMMA int* idx
COMMA double* dist);
/*----------------------------------------------------------------------------*/
DECLARE_FUNC(int, fir_linphase, int ord
COMMA double w0
COMMA double w1
@ -1496,6 +1525,14 @@ DECLARE_FUNC(int, std_cmplx, complex_t* x
COMMA int n
COMMA double* s);
/*----------------------------------------------------------------------------*/
DECLARE_FUNC(int, sum, double* x
COMMA int n
COMMA double* s);
/*----------------------------------------------------------------------------*/
DECLARE_FUNC(int, sum_sqr, double* x
COMMA int n
COMMA double* s);
/*----------------------------------------------------------------------------*/
DECLARE_FUNC(int, trapint, double*
COMMA double*
COMMA int