-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
Hi,
Thanks for such an incredible package; I am currently experimenting with the vector capabilities. According to the example you gave, is there a reason for not overloading the base operators, e.g. doing some like:
import Base: +, *
using DynamicExpressions
using DynamicExpressions: @declare_expression_operator
T = Union{Float64,Vector{Float64}}
+(x::AbstractVector, y::AbstractVector) = x .+ y
+(x::AbstractFloat, y::AbstractVector) = y .+ x
+(x::AbstractVector, y::AbstractFloat) = x .+ y
*(x::AbstractVector, y::AbstractVector) = x .* y
@declare_expression_operator(+, 2)
@declare_expression_operator(*, 2)
operators = GenericOperatorEnum(
binary_operators=[+, *])
variable_names = ["x1"]
c1 = Expression(Node{T}(val=0.0); operators, variable_names)
c2 = Expression(Node{T}(val=[1.0, 2.0, 3.0]); operators, variable_names)
x1 = Expression(Node{T}(feature=1); operators, variable_names )
expression = ((x1 * x1) + c2) + c1
X = [[-1.0, 5.2, 0.1], [0.0, 0.0, 0.0]]
result = expression(X)
println(result)
Best wishes
Metadata
Metadata
Assignees
Labels
No labels