updated all to 32-bit to save registers and boost performance
Some checks failed
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Has been cancelled
Some checks failed
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Has been cancelled
This commit is contained in:
@ -1,20 +1,20 @@
|
||||
using .ExpressionProcessing
|
||||
|
||||
expressions = Vector{Expr}(undef, 1)
|
||||
variables = Matrix{Float64}(undef, 1,2)
|
||||
parameters = Vector{Vector{Float64}}(undef, 1)
|
||||
variables = Matrix{Float32}(undef, 1,2)
|
||||
parameters = Vector{Vector{Float32}}(undef, 1)
|
||||
|
||||
# Resulting value should be 10
|
||||
expressions[1] = :(x1 + 1 * x2 + p1)
|
||||
variables[1,1] = 2
|
||||
variables[1,2] = 3
|
||||
parameters[1] = Vector{Float64}(undef, 1)
|
||||
parameters[1] = Vector{Float32}(undef, 1)
|
||||
parameters[1][1] = 5
|
||||
|
||||
@testset "Test conversion expression element" begin
|
||||
reference1 = ExpressionElement(FLOAT64, reinterpret(Int64, 1.0))
|
||||
reference2 = ExpressionElement(INDEX, reinterpret(Int64, 1))
|
||||
reference3 = ExpressionElement(OPERATOR, reinterpret(Int64, ADD))
|
||||
reference1 = ExpressionElement(FLOAT32, reinterpret(Int32, 1f0))
|
||||
reference2 = ExpressionElement(INDEX, reinterpret(Int32, Int32(1)))
|
||||
reference3 = ExpressionElement(OPERATOR, reinterpret(Int32, ADD))
|
||||
|
||||
@test isequal(reference1, ExpressionProcessing.convert_to_ExpressionElement(1.0))
|
||||
@test isequal(reference2, ExpressionProcessing.convert_to_ExpressionElement(1))
|
||||
|
@ -3,8 +3,8 @@ using .ExpressionProcessing
|
||||
using .Interpreter
|
||||
|
||||
expressions = Vector{Expr}(undef, 2)
|
||||
variables = Matrix{Float64}(undef, 2,2)
|
||||
parameters = Vector{Vector{Float64}}(undef, 2)
|
||||
variables = Matrix{Float32}(undef, 2,2)
|
||||
parameters = Vector{Vector{Float32}}(undef, 2)
|
||||
|
||||
# Resulting value should be 10 for the first expression
|
||||
expressions[1] = :(x1 + 1 * x2 + p1)
|
||||
@ -13,34 +13,36 @@ variables[1,1] = 2.0
|
||||
variables[2,1] = 3.0
|
||||
variables[1,2] = 0.0
|
||||
variables[2,2] = 5.0
|
||||
parameters[1] = Vector{Float64}(undef, 1)
|
||||
parameters[2] = Vector{Float64}(undef, 2)
|
||||
parameters[1] = Vector{Float32}(undef, 1)
|
||||
parameters[2] = Vector{Float32}(undef, 2)
|
||||
parameters[1][1] = 5.0
|
||||
parameters[2][1] = 5.0
|
||||
parameters[2][2] = 0.0
|
||||
|
||||
function testHelper(expression::Expr, variables::Matrix{Float64}, parameters::Vector{Vector{Float64}}, expectedResult::Float64)
|
||||
function testHelper(expression::Expr, variables::Matrix{Float32}, parameters::Vector{Vector{Float32}}, expectedResult)
|
||||
postfix = Vector([expr_to_postfix(expression)])
|
||||
result = Interpreter.interpret(postfix, variables, parameters)
|
||||
@test isequal(result[1,1], expectedResult)
|
||||
|
||||
expectedResult32 = convert(Float32, expectedResult)
|
||||
@test isequal(result[1,1], expectedResult32)
|
||||
end
|
||||
|
||||
@testset "Test conversion to matrix" begin
|
||||
reference = Matrix{Float64}(undef, 2, 2)
|
||||
reference = Matrix{Float32}(undef, 2, 2)
|
||||
reference[1,1] = 5.0
|
||||
reference[2,1] = NaN64
|
||||
reference[2,1] = NaN32
|
||||
reference[1,2] = 5.0
|
||||
reference[2,2] = 0.0
|
||||
# reference = Matrix([5.0, NaN],
|
||||
# [5.0, 0.0])
|
||||
result = Interpreter.convert_to_matrix(parameters, NaN64)
|
||||
result = Interpreter.convert_to_matrix(parameters, NaN32)
|
||||
|
||||
@test isequal(result, reference)
|
||||
end
|
||||
|
||||
@testset "Test commutative interpretation" begin
|
||||
var = Matrix{Float64}(undef, 2, 1)
|
||||
param = Vector{Vector{Float64}}(undef, 1)
|
||||
var = Matrix{Float32}(undef, 2, 1)
|
||||
param = Vector{Vector{Float32}}(undef, 1)
|
||||
expectedResult = 8.0 # Not using "eval" because the variables are not stored in global scope
|
||||
|
||||
var[1,1] = 3.0
|
||||
@ -59,8 +61,8 @@ end
|
||||
end
|
||||
|
||||
@testset "Test non commutative interpretation" begin
|
||||
var = Matrix{Float64}(undef, 2, 1)
|
||||
param = Vector{Vector{Float64}}(undef, 1)
|
||||
var = Matrix{Float32}(undef, 2, 1)
|
||||
param = Vector{Vector{Float32}}(undef, 1)
|
||||
expectedResult = -2.0 # Not using "eval" because the variables are not stored in global scope
|
||||
|
||||
var[1,1] = 3.0
|
||||
@ -89,8 +91,8 @@ end
|
||||
end
|
||||
|
||||
@testset "Test single value operator interpretation" begin
|
||||
var = Matrix{Float64}(undef, 1, 1)
|
||||
param = Vector{Vector{Float64}}(undef, 1)
|
||||
var = Matrix{Float32}(undef, 1, 1)
|
||||
param = Vector{Vector{Float32}}(undef, 1)
|
||||
expectedResult = 3.0 # Not using "eval" because the variables are not stored in global scope
|
||||
|
||||
var[1,1] = -3.0
|
||||
@ -108,8 +110,8 @@ end
|
||||
end
|
||||
|
||||
@testset "Test complex expressions" begin
|
||||
var = Matrix{Float64}(undef, 2, 2)
|
||||
param = Vector{Vector{Float64}}(undef, 2)
|
||||
var = Matrix{Float32}(undef, 2, 2)
|
||||
param = Vector{Vector{Float32}}(undef, 2)
|
||||
|
||||
# var set 1
|
||||
var[1,1] = 3.0
|
||||
|
@ -3,8 +3,8 @@ using .ExpressionProcessing
|
||||
using .Transpiler
|
||||
|
||||
expressions = Vector{Expr}(undef, 2)
|
||||
variables = Matrix{Float64}(undef, 2,2)
|
||||
parameters = Vector{Vector{Float64}}(undef, 2)
|
||||
variables = Matrix{Float32}(undef, 2,2)
|
||||
parameters = Vector{Vector{Float32}}(undef, 2)
|
||||
|
||||
# Resulting value should be 10 for the first expression
|
||||
expressions[1] = :(1 + 3 * 5 / 7 - 1)
|
||||
@ -13,8 +13,8 @@ variables[1,1] = 2.0
|
||||
variables[2,1] = 3.0
|
||||
variables[1,2] = 0.0
|
||||
variables[2,2] = 5.0
|
||||
parameters[1] = Vector{Float64}(undef, 1)
|
||||
parameters[2] = Vector{Float64}(undef, 2)
|
||||
parameters[1] = Vector{Float32}(undef, 1)
|
||||
parameters[2] = Vector{Float32}(undef, 2)
|
||||
parameters[1][1] = 5.0
|
||||
parameters[2][1] = 5.0
|
||||
parameters[2][2] = 0.0
|
||||
|
Reference in New Issue
Block a user