nodes_value_containers.hpp 4.11 KB
Newer Older
1
2
#ifndef NODE_VALUE_ARR
#define NODE_VALUE_ARR
Thomas Purcell's avatar
Thomas Purcell committed
3

Thomas Purcell's avatar
Thomas Purcell committed
4
#include <algorithm>
Thomas Purcell's avatar
Thomas Purcell committed
5
6
7
8
9
10
11
#include <memory>
#include <vector>

#include<utils/enum.hpp>

namespace node_value_arrs
{
12
    extern int N_SELECTED; //!< Number of features selected
Thomas Purcell's avatar
Thomas Purcell committed
13
14
15
    extern int N_SAMPLES; //!< Number of samples in the nodes
    extern int N_STORE_FEATURES; //!< Number of features with stored values
    extern int N_RUNGS_STORED; //!< Number of rungs with values stored
Thomas Purcell's avatar
Thomas Purcell committed
16

17
    extern std::vector<int> TEMP_STORAGE_REG; //!< Register to see which feature is stored in each slot
18
    extern std::vector<double> D_MATRIX; //!< The descriptor matrix
19
20
    extern std::vector<double> VALUES_ARR; //!< Value of the stored features
    extern std::vector<double> TEMP_STORAGE_ARR; //!< Array to temporarily store feature values
Thomas Purcell's avatar
Thomas Purcell committed
21

Thomas Purcell's avatar
Thomas Purcell committed
22
23
24
25
26
27
28
29
    /**
     * @brief Get the maximum number of new features for each rung
     *
     * @param new_op operator that will add new features
     * @param n_current_features current number of of features in the rung
     *
     * @return [description]
     */
30
    int get_number_new_features(std::string new_op, int n_current_features);
Thomas Purcell's avatar
Thomas Purcell committed
31

Thomas Purcell's avatar
Thomas Purcell committed
32
33
34
35
36
37
38
39
    /**
     * @brief Get the maximum number of features to store
     *
     * @param allowed_operators list of allowed operators
     * @param n_dims Number of dimensions to store
     * @param n_feats number of features in Phi_0
     * @return [description]
     */
40
    int get_max_number_features(std::vector<std::string> allowed_operators, int n_dims, int n_feats);
Thomas Purcell's avatar
Thomas Purcell committed
41

Thomas Purcell's avatar
Thomas Purcell committed
42
43
44
45
46
47
48
    /**
     * @brief set of the value arrays
     * @details Take initial parameters and construct the feature arraies
     *
     * @param n_samples number of samples per feature
     * @param n_primary_feat number of primary features
     */
Thomas Purcell's avatar
Thomas Purcell committed
49
50
51
52
53
54
55
56
57
58
59
    void initialize_values_arr(int n_samples, int n_primary_feat);

    /**
     * @brief set of the value arrays
     * @details Take initial parameters and construct the feature arraies
     *
     * @param n_dims Number of dimensions to store
     * @param n_feat number of features to store
     * @param use_temp If true keep the temporary_storage
     */
    void resize_values_arr(int n_dims, int n_feat, bool use_temp);
Thomas Purcell's avatar
Thomas Purcell committed
60

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    /**
     * @brief set of the value arrays
     * @details Take initial parameters and construct the feature arraies
     *
     * @param n_samples number of samples per feature
     * @param n_primary_feat number of primary features
     */
    void initialize_d_matrix_arr();

    /**
     * @brief set of the value arrays
     * @details Take initial parameters and construct the feature arraies
     *
     * @param n_select Number of features to select
     */
    void resize_d_matrix_arr(int n_select);

Thomas Purcell's avatar
Thomas Purcell committed
78
79
80
81
82
83
84
85
    /**
     * @brief Get a reference slot/feature register
     *
     * @param ind Feature index
     * @param offset Offset integer for TEMP_STORE_ARRAY
     *
     * @return The register element for a given feature index and offset
     */
Thomas Purcell's avatar
Thomas Purcell committed
86
    inline int& temp_storage_reg(int ind, int offset = 0){return TEMP_STORAGE_REG[(ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES];}
Thomas Purcell's avatar
Thomas Purcell committed
87

Thomas Purcell's avatar
Thomas Purcell committed
88
89
90
91
92
93
94
    /**
     * @brief Access element of the permanent storage array
     *
     * @param feature_ind The feature index to access
     *
     * @return pointer to the feature;s data array
     */
95
    inline double* access_value_arr(int feature_ind){return VALUES_ARR.data() + feature_ind*N_SAMPLES;}
96

Thomas Purcell's avatar
Thomas Purcell committed
97
98
99
100
101
102
103
    /**
     * @brief Access element of temporary storage array
     *
     * @param slot The slot of the temporary storage arrays
     *
     * @return pointer to the feature's temporary storage
     */
104
    inline double* access_temp_storage(int slot){return TEMP_STORAGE_ARR.data() + slot*N_SAMPLES;}
105

Thomas Purcell's avatar
Thomas Purcell committed
106
107
108
109
110
111
112
113
    /**
     * @brief Access the value_ptr to a feature
     *
     * @param ind Feature index
     * @param offset the offset for the storage
     *
     * @return The value pointer
     */
114
    double* get_value_ptr(int ind, int offset = 0);
Thomas Purcell's avatar
Thomas Purcell committed
115

116
117
118
119
    /**
     * @brief Get the pointer to a primary feature
     *
     * @param ind Index of the primary feature
120
     * @return The pointer to the descriptor matrix's data
121
     */
122
    inline double* get_d_matrix_ptr(int ind)
Thomas Purcell's avatar
Thomas Purcell committed
123
    {
124
        return D_MATRIX.data() + ind * N_SAMPLES;
Thomas Purcell's avatar
Thomas Purcell committed
125
    }
Thomas Purcell's avatar
Thomas Purcell committed
126
127
}

128
#endif