-
Thomas Purcell authored
Added type condition tests (initial simplification) Added som more documenatation
Thomas Purcell authoredAdded type condition tests (initial simplification) Added som more documenatation
nodes_value_containers.hpp 3.24 KiB
#ifndef NODE_VALEU_ARR
#define NODE_VALEU_ARR
#include <algorithm>
#include <memory>
#include <vector>
#include<utils/enum.hpp>
namespace node_value_arrs
{
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
extern std::unique_ptr<int[]> TEMP_STORAGE_REG; //!< Register to see which feature is stored in each slot
extern std::unique_ptr<double[]> VALUES_ARR; //!< Value of the stored features
extern std::unique_ptr<double[]> TEMP_STORAGE_ARR; //!< Array to temporarily store feature values
/**
* @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]
*/
int get_number_new_features(std::string new_op, int n_current_features);
/**
* @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]
*/
int get_max_number_features(std::vector<std::string> allowed_operators, int n_dims, int n_feats);
/**
* @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_dims Number of dimensions to store
* @param n_primary_feat number of primary features
* @param allowed_operators list of allowed operators
*/
void setup_values_arr(int n_samples, int n_dims, int n_primary_feat, std::vector<std::string> allowed_operators);
/**
* @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
*/
inline int& temp_storage_reg(int ind, int offset = 0){return TEMP_STORAGE_REG[(ind % N_STORE_FEATURES) + offset * N_STORE_FEATURES];}
/**
* @brief Access element of the permanent storage array
*
* @param feature_ind The feature index to access
*
* @return pointer to the feature;s data array
*/
inline double* access_value_arr(int feature_ind){return VALUES_ARR.get() + feature_ind*N_SAMPLES;}
/**
* @brief Access element of temporary storage array
*
* @param slot The slot of the temporary storage arrays
*
* @return pointer to the feature's temporary storage
*/
inline double* access_temp_storage(int slot){return TEMP_STORAGE_ARR.get() + slot*N_SAMPLES;}
/**
* @brief Access the value_ptr to a feature
*
* @param ind Feature index
* @param offset the offset for the storage
*
* @return The value pointer
*/
inline double* get_value_ptr(int ind, int offset = 0)
{
if(ind < N_STORE_FEATURES)
return access_value_arr(ind);
temp_storage_reg(ind, offset) = ind;
return access_temp_storage((ind % N_STORE_FEATURES) + offset * N_STORE_FEATURES);
}
}
#endif