nodes_value_containers.hpp 22.2 KB
Newer Older
1
// Copyright 2021 Thomas A. R. Purcell
2
//
3
4
5
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
10
11
12
13
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
14

15
/** @file feature_creation/node/value_storage/node_value_containers.hpp
16
 *  @brief Creates a central storage area for the feature's input data and the descriptor matrix
17
 *
18
 *  @author Thomas A. R. Purcell (tpurcell90)
19
20
 *  @bug No known bugs.
 */
21

22
23
#ifndef NODE_VALUE_ARR
#define NODE_VALUE_ARR
Thomas Purcell's avatar
Thomas Purcell committed
24

Thomas Purcell's avatar
Thomas Purcell committed
25
#include <algorithm>
26
#include <cmath>
Thomas Purcell's avatar
Thomas Purcell committed
27
#include <memory>
Thomas Purcell's avatar
Thomas Purcell committed
28
#include <numeric>
Thomas Purcell's avatar
Thomas Purcell committed
29
#include <vector>
30
#include <iostream>
Thomas Purcell's avatar
Thomas Purcell committed
31

32
33
#include <omp.h>

Thomas Purcell's avatar
Thomas Purcell committed
34
#include"utils/enum.hpp"
Thomas Purcell's avatar
Thomas Purcell committed
35

36
#ifdef PY_BINDINGS
37
#include "python/py_binding_cpp_def/conversion_utils.hpp"
38
39
40
41
namespace np = boost::python::numpy;
namespace py = boost::python;
#endif

Thomas Purcell's avatar
Thomas Purcell committed
42
43
namespace node_value_arrs
{
Thomas Purcell's avatar
Thomas Purcell committed
44
45
46
47
48
49
50
51
52
53
54
55
56
    extern std::vector<double> VALUES_ARR; //!< The central storage location for the values of the training data for each feature with a rung <= N_RUNGS_STORED
    extern std::vector<double> TEST_VALUES_ARR; //!< The central storage location for the values of the test data for each feature with a rung <= N_RUNGS_STORED

    extern std::vector<double> TEMP_STORAGE_ARR; //!< The vector used to temporarily store the values of each feature with a rung > N_RUNGS_STORED (These are calculated on the fly when the values are required)
    extern std::vector<double> TEMP_STORAGE_TEST_ARR; //!< The vector used to temporarily store the values of each feature with a rung > N_RUNGS_STORED (These are calculated on the fly when the values are required)
    extern std::vector<int> TEMP_STORAGE_REG; //!< Register that maps the slots in TEMP_STORAGE_ARR to the index of the feature whose data is currently stored there (reset by setting all elements of this vector to -1)
    extern std::vector<int> TEMP_STORAGE_TEST_REG; //!< Register that maps the slots in TEMP_STORAGE_TEST_ARR to the index of the feature whose data is currently stored there (reset by setting all elements of this vector to -1)

    extern std::vector<double> PARAM_STORAGE_ARR; //!< The vector used to temporarily store the values of each feature that has free-parameters (These are calculated on the fly when the values are required)
    extern std::vector<double> PARAM_STORAGE_TEST_ARR; //!< The vector used to temporarily store the values of each feature that has free-parameters (These are calculated on the fly when the values are required)

    extern std::vector<double> D_MATRIX; //!< The descriptor matrix (Central storage for the selected feature space)

Thomas Purcell's avatar
Thomas Purcell committed
57
    extern std::vector<int> TASK_SZ_TRAIN; //!< Number of training samples per task
Thomas Purcell's avatar
Thomas Purcell committed
58
    extern std::vector<int> TASK_START_TRAIN; //!< The starting point for each task in the training data
Thomas Purcell's avatar
Thomas Purcell committed
59
60
    extern std::vector<int> TASK_SZ_TEST; //!< Number of test sample per task

61
62
63
64
    extern std::vector<double> STANDARDIZED_D_MATRIX; //!< The descriptor matrix filled with standardized feature values (Central storage for the selected feature space)
    extern std::vector<double> STANDARDIZED_STORAGE_ARR; //!< //!< The vector used to temporarily store the values of the standardized feature training values
    extern std::vector<double> STANDARDIZED_TEST_STORAGE_ARR; //!< //!< The vector used to temporarily store the values of the standardized feature test values

Thomas Purcell's avatar
Thomas Purcell committed
65
66
67
68
69
70
    extern int N_SELECTED; //!< Number of selected features

