Miscellaneous methods¶
Allocation and de-allocation functions¶
In general, allocating arrays requires one to know the size of all dimensions of the array, whereas de-allocating requires you to know the all but the inner dimension size.
- void
allocate_1d_array
(real_simulation *&pDouble, int dim1)¶
Function to allocate 1d dynamic arrays.
- Parameters
-
pDouble
: rvalue to pointer of 1d array.dim1
: First dimension of 1d array.
- void
deallocate_1d_array
(real_simulation *&pDouble)¶ Function to de-allocate 1d dynamic arrays.
- Parameters
-
pDouble
: rvalue to pointer of 1d array.
- void
allocate_2d_array
(real_simulation **&pDouble, int dim1, int dim2)¶
Function to allocate 2d dynamic arrays.
- Parameters
-
pDouble
: rvalue to pointer of 2d array.dim1
: First dimension of 2d array.dim2
: Second dimension of 2d array.
- void
deallocate_2d_array
(real_simulation **&pDouble, int dim1)¶ Function to de-allocate 2d dynamic arrays.
- Parameters
-
pDouble
: rvalue to pointer of 2d array.dim1
: First dimension of 2d array.
- void
allocate_3d_array
(real_simulation ***&pDouble, int dim1, int dim2, int dim3)¶ Function to allocate 4d dynamic arrays.
- Parameters
-
pDouble
: rvalue to pointer of 3d array.dim1
: First dimension of 3d array.dim2
: Second dimension of 3d array.dim3
: Third dimension of 3d array.
- void
deallocate_3d_array
(real_simulation ***&pDouble, int dim1, int dim2)¶
Function to de-allocate 3d dynamic arrays.
- Parameters
-
pDouble
: rvalue to pointer of 3d array.dim1
: First dimension of 3d array.dim2
: Second dimension of 3d array.
- void
allocate_4d_array
(real_simulation ****&pDouble, int dim1, int dim2, int dim3, int dim4)¶ Function to allocate 4d dynamic arrays.
- Parameters
-
pDouble
: rvalue to pointer of 4d array.dim1
: First dimension of 4d array.dim2
: Second dimension of 4d array.dim3
: Third dimension of 4d array.dim4
: Fourth dimension of 4d array.
- void
deallocate_4d_array
(real_simulation ****&pDouble, int dim1, int dim2, int dim3)¶
Function to de-allocate 4d dynamic arrays.
- Parameters
-
pDouble
: rvalue to pointer of 4d array.dim1
: First dimension of 4d array.dim2
: Second dimension of 4d array.dim3
: Third dimension of 4d array.
Parse functions¶
- template<class
T
>
voidparse_string_to_vector
(std::basic_string<char> string_to_parse, std::vector<T> *destination_vector)¶ Function to parse strings containing lists to std::vectors.
Parses any string in the format {a, b, c, d, …} to a vector of int, float, double. Only types that can be cast to floats are supported for now. This is due to the usage of strtof(); no template variant is used as of yet. The input string is allowed to be trailed by a comment leading with a semicolon. Items are appended to the passed vector.
- Template Parameters
-
T
: Arbitrary numeric type that has a cast to and from float.
- Parameters
-
string_to_parse
: Input string of the form “{<item1>, <item2>, <item3>, … } ; comment “.destination_vector
: Pointer to an (not necessarily empty) vector of suitable type.
- void
parse_string_to_nested_int_vector
(std::basic_string<char> string_to_parse, std::vector<std::vector<int>> *destination_vector)¶
Function to parse strings containing 2d integer lists to std::vector<std::vector<int>>. Sublists do not need to be of the same length.
- Parameters
-
string_to_parse
: Input string of the form “{{<item1.1>, <item1.2>, <item1.3>, …}, {<item2.1>, <item2.2>, …}, … } ; comment “.destination_vector
: Pointer to an (not necessarily empty) std::vector<std::vector<int>>.
Signal processing functions¶
- void
cross_correlate
(const real_simulation *signal1, const real_simulation *signal2, real_simulation *r, int length, int max_delay = 1000)¶ Method to the compute cross correlation between two signals up to a maximum delay.
- Parameters
-
signal1
: Pointer to first signal.signal2
: Pointer to second signal.r
: Pointer to cross-correlation array. Should be have memory allocated twice the max_delay size.length
: Size of both signal1 and signal2.max_delay
: Maximum delay for which to compute the cross correlation.