@@ -432,6 +432,45 @@ function deg2_diff_eval(
432432 return (out, no_nans)
433433end
434434
435+ """
436+ eval_tree_array(tree::Node, cX::AbstractMatrix{T,N}, operators::GenericOperatorEnum) where {T,N}
437+
438+ Evaluate a generic binary tree (equation) over a given input data,
439+ whatever that input data may be. The `operators` enum contains all
440+ of the operators used. Unlike `eval_tree_array` with the normal
441+ `OperatorEnum`, the array `cX` is sliced only along the first dimension.
442+ i.e., if `cX` is a vector, then the output of a feature node
443+ will be a scalar. If `cX` is a 3D tensor, then the output
444+ of a feature node will be a 2D tensor.
445+ Note also that `tree.feature` will index along the first axis of `cX`.
446+
447+ However, there is no requirement about input and output types in general.
448+ You may set up your tree such that some operator nodes work on tensors, while
449+ other operator nodes work on scalars. `eval_tree_array` will simply
450+ return `nothing` if a given operator is not defined for the given input type.
451+
452+ This function can be represented by the following pseudocode:
453+
454+ ```
455+ function eval(current_node)
456+ if current_node is leaf
457+ return current_node.value
458+ elif current_node is degree 1
459+ return current_node.operator(eval(current_node.left_child))
460+ else
461+ return current_node.operator(eval(current_node.left_child), eval(current_node.right_child))
462+ ```
463+
464+
465+
466+ # Returns
467+
468+ - `(output, complete)::Tuple{Any, Bool}`: the result,
469+ as well as if the evaluation completed successfully (true/false).
470+ If evaluation failed, `nothing` will be returned for the first argument.
471+ A `false` complete means an operator was called on input types
472+ that it was not defined for.
473+ """
435474function eval_tree_array (
436475 tree, cX:: AbstractArray{T,N} , operators:: GenericOperatorEnum
437476) where {T,N}
0 commit comments