    extern int N_SAMPLES; //!< Number of training samples for each feature (Sum of all elements in TASK_SZ_TRAIN)
    extern int N_SAMPLES_TEST; //!< Number of test samples for each feature (Sum of all elements in TASK_SZ_TEST)

    extern int N_PRIMARY_FEATURES; //!< Number of primary features
Thomas Purcell's avatar
Thomas Purcell committed
71
    extern int N_STORE_FEATURES; //!< Number of features with stored values
Thomas Purcell's avatar
Thomas Purcell committed
72
    extern int N_RUNGS_STORED; //!< Maximum rung for permanently storing a features value
73
    extern int MAX_RUNG; //!< The maximum rung for all features
Thomas Purcell's avatar
Thomas Purcell committed
74

Thomas Purcell's avatar
Thomas Purcell committed
75
76
77
    extern int MAX_N_THREADS; //!< Get the maximum number of threads possible for a calculation
    extern int N_OP_SLOTS; //!< The number of possible nodes of the binary expression tree that maybe calculated on the fly
    extern int N_PARAM_OP_SLOTS; //!< The number of possible non-leaf nodes of the binary expression tree
78
79
80
81
82

    // DocString: node_vals_finalize
    /**
     * @brief Resize all storage arrays to be empty
     */
83
    void finalize_values_arr();
84

85
86
87
88
89
90
91
92
93
94
95
96
    /**
     * @brief Initialize all central storage vectors/descriptive variables without changing MAX_RUNG
     *
     * @param n_samples The number of training samples for each feature (Sum of all elements in TASK_SZ_TRAIN)
     * @param n_samples_test The number of test samples for each feature (Sum of all elements in TASK_SZ_TEST)
     * @param n_primary_feat The number of primary features
     */
    void initialize_values_arr(
        const int n_samples,
        const int n_samples_test,
        const int n_primary_feat
    );
Thomas Purcell's avatar
Thomas Purcell committed
97

Thomas Purcell's avatar
Thomas Purcell committed
98
    /**
Thomas Purcell's avatar
Thomas Purcell committed
99
     * @brief Initialize all central storage vectors/descriptive variables
Thomas Purcell's avatar
Thomas Purcell committed
100
     *
Thomas Purcell's avatar
Thomas Purcell committed
101
102
103
104
105
     * @param task_sz_train The number of training samples per task
     * @param task_sz_test The number of test sample per task
     * @param n_primary_feat The number of primary features
     * @param max_rung The maximum rung for all features
     * @param use_params If True set up parameterized feature storage as well
Thomas Purcell's avatar
Thomas Purcell committed
106
     */
107
108
109
110
111
112
113
    void initialize_values_arr(
        const std::vector<int> task_sz_train,
        const std::vector<int> task_sz_test,
        const int n_primary_feat,
        const int max_rung,
        const bool use_params
    );
Thomas Purcell's avatar
Thomas Purcell committed
114
115

    /**
Thomas Purcell's avatar
Thomas Purcell committed
116
     * @brief Resize the central storage array given a new number of features and the current rung of the features
Thomas Purcell's avatar
Thomas Purcell committed
117
     *
Thomas Purcell's avatar
Thomas Purcell committed
118
119
     * @param n_rung The current rung of the generated features
     * @param n_feat The new number of features to store
Thomas Purcell's avatar
Thomas Purcell committed
120
     */
Thomas Purcell's avatar
Thomas Purcell committed
121
    void resize_values_arr(const int n_dims, const int n_feat);
Thomas Purcell's avatar
Thomas Purcell committed
122

Thomas Purcell's avatar
Thomas Purcell committed
123
    // DocString: node_vals_init_param
124
125
126
    /**
     * @brief Initialize the parameter storage array
     */
Thomas Purcell's avatar
Thomas Purcell committed
127

128
129
    void initialize_param_storage();

Thomas Purcell's avatar
Thomas Purcell committed
130
    // DocString: node_vals_init_d_mat
131
    /**
132
     * @brief Initialize the descriptor matrix
133
134
135
136
137
     *
     */
    void initialize_d_matrix_arr();

