-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfftautocorr.h
101 lines (89 loc) · 2.76 KB
/
fftautocorr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* @file fftautocorr.h
* @author CareF <CareF.LM@gmail.com>
* @brief Header definition for fftautocorr
* @version 0.1
* @date 2020-07-04
*
* This file is part of fftautocorr
*
* @copyright Copyright (c) 2020
* Licensed under a 3-clause BSD style license - see LICENSE.md
*/
#ifndef FFTAUTOCORR_H
#define FFTAUTOCORR_H
#include <stdlib.h>
/**
* @brief The internal struct for FFT plan.
*
* Should not be directly used by the user.
*/
struct autocorr_plan_i;
/**
* @brief The FFT plan.
*
* Created by make_autocorr_plan()
*/
typedef struct autocorr_plan_i * autocorr_plan;
/**
* @brief Create an autocorr_plan for later calculation.
*
* destroy_autocorr_plan() must be called on the function to avoid memory leak.
*
* @param[in] length The length for input data array.
* @return autocorr_plan The plan to be used for calculation.
*/
autocorr_plan make_autocorr_plan(size_t length);
/**
* @brief Destroy the plan to release memory.
*
* @param[in] plan the plan to be destroyed.
*/
void destroy_autocorr_plan(autocorr_plan plan);
/**
* @brief Get the length of the memory needed for a plan.
*
* The memory needed is at least 2 times the size of the input data.
*
* @param[in] plan The plan to get the memory needed for.
* @return The size of the memory needed.
*/
size_t mem_len(autocorr_plan plan);
/**
* @brief The logical length (length of input and output data) for the
* calculation.
*
* @param[in] plan The plan to get the logical length for.
* @return The logical length.
*/
size_t data_len(autocorr_plan plan);
/**
* @brief One stop solution to calculate the autocorrelation for \p data with
* size \p length.
*
* @param[in,out] data The input data and the output autocorrelation.
* @param[in] length The length of the input data.
* @return 0 for success, -1 for fail.
*/
int autocorr(double data[], size_t length);
/**
* @brief Calcualte the autocorrelation using the given \p plan.
*
* @param[in] plan The plan for the calculation
* @param[in,out] data Input and output data, with length defined i
* @return 0 for success, -1 for fail.
*/
int autocorr_p(autocorr_plan plan, double data[]);
/**
* @brief Calcualate autocorrelation using \p plan for FFT and \mempool for
* the mem used in the calculation.
*
* @param[in] plan FFT plan generated by make_autocorr_plan()
* @param[in,out] data The data to be calculated from, and also the output for
* the autocorrelation result.
* @param[in] mempool The address for memory needed for the autocorrelationm. needs
* to be at least ::mem_len(plan)*sizeof(double) long.
* @return 0 for success, -1 for fail.
*/
int autocorr_mem(autocorr_plan plan, double data[], double *mempool);
#endif /* ifndef FFTAUTOCORR_H */