Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/symbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function mul_numeric_args(args)
(prod, sym_args)
end

# Handles all lengths for ex.args
# Handles `args` of all lengths
# Removes any 0's in a sum
function simplify(::SymbolParameter{:+}, args)
new_args = map(x -> simplify(x), filter(x -> x != 0, args))
Expand All @@ -144,7 +144,7 @@ function simplify(::SymbolParameter{:+}, args)
end
end

# Assumes length(ex.args) == 3
# Assumes length(args) == 3
# Removes any 0's in a subtraction
function simplify(::SymbolParameter{:-}, args)
new_args = map(x -> simplify(x), filter(x -> x != 0, args))
Expand All @@ -158,13 +158,13 @@ function simplify(::SymbolParameter{:-}, args)
end
end

# Handles all lengths for ex.args
# Handles `args` of all lengths
# Removes any 1's in a product
function simplify(::SymbolParameter{:*}, args)
new_args = map(x -> simplify(x), filter(x -> x != 1, args))
if length(new_args) == 0
return 1
# Special Case: simplify(:(*x)) == x
# Special Case: simplify(:(*(x))) == x
elseif length(new_args) == 1
return new_args[1]
# Special Case: simplify(:(x * y * z * 0)) == 0
Expand All @@ -177,7 +177,7 @@ function simplify(::SymbolParameter{:*}, args)
end
end

# Assumes length(ex.args) == 3
# Assumes length(args) == 3
function simplify(::SymbolParameter{:/}, args)
new_args = map(x -> simplify(x), args)
# Special Case: simplify(:(x / 1)) == x
Expand All @@ -191,7 +191,7 @@ function simplify(::SymbolParameter{:/}, args)
end
end

# Assumes length(ex.args) == 3
# Assumes length(args) == 3
function simplify(::SymbolParameter{:^}, args)
new_args = map(x -> simplify(x), args)
# Special Case: simplify(:(x ^ 0)) == 1
Expand Down