    /**
Thomas Purcell's avatar
Thomas Purcell committed
138
     * @brief Resize the descriptor matrix for the new number of selected features
139
140
141
     *
     * @param n_select Number of features to select
     */
142
    void resize_d_matrix_arr(const int n_select);
143

Thomas Purcell's avatar
Thomas Purcell committed
144
145
146
147
148
    /**
     * @brief Reset the global TASK_SZ_TRAIN vector
     *
     * @param task_sz_train the new task_sz train
     */
149
    void set_task_sz_train(const std::vector<int> task_sz_train);
Thomas Purcell's avatar
Thomas Purcell committed
150
151
152
153
154
155

    /**
     * @brief Reset the global TASK_SZ_TEST vector
     *
     * @param task_sz_train the new test_sz train
     */
156
    void set_task_sz_test(const std::vector<int> task_sz_test);
Thomas Purcell's avatar
Thomas Purcell committed
157

158
159
160
161
162
163
164
    /**
     * @brief Set max_rung and initialize the temporary storage arrays
     *
     * @param max_rung The maximum rung for the calculation
     */
    void set_max_rung(const int max_rung, bool use_params=false);

165
166
167
168
    /**
     * @brief Get the operator slot associated with a given rung/offset
     *
     * @param rung Rung of the feature
Thomas Purcell's avatar
Thomas Purcell committed
169
     * @param offset Offset used to prevent overwrites (determines where in the binary expression tree this operator is)
170
     * @param for_comp If true get a slot dedicated to comparing features
171
172
173
     *
     * @return The operator slot to use
     */
174
    inline int get_op_slot(const int rung, const int offset, const bool for_comp)
175
176
177
    {
        return std::abs(N_OP_SLOTS / (1 + !for_comp) - static_cast<int>(std::pow(2, MAX_RUNG - rung)) - offset);
    }
178

179
180
181
182
    /**
     * @brief Get the parameter operator slot associated with a given rung/offset
     *
     * @param rung Rung of the feature
Thomas Purcell's avatar
Thomas Purcell committed
183
     * @param offset Offset used to prevent overwrites (determines where in the binary expression tree this operator is)
184
185
186
187
188
189
190
191
192
     * @param for_comp If true get a slot dedicated to comparing features
     *
     * @return The operator slot to use
     */
    inline int get_param_op_slot(const int rung, const int offset, const bool for_comp)
    {
        return std::abs(N_PARAM_OP_SLOTS / (1 + !for_comp) - static_cast<int>(std::pow(2, MAX_RUNG - rung)) - offset);
    }

Thomas Purcell's avatar
Thomas Purcell committed
193
    /**
194
     * @brief Get a reference slot/feature register of the training data
Thomas Purcell's avatar
Thomas Purcell committed
195
     *
196
     * @param ind The Node's arr_ind
197
198
199
200
     * @param op_slot(int) Offset integer for TEMP_STORE_ARRAY
     *
     * @return The register element for a given feature index and op_slot
     */
201
    inline int& temp_storage_reg(const unsigned long int ind, const int op_slot=0)
202
203
    {
        return TEMP_STORAGE_REG[
Thomas Purcell's avatar
Thomas Purcell committed
204
            (ind % N_PRIMARY_FEATURES) + (op_slot % N_OP_SLOTS) * N_PRIMARY_FEATURES + omp_get_thread_num() * (N_PRIMARY_FEATURES * N_OP_SLOTS + 1)
205
206
        ];
    }
207
208
209
210
211
212
213
214
215

