layed groundwork for implementing interpretation
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,21 +1,42 @@
|
||||
using CUDA
|
||||
using .ExpressionProcessing
|
||||
using .Interpreter
|
||||
|
||||
expressions = Vector{Expr}(undef, 1)
|
||||
variables = Matrix{Float64}(undef, 1,2)
|
||||
parameters = Vector{Vector{Float64}}(undef, 1)
|
||||
expressions = Vector{Expr}(undef, 2)
|
||||
variables = Matrix{Float64}(undef, 2,2)
|
||||
parameters = Vector{Vector{Float64}}(undef, 2)
|
||||
|
||||
# Resulting value should be 10
|
||||
expressions[1] = :(x1 + 1 * x2 + p1)
|
||||
variables[1,1] = 2
|
||||
variables[1,2] = 3
|
||||
expressions[2] = :(5 + x1 + 1 * x2 + p1 + p2)
|
||||
variables[1,1] = 2.0
|
||||
variables[1,2] = 3.0
|
||||
variables[2,1] = 2.0
|
||||
variables[2,2] = 3.0
|
||||
parameters[1] = Vector{Float64}(undef, 1)
|
||||
parameters[1][1] = 5
|
||||
parameters[2] = Vector{Float64}(undef, 2)
|
||||
parameters[1][1] = 5.0
|
||||
parameters[2][1] = 5.0
|
||||
parameters[2][2] = 0.0
|
||||
|
||||
@testset "Test interpretation" begin
|
||||
postfixExpr = expr_to_postfix(expressions[1])
|
||||
postfixExprs = Vector{PostfixType}(undef, 1)
|
||||
postfixExprs[1] = postfixExpr
|
||||
postfixExprs = Vector([postfixExpr])
|
||||
push!(postfixExprs, expr_to_postfix(expressions[2]))
|
||||
|
||||
Interpret(postfixExprs, variables, parameters)
|
||||
CUDA.@sync interpret(postfixExprs, variables, parameters)
|
||||
end
|
||||
|
||||
@testset "Test conversion to matrix" begin
|
||||
reference = Matrix{Float64}(undef, 2, 2)
|
||||
reference[1,1] = 5.0
|
||||
reference[2,1] = NaN64
|
||||
reference[1,2] = 5.0
|
||||
reference[2,2] = 0.0
|
||||
# fill!(reference, [[], [5.0, 0.0]])
|
||||
# reference = Matrix([5.0, NaN],
|
||||
# [5.0, 0.0])
|
||||
result = Interpreter.convert_to_matrix(parameters, NaN64)
|
||||
|
||||
@test isequal(result, reference)
|
||||
end
|
Reference in New Issue
Block a user