You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#' Add a constant value to every leaf of every tree in an ensemble. If leaves are multi-dimensional, `constant_value` will be added to every dimension of the leaves.
655
+
#' @param constant_value Value that will be added to every leaf of every tree
#' Multiply every leaf of every tree by a constant value. If leaves are multi-dimensional, `constant_multiple` will be multiplied through every dimension of the leaves.
662
+
#' @param constant_multiple Value that will be multiplied by every leaf of every tree
* \brief Add a constant value to every leaf of every tree in an ensemble. If leaves are multi-dimensional, `constant_value` will be added to every dimension of the leaves.
112
+
*
113
+
* \param constant_value Value that will be added to every leaf of every tree
114
+
*/
115
+
voidAddValueToLeaves(double constant_value) {
116
+
for (int j = 0; j < num_trees_; j++) {
117
+
Tree* tree = GetTree(j);
118
+
tree->AddValueToLeaves(constant_value);
119
+
}
120
+
}
121
+
122
+
/*!
123
+
* \brief Multiply every leaf of every tree by a constant value. If leaves are multi-dimensional, `constant_multiple` will be multiplied through every dimension of the leaves.
124
+
*
125
+
* \param constant_multiple Value that will be multiplied by every leaf of every tree
Copy file name to clipboardExpand all lines: include/stochtree/tree.h
+34Lines changed: 34 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -201,6 +201,40 @@ class Tree {
201
201
this->ChangeToLeaf(nid, value_vector);
202
202
}
203
203
204
+
/*!
205
+
* \brief Add a constant value to every leaf of a tree. If leaves are multi-dimensional, `constant_value` will be added to every dimension of the leaves.
206
+
*
207
+
* \param constant_value Value that will be added to every leaf of a tree
208
+
*/
209
+
voidAddValueToLeaves(double constant_value) {
210
+
if (output_dimension_ == 1) {
211
+
for (int j = 0; j < leaf_value_.size(); j++) {
212
+
leaf_value_[j] += constant_value;
213
+
}
214
+
} else {
215
+
for (int j = 0; j < leaf_vector_.size(); j++) {
216
+
leaf_vector_[j] += constant_value;
217
+
}
218
+
}
219
+
}
220
+
221
+
/*!
222
+
* \brief Multiply every leaf of a tree by a constant value. If leaves are multi-dimensional, `constant_value` will be multiplied through every dimension of the leaves.
223
+
*
224
+
* \param constant_multiple Value that will be multiplied by every leaf of a tree
0 commit comments