    /**
     * @brief Get a reference slot/feature register of the test data
     *
     * @param ind The Node's arr_ind
     * @param op_slot(int) Offset integer for TEMP_STORE_TEST_ARRAY
     *
     * @return The register element for a given feature index and op_slot
     */
216
    inline int& temp_storage_test_reg(const unsigned long int ind, const int op_slot=0)
217
218
    {
        return TEMP_STORAGE_TEST_REG[
Thomas Purcell's avatar
Thomas Purcell committed
219
            (ind % N_PRIMARY_FEATURES) + (op_slot % N_OP_SLOTS) * N_PRIMARY_FEATURES + omp_get_thread_num() * (N_PRIMARY_FEATURES * N_OP_SLOTS + 1)
220
221
        ];
    }
222

Thomas Purcell's avatar
Thomas Purcell committed
223
    /**
224
     * @brief Get a reference slot/feature register of the training data
Thomas Purcell's avatar
Thomas Purcell committed
225
     *
226
     * @param ind The Node's arr_ind
227
     * @param rung Rung of the feature
Thomas Purcell's avatar
Thomas Purcell committed
228
     * @param offset Offset used to prevent overwrites (determines where in the binary expression tree this operator is)
229
     * @param for_comp If true get a slot dedicated to comparing features
Thomas Purcell's avatar
Thomas Purcell committed
230
231
232
     *
     * @return The register element for a given feature index and offset
     */
233
    inline int& temp_storage_reg(const unsigned long int ind, const int rung, const int offset, const bool for_comp)
234
235
    {
        return TEMP_STORAGE_REG[
Thomas Purcell's avatar
Thomas Purcell committed
236
237
238
            (ind % N_PRIMARY_FEATURES) +
            (get_op_slot(rung, offset, for_comp) % N_OP_SLOTS) * N_PRIMARY_FEATURES +
            omp_get_thread_num() * (N_PRIMARY_FEATURES * N_OP_SLOTS + 1)
239
240
        ];
    }
Thomas Purcell's avatar
Thomas Purcell committed
241

242
    /**
243
     * @brief Get a reference slot/feature register of the test data
244
     *
245
     * @param ind The Node's arr_ind
246
     * @param rung Rung of the feature
Thomas Purcell's avatar
Thomas Purcell committed
247
     * @param offset Offset used to prevent overwrites (determines where in the binary expression tree this operator is)
248
     * @param for_comp If true get a slot dedicated to comparing features
249
250
251
     *
     * @return The register element for a given feature index and offset
     */
252
    inline int& temp_storage_test_reg(const unsigned long int ind, const int rung, const int offset, const bool for_comp)
253
254
    {
        return TEMP_STORAGE_TEST_REG[
Thomas Purcell's avatar
Thomas Purcell committed
255
            (ind % N_PRIMARY_FEATURES) +
Thomas Purcell's avatar
Thomas Purcell committed
256
257
            (get_op_slot(rung, offset, for_comp) % N_OP_SLOTS) * N_PRIMARY_FEATURES +
            omp_get_thread_num() * (N_PRIMARY_FEATURES * N_OP_SLOTS + 1)
258
259
        ];
    }
260

Thomas Purcell's avatar
Thomas Purcell committed
261
    /**
262
     * @brief Access element of the permanent training data storage array
Thomas Purcell's avatar
Thomas Purcell committed
263
     *
Thomas Purcell's avatar
Thomas Purcell committed
264
     * @param feature_ind The _feat_ind of Node to get the training data of
Thomas Purcell's avatar
Thomas Purcell committed
265
     *
266
     * @return pointer to the Node's training data
Thomas Purcell's avatar
Thomas Purcell committed
267
     */
268
    inline double* access_value_arr(const unsigned long int feature_ind){return &VALUES_ARR[feature_ind*N_SAMPLES];}
269

270
    /**
271
     * @brief Access element of the permanent test data storage array
272
     *
Thomas Purcell's avatar
Thomas Purcell committed
273
     * @param feature_ind The _feat_ind of Node to get the test data of
274
     *
275
     * @return pointer to the Node's test data
276
     */
277
    inline double* access_test_value_arr(const unsigned long int feature_ind){return &TEST_VALUES_ARR[feature_ind*N_SAMPLES_TEST];}
278

Thomas Purcell's avatar
Thomas Purcell committed
279
    /**
280
     * @brief Access element of temporary storage array for the training data
Thomas Purcell's avatar
Thomas Purcell committed
281
     *
282
     * @param slot The slot of the temporary storage array
Thomas Purcell's avatar
Thomas Purcell committed
283
     *
284
     * @return pointer to the data stored in the specified slot
Thomas Purcell's avatar
Thomas Purcell committed
285
     */
286
    inline double* access_temp_storage(const unsigned long int slot){return &TEMP_STORAGE_ARR[slot*N_SAMPLES];}
287

288
    /**
289
     * @brief Access element of temporary storage array for the test data
290
     *
291
     * @param slot The slot of the temporary storage array
292
     *
293
     * @return pointer to the data stored in the specified slot
294
     */
295
    inline double* access_temp_storage_test(const unsigned long int slot){return &TEMP_STORAGE_TEST_ARR[slot*N_SAMPLES_TEST];}
296

297
298
299
    /**
     * @brief Access element of temporary standardized storage array for the training data
     *
300
301
     * @param arr_ind The array index of the feature
     * @param for_comp True if used for a comparison
302
303
304
     *
     * @return pointer to the data stored in the specified slot
     */
305
306
307
308
    inline double* access_temp_stand_storage(const unsigned long int arr_ind, const bool for_comp)
    {
        return &STANDARDIZED_STORAGE_ARR[((arr_ind % N_PRIMARY_FEATURES) + for_comp * N_PRIMARY_FEATURES) * N_PRIMARY_FEATURES];
    }
309
310
311
312

