-
Notifications
You must be signed in to change notification settings - Fork 0
/
array_utilities.h
132 lines (113 loc) · 4.15 KB
/
array_utilities.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* array_utilities.h
*
* Created on: 2020年12月10日
* Author: 123
*/
#ifndef ARRAY_UTILITIES_H_
#define ARRAY_UTILITIES_H_
#include "arm_math.h"
/**
* @brief Function to reverse an array
* @param arr Pointer to the array
* @param len Length of the array
*/
void array_flip(float *arr, uint32_t len);
/**
* @brief Function to calculate the sum of an array
* @param arr Pointer to the array
* @param len Length of the array
* @return Sum of the array
*/
float array_sum(const float *arr, uint32_t len);
/**
* @brief Function to calculate the dot-product of two 1-D vectors/arrays
* @param in1 Pointer to the first vector
* @param in2 Pointer to the second vector
* @param len Length of the vectors
* @return Dot product (inner product) of the two vectors
* @warning Assumes both the vectors are of same length and takes only one length parameter
*/
float array_dot_product(const float *in1, const float *in2, uint32_t len);
/**
* @brief Function to right shift an array by one place. Left most value will be replaced by zero
* @param arr Pointer to the array
* @param len Length of the array
*/
void array_right_shift(float *arr, uint32_t len);
/**
* @brief Function to multiply each element of an array by a scalar constant
* @param arr Pointer to the array
* @param constant The constant scalar multiplier
* @param len Length of the array
*/
void array_multiply_const(float *arr, float constant, uint32_t len);
/**
* @brief Function to add a scalar constant to each element of an array
* @param arr Pointer to the array
* @param constant The constant scalar adder
* @param len Length of the array
*/
void array_add_const(float *arr, float constant, uint32_t len);
/**
* @brief Function to do element wise addition of two arrays
* @param in1 Pointer to the first array
* @param in2 Pointer to the second array
* @param len Length of the arrays
* @warning Assumes both the arrays are of same length and takes only one length parameter
*/
void array_add_array(float *in1, const float *in2, uint32_t len);
/**
* @brief Function to do element wise subtraction of two arrays
* @param in1 Pointer to the first array
* @param in2 Pointer to the second array
* @param len Length of the arrays
* @warning Assumes both the arrays are of same length and takes only one length parameter
*/
void array_subtract_array(float *in1, const float *in2, uint32_t len);
/**
* @brief Function to do element wise multiplication of two arrays
* @param in1 Pointer to the first array
* @param in2 Pointer to the second array
* @param len Length of the arrays
* @warning Assumes both the arrays are of same length and takes only one length parameter
*/
void array_element_multiply_array(float *in1, const float *in2, uint32_t len);
/**
* @brief Function to do element wise division of two arrays
* @param in1 Pointer to the first array
* @param in2 Pointer to the second array
* @param len Length of the arrays
* @warning Assumes both the arrays are of same length and takes only one length parameter
*/
void array_element_divide_array(float *in1, const float *in2, uint32_t len);
/**
* @brief Function to return the minimum of the elements of an array
* @param arr Pointer to the array
* @param len Length of the array
* @return Minimum of the array elements
*/
float array_min(const float *arr, uint32_t len);
/**
* @brief Function to calculate the mean of the elements of an array
* @param arr Pointer to the array
* @param len Length of the array
* @return Mean of the array elements
*/
float array_mean(float *arr, uint32_t len);
/**
* @brief Function to populate the output array with square of the elements of an input array
* @param in Pointer to the input array
* @param out Pointer to the output array
* @param len Length of the arrays
* @warning Assumes that output array already has memory allocated to it
*/
void array_square(const float *in, float *out, uint32_t len);
/**
* @brief Function to calculate the mean square of the elements of an array
* @param arr Pointer to the array
* @param len Length of the array
* @return Mean square of the array elements
*/
float array_mean_square(const float *arr, uint32_t len);
#endif /* ARRAY_UTILITIES_H_ */