Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
c835184
1
Parent(s):
9fe2f40
Add square and cube operators
Browse files- docs/operators.md +2 -0
- julia/operators.jl +2 -0
- pysr/sr.py +2 -0
docs/operators.md
CHANGED
@@ -14,6 +14,8 @@ of these and other valid operators are stated below.
|
|
14 |
**Unary**
|
15 |
|
16 |
`neg`,
|
|
|
|
|
17 |
`exp`,
|
18 |
`abs`,
|
19 |
`logm` (=log(abs(x) + 1e-8)),
|
|
|
14 |
**Unary**
|
15 |
|
16 |
`neg`,
|
17 |
+
`square`,
|
18 |
+
`cube`,
|
19 |
`exp`,
|
20 |
`abs`,
|
21 |
`logm` (=log(abs(x) + 1e-8)),
|
julia/operators.jl
CHANGED
@@ -16,6 +16,8 @@ import Base.FastMath: sqrt_llvm_fast, neg_float_fast,
|
|
16 |
plus(x::Float32, y::Float32)::Float32 = add_float_fast(x, y) #Do not change the name of this operator.
|
17 |
sub(x::Float32, y::Float32)::Float32 = sub_float_fast(x, y) #Do not change the name of this operator.
|
18 |
mult(x::Float32, y::Float32)::Float32 = mul_float_fast(x, y) #Do not change the name of this operator.
|
|
|
|
|
19 |
pow(x::Float32, y::Float32)::Float32 = sign_fast(x)*pow_fast(abs(x), y)
|
20 |
div(x::Float32, y::Float32)::Float32 = div_float_fast(x, y)
|
21 |
logm(x::Float32)::Float32 = log_fast(abs_fast(x) + 1f-8)
|
|
|
16 |
plus(x::Float32, y::Float32)::Float32 = add_float_fast(x, y) #Do not change the name of this operator.
|
17 |
sub(x::Float32, y::Float32)::Float32 = sub_float_fast(x, y) #Do not change the name of this operator.
|
18 |
mult(x::Float32, y::Float32)::Float32 = mul_float_fast(x, y) #Do not change the name of this operator.
|
19 |
+
square(x::Float32)::Float32 = mul_float_fast(x, x)
|
20 |
+
cube(x::Float32)::Float32 = mul_float_fast(mul_float_fast(x, x), x)
|
21 |
pow(x::Float32, y::Float32)::Float32 = sign_fast(x)*pow_fast(abs(x), y)
|
22 |
div(x::Float32, y::Float32)::Float32 = div_float_fast(x, y)
|
23 |
logm(x::Float32)::Float32 = log_fast(abs_fast(x) + 1f-8)
|
pysr/sr.py
CHANGED
@@ -16,6 +16,8 @@ global_extra_sympy_mappings = {}
|
|
16 |
sympy_mappings = {
|
17 |
'div': lambda x, y : x/y,
|
18 |
'mult': lambda x, y : x*y,
|
|
|
|
|
19 |
'plus': lambda x, y : x + y,
|
20 |
'sub': lambda x, y : x - y,
|
21 |
'neg': lambda x : -x,
|
|
|
16 |
sympy_mappings = {
|
17 |
'div': lambda x, y : x/y,
|
18 |
'mult': lambda x, y : x*y,
|
19 |
+
'square':lambda x : x**2,
|
20 |
+
'cube': lambda x : x**3,
|
21 |
'plus': lambda x, y : x + y,
|
22 |
'sub': lambda x, y : x - y,
|
23 |
'neg': lambda x : -x,
|