    /**
     * @brief Access element of temporary standardized storage array for the test data
     *
313
314
     * @param arr_ind The array index of the feature
     * @param for_comp True if used for a comparison
315
316
317
     *
     * @return pointer to the data stored in the specified slot
     */
318
319
320
321
    inline double* access_temp_stand_storage_test(const unsigned long int arr_ind, const bool for_comp)
    {
        return &STANDARDIZED_TEST_STORAGE_ARR[((arr_ind % N_PRIMARY_FEATURES) + for_comp * N_PRIMARY_FEATURES) * N_SAMPLES_TEST];
    }
322

323
324
325
326
    /**
     * @brief Access the param storage array
     *
     * @param rung Rung of the feature
Thomas Purcell's avatar
Thomas Purcell committed
327
     * @param offset Offset used to prevent overwrites (determines where in the binary expression tree this operator is)
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
     * @param for_comp If true get a slot dedicated to comparing features
     * @return pointer to the correct element of the PARAM_STORAGE_ARR
     */
    inline double* access_param_storage(const int rung=0, const int offset=0, const bool for_comp=false)
    {
        return &PARAM_STORAGE_ARR[
            N_SAMPLES *
            (
                (get_param_op_slot(rung, offset, for_comp) % N_PARAM_OP_SLOTS) +
                omp_get_thread_num() * (N_PARAM_OP_SLOTS + 1)
            )
        ];
    }

