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
|
/*******************************************************************************
** ArrayOperations.h
** Part of the mutual information toolbox
**
** Contains functions to floor arrays, and to merge arrays into a joint
** state.
**
** Author: Adam Pocock
** Created 17/2/2010
**
** Copyright 2010 Adam Pocock, The University Of Manchester
** www.cs.manchester.ac.uk
**
** This file is part of MIToolbox.
**
** MIToolbox is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** MIToolbox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with MIToolbox. If not, see <http://www.gnu.org/licenses/>.
**
*******************************************************************************/
#ifndef __ArrayOperations_H
#define __ArrayOperations_H
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
** Simple print function for debugging
*******************************************************************************/
void printDoubleVector(double *vector, int vectorLength);
void printIntVector(int *vector, int vectorLength);
/*******************************************************************************
** numberOfUniqueValues finds the number of unique values in an array by
** repeatedly iterating through the array and checking if a value has been
** seen previously
*******************************************************************************/
int numberOfUniqueValues(double *featureVector, int vectorLength);
/*******************************************************************************
** normaliseArray takes an input vector and writes an output vector
** which is a normalised version of the input, and returns the number of states
** A normalised array has min value = 0, max value = number of states
** and all values are integers
**
** length(inputVector) == length(outputVector) == vectorLength otherwise there
** is a memory leak
*******************************************************************************/
int normaliseArray(double *inputVector, int *outputVector, int vectorLength);
/*******************************************************************************
** mergeArrays takes in two arrays and writes the joint state of those arrays
** to the output vector
**
** the length of the vectors must be the same and equal to vectorLength
*******************************************************************************/
int mergeArrays(double *firstVector, double *secondVector, double *outputVector, int vectorLength);
int mergeArraysArities(double *firstVector, int numFirstStates, double *secondVector, int numSecondStates, double *outputVector, int vectorLength);
/*******************************************************************************
** mergeMultipleArrays takes in a matrix and repeatedly merges the matrix using
** merge arrays and writes the joint state of that matrix
** to the output vector
**
** the length of the vectors must be the same and equal to vectorLength
** matrixWidth = the number of columns in the matrix
*******************************************************************************/
int mergeMultipleArrays(double *inputMatrix, double *outputVector, int matrixWidth, int vectorLength);
int mergeMultipleArraysArities(double *inputMatrix, double *outputVector, int matrixWidth, int *arities, int vectorLength);
#ifdef __cplusplus
}
#endif
#endif
|