diff --git a/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_bit.hpp b/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_bit.hpp index f9d90b75b..a94f735b1 100644 --- a/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_bit.hpp +++ b/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_bit.hpp @@ -20,12 +20,13 @@ namespace boosting { public: /** - * @param numElements The number of gradients and Hessians in the vector - * @param numBitsPerElement The number of bits per element in the bit vector - * @param init True, if all gradients and Hessians in the vector should be initialized with - * zero, false otherwise + * @param view A reference to an object of type `BitDecomposableStatisticView` + * @param numElements The number of gradients and Hessians in the vector + * @param init True, if all gradients and Hessians in the vector should be initialized with zero, + * false otherwise */ - BitDecomposableStatisticVector(uint32 numElements, uint32 numBitsPerElement, bool init = false); + BitDecomposableStatisticVector(const BitDecomposableStatisticView& view, uint32 numElements, + bool init = false); /** * @param other A reference to an object of type `BitDecomposableStatisticVector` to be copied diff --git a/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_dense.hpp b/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_dense.hpp index 6897b33c4..d6eaf3e18 100644 --- a/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_dense.hpp +++ b/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_dense.hpp @@ -21,11 +21,13 @@ namespace boosting { public: /** + * @param view A reference to an object of type `CContiguousView` * @param numElements The number of gradients and Hessians in the vector * @param init True, if all gradients and Hessians in the vector should be initialized with zero, * false otherwise */ - DenseDecomposableStatisticVector(uint32 numElements, bool init = false); + DenseDecomposableStatisticVector(const CContiguousView>& view, uint32 numElements, + bool init = false); /** * @param other A reference to an object of type `DenseDecomposableStatisticVector` to be copied diff --git a/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_sparse.hpp b/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_sparse.hpp index aaaedc21d..58c53e890 100644 --- a/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_sparse.hpp +++ b/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_decomposable_sparse.hpp @@ -138,11 +138,13 @@ namespace boosting { public: /** + * @param view A reference to an object of type `SparseSetView` * @param numElements The number of gradients and Hessians in the vector * @param init True, if all gradients and Hessians in the vector should be initialized with zero, * false otherwise */ - SparseDecomposableStatisticVector(uint32 numElements, bool init = false); + SparseDecomposableStatisticVector(const SparseSetView>& view, uint32 numElements, + bool init = false); /** * @param other A reference to an object of type `SparseDecomposableStatisticVector` to be copied diff --git a/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_non_decomposable_dense.hpp b/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_non_decomposable_dense.hpp index 302fa04ac..7d839965c 100644 --- a/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_non_decomposable_dense.hpp +++ b/cpp/subprojects/boosting/include/mlrl/boosting/data/vector_statistic_non_decomposable_dense.hpp @@ -23,11 +23,13 @@ namespace boosting { public: /** - * @param numGradients The number of gradients in the vector - * @param init True, if all gradients and Hessians in the vector should be initialized with zero, - * false otherwise + * @param view A reference to an object of type `DenseNonDecomposableStatisticView` + * @param numGradients The number of gradients in the vector + * @param init True, if all gradients and Hessians in the vector should be initialized with zero, + * false otherwise */ - DenseNonDecomposableStatisticVector(uint32 numGradients, bool init = false); + DenseNonDecomposableStatisticVector(const DenseNonDecomposableStatisticView& view, uint32 numGradients, + bool init = false); /** * @param other A reference to an object of type `DenseNonDecomposableStatisticVector` to be copied diff --git a/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_bit.cpp b/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_bit.cpp index 257563694..fc5c0dbcc 100644 --- a/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_bit.cpp +++ b/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_bit.cpp @@ -50,14 +50,16 @@ namespace boosting { } } - BitDecomposableStatisticVector::BitDecomposableStatisticVector(uint32 numElements, uint32 numBitsPerElement, - bool init) + BitDecomposableStatisticVector::BitDecomposableStatisticVector(const BitDecomposableStatisticView& view, + uint32 numElements, bool init) : CompositeView, AllocatedBitVector>( - AllocatedBitVector(numElements, numBitsPerElement, init), - AllocatedBitVector(numElements, numBitsPerElement, init)) {} + AllocatedBitVector(numElements, view.firstView.numBitsPerElement, init), + AllocatedBitVector(numElements, view.secondView.numBitsPerElement, init)) {} BitDecomposableStatisticVector::BitDecomposableStatisticVector(const BitDecomposableStatisticVector& other) - : BitDecomposableStatisticVector(other.getNumElements(), other.getNumBitsPerElement()) { + : CompositeView, AllocatedBitVector>( + AllocatedBitVector(other.firstView.numElements, other.firstView.numBitsPerElement), + AllocatedBitVector(other.secondView.numElements, other.secondView.numBitsPerElement)) { copyInternally(other.firstView, this->firstView); copyInternally(other.secondView, this->secondView); } diff --git a/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_dense.cpp b/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_dense.cpp index 0e6523558..f0aab8efd 100644 --- a/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_dense.cpp +++ b/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_dense.cpp @@ -2,12 +2,14 @@ namespace boosting { - DenseDecomposableStatisticVector::DenseDecomposableStatisticVector(uint32 numElements, bool init) + DenseDecomposableStatisticVector::DenseDecomposableStatisticVector(const CContiguousView>& view, + uint32 numElements, bool init) : ClearableViewDecorator>>>( AllocatedVector>(numElements, init)) {} DenseDecomposableStatisticVector::DenseDecomposableStatisticVector(const DenseDecomposableStatisticVector& other) - : DenseDecomposableStatisticVector(other.getNumElements()) { + : ClearableViewDecorator>>>( + AllocatedVector>(other.getNumElements())) { util::copyView(other.cbegin(), this->begin(), this->getNumElements()); } diff --git a/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_sparse.cpp b/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_sparse.cpp index c0f2fff17..2a734cb95 100644 --- a/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_sparse.cpp +++ b/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_decomposable_sparse.cpp @@ -57,13 +57,15 @@ namespace boosting { return iterator_ - rhs.iterator_; } - SparseDecomposableStatisticVector::SparseDecomposableStatisticVector(uint32 numElements, bool init) + SparseDecomposableStatisticVector::SparseDecomposableStatisticVector(const SparseSetView>& view, + uint32 numElements, bool init) : ClearableViewDecorator>>>( AllocatedVector>(numElements, init)), sumOfWeights_(0) {} SparseDecomposableStatisticVector::SparseDecomposableStatisticVector(const SparseDecomposableStatisticVector& other) - : SparseDecomposableStatisticVector(other.getNumElements()) { + : ClearableViewDecorator>>>( + AllocatedVector>(other.getNumElements())) { util::copyView(other.view.cbegin(), this->view.begin(), this->getNumElements()); sumOfWeights_ = other.sumOfWeights_; } diff --git a/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_non_decomposable_dense.cpp b/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_non_decomposable_dense.cpp index 02d64a32f..0c367e21e 100644 --- a/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_non_decomposable_dense.cpp +++ b/cpp/subprojects/boosting/src/mlrl/boosting/data/vector_statistic_non_decomposable_dense.cpp @@ -4,7 +4,8 @@ namespace boosting { - DenseNonDecomposableStatisticVector::DenseNonDecomposableStatisticVector(uint32 numGradients, bool init) + DenseNonDecomposableStatisticVector::DenseNonDecomposableStatisticVector( + const DenseNonDecomposableStatisticView& view, uint32 numGradients, bool init) : ClearableViewDecorator, AllocatedVector>>>( CompositeVector, AllocatedVector>( AllocatedVector(numGradients, init), @@ -12,7 +13,9 @@ namespace boosting { DenseNonDecomposableStatisticVector::DenseNonDecomposableStatisticVector( const DenseNonDecomposableStatisticVector& other) - : DenseNonDecomposableStatisticVector(other.getNumGradients()) { + : ClearableViewDecorator, AllocatedVector>>>( + CompositeVector, AllocatedVector>( + AllocatedVector(other.getNumGradients()), AllocatedVector(other.getNumHessians()))) { util::copyView(other.gradients_cbegin(), this->gradients_begin(), this->getNumGradients()); util::copyView(other.hessians_cbegin(), this->hessians_begin(), this->getNumHessians()); } diff --git a/cpp/subprojects/boosting/src/mlrl/boosting/statistics/statistics_common.hpp b/cpp/subprojects/boosting/src/mlrl/boosting/statistics/statistics_common.hpp index 7f148943a..8b5ed03f8 100644 --- a/cpp/subprojects/boosting/src/mlrl/boosting/statistics/statistics_common.hpp +++ b/cpp/subprojects/boosting/src/mlrl/boosting/statistics/statistics_common.hpp @@ -98,8 +98,8 @@ namespace boosting { */ StatisticsSubset(const StatisticView& statisticView, const RuleEvaluationFactory& ruleEvaluationFactory, const WeightVector& weights, const IndexVector& outputIndices) - : sumVector_(outputIndices.getNumElements(), true), statisticView_(statisticView), weights_(weights), - outputIndices_(outputIndices), + : sumVector_(statisticView, outputIndices.getNumElements(), true), statisticView_(statisticView), + weights_(weights), outputIndices_(outputIndices), ruleEvaluationPtr_(ruleEvaluationFactory.create(sumVector_, outputIndices)) {} /** @@ -182,7 +182,8 @@ namespace boosting { : StatisticsSubset(statistics.statisticView_, statistics.ruleEvaluationFactory_, statistics.weights_, outputIndices), - tmpVector_(outputIndices.getNumElements()), totalSumVector_(&totalSumVector) {} + tmpVector_(statistics.statisticView_, outputIndices.getNumElements()), + totalSumVector_(&totalSumVector) {} /** * @see `IWeightedStatisticsSubset::resetSubset` @@ -388,7 +389,7 @@ namespace boosting { const WeightVector& weights) : AbstractImmutableWeightedStatistics(statisticView, ruleEvaluationFactory, weights), - totalSumVectorPtr_(std::make_unique(statisticView.numCols, true)) { + totalSumVectorPtr_(std::make_unique(statisticView, statisticView.numCols, true)) { uint32 numStatistics = weights.getNumElements(); for (uint32 i = 0; i < numStatistics; i++) {