    /**
     * @brief Access the param storage array for the test set
     *
     * @param rung Rung of the feature
Thomas Purcell's avatar
Thomas Purcell committed
346
     * @param offset Offset used to prevent overwrites (determines where in the binary expression tree this operator is)
347
348
349
350
351
352
353
354
355
356
357
358
359
360
     * @param for_comp If true get a slot dedicated to comparing features
     * @return pointer to the correct element of the PARAM_STORAGE_ARR
     */
    inline double* access_param_storage_test(const int rung=0, const int offset=0, const bool for_comp=false)
    {
        return &PARAM_STORAGE_TEST_ARR[
            N_SAMPLES_TEST *
            (
                (get_param_op_slot(rung, offset, for_comp) % N_PARAM_OP_SLOTS) +
                omp_get_thread_num() * (N_PARAM_OP_SLOTS + 1)
            )
        ];
    }

Thomas Purcell's avatar
Thomas Purcell committed
361
    /**
362
     * @brief Get a Node's value_ptr
Thomas Purcell's avatar
Thomas Purcell committed
363
     *
364
365
     * @param arr_ind Nodes _arr_ind
     * @param feat_ind Nodes _feat_ind
366
     * @param rung Rung of the feature
Thomas Purcell's avatar
Thomas Purcell committed
367
     * @param offset Offset used to prevent overwrites (determines where in the binary expression tree this operator is)
368
     * @param for_comp If true get a slot dedicated to comparing features
Thomas Purcell's avatar
Thomas Purcell committed
369
370
371
     *
     * @return The value pointer
     */
372
373
374
375
376
    double* get_value_ptr(
        const unsigned long int arr_ind,
        const unsigned long int feat_ind,
        const int rung=0,
        const int offset=0,
377
        const bool for_comp=false
378
    );
Thomas Purcell's avatar
Thomas Purcell committed
379

380
    /**
381
     * @brief Get a Node's test_value_ptr
382
     *
383
384
     * @param arr_ind Nodes _arr_ind
     * @param feat_ind Nodes _feat_ind
385
     * @param rung Rung of the feature
Thomas Purcell's avatar
Thomas Purcell committed
386
     * @param offset Offset used to prevent overwrites (determines where in the binary expression tree this operator is)
387
     * @param for_comp If true get a slot dedicated to comparing features
388
389
390
     *
     * @return The value pointer
     */
391
392
393
394
395
    double* get_test_value_ptr(
        const unsigned long int arr_ind,
        const unsigned long int feat_ind,
        const int rung=0,
        const int offset=0,
396
        const bool for_comp=false
397
    );
398

399
    /**
400
     * @brief Get the pointer to a particular selected Node's data from sis
401
     *
402
     * @param ind Index of the data in the descriptor matrix
403
     * @return The pointer to the descriptor matrix's data
404
     */
405
    inline double* get_d_matrix_ptr(const int ind){return &D_MATRIX[ind * N_SAMPLES];}
Thomas Purcell's avatar
Bug Fix    
Thomas Purcell committed
406

Thomas Purcell's avatar
Thomas Purcell committed
407
    /**
408
     * @brief Get the pointer to a particular selected Node's data from sis
Thomas Purcell's avatar
Thomas Purcell committed
409
410
411
412
413
414
415
     *
     * @param ind Index of the data in the descriptor matrix
     * @param taskind The index for the given task
     * @return The pointer to the descriptor matrix's data
     */
    inline double* get_d_matrix_ptr(const int ind, const int taskind){return &D_MATRIX[ind * N_SAMPLES + TASK_START_TRAIN[taskind]];}

416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
    /**
     * @brief Get the pointer to a particular selected Node's standardized from sis
     *
     * @param ind Index of the data in the descriptor matrix
     * @return The pointer to the descriptor matrix's standardized data
     */
    inline double* get_stand_d_matrix_ptr(const int ind){return &STANDARDIZED_D_MATRIX[ind * N_SAMPLES];}

