text:
using ITensors,
  ITensorGPU,
  LinearAlgebra, # For tr()
  Combinatorics, # For permutations()
  Random,
  CUDA,
  Test

@testset "cuITensor $T Contractions" for T in (Float64, ComplexF64)
  mi, mj, mk, ml, ma = 2, 3, 4, 5, 6, 7
  i = Index(mi, "i")
  j = Index(mj, "j")
  k = Index(mk, "k")
  l = Index(ml, "l")
  a = Index(ma, "a")
  @testset "Test contract cuITensors" begin
    A = cuITensor(randomITensor(T))
    B = cuITensor(randomITensor(T))
    Ai = cuITensor(randomITensor(T, i))
    Bi = cuITensor(randomITensor(T, i))
    Aj = cuITensor(randomITensor(T, j))
    Aij = cuITensor(randomITensor(T, i, j))
    Aji = cuITensor(randomITensor(T, j, i))
    Bij = cuITensor(randomITensor(T, i, j))
    Aik = cuITensor(randomITensor(T, i, k))
    Ajk = cuITensor(randomITensor(T, j, k))
    Ajl = cuITensor(randomITensor(T, j, l))
    Akl = cuITensor(randomITensor(T, k, l))
    Aijk = cuITensor(randomITensor(T, i, j, k))
    Ajkl = cuITensor(randomITensor(T, j, k, l))
    Aikl = cuITensor(randomITensor(T, i, k, l))
    Akla = cuITensor(randomITensor(T, k, l, a))
    Aijkl = cuITensor(randomITensor(T, i, j, k, l))
    @testset "Test contract cuITensor (Scalar*Scalar -> Scalar)" begin
      C = A * B
      @test scalar(C) ≈ scalar(A) * scalar(B)
      C = cuITensor(T(2.0)) * cuITensor(T(2.0))
      @test scalar(C) ≈ T(4.0)
    end
    @testset "Test contract cuITensor (Scalar*Vector -> Vector)" begin
      C = A * Ai
      @test cpu(C) ≈ scalar(A) * cpu(Ai)
      C = cuITensor(T(2.0)) * Ai
      @test cpu(C) ≈ T(2.0) * cpu(Ai)
      C = Ai * cuITensor(T(2.0))
      @test cpu(C) ≈ T(2.0) * cpu(Ai)
    end
    @testset "Test contract cuITensor (Vector*Scalar -> Vector)" begin
      C = Aj * A
      @test cpu(C) ≈ scalar(A) * cpu(Aj)
    end
    @testset "Test contract cuITensors (Vectorᵀ*Vector -> Scalar)" begin
      C = Ai * Bi
      Ccpu = cpu(Ai) * cpu(Bi)
      @test scalar(Ccpu) ≈ scalar(C)
    end
    @testset "Test contract cuITensors (Vector*Vectorᵀ -> Matrix)" begin
      C = Ai * Aj
      Ccpu = cpu(Ai) * cpu(Aj)
      @test Ccpu ≈ cpu(permute(C, i, j))
    end
    @testset "Test contract cuITensors (Matrix*Scalar -> Matrix)" begin
      Aij = permute(Aij, i, j)
      C = Aij * A
      @test cpu(permute(C, i, j)) ≈ scalar(A) * cpu(Aij)
    end
    @testset "Test contract cuITensors (Matrixᵀ*Vector -> Vector)" begin
      cAij = permute(copy(Aij), j, i)
      Ccpu = cpu(Aij) * cpu(Aj)
      C = cAij * Aj
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (Matrix*Vector -> Vector)" begin
      cpAij = permute(copy(Aij), i, j)
      Ccpu = cpu(cpAij) * cpu(Aj)
      C = copy(cpAij) * copy(Aj)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (Vector*Matrix -> Vector)" begin
      Aij = permute(Aij, i, j)
      C = Ai * Aij
      Ccpu = cpu(Ai) * cpu(Aij)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (Vector*Matrixᵀ -> Vector)" begin
      C = Ai * Aji
      Ccpu = cpu(Ai) * cpu(Aji)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (Matrix*Matrix -> Scalar)" begin
      Aij = permute(Aij, i, j)
      Bij = permute(Bij, i, j)
      C = Aij * Bij
      Ccpu = cpu(Aij) * cpu(Bij)
      @test scalar(Ccpu) ≈ scalar(C)
    end
    @testset "Test contract cuITensors (Matrix*Matrix -> Matrix)" begin
      Aij = permute(Aij, i, j)
      Ajk = permute(Ajk, j, k)
      C = Aij * Ajk
      Ccpu = cpu(Aij) * cpu(Ajk)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (Matrixᵀ*Matrix -> Matrix)" begin
      Aij = permute(Aij, j, i)
      Ajk = permute(Ajk, j, k)
      C = Aij * Ajk
      Ccpu = cpu(Aij) * cpu(Ajk)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (Matrix*Matrixᵀ -> Matrix)" begin
      Aij = permute(Aij, i, j)
      Ajk = permute(Ajk, k, j)
      C = Aij * Ajk
      Ccpu = cpu(Aij) * cpu(Ajk)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (Matrixᵀ*Matrixᵀ -> Matrix)" begin
      Aij = permute(Aij, j, i)
      Ajk = permute(Ajk, k, j)
      C = Aij * Ajk
      Ccpu = cpu(Aij) * cpu(Ajk)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (3-Tensor*Scalar -> 3-Tensor)" begin
      Aijk = permute(Aijk, i, j, k)
      C = Aijk * A
      @test cpu(permute(C, i, j, k)) ≈ scalar(A) * cpu(Aijk)
    end
    @testset "Test contract cuITensors (3-Tensor*Vector -> Matrix)" begin
      cAijk = permute(copy(Aijk), i, j, k)
      C = cAijk * Ai
      Ccpu = cpu(cAijk) * cpu(Ai)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (Vector*3-Tensor -> Matrix)" begin
      Aijk = permute(Aijk, i, j, k)
      C = Aj * Aijk
      Ccpu = cpu(Aj) * cpu(Aijk)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (3-Tensor*Matrix -> Vector)" begin
      Aijk = permute(Aijk, i, j, k)
      Aik = permute(Aik, i, k)
      C = Aijk * Aik
      Ccpu = cpu(Aijk) * cpu(Aik)
      @test Ccpu ≈ cpu(C)
    end
    @testset "Test contract cuITensors (3-Tensor*Matrix -> 3-Tensor)" begin
      Aijk = permute(Aijk, i, j, k)
      Ajl = permute(Ajl, j, l)
      C = Aijk * Ajl
      Ccpu = cpu(Aijk) * cpu(Ajl)
      @test Ccpu ≈ cpu(permute(C, i, k, l))
    end
    @testset "Test contract cuITensors (Matrix*3-Tensor -> 3-Tensor)" begin
      Aijk = permute(Aijk, i, j, k)
      Akl = permute(Akl, k, l)
      C = Akl * Aijk
      Ccpu = cpu(Aijk) * cpu(Akl)
      @test Ccpu ≈ cpu(permute(C, l, i, j))
    end
    @testset "Test contract cuITensors (3-Tensor*3-Tensor -> 3-Tensor)" begin
      Aijk = permute(Aijk, i, j, k)
      Ajkl = permute(Ajkl, j, k, l)
      C = Aijk * Ajkl
      Ccpu = cpu(Aijk) * cpu(Ajkl)
      @test Ccpu ≈ cpu(permute(C, i, l))
    end
    @testset "Test contract cuITensors (3-Tensor*3-Tensor -> 3-Tensor)" begin
      for inds_ijk in permutations([i, j, k]), inds_jkl in permutations([j, k, l])
        Aijk = permute(Aijk, inds_ijk...)
        Ajkl = permute(Ajkl, inds_jkl...)
        C = Ajkl * Aijk
        Ccpu = cpu(Ajkl) * cpu(Aijk)
        @test Ccpu ≈ cpu(C)
      end
    end
    @testset "Test contract cuITensors (4-Tensor*3-Tensor -> 3-Tensor)" begin
      for inds_ijkl in permutations([i, j, k, l]), inds_kla in permutations([k, l, a])
        Aijkl = permute(Aijkl, inds_ijkl...)
        Akla = permute(Akla, inds_kla...)
        C = Akla * Aijkl
        Ccpu = cpu(Akla) * cpu(Aijkl)
        @test Ccpu ≈ cpu(C)
      end
    end
    @testset "Test contract cuITensors (4-Tensor*3-Tensor -> 1-Tensor)" begin
      for inds_ijkl in permutations([i, j, k, l]), inds_jkl in permutations([j, k, l])
        Aijkl = permute(Aijkl, inds_ijkl...)
        Ajkl = permute(Ajkl, inds_jkl...)
        C = Ajkl * Aijkl
        Ccpu = cpu(Ajkl) * cpu(Aijkl)
        @test Ccpu ≈ cpu(C)
      end
    end
    @testset "Test supersized contract cuITensors (14-Tensor*14-Tensor -> 14-Tensor)" begin
      a_only_inds = [Index(2) for ii in 1:7]
      b_only_inds = [Index(2) for ii in 1:7]
      shared_inds = [Index(2) for ii in 1:7]
      A = randomITensor(IndexSet(vcat(a_only_inds, shared_inds)))
      B = randomITensor(IndexSet(vcat(b_only_inds, shared_inds)))
      cA = cuITensor(A)
      cB = cuITensor(B)
      inds_a = vcat(a_only_inds, shared_inds)
      inds_b = vcat(b_only_inds, shared_inds)
      cA_ = permute(cA, inds_a...)
      cB_ = permute(cB, inds_b...)
      @disable_warn_order begin
        C = cA_ * cB_
        Ccpu = cpu(cA_) * cpu(cB_)
      end
      @test Ccpu ≈ cpu(C)
      for shuffles in 1:1 # too many permutations to test all
        inds_a = shuffle(vcat(a_only_inds, shared_inds))
        inds_b = shuffle(vcat(b_only_inds, shared_inds))
        cA_ = permute(cA, inds_a...)
        cB_ = permute(cB, inds_b...)
        @disable_warn_order begin
          C = cA_ * cB_
          Ccpu = cpu(cA_) * cpu(cB_)
        end
        @test Ccpu ≈ cpu(C)
      end
    end
  end # End contraction testset
