File indexing completed on 2024-05-12 03:47:50
0001 /* 0002 File : nsl_corr.h 0003 Project : LabPlot 0004 Description : NSL discrete correlation functions 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2018 Stefan Gerlach <stefan.gerlach@uni.kn> 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #ifndef NSL_CORR_H 0011 #define NSL_CORR_H 0012 0013 #include <stdlib.h> 0014 0015 #define NSL_CORR_TYPE_COUNT 2 0016 /* linear (zero-padded), circular */ 0017 typedef enum { nsl_corr_type_linear, nsl_corr_type_circular } nsl_corr_type_type; 0018 extern const char* nsl_corr_type_name[]; 0019 0020 #define NSL_CORR_NORM_COUNT 4 0021 /* how to normalize (see octave) 0022 * biased - 1/N 0023 * unbiased - 1/(N-|m|) 0024 * coeff - 1/sqrt(R_xx(0) R_yy(0)) = 1/sqrt(sum x_i^2 sum y_i^2) [used in Origin] 0025 * */ 0026 typedef enum { nsl_corr_norm_none, nsl_corr_norm_biased, nsl_corr_norm_unbiased, nsl_corr_norm_coeff } nsl_corr_norm_type; 0027 extern const char* nsl_corr_norm_name[]; 0028 0029 int nsl_corr_correlation(double s[], size_t n, double r[], size_t m, nsl_corr_type_type, nsl_corr_norm_type normalize, double out[]); 0030 0031 /* linear/circular correlation using FFT method 0032 * s and r are untouched 0033 */ 0034 int nsl_corr_fft_type(double s[], size_t n, double r[], size_t m, nsl_corr_type_type, nsl_corr_norm_type normalize, double out[]); 0035 /* actual FFT method calculation using zero-padded arrays 0036 * uses FFTW if available and GSL otherwise 0037 * s and r are overwritten 0038 */ 0039 #ifdef HAVE_FFTW3 0040 int nsl_corr_fft_FFTW(double s[], double r[], size_t n, double out[]); 0041 #endif 0042 int nsl_corr_fft_GSL(double s[], double r[], size_t n, double out[]); 0043 0044 #endif /* NSL_CORR_H */