    /**
     * @brief Get the pointer to a particular selected Node's standardized from sis
     *
     * @param ind Index of the data in the descriptor matrix
     * @param taskind The index for the given task
     * @return The pointer to the descriptor matrix's standardized data
     */
    inline double* get_stand_d_matrix_ptr(const int ind, const int taskind){return &STANDARDIZED_D_MATRIX[ind * N_SAMPLES + TASK_START_TRAIN[taskind]];}

433
434
435
436
    /**
     * @brief Flush the temporary storage register (training data)
     * @details Reset all slots in the register to -1
     */
437
    inline void clear_temp_reg(){std::fill_n(TEMP_STORAGE_REG.begin(), TEMP_STORAGE_REG.size(), -1);}
438

439
440
441
442
    /**
     * @brief Flush the temporary storage register (training data)
     * @details Reset all slots in the register to -1
     */
443
444
    inline void clear_temp_reg_thread()
    {
Thomas Purcell's avatar
Thomas Purcell committed
445
        std::fill_n(TEMP_STORAGE_REG.begin() + (N_PRIMARY_FEATURES * N_OP_SLOTS + 1) * omp_get_thread_num(), N_PRIMARY_FEATURES * N_OP_SLOTS + 1, -1);
446
    }
447

448
449
450
451
    /**
     * @brief Flush the temporary storage register (test data)
     * @details Reset all slots in the register to -1
     */
452
    inline void clear_temp_test_reg(){std::fill_n(TEMP_STORAGE_TEST_REG.begin(), TEMP_STORAGE_TEST_REG.size(), -1);}
453

454
455
#ifdef PY_BINDINGS

456
    // DocString: node_vals_ts_list_no_params
457
458
459
460
    /**
     * @brief Initialize the node value arrays
     * @details Using the size of the initial feature space constructor the storage arrays
     *
Thomas Purcell's avatar
Thomas Purcell committed
461
462
463
464
     * @param task_sz_train (list) The number of training samples per task
     * @param task_sz_test (list) The number of test sample per task
     * @param n_primary_feat (int) The number of primary features
     * @param max_rung (int) The maximum rung for all features
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
     */
    inline void initialize_values_arr(
        py::list task_sz_train,
        py::list task_sz_test,
        int n_primary_feat,
        int max_rung
    )
    {
        initialize_values_arr(
            python_conv_utils::from_list<int>(task_sz_train),
            python_conv_utils::from_list<int>(task_sz_test),
            n_primary_feat,
            max_rung,
            false
        );
    }

482
    // DocString: node_vals_ts_arr_no_params
483
484
485
486
    /**
     * @brief Initialize the node value arrays
     * @details Using the size of the initial feature space constructor the storage arrays
     *
Thomas Purcell's avatar
Thomas Purcell committed
487
488
489
490
     * @param task_sz_train (np.ndarray) The number of training samples per task
     * @param task_sz_test (np.ndarray) The number of test sample per task
     * @param n_primary_feat (int) The number of primary features
     * @param max_rung (int) The maximum rung for all features
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
     */
    inline void initialize_values_arr(
        np::ndarray task_sz_train,
        np::ndarray task_sz_test,
        int n_primary_feat,
        int max_rung
    )
    {
        initialize_values_arr(
            python_conv_utils::from_ndarray<int>(task_sz_train),
            python_conv_utils::from_ndarray<int>(task_sz_test),
            n_primary_feat,
            max_rung,
            false
        );
    }
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562

    // DocString: node_vals_ts_list
    /**
     * @brief Initialize the node value arrays
     * @details Using the size of the initial feature space constructor the storage arrays
     *
     * @param task_sz_train (list): The number of training samples per task
     * @param task_sz_test (list): The number of test sample per task
     * @param n_primary_feat (int): The number of primary features
     * @param max_rung (int): The maximum rung for all features
     * @param use_params (bool): If true also initialize parameterized storage
     */
    inline void initialize_values_arr(
        py::list task_sz_train,
        py::list task_sz_test,
        int n_primary_feat,
        int max_rung,
        bool use_params
    )
    {
        initialize_values_arr(
            python_conv_utils::from_list<int>(task_sz_train),
            python_conv_utils::from_list<int>(task_sz_test),
            n_primary_feat,
            max_rung,
            use_params
        );
    }

    // DocString: node_vals_ts_arr
    /**
     * @brief Initialize the node value arrays
     * @details Using the size of the initial feature space constructor the storage arrays
     *
     * @param task_sz_train (np.ndarray): The number of training samples per task
     * @param task_sz_test (np.ndarray): The number of test sample per task
     * @param n_primary_feat (int): The number of primary features
     * @param max_rung (int): The maximum rung for all features
     * @param use_params (bool): If true also initialize parameterized storage
     */
    inline void initialize_values_arr(
        np::ndarray task_sz_train,
        np::ndarray task_sz_test,
        int n_primary_feat,
        int max_rung,
        bool use_params
    )
    {
        initialize_values_arr(
            python_conv_utils::from_ndarray<int>(task_sz_train),
            python_conv_utils::from_ndarray<int>(task_sz_test),
            n_primary_feat,
            max_rung,
            use_params
        );
    }
563
#endif
Thomas Purcell's avatar
Thomas Purcell committed
564
565
}

566
#endif