end


text:
module runtestsWithModiaAndModia3D

import Modia
import Modia3D
import ModiaMath

# Desired:
#   using Test
#
# In order that Test need not to be defined in the user environment, it is included via ModiaMath:
using ModiaMath.Test

@testset "Test Modia and Modia3D" begin
    include("$(Modia.ModiaDir)/test/runtests.jl")
    include("$(Modia3D.path)/test/runtests.jl")

    println("\n... close all open figures.")
    ModiaMath.closeAllFigures()
end

end

ext: jl


text:
using Test

using MathOptInterface
const MOI = MathOptInterface
const MOIT = MOI.DeprecatedTest
const MOIU = MOI.Utilities
const MOIB = MOI.Bridges

using NLopt
const solver = MOI.OptimizerWithAttributes(NLopt.Optimizer, "algorithm" => :LD_SLSQP)

optimizer = MOI.instantiate(solver)

const config = MOIT.Config(atol=1e-2, rtol=1e-2, duals=false,
                               optimal_status=MOI.LOCALLY_SOLVED)

@testset "SolverName" begin
    @test MOI.get(optimizer, MOI.SolverName()) == "NLopt"
end

@testset "supports_default_copy_to" begin
    @test MOI.supports_incremental_interface(optimizer)
end

function test_nlp(solver)
    optimizer = MOI.instantiate(solver)
    MOIT.nlptest(optimizer, config)
end
@testset "Non-Linear tests" begin
    test_nlp(solver)
    test_nlp(MOI.OptimizerWithAttributes(
        NLopt.Optimizer,
        "algorithm" => :AUGLAG,
        "local_optimizer" => :LD_LBFGS,
    ))
    # NLP tests have different number of variables so we
    # cannot run through them all with the same `local_optimizer`.
    # Let's just do hs071.
    local_optimizer = Opt(:LD_LBFGS, 4)
    MOIT.hs071_test(MOI.instantiate(MOI.OptimizerWithAttributes(
        NLopt.Optimizer,
        "algorithm" => :AUGLAG,
        "local_optimizer" => local_optimizer,
    )), config)
end

@testset "Testing getters" begin
    MOIT.copytest(MOI.instantiate(solver, with_bridge_type=Float64), MOIU.Model{Float64}())
end

@testset "Bounds set twice" begin
    MOIT.set_lower_bound_twice(optimizer, Float64)
    MOIT.set_upper_bound_twice(optimizer, Float64)
end

MOI.empty!(optimizer)
bridged = MOIB.full_bridge_optimizer(MOIU.CachingOptimizer(MOIU.UniversalFallback(MOIU.Model{Float64}()), optimizer), Float64)

@testset "Continuous Linear tests" begin
    exclude = [
        # Infeasibility and unboundedness not detected by NLopt
        "linear8a", "linear8b", "linear8c", "linear12",
        # Terminates with `:ROUNDOFF_LIMITED` due to the bad scaling of input problem
        "linear9",
        # FIXME invalid NLopt arguments: too many equality constraints
        "linear15",
    ]
    if Sys.WORD_SIZE == 32
        # FIXME
        #  Expression: MOI.get(model, MOI.TerminationStatus()) == config.optimal_status
        #  Evaluated: MathOptInterface.OTHER_ERROR == MathOptInterface.LOCALLY_SOLVED
        #  Expression: MOI.get(model, MOI.PrimalStatus()) == MOI.FEASIBLE_POINT
        #  Evaluated: MathOptInterface.UNKNOWN_RESULT_STATUS == MathOptInterface.FEASIBLE_POINT
        push!(exclude, "linear1")
    end
    MOIT.contlineartest(bridged, config, exclude)
end

@testset "Continuous Quadratic tests" begin
    MOIT.qptest(bridged, config)
end

MOIB.add_bridge(bridged, MOIB.Constraint.SOCtoNonConvexQuadBridge{Float64})

@testset "Continuous Conic tests" begin
    MOIT.lintest(bridged, config, [
        # Infeasibility and unboundedness not detected by NLopt
        "lin3", "lin4"
    ])
    MOIT.soctest(bridged, config, [
        # Infeasibility and unboundedness not detected by NLopt
        "soc3"
    ])
    MOIT.rsoctest(bridged, config, [
        # Infeasibility and unboundedness not detected by NLopt
        "rotatedsoc2",
        # FIXME invalid NLopt arguments: bounds 4 fail 1 <= 0 <= 1
        "rotatedsoc3",
    ])
    MOIT.geomeantest(bridged, config, [
        # FIXME Status is ok but solution is not, e.g.
        #   Expression: ≈(MOI.get(model, MOI.ObjectiveValue()), 1.0, atol = atol, rtol = rtol)
        #   Evaluated: 0.006271435980170771 ≈ 1.0 (atol=0.01, rtol=0.01)
        "geomean2v", "geomean2f",
        # FIXME Status is ok but solution is not, e.g.
        #   Expression: ≈(MOI.get(model, MOI.ObjectiveValue()), 1, atol = atol, rtol = rtol)
        #   Evaluated: 0.0881801049773095 ≈ 1 (atol=0.01, rtol=0.01)
        "geomean1v", "geomean1f",
    ])
    MOIT.norminftest(bridged, config, [
        # Infeasibility and unboundedness not detected by NLopt
        "norminf2",
    ])
    MOIT.normonetest(bridged, config, [
        # Infeasibility and unboundedness not detected by NLopt
        "normone2",
    ])
end

@testset "Unit" begin
    exclude = [
        # Integer variables not supported
        "solve_zero_one_with_bounds_1",
        "solve_zero_one_with_bounds_2",
        "solve_zero_one_with_bounds_3",
        "solve_integer_edge_cases",
        # ObjectiveBound not supported.
        "solve_objbound_edge_cases",
        # NumberOfThreads not supported
        "number_threads",
        # Infeasibility and unboundedness not detected by NLopt
        "solve_unbounded_model",
        "solve_farkas_interval_lower",
        "solve_farkas_lessthan",
        "solve_farkas_equalto_lower",
        "solve_farkas_equalto_upper",
        "solve_farkas_variable_lessthan",
        "solve_farkas_variable_lessthan_max",
        "solve_farkas_greaterthan",
        "solve_farkas_interval_upper",
        "solve_farkas_lessthan",
    ]
    if Sys.WORD_SIZE == 32
        # FIXME
        #  Expression: MOI.get(model, MOI.TerminationStatus()) == config.optimal_status
        #  Evaluated: MathOptInterface.OTHER_ERROR == MathOptInterface.LOCALLY_SOLVED
        #  Expression: MOI.get(model, MOI.PrimalStatus()) == MOI.FEASIBLE_POINT
        #  Evaluated: MathOptInterface.UNKNOWN_RESULT_STATUS == MathOptInterface.FEASIBLE_POINT
        push!(exclude, "solve_qcp_edge_cases")
    end
    MOIT.unittest(bridged, config, exclude)
end


text:
struct Dependency
    package::Symbol
    precompile_file::Union{String,Nothing}
end

struct SysImageConfig
    name::String
    dependencies::Vector{Dependency}
end


text:
using TensorFlow
using Images

data_set_folder = "/raided/datasets/sketches_png/png/"
files_in_folder = readdir(data_set_folder)
labels = filter(x->isdir(data_set_folder * x) == true, files_in_folder)

function sketch_input(path, sketch_name)
    x = zeros(Float32, 1, 77841)
    y = zeros(Float32, 1, 250)
    img = load(path)
    img = restrict(restrict(img))
    flatten_img = reshape(img, 77841)
    x[1, :] = flatten_img

    label = find((x -> x == sketch_name), labels)[1]
    y[1, label] = 1.0

    x, y
end

function classify_sketch(sketch_path, sketch_label)
    x = TensorFlow.placeholder(Float32)
    y_ = TensorFlow.placeholder(Float32)
    W = get_variable("weights", [77841, 250], Float32)
    b = get_variable("bias", [250], Float32)

    y = nn.softmax(x*W + b)
    cross_entropy = reduce_mean(-reduce_sum(y_ .* log(y), reduction_indices=[2]))
    train_step = train.minimize(train.GradientDescentOptimizer(.00001), cross_entropy)

    saver = train.Saver()
    gpu_options = TensorFlow.tensorflow.GPUOptions(allow_growth=true, per_process_gpu_memory_fraction=0.4)
    config = TensorFlow.tensorflow.ConfigProto(gpu_options=gpu_options)
    sess = Session(config=config)

    train.restore(saver, sess, "models/4percAcc-allCats")

    test_img, test_label = sketch_input(sketch_path, sketch_label)
    labels[run(sess, indmax(y,2), Dict(x=>test_img, y_=>test_label))[1] + 1]
end

print(classify_sketch(ARGS[1], ARGS[2]))


text:
using ITensors

function ising(n; h)
  H = OpSum()
  for j in 1:(n - 1)
    H -= "Z", j, "Z", j + 1
  end
  for j in 1:n
    H += h, "X", j
  end
  return H
end


text:
abstract type AbstractProperties end

mutable struct Properties{T<:Any}<: AbstractProperties
    name::String
    value::T

    Properties() = new{Float64}(" ", 0.0)
    Properties(name::String) = new{Float64}(name, 0.0)
    function Properties{U}(name::String, val::U) where U<:Any
        new{U}(name, val)
    end
end

mutable struct Energy <: AbstractProperties
    name::String
    value::Float64

    Energy() = new("energy", 0.0)
    Energy(val::Float64) = new("energy", val)
    Energy(val::Real) = Energy(Float64(val))
end

function Base.eltype(prop::AbstractProperties)
    return typeof(prop.value)
end

function (prop::AbstractProperties)()
    return prop.value
end

function (prop::AbstractProperties)(val)
    if typeof(val) != eltype(prop)
        throw(ArgumentError("Wrong type for functor."))
    else
        prop.value = val
    end
end

function Base.show(io::IO, prop::AbstractProperties)
    print(io, prop.name, "=", prop.value)
end

mutable struct Atoms
    atom::Array{AbstractAtom, 1}
    number::Int64
    properties::Array{AbstractProperties, 1}

    Atoms() = new(Array{Atom, 1}(undef, 0), 0, Array{Properties, 1}(undef, 0))
    function Atoms(atom::Array{T1, 1}, num::Int64, prop::Array{T2, 1}) where T1<:AbstractAtom where T2<:AbstractProperties
        if num == length(atom)
            new(atom, num, prop)
        else
            throw(BoundsError(atom, num))
        end
    end

    function Atoms(atom::Array{T1, 1}, prop::Array{T2, 1}) where T1<:AbstractAtom where T2<:AbstractProperties
        Atoms(atom, length(atom), prop)
    end

    function Atoms(atom::Array{T, 1}) where T<:AbstractAtom
        Atoms(atom, length(atom), Array{Properties, 1}(undef, 0))
    end

    function Atoms(atom::T1, prop::Array{T2, 1}) where T1<:AbstractAtom where T2<:AbstractProperties
        Atoms([atom, ], 1, prop)
    end

    function Atoms(atom::AbstractAtom)
        Atoms([atom, ], 1, Array{Properties, 1}(undef, 0))
    end

    function Atoms(atom::Array{T, 1}, num::Int64, prop::AbstractProperties) where T<:AbstractAtom
        if num == length(atom)
            new(atom, num, [prop, ])
        else
            throw(BoundsError(atom, num))
        end
    end

    function Atoms(atom::Array{T, 1}, prop::AbstractProperties) where T<:AbstractAtom
        Atoms(atom, length(atom), [prop, ])
    end

    function Atoms(atom::AbstractAtom, prop::AbstractProperties)
        Atoms([atom, ], 1, [prop, ])
    end
end

# add new atom
function addAtom!(atoms::Atoms, atom::AbstractAtom)
    push!(atoms.atom, atom)
    atoms.number += 1
end

# add new property
function addProperty!(atoms::Atoms, prop::AbstractProperties)
    push!(atoms.properties, prop)
end

function Base.iterate(atoms::Atoms, state=1)
    state > atoms.number ? nothing : (atoms.atom[state], state+1)
end

function Base.length(atoms::Atoms)
    atoms.number
end

function Base.getindex(atoms::Atoms, i::Int)
    1 <= i <= atoms.number || throw(BoundsError(atoms, i))
    return atoms.atom[i]
end

Base.firstindex(atoms::Atoms) = 1
Base.lastindex(atoms::Atoms) = length(atoms)
Base.getindex(atoms::Atoms, i::Number) = atoms[convert(Int, i)]
Base.getindex(atoms::Atoms, I) = [atoms[i] for i in I]

function Base.show(io::IO, atoms::Atoms)
    println(io, atoms.number)
    for prop in atoms.properties
        print(io, prop, " ")
    end
    print(io, "\n")
    for atom in atoms
        println(io, atom)
    end
end


text:
export viewOrthoSlices2D

"""
	function jInv.Vis.viewOrthoSlices2D

	visualizes 3D image by orthogonal slices

	Input:

		I    - image
		Mesh - tensor mesh describing image domain

	Optional Input:

		slices    - vector describing which slices to show, default: Mesh.n/2
		axis      - show axis label (useful to clarify how image is presented)
		linewidth - width of dividing lines
		color     - color of dividing lines
		cmap      - colormap
		vmin/vmax - specify intensity range
"""
function viewOrthoSlices2D(I,Mesh::AbstractTensorMesh;slices=Int.(round.(Mesh.n/2)),axis=false,linewidth=2,color="w",cmap="jet",vmin=minimum(I),vmax=maximum(I))

    #  create big image
    I   = reshape(I,tuple(Mesh.n...));
    Ixz = I[:,slices[2],:];   # xz view
    Iyz = I[slices[1],:,:]; # yz view
    Ixy = I[:,:,slices[3]]; # xy view

    Ibl = reverse(Ixy,dims=2)
    Ibr = reverse(Iyz,dims=1)'
    Itl = reverse(Ixz,dims=2)
    Itr = fill(0,Mesh.n[3],Mesh.n[3])
    I   = [Itl Ibl; Itr Ibr]

    # put together x and y axis of plot
    x,y,z = getNodalAxes(Mesh)
    xa = [vec(x);z[2:end].+maximum(x)]
    ya = [vec(y);z[2:end].+maximum(y)]

    domain = [x[1] x[end] y[1] y[end] z[1] z[end]]
    # plot image
    pcolormesh(xa,ya,reverse(I',dims=1),cmap=cmap,vmin=vmin,vmax=vmax)

    # add labels to clarify axis
    axis && xlabel("|-- x -- | -- z -- |")
    axis && ylabel("|-- y -- | -- z -- |")

    #     draw lines
	xc = .5*(x[slices[1]] + x[slices[1]+1])
	yc = .5*(y[slices[2]] + y[slices[2]+1])
	zc = .5*(z[slices[3]] + z[slices[3]+1])
    plot([0;maximum(xa)],[domain[4];domain[4]],linewidth=linewidth,color=color)
    plot([domain[2]; domain[2]],[0;maximum(ya)],linewidth=linewidth,color=color)
    plot([0;maximum(xa)],[yc;yc],"--",linewidth=linewidth,color=color)
 plot([0;maximum(x)],[zc;zc].+domain[4],"--",linewidth=linewidth,color=color);
  plot([xc;xc],[0;maximum(ya)],"--",linewidth=linewidth,color=color);	    plot([zc;zc].+domain[2],[0;maximum(y)],"--",linewidth=linewidth,color=color);

end


text:
#!/usr/bin/env julia

function login()
    print("Login: ")
    user = readline(stdin)

    print("Password: ")
    password = readline(stdin)

    if user == "Jeff"
        if password == "secret"
            println("Correct! You are now logged in")
        else
            println("Wrong password")
        end
    elseif user == "Alex"
        if password == "123many"
            println("Correct! You are now logged in")
        else
            println("Wrong password")
        end
    else
        println("There is no login account with name $user")
    end
end

login()


text:
module Atmos

export AtmosModel,
    AtmosAcousticLinearModel, AtmosAcousticGravityLinearModel, RemainderModel

using CLIMAParameters
using CLIMAParameters.Planet: grav, cp_d
using CLIMAParameters.Atmos.SubgridScale: C_smag
using LinearAlgebra, StaticArrays
using ..ConfigTypes
using ..VariableTemplates
using ..MoistThermodynamics
import ..MoistThermodynamics: internal_energy
using ..MPIStateArrays: MPIStateArray
using ..Mesh.Grids:
    VerticalDirection, HorizontalDirection, min_node_distance, EveryDirection

import CLIMA.DGmethods:
    BalanceLaw,
    vars_aux,
    vars_state,
    vars_gradient,
    vars_gradient_laplacian,
    vars_diffusive,
    vars_hyperdiffusive,
    flux_nondiffusive!,
    flux_diffusive!,
    source!,
    wavespeed,
    boundary_state!,
    gradvariables!,
    diffusive!,
    hyperdiffusive!,
    init_aux!,
    init_state!,
    update_aux!,
    LocalGeometry,
    lengthscale,
    resolutionmetric,
    DGModel,
    nodal_update_aux!,
    num_state,
    num_integrals,
    vars_integrals,
    vars_reverse_integrals,
    indefinite_stack_integral!,
    reverse_indefinite_stack_integral!,
    integral_load_aux!,
    integral_set_aux!,
    reverse_integral_load_aux!,
    reverse_integral_set_aux!
import ..DGmethods.NumericalFluxes:
    boundary_state!,
    boundary_flux_diffusive!,
    normal_boundary_flux_diffusive!,
    NumericalFluxNonDiffusive,
    NumericalFluxGradient,
    NumericalFluxDiffusive,
    CentralHyperDiffusiveFlux,
    CentralDivPenalty

import ..Courant: advective_courant, nondiffusive_courant, diffusive_courant

"""
    AtmosModel <: BalanceLaw

A `BalanceLaw` for atmosphere modeling.

# Usage

    AtmosModel(orientation, ref_state, turbulence, hyperdiffusion, moisture, radiation, source,
               boundarycondition, init_state)

"""
struct AtmosModel{FT, PS, O, RS, T, HD, M, P, R, S, BC, IS, DC} <: BalanceLaw
    param_set::PS
    orientation::O
    ref_state::RS
    turbulence::T
    hyperdiffusion::HD
    moisture::M
    precipitation::P
    radiation::R
    source::S
    # TODO: Probably want to have different bc for state and diffusion...
    boundarycondition::BC
    init_state::IS
    data_config::DC
end

function AtmosModel{FT}(
    ::Type{AtmosLESConfigType},
    param_set::AbstractParameterSet;
    orientation::O = FlatOrientation(),
    ref_state::RS = HydrostaticState(
        LinearTemperatureProfile(
            FT(200),
            FT(280),
            FT(grav(param_set)) / FT(cp_d(param_set)),
        ),
        FT(0),
    ),
    turbulence::T = SmagorinskyLilly{FT}(0.21),
    hyperdiffusion::HD = NoHyperDiffusion(),
    moisture::M = EquilMoist{FT}(),
    precipitation::P = NoPrecipitation(),
    radiation::R = NoRadiation(),
    source::S = (Gravity(), Coriolis(), GeostrophicForcing{FT}(7.62e-5, 0, 0)),
    # TODO: Probably want to have different bc for state and diffusion...
    boundarycondition::BC = AtmosBC(),
    init_state::IS = nothing,
    data_config::DC = nothing,
) where {FT <: AbstractFloat, O, RS, T, HD, M, P, R, S, BC, IS, DC}
    @assert init_state ≠ nothing

    atmos = (
        param_set,
        orientation,
        ref_state,
        turbulence,
        hyperdiffusion,
        moisture,
        precipitation,
        radiation,
        source,
        boundarycondition,
        init_state,
        data_config,
    )

    return AtmosModel{FT, typeof.(atmos)...}(atmos...)
end
function AtmosModel{FT}(
    ::Type{AtmosGCMConfigType},
    param_set::AbstractParameterSet;
    orientation::O = SphericalOrientation(),
    ref_state::RS = HydrostaticState(
        LinearTemperatureProfile(
            FT(200),
            FT(280),
            FT(grav(param_set)) / FT(cp_d(param_set)),
        ),
        FT(0),
    ),
    turbulence::T = SmagorinskyLilly{FT}(C_smag(param_set)),
    hyperdiffusion::HD = NoHyperDiffusion(),
    moisture::M = EquilMoist{FT}(),
    precipitation::P = NoPrecipitation(),
    radiation::R = NoRadiation(),
    source::S = (Gravity(), Coriolis()),
    boundarycondition::BC = AtmosBC(),
    init_state::IS = nothing,
    data_config::DC = nothing,
) where {FT <: AbstractFloat, O, RS, T, HD, M, P, R, S, BC, IS, DC}
    @assert init_state ≠ nothing
    atmos = (
        param_set,
        orientation,
        ref_state,
        turbulence,
        hyperdiffusion,
        moisture,
        precipitation,
        radiation,
        source,
        boundarycondition,
        init_state,
        data_config,
    )

    return AtmosModel{FT, typeof.(atmos)...}(atmos...)
end

function vars_state(m::AtmosModel, FT)
    @vars begin
        ρ::FT
        ρu::SVector{3, FT}
        ρe::FT
        turbulence::vars_state(m.turbulence, FT)
        hyperdiffusion::vars_state(m.hyperdiffusion, FT)
        moisture::vars_state(m.moisture, FT)
        radiation::vars_state(m.radiation, FT)
    end
end
function vars_gradient(m::AtmosModel, FT)
    @vars begin
        u::SVector{3, FT}
        h_tot::FT
        turbulence::vars_gradient(m.turbulence, FT)
        hyperdiffusion::vars_gradient(m.hyperdiffusion, FT)
        moisture::vars_gradient(m.moisture, FT)
    end
end
function vars_diffusive(m::AtmosModel, FT)
    @vars begin
        ∇h_tot::SVector{3, FT}
        turbulence::vars_diffusive(m.turbulence, FT)
        hyperdiffusion::vars_diffusive(m.hyperdiffusion, FT)
        moisture::vars_diffusive(m.moisture, FT)
    end
end
function vars_gradient_laplacian(m::AtmosModel, FT)
    @vars begin
        hyperdiffusion::vars_gradient_laplacian(m.hyperdiffusion, FT)
    end
end
function vars_hyperdiffusive(m::AtmosModel, FT)
    @vars begin
        hyperdiffusion::vars_hyperdiffusive(m.hyperdiffusion, FT)
    end
end
function vars_aux(m::AtmosModel, FT)
    @vars begin
        ∫dz::vars_integrals(m, FT)
        ∫dnz::vars_reverse_integrals(m, FT)
        coord::SVector{3, FT}
        orientation::vars_aux(m.orientation, FT)
        ref_state::vars_aux(m.ref_state, FT)
        turbulence::vars_aux(m.turbulence, FT)
        hyperdiffusion::vars_aux(m.hyperdiffusion, FT)
        moisture::vars_aux(m.moisture, FT)
        radiation::vars_aux(m.radiation, FT)
    end
end
function vars_integrals(m::AtmosModel, FT)
    @vars begin
        radiation::vars_integrals(m.radiation, FT)
    end
end
function vars_reverse_integrals(m::AtmosModel, FT)
    @vars begin
        radiation::vars_reverse_integrals(m.radiation, FT)
    end
end

include("orientation.jl")
include("ref_state.jl")
include("turbulence.jl")
include("hyperdiffusion.jl")
include("moisture.jl")
include("precipitation.jl")
include("radiation.jl")
include("source.jl")
include("boundaryconditions.jl")
include("linear.jl")
include("remainder.jl")
include("courant.jl")

"""
    flux_nondiffusive!(m::AtmosModel, flux::Grad, state::Vars, aux::Vars,
                       t::Real)

Computes flux non-diffusive flux portion of `F` in:

```
∂Y
-- = - ∇ • (F_{adv} + F_{press} + F_{nondiff} + F_{diff}) + S(Y)
∂t
```
Where

 - `F_{adv}`      Advective flux             ; see [`flux_advective!`]@ref()
 - `F_{press}`    Pressure flux              ; see [`flux_pressure!`]@ref()
 - `F_{diff}`     Fluxes that state gradients; see [`flux_diffusive!`]@ref()
"""
@inline function flux_nondiffusive!(
    m::AtmosModel,
    flux::Grad,
    state::Vars,
    aux::Vars,
    t::Real,
)
    ρ = state.ρ
    ρinv = 1 / ρ
    ρu = state.ρu
    u = ρinv * ρu

    # advective terms
    flux.ρ = ρ * u
    flux.ρu = ρ * u .* u'
    flux.ρe = u * state.ρe

    # pressure terms
    p = pressure(m, m.moisture, state, aux)
    if m.ref_state isa HydrostaticState
        flux.ρu += (p - aux.ref_state.p) * I
    else
        flux.ρu += p * I
    end
    flux.ρe += u * p
    flux_radiation!(m.radiation, m, flux, state, aux, t)
    flux_moisture!(m.moisture, m, flux, state, aux, t)
end

function gradvariables!(
    atmos::AtmosModel,
    transform::Vars,
    state::Vars,
    aux::Vars,
    t::Real,
)
    ρinv = 1 / state.ρ
    transform.u = ρinv * state.ρu
    transform.h_tot = total_specific_enthalpy(atmos, atmos.moisture, state, aux)

    gradvariables!(atmos.moisture, transform, state, aux, t)
    gradvariables!(atmos.turbulence, transform, state, aux, t)
    gradvariables!(atmos.hyperdiffusion, transform, state, aux, t)
end

function diffusive!(
    atmos::AtmosModel,
    diffusive::Vars,
    ∇transform::Grad,
    state::Vars,
    aux::Vars,
    t::Real,
)
    diffusive.∇h_tot = ∇transform.h_tot

    # diffusion terms required for SGS turbulence computations
    diffusive!(
        atmos.turbulence,
        atmos.orientation,
        diffusive,
        ∇transform,
        state,
        aux,
        t,
    )
    # diffusivity of moisture components
    diffusive!(atmos.moisture, diffusive, ∇transform, state, aux, t)
end

function hyperdiffusive!(
    atmos::AtmosModel,
    hyperdiffusive::Vars,
    hypertransform::Grad,
    state::Vars,
    aux::Vars,
    t::Real,
)
    hyperdiffusive!(
        atmos.hyperdiffusion,
        hyperdiffusive,
        hypertransform,
        state,
        aux,
        t,
    )
end

@inline function flux_diffusive!(
    atmos::AtmosModel,
    flux::Grad,
    state::Vars,
    diffusive::Vars,
    hyperdiffusive::Vars,
    aux::Vars,
    t::Real,
)
    ν, D_t, τ = turbulence_tensors(atmos, state, diffusive, aux, t)
    d_h_tot = -D_t .* diffusive.∇h_tot
    flux_diffusive!(atmos, flux, state, τ, d_h_tot)
    flux_diffusive!(atmos.moisture, flux, state, diffusive, aux, t, D_t)
    flux_diffusive!(
        atmos.hyperdiffusion,
        flux,
        state,
        diffusive,
        hyperdiffusive,
        aux,
        t,
    )
end

#TODO: Consider whether to not pass ρ and ρu (not state), foc BCs reasons
@inline function flux_diffusive!(
    atmos::AtmosModel,
    flux::Grad,
    state::Vars,
    τ,
    d_h_tot,
)
    flux.ρu += τ * state.ρ
    flux.ρe += τ * state.ρu
    flux.ρe += d_h_tot * state.ρ
end

@inline function wavespeed(m::AtmosModel, nM, state::Vars, aux::Vars, t::Real)
    ρinv = 1 / state.ρ
    u = ρinv * state.ρu
    return abs(dot(nM, u)) + soundspeed(m, m.moisture, state, aux)
end

function update_aux!(
    dg::DGModel,
    m::AtmosModel,
    Q::MPIStateArray,
    t::Real,
    elems::UnitRange,
)
    FT = eltype(Q)
    auxstate = dg.auxstate

    if num_integrals(m, FT) > 0
        indefinite_stack_integral!(dg, m, Q, auxstate, t, elems)
        reverse_indefinite_stack_integral!(dg, m, Q, auxstate, t, elems)
    end

    nodal_update_aux!(atmos_nodal_update_aux!, dg, m, Q, t, elems)

    return true
end

function atmos_nodal_update_aux!(m::AtmosModel, state::Vars, aux::Vars, t::Real)
    atmos_nodal_update_aux!(m.moisture, m, state, aux, t)
    atmos_nodal_update_aux!(m.radiation, m, state, aux, t)
    atmos_nodal_update_aux!(m.turbulence, m, state, aux, t)
end

function integral_load_aux!(m::AtmosModel, integ::Vars, state::Vars, aux::Vars)
    integral_load_aux!(m.radiation, integ, state, aux)
end

function integral_set_aux!(m::AtmosModel, aux::Vars, integ::Vars)
    integral_set_aux!(m.radiation, aux, integ)
end

function reverse_integral_load_aux!(
    m::AtmosModel,
    integ::Vars,
    state::Vars,
    aux::Vars,
)
    reverse_integral_load_aux!(m.radiation, integ, state, aux)
end

function reverse_integral_set_aux!(m::AtmosModel, aux::Vars, integ::Vars)
    reverse_integral_set_aux!(m.radiation, aux, integ)
end

# TODO: figure out a nice way to handle this
function init_aux!(m::AtmosModel, aux::Vars, geom::LocalGeometry)
    aux.coord = geom.coord
    atmos_init_aux!(m.orientation, m, aux, geom)
    atmos_init_aux!(m.ref_state, m, aux, geom)
    atmos_init_aux!(m.turbulence, m, aux, geom)
    atmos_init_aux!(m.hyperdiffusion, m, aux, geom)
end

"""
    source!(m::AtmosModel, source::Vars, state::Vars, diffusive::Vars,
            aux::Vars, t::Real, direction::Direction)
Computes flux `S(Y)` in:
```
∂Y
-- = - ∇ • F + S(Y)
∂t
```
"""
function source!(
    m::AtmosModel,
    source::Vars,
    state::Vars,
    diffusive::Vars,
    aux::Vars,
    t::Real,
    direction,
)
    atmos_source!(m.source, m, source, state, diffusive, aux, t, direction)
end

function init_state!(m::AtmosModel, state::Vars, aux::Vars, coords, t, args...)
    m.init_state(m, state, aux, coords, t, args...)
end
end # module

max_stars_repo_name: yairchn/CLIMA

max_issues_repo_name: yairchn/CLIMA

max_forks_repo_name: yairchn/CLIMA


text:
# # Utilities

const AVec = AbstractVector
const AMat = AbstractMatrix
const KW = Dict{Symbol, Any}
const AKW = AbstractDict{Symbol, Any}

# --------------------------------
# ## DefaultsDict
# --------------------------------

struct DefaultsDict <: AbstractDict{Symbol, Any}
    explicit::KW
    defaults::KW
end

function Base.getindex(dd::DefaultsDict, k)
    return haskey(dd.explicit, k) ? dd.explicit[k] : dd.defaults[k]
end
Base.haskey(dd::DefaultsDict, k) = haskey(dd.explicit, k) || haskey(dd.defaults, k)
Base.get(dd::DefaultsDict, k, default) = haskey(dd, k) ? dd[k] : default
function Base.get!(dd::DefaultsDict, k, default)
    v = if haskey(dd, k)
        dd[k]
    else
        dd.defaults[k] = default
    end
    return v
end
function Base.delete!(dd::DefaultsDict, k)
    haskey(dd.explicit, k) && delete!(dd.explicit, k)
    haskey(dd.defaults, k) && delete!(dd.defaults, k)
end
Base.length(dd::DefaultsDict) = length(union(keys(dd.explicit), keys(dd.defaults)))
function Base.iterate(dd::DefaultsDict)
    exp_keys = keys(dd.explicit)
    def_keys = setdiff(keys(dd.defaults), exp_keys)
    key_list = collect(Iterators.flatten((exp_keys, def_keys)))
    iterate(dd, (key_list, 1))
end
function Base.iterate(dd::DefaultsDict, (key_list, i))
    i > length(key_list) && return nothing
    k = key_list[i]
    (k => dd[k], (key_list, i + 1))
end

Base.copy(dd::DefaultsDict) = DefaultsDict(copy(dd.explicit), dd.defaults)

RecipesBase.is_explicit(dd::DefaultsDict, k) = haskey(dd.explicit, k)
isdefault(dd::DefaultsDict, k) = !is_explicit(dd, k) && haskey(dd.defaults, k)

Base.setindex!(dd::DefaultsDict, v, k) = dd.explicit[k] = v

# Reset to default value and return dict
reset_kw!(dd::DefaultsDict, k) = is_explicit(dd, k) ? delete!(dd.explicit, k) : dd
# Reset to default value and return old value
pop_kw!(dd::DefaultsDict, k) = is_explicit(dd, k) ? pop!(dd.explicit, k) : dd.defaults[k]
pop_kw!(dd::DefaultsDict, k, default) =
    is_explicit(dd, k) ? pop!(dd.explicit, k) : get(dd.defaults, k, default)
# Fallbacks for dicts without defaults
reset_kw!(d::AKW, k) = delete!(d, k)
pop_kw!(d::AKW, k) = pop!(d, k)
pop_kw!(d::AKW, k, default) = pop!(d, k, default)

# --------------------------------
# ## 3D types
# --------------------------------

abstract type AbstractSurface end

"represents a contour or surface mesh"
struct Surface{M <: AMat} <: AbstractSurface
    surf::M
end

Surface(f::Function, x, y) = Surface(Float64[f(xi, yi) for yi in y, xi in x])

Base.Array(surf::Surface) = surf.surf

for f in (:length, :size, :axes, :iterate)
    @eval Base.$f(surf::Surface, args...) = $f(surf.surf, args...)
end
Base.copy(surf::Surface) = Surface(copy(surf.surf))
Base.eltype(surf::Surface{T}) where {T} = eltype(T)

struct Volume{T}
    v::Array{T, 3}
    x_extents::Tuple{T, T}
    y_extents::Tuple{T, T}
    z_extents::Tuple{T, T}
end

default_extents(::Type{T}) where {T} = (zero(T), one(T))

function Volume(
    v::Array{T, 3},
    x_extents = default_extents(T),
    y_extents = default_extents(T),
    z_extents = default_extents(T),
) where {T}
    Volume(v, x_extents, y_extents, z_extents)
end

Base.Array(vol::Volume) = vol.v
for f in (:length, :size, :axes, :iterate)
    @eval Base.$f(vol::Volume, args...) = $f(vol.v, args...)
end
Base.copy(vol::Volume{T}) where {T} =
    Volume{T}(copy(vol.v), vol.x_extents, vol.y_extents, vol.z_extents)
Base.eltype(vol::Volume{T}) where {T} = T

# --------------------------------
# ## Formatting
# --------------------------------

"Represents data values with formatting that should apply to the tick labels."
struct Formatted{T}
    data::T
    formatter::Function
end

# -------------------------------
# ## 3D seriestypes
# -------------------------------

# TODO: Move to RecipesBase?
"""
    is3d(::Type{Val{:myseriestype}})

Returns `true` if `myseriestype` represents a 3D series, `false` otherwise.
"""
is3d(st) = false
for st in (
    :contour,
    :contourf,
    :contour3d,
    :heatmap,
    :image,
    :path3d,
    :scatter3d,
    :surface,
    :volume,
    :wireframe,
    :mesh3d
)
    @eval is3d(::Type{Val{Symbol($(string(st)))}}) = true
end
is3d(st::Symbol) = is3d(Val{st})
is3d(plt, stv::AbstractArray) = all(st -> is3d(plt, st), stv)
is3d(plotattributes::AbstractDict) = is3d(get(plotattributes, :seriestype, :path))

"""
    is_surface(::Type{Val{:myseriestype}})

Returns `true` if `myseriestype` represents a surface series, `false` otherwise.
"""
is_surface(st) = false
for st in (:contour, :contourf, :contour3d, :image, :heatmap, :surface, :wireframe)
    @eval is_surface(::Type{Val{Symbol($(string(st)))}}) = true
end
is_surface(st::Symbol) = is_surface(Val{st})
is_surface(plt, stv::AbstractArray) = all(st -> is_surface(plt, st), stv)
is_surface(plotattributes::AbstractDict) =
    is_surface(get(plotattributes, :seriestype, :path))

"""
    needs_3d_axes(::Type{Val{:myseriestype}})

Returns `true` if `myseriestype` needs 3d axes, `false` otherwise.
"""
needs_3d_axes(st) = false
for st in (
    :contour3d,
    :path3d,
    :scatter3d,
    :surface,
    :volume,
    :wireframe,
    :mesh3d
)
    @eval needs_3d_axes(::Type{Val{Symbol($(string(st)))}}) = true
end
needs_3d_axes(st::Symbol) = needs_3d_axes(Val{st})
needs_3d_axes(plt, stv::AbstractArray) = all(st -> needs_3d_axes(plt, st), stv)
needs_3d_axes(plotattributes::AbstractDict) =
    needs_3d_axes(get(plotattributes, :seriestype, :path))

# --------------------------------
# ## Scales
# --------------------------------

const SCALE_FUNCTIONS = Dict{Symbol, Function}(:log10 => NaNMath.log10, :log2 => NaNMath.log2, :ln => NaNMath.log)
const INVERSE_SCALE_FUNCTIONS =
    Dict{Symbol, Function}(:log10 => exp10, :log2 => exp2, :ln => exp)

scale_func(scale::Symbol) = x -> get(SCALE_FUNCTIONS, scale, identity)(Float64(x))
inverse_scale_func(scale::Symbol) =
    x -> get(INVERSE_SCALE_FUNCTIONS, scale, identity)(Float64(x))

# --------------------------------
# ## Unzip
# --------------------------------

unzip(v::AVec{<:Tuple}) = tuple((([t[j] for t in v]) for j in 1:length(v[1]))...)

# --------------------------------
# ## Map functions on vectors
# --------------------------------

_map_funcs(f::Function, u::AVec) = map(f, u)
_map_funcs(fs::AVec{F}, u::AVec) where {F <: Function} = [map(f, u) for f in fs]

# --------------------------------
# ## Signature strings
# --------------------------------

@nospecialize

function userrecipe_signature_string(args)
    return string("(::", join(string.(typeof.(args)), ", ::"), ")")
end
typerecipe_signature_string(::T) where T = "(::Type{$T}, ::$T)"
plotrecipe_signature_string(st) = "(::Type{Val{:$st}}, ::AbstractPlot)"
seriesrecipe_signature_string(st) = "(::Type{Val{:$st}}, x, y, z)"

@specialize


text:
using JuMP, EAGO

                     m = Model()

                     EAGO.register_eago_operators!(m)

                     @variable(m, -1 <= x[i=1:3] <= 1)

                     @variable(m, -0.27492067550218746 <= q <= 2.084201684402027)

                     add_NL_constraint(m, :((-0.0416569430659357 + 0.13675627334278007*(0.1752604319892206 + -0.8557289632032381*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.21149394336428795*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((0.1752604319892206 + -0.8557289632032381*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.21149394336428795*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 + 0.703085236566185*(-0.4914467550189556 + 0.5078124686195609*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.7523099505151869*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((-0.4914467550189556 + 0.5078124686195609*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.7523099505151869*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((-0.0416569430659357 + 0.13675627334278007*(0.1752604319892206 + -0.8557289632032381*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.21149394336428795*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((0.1752604319892206 + -0.8557289632032381*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.21149394336428795*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 + 0.703085236566185*(-0.4914467550189556 + 0.5078124686195609*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.7523099505151869*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((-0.4914467550189556 + 0.5078124686195609*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.7523099505151869*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 + (0.6991595157542867 + 0.5132010992296534*(0.1752604319892206 + -0.8557289632032381*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.21149394336428795*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((0.1752604319892206 + -0.8557289632032381*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.21149394336428795*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 + 0.6682334830395109*(-0.4914467550189556 + 0.5078124686195609*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.7523099505151869*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((-0.4914467550189556 + 0.5078124686195609*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.7523099505151869*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((0.6991595157542867 + 0.5132010992296534*(0.1752604319892206 + -0.8557289632032381*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.21149394336428795*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((0.1752604319892206 + -0.8557289632032381*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.21149394336428795*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 + 0.6682334830395109*(-0.4914467550189556 + 0.5078124686195609*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.7523099505151869*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((-0.4914467550189556 + 0.5078124686195609*(-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.028885055816546323 + 0.15091441453709065*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + -0.8760277243880852*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.7523099505151869*(-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)*(1 + erf((-0.29077418744555983 + -0.11119024401630329*(-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))*(1 + erf((-0.5352161553133312 + 0.05336126885466008*$(x[1]) + 0.7318437425770079*$(x[2]) + -0.7787417630340121*$(x[3]))/sqrt(2)))/2 + 0.4817613487326513*(0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))*(1 + erf((0.0006254708492061667 + 0.44360632638752495*$(x[1]) + -0.9819405794216607*$(x[2]) + 0.2295552892872319*$(x[3]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 - $q <= 0.0))

                     @objective(m, Min, q)

                     return m

max_stars_repo_name: PSORLab/RSActivationFunctions

max_issues_repo_name: PSORLab/RSActivationFunctions

max_forks_repo_name: PSORLab/RSActivationFunctions


text:
using Gtk
using Sockets
params = LakeShoreF71GaussMeterParams(comport="COM4", connectionMode=F71_CM_USB, measurementMode=F71_MM_DC)
gauss = LakeShoreF71GaussMeter(deviceID="lakeshoref71", params=params, dependencies=Dict{String, Union{Device, Missing}}())

if ask_dialog("You are trying to start the LakeShore F71 hardware test. Please ensure that the device is turned on and working.","Cancel","Start test")
	init(gauss)

	setMeasurementMode(gauss, F71_MM_AC)
	@test ask_dialog("Is the measurement mode set to AC?", "No", "Yes")

	setMeasurementMode(gauss, F71_MM_HIFR)
	@test ask_dialog("Is the measurement mode set to HIFR?", "No", "Yes")

	setMeasurementMode(gauss, F71_MM_DC)
	@test ask_dialog("Is the measurement mode set to DC?", "No", "Yes")

	info_dialog("Please position a magnet near the probe.")

	currentValue = uparse(input_dialog("Please enter the current reading of the x-channel (including the unit and without a space).", "")[2])
	@test isapprox(currentValue, getXValue(gauss), rtol=0.1)

	currentValue = uparse(input_dialog("Please enter the current reading of the y-channel (including the unit and without a space).", "")[2])
	@test isapprox(currentValue, getYValue(gauss), rtol=0.1)

	currentValue = uparse(input_dialog("Please enter the current reading of the z-channel (including the unit and without a space).", "")[2])
	@test isapprox(currentValue, getZValue(gauss), rtol=0.1)

	@test ask_dialog("Is the probe's temperature reading of $(getTemperature(gauss)) a probable value?")
	@test ask_dialog("Is the probe's frequency reading of $(getFrequency(gauss)) a probable value?")

	@test ask_dialog("Did everything seem normal?")
else
  @test_broken 0
end


text:
"""
    cl1(x::Float64)::Float64

Returns the value of the Clausen function ``\\operatorname{Cl}_1(x)``
for a real angle ``x`` of type `Float64`.  This function is defined as

```math
\\operatorname{Cl}_1(x) = \\Re[\\operatorname{Li}_1(e^{ix})] = \\Re[-\\log(1 - e^{ix})]
```

Note: ``\\operatorname{Cl}_1(x)`` is not defined for ``x=2n\\pi`` with
``n\\in\\mathbb{Z}``.

Author: Alexander Voigt

License: MIT

# Example
```jldoctest; setup = :(using ClausenFunctions), output = false
julia> cl1(1.0)
0.04201950582536895
```
"""
function cl1(x::Float64)::Float64
    x = range_reduce_odd(x)

    if x == zero(x)
        return Inf
    end

    -log(2.0*sin(0.5*x))
end


text:
using MolecularPotentials

mutable struct Water{T} <: AbstractMolecule
    coords::SMatrix{3, 3, Float64}
end

max_stars_repo_name: heindelj/MolecularPotentials

max_issues_repo_name: heindelj/MolecularPotentials

max_forks_repo_name: heindelj/MolecularPotentials


text:
#module Enums

export Enum, @enum

abstract Enum

Base.convert{T<:Integer}(::Type{T},x::Enum) = convert(T, x.val)
Base.convert{T<:Enum}(::Type{T},x::Integer) = T(x)
Base.start{T<:Enum}(::Type{T}) = 1
# next, done defined per Enum

# generate code to test whether expr is in the given set of values
function membershiptest(expr, values)
    lo, hi = extrema(values)
    sv = sort(values)
    if sv == [lo:hi;]
        :($lo <= $expr <= $hi)
    elseif length(values) < 20
        foldl((x1,x2)->:($x1 || ($expr == $x2)), :($expr == $(values[1])), values[2:end])
    else
        :($expr in $(Set(values)))
    end
end

#@noinline enum_argument_error(typename, x) = throw(ArgumentError(string("invalid value for Enum $(typename): $x")))

macro enum(T,syms...)
    if isempty(syms)
        throw(ArgumentError("no arguments given for Enum $T"))
    end
    if isa(T,Symbol)
        typename = T
    elseif isa(T,Expr) && T.head === :curly
        typename = T.args[1]
    else
        throw(ArgumentError("invalid type expression for enum $T"))
    end
    vals = Array((Symbol,Integer),0)
    lo = hi = 0
    i = -1
    enumT = typeof(i)
    hasexpr = false
    for s in syms
        if isa(s,Symbol)
            if i == typemax(typeof(i))
                i = widen(i) + one(i)
            else
                i += one(i)
            end
        elseif isa(s,Expr) &&
               (s.head == :(=) || s.head == :kw) &&
               length(s.args) == 2 && isa(s.args[1],Symbol)
            i = eval(s.args[2]) # allow exprs, e.g. uint128"1"
            s = s.args[1]
            hasexpr = true
        else
            throw(ArgumentError(string("invalid argument for Enum ", typename, ": ", s)))
        end
        if !isa(i, Integer)
            throw(ArgumentError("invalid value for Enum $typename, $s=$i; values must be integers"))
        end
        #if !Base.isidentifier(s)
        #    throw(ArgumentError("invalid name for Enum $typename; \"$s\" is not a valid identifier."))
        #end
        push!(vals, (s,i))
        I = typeof(i)
        if length(vals) == 1
            enumT = I
            lo = hi = i
        else
            enumT = promote_type(enumT,I)
            lo = min(lo, i)
            hi = max(hi, i)
        end
    end
    if !hasexpr
        n = length(vals)
        enumT = n <= typemax(Int8) ? Int8 :
                n <= typemax(Int16) ? Int16 :
                n <= typemax(Int32) ? Int32 : Int64
    end
    values = enumT[i[2] for i in vals]
    if hasexpr && values != unique(values)
        throw(ArgumentError("values for Enum $typename are not unique"))
    end
    lo = convert(enumT, lo)
    hi = convert(enumT, hi)
    vals = map(x->(x[1],convert(enumT,x[2])), vals)
    blk = quote
        # enum definition
        immutable $(esc(T)) <: Enum
            val::$enumT
            function $(esc(typename))(x::Integer)
                $(membershiptest(:x, values)) || enum_argument_error($(Meta.quot(typename)), x)
                new(x)
            end
        end
        Base.typemin{E<:$(esc(typename))}(x::Type{E}) = E($lo)
        Base.typemax{E<:$(esc(typename))}(x::Type{E}) = E($hi)
        Base.length{E<:$(esc(typename))}(x::Type{E}) = $(length(vals))
        Base.next{E<:$(esc(typename))}(x::Type{E},s) = (E($values[s]),s+1)
        Base.done{E<:$(esc(typename))}(x::Type{E},s) = s > $(length(values))
        Base.names{E<:$(esc(typename))}(x::Type{E}) = [$(map(x->Meta.quot(x[1]), vals)...)]
        function Base.print{E<:$(esc(typename))}(io::IO,x::E)
            for (sym, i) in $vals
                if i == x.val
                    print(io, sym); break
                end
            end
        end
        Base.show{E<:$(esc(typename))}(io::IO,x::E) = print(io, x, "::", E)
    end
    if isa(T,Symbol)
        for (sym,i) in vals
            push!(blk.args, :(const $(esc(sym)) = $(esc(T))($i)))
        end
    end
    push!(blk.args, :nothing)
    blk.head = :toplevel
    return blk
end

#end # module

max_stars_repo_name: YingzhouLi/HMat

max_issues_repo_name: YingzhouLi/HMat


text:
function missingperm2(arr::Vector)
    len = length(arr[1])
    xorval = zeros(UInt8, len)
    for perm in [Vector{UInt8}(s) for s in arr], i in 1:len
        xorval[i] ⊻= perm[i]
    end
    return String(xorval)
end

@show missingperm(arr)
@show missingperm1(arr)
@show missingperm2(arr)

@btime missingperm(arr)
@btime missingperm1(arr)
@btime missingperm2(arr)

max_stars_repo_name: ethansaxenian/RosettaDecode

max_issues_repo_name: ethansaxenian/RosettaDecode

max_forks_repo_name: ethansaxenian/RosettaDecode


text:
import CUDArt
import CUFFT
using Base.Test

CUDArt.devices(dev->CUDArt.capability(dev)[1] >= 2, nmax=1) do devlist
    CUDArt.device(devlist[1])
    # A simple 1d transform
    n = 64
    nc = div(n,2)+1
    # Create an array and move to the GPU
    a = randn(n)
    g = CUDArt.CudaArray(a)
    # Allocate space for the FFT
    gfft = CUDArt.CudaArray(Complex128, nc)
    # Perform the FFT
    pl! = CUFFT.plan(gfft, g)
    pl!(gfft, g, true)
    afftg = CUDArt.to_host(gfft)
    afft = rfft(a)
    @test afftg ≈ afft
    # Perform the IFFT
    pli! = CUFFT.plan(g, gfft)
    pli!(g, gfft, false)
    # Move back to host and compare
    a2 = CUDArt.to_host(g)
    @test a ≈ a2/n

    # 2D transform with CudaArrays
    A = rand(7,6)
    G = CUDArt.CudaArray(A)
    GFFT = CUDArt.CudaArray(Complex{eltype(A)}, div(size(G,1),2)+1, size(G,2))
    pl! = CUFFT.plan(GFFT, G)
    pl!(GFFT, G, true)
    AFFTG = CUDArt.to_host(GFFT)
    AFFT = rfft(A)
    @test AFFTG ≈ AFFT
    pli! = CUFFT.plan(G,GFFT)
    pli!(G, GFFT, false)
    A2 = CUDArt.to_host(G)
    @test A ≈ A2/length(A)

    # 2D transform with CudaPitchedArrays
    A = rand(8,3)
    G = CUDArt.CudaPitchedArray(A)
    GFFT = CUDArt.CudaPitchedArray(Complex{eltype(A)}, div(size(G,1),2)+1, size(G,2))
    pl! = CUFFT.plan(GFFT, G)
    pl!(GFFT, G, true)
    AFFTG = CUDArt.to_host(GFFT)
    AFFT = rfft(A)
    @test AFFTG ≈ AFFT
    pli! = CUFFT.plan(G,GFFT)
    pli!(G, GFFT, false)
    A2 = CUDArt.to_host(G)
    @test A ≈ A2/length(A)

    # 2D in-place transform
    A = rand(8,3)
    G, GFFT = CUFFT.RCpair(A)
    pl! = CUFFT.plan(GFFT, G)
    pl!(GFFT, G, true)
    AFFTG = CUDArt.to_host(GFFT)
    AFFT = rfft(A)
    @test AFFTG ≈ AFFT
    pli! = CUFFT.plan(G,GFFT)
    pli!(G, GFFT, false)
    A2 = CUDArt.to_host(G)
    @test A ≈ A2/length(A)

    # 3D transform using CudaArray
    NX, NY, NZ = 38, 69, 108
    A = randn(NX, NY, NZ)
    G = CUDArt.CudaArray(A)
    GFFT = CUDArt.CudaArray(Complex{eltype(G)}, div(size(G,1),2)+1, size(G,2), size(G,3))
    pl! = CUFFT.plan(GFFT, G)
    pl!(GFFT, G, true)
    AFFTG = CUDArt.to_host(GFFT)
    AFFT = rfft(A)
    @test AFFTG ≈ AFFT
    pli! = CUFFT.plan(G, GFFT)
    pli!(G, GFFT, false)
    A2 = CUDArt.to_host(G)
    @test A ≈ A2/length(A)

    # ... and with CudaPitchedArrays
    G = CUDArt.CudaPitchedArray(A)
    GFFT = CUDArt.CudaPitchedArray(Complex{eltype(G)}, div(size(G,1),2)+1, size(G,2), size(G,3))
    pl! = CUFFT.plan(GFFT, G)
    pl!(GFFT, G, true)
    AFFTG = CUDArt.to_host(GFFT)
    AFFT = rfft(A)
    @test AFFTG ≈ AFFT
    pli! = CUFFT.plan(G, GFFT)
    pli!(G, GFFT, false)
    A2 = CUDArt.to_host(G)
    @test A ≈ A2/length(A)
end


text:
using FEMfunctions

import Gmsh: gmsh
using LinearAlgebra

using AbstractPlotting
using SparseArrays
using SpecialMatrices
using Polynomials
using Printf
using WriteVTK

include("makeMesh.jl")
include("twodAdvectionDiffusion.jl")

κ = 1.0
ω = -1.0    # advection velocity parameter

### define the N parameters that describe the inner boundary
N = 160      # number of BSplines used to represent the inner boundary

### describe the inner boundary using BSplines
r = ones(N,1)

x,eConn,eConn2, innerNodes,innerX, outerNodes,outerX = makeMesh(r)

sort!(innerNodes);
sort!(outerNodes);

#   Let's look at the mesh...
nNodes = size(x,2)
nElements = size(eConn,2)

xT = zeros(Float64,nNodes,2)   # xT = transpose(x[1:2,:])
eC = zeros(Int64,nElements,6)  # eC = transpose(eConn), converted to Int64
for i=1:nNodes
  xT[i,1] = x[1,i]
  xT[i,2] = x[2,i]
end
for i=1:nElements#-nElementsSensor # the sensor elements are orientated correctly (why?)
  eC[i,1] = convert(Int64,eConn[1,i])
  eC[i,2] = convert(Int64,eConn[3,i])
  eC[i,3] = convert(Int64,eConn[2,i])
  eC[i,4] = convert(Int64,eConn[6,i])
  eC[i,5] = convert(Int64,eConn[5,i])
  eC[i,6] = convert(Int64,eConn[4,i])
end

velocity = Array{Float64,2}(undef,nNodes,2)
for i=1:nNodes
  velocity[i,1] = -ω*xT[i,2]
  velocity[i,2] = ω*xT[i,1]
end

temperature,exactTemperature = twodAdvectionDiffusion(xT,eC,innerNodes,outerNodes,velocity,κ,ω)

M = twodMassMatrix(xT,eC)
error = temperature-exactTemperature
#  The inner boundary isn't exactly a circle of radius 1, so we have a weaker error
@test sqrt( dot(error,(M*error)) ) < 2e-1

#  To manually check the function saveFEMasVTK, enter the following line
#  and use ParaView:
#  saveFEMasVTK("advDiff",xT,eC,["temperature"],temperature,["velocity"],velocity)


text:
function ssaargmap(f, @nospecialize(stmt))
    urs = userefs(stmt)
    urs === () && return stmt
    for op in urs
        val = op[]
        if isa(val, Union{SSAValue, Argument})
            op[] = f(val)
        end
    end
    urs[]
end

function line_to_vector(line::Int, linetable::Vector{LineInfoNode})
    lines = Int[]
    while line != 0
        push!(lines, line)
        line = linetable[line].inlined_at
    end
    return lines
end

function push_new_lineinfo!(new_code::Vector{Any}, topline::Int, line::Int, linetable::Vector{LineInfoNode})
    # separate the info into three sets: pops, line-change, pushes
    do_coverage = coverage_enabled()
    topmod = linetable[line].mod
    toplines = line_to_vector(topline, linetable)
    lines = line_to_vector(line, linetable)
    while !isempty(lines) && !isempty(toplines) && lines[end] == toplines[end]
        # remove common frames, recording changes to topmod
        topmod = linetable[pop!(lines)].mod
        pop!(toplines)
    end
    # check whether the outermost frame changed, or just the line number
    newframe = true
    topfile = NullLineInfo.file
    if !isempty(lines) && !isempty(toplines)
        let topline = linetable[toplines[end]]
            line = linetable[lines[end]]
            if topline.inlined_at == 0 || (topline.mod === line.mod && topline.method === line.method)
                # we could track frame_id precisely, but llvm / dwarf has no support for that,
                # and it wouldn't really be that meaningful after statements moved around,
                # so we just do fuzzy matching here in the legacy-format writer
                newframe = false
                topfile = topline.file
            end
        end
    end
    # first pop the old frame(s)
    npops = length(toplines) + newframe - 1
    if npops > 0
        push!(new_code, (npops == 1) ? Expr(:meta, :pop_loc) : Expr(:meta, :pop_loc, npops))
    end
    # then change the line number
    if !newframe
        let line = linetable[pop!(lines)]
            if line.file === topfile
                loc = LineNumberNode(line.line)
            else
                loc = LineNumberNode(line.line, line.file)
            end
            push!(new_code, loc)
            topmod = line.mod
        end
    end
    # then push the new frames
    while !isempty(lines)
        let line = linetable[pop!(lines)]
            if !do_coverage || line.mod == topmod
                loc = Expr(:meta, :push_loc, line.file, line.method, line.line)
            else
                loc = Expr(:meta, :push_loc, line.file, line.method, line.line, line.mod)
            end
            push!(new_code, loc)
            topmod = line.mod
        end
    end
    nothing
end

function replace_code!(ci::CodeInfo, code::IRCode, nargs::Int, linetable::Vector{LineInfoNode})
    if !isempty(code.new_nodes)
        code = compact!(code)
    end
    # All but the first `nargs` slots will now be unused
    resize!(ci.slottypes, nargs+1)
    resize!(ci.slotnames, nargs+1)
    resize!(ci.slotflags, nargs+1)
    # For every used SSAValues, we register one base format ssa value
    used = IdSet{Int}()
    foreach(stmt->scan_ssa_use!(used, stmt), code.stmts)
    mapping = IdDict{Int, Int}()
    n = 0
    resize!(ci.ssavaluetypes, length(used))
    for ssa in sort(Int[x for x in used])
        mapping[ssa] = n
        n += 1
        ci.ssavaluetypes[n] = code.types[ssa]
    end
    # Find all jump targets (we need to insert LabelNodes for them) and
    # jump origins (we insert a label node on the statement after, to
    # make sure we can track them)
    dest_blocks = IdSet{Int}()
    jump_origins = IdSet{Int}()
    for stmt in code.stmts
        if isa(stmt, GotoNode)
            push!(dest_blocks, stmt.label)
        elseif isa(stmt, GotoIfNot)
            push!(dest_blocks, stmt.dest)
        elseif isa(stmt, PhiNode)
            for edge in stmt.edges
                push!(jump_origins, edge)
            end
        end
    end
    cfg = code.cfg
    block_start = IdDict{Int, Int}(first(cfg.blocks[x].stmts)=>x for x in dest_blocks)
    comefrom_labels = IdSet{Int}(last(cfg.blocks[x].stmts)+1 for x in jump_origins)
    block_terminators = IdDict{Int, Int}(last(block.stmts)=>i for (i,block) in pairs(cfg.blocks))
    local rename
    let mapping = mapping
        function rename(@nospecialize(val))
            if isa(val, SSAValue)
                if haskey(mapping, val.id)
                    return SSAValue(mapping[val.id])
                end
            elseif isa(val, Argument)
                return SlotNumber(val.n)
            end
            return val
        end
    end
    # Now translate the code
    new_code = Vector{Any}()
    append!(new_code, code.meta)
    label_mapping = IdDict{Int, Int}()
    terminator_mapping = IdDict{Int, Int}()
    fixup = Int[]
    topline = 1
    for (idx, stmt) in pairs(code.stmts)
        line = code.lines[idx]
        # push labels first
        if haskey(block_start, idx)
            push!(new_code, LabelNode(length(new_code) + 1))
            label_mapping[block_start[idx]] = length(new_code)
        elseif idx in comefrom_labels
            push!(new_code, LabelNode(length(new_code) + 1))
        end
        # then metadata
        if line != 0 && line != topline
            push_new_lineinfo!(new_code, topline, line, linetable)
            topline = line
        end
        # record if this'll need a fixup after stmt number
        if isa(stmt, GotoIfNot)
            new_stmt = Expr(:gotoifnot, rename(stmt.cond), stmt.dest)
            push!(fixup, length(new_code)+1)
        elseif isa(stmt, ReturnNode)
            if isdefined(stmt, :val)
                new_stmt = Expr(:return, rename(stmt.val))
            else
                # Unreachable, so no issue with this
                new_stmt = nothing
            end
        elseif isa(stmt, SSAValue)
            new_stmt = rename(stmt)
        elseif isa(stmt, PhiNode)
            new_stmt = ssaargmap(rename, stmt)
            push!(fixup, length(new_code)+1)
        elseif isa(stmt, GotoNode)
            push!(fixup, length(new_code)+1)
            new_stmt = stmt
        else
            new_stmt = ssaargmap(rename, stmt)
        end
        if haskey(mapping, idx)
            new_stmt = Expr(:(=), SSAValue(mapping[idx]), new_stmt)
        end
        # record fixup targets
        if haskey(block_terminators, idx)
            terminator_mapping[block_terminators[idx]] = length(new_code)+1
        end
        # and finally, record the new new statement
        push!(new_code, new_stmt)
    end
    for i in fixup
        val = new_code[i]
        isassign = isexpr(val, :(=))
        if isassign
            val = val.args[2]
        end
        if isa(val, PhiNode)
            # Translate from BB edges to statement edges
            edges = Any[terminator_mapping[edge] for edge in val.edges]
            val = PhiNode(convert(Vector{Any}, edges), val.values)
        elseif isa(val, GotoNode)
            val = GotoNode(label_mapping[val.label])
        elseif isexpr(val, :gotoifnot)
            val = Expr(:gotoifnot, val.args[1], label_mapping[val.args[2]])
        else
            #@show val
            error()
        end
        if isassign
            new_code[i].args[2] = val
        else
            new_code[i] = val
        end
    end
    ci.code = new_code
    return ci
end

max_stars_repo_name: blegat/julia

max_issues_repo_name: blegat/julia

max_forks_repo_name: blegat/julia


text:
using Quon, Test

cp = tait_copy()
contract_boundary_vertices!(cp, [1], [3])
plot(cp)

rx0 = tait_rx(π*im)
contract_boundary_vertices!(rx0, [1], [6])
@test length(faces(rx0)) == 2

rx = tait_rx(π)
trace_vertex(rx, 1)
rz = tait_rz(π)
merge_graph!(rz, rx)
contract_boundary_vertices!(rz, [5], [6])

rz2 = tait_rz(im*pi)
rx2 = tait_rx(im*pi)
contract!(rz2, rx2)

@test nv(rz) == 6 == nv(rz2)
@test ne(rz) == 8 == ne(rz2)
@test nf(rz) == 4 == nf(rz2)
@test check_combinatorial_maps(rz) && check_combinatorial_maps(rz2)
@test check_vertices(rz) && check_faces(rz)
@test check_vertices(rz2) && check_faces(rz2)

idr = tensor_product!(tait_id(), rz2)
@test length(trace_vertex(idr, 4)) == 5

cp1 = tait_copy()
push!(cp1.inputs, pop!(cp1.outputs))
c = merge_graph!(cp1, tait_copy())
contract_boundary_vertices!(c, [2], [9])
contract_boundary_vertices!(c, [3], [8])
@test length(c.g.vs_isolated) == 1
plot(c)

rx = tait_rx(im)
plot(rx)
rx.g.next[8]
rem_edge!(rx, 8; update = true)
rem_edge!(rx, 11; update = true)
@test length(rx.g.vs_isolated) == 1


text:
module ArbExtras

using Arblib, SpecialFunctions

include("temporary.jl")
include("utilities.jl")

include("isolate_roots.jl")
include("refine_root.jl")

include("extrema_polynomial.jl")
include("extrema_series.jl")
include("extrema_enclosure.jl")

include("bounded_by.jl")

include("special_functions.jl")

include("integrate.jl")

end # module