text:
using PSCOPF

using Test
using Dates

@testset verbose=true "test_init_firmness" begin

    gen1 = PSCOPF.Networks.Generator("fuel_1_0", "bus_1", PSCOPF.Networks.PILOTABLE, 10., 100., 0., 10.,
                                    Dates.Second(210*60), Dates.Second(210*60)) #dmo, dp
    gen2 = PSCOPF.Networks.Generator( "fuel_1_1", "bus_1", PSCOPF.Networks.PILOTABLE, 10., 100., 0., 10.,
                                    Dates.Second(4*60*60), Dates.Second(210*60)) #dmo, dp
    gen_no_pmin = PSCOPF.Networks.Generator("fuel_1_2", "bus_1", PSCOPF.Networks.PILOTABLE, 0., 0., 0., 10.,
                                    Dates.Second(4*60*60), Dates.Second(210*60)) #dmo, dp
    lim1 = PSCOPF.Networks.Generator("wind_1_0", "bus_1", PSCOPF.Networks.LIMITABLE, 0., 0., 0., 10.,
                                    Dates.Second(4*60*60), Dates.Second(210*60)) #dmo, dp
    TS = [DateTime("2015-01-01T14:00:00"), DateTime("2015-01-01T14:30:00")]

    #=

      7h             10h30                      14h   14h30
     ECH          TS-Delta  NextECH             TS1   TS2
       |                 |  |                     |     |
                          <---------------------->
                                     3h30
                               |<---------------------->
                       TS2-Delta
                            11h
    =#
    @testset "gen_with_no_pmin" begin
        generators = [gen_no_pmin]
        ech = Dates.DateTime("2015-01-01T07:00:00")

        next_ech = Dates.DateTime("2015-01-01T10:45:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test ismissing(PSCOPF.get_commitment_firmness(firmness, "fuel_1_2"))
        @test ismissing(PSCOPF.get_commitment_firmness(firmness, "fuel_1_2", TS[1]))
        @test ismissing(PSCOPF.get_commitment_firmness(firmness, "fuel_1_2", TS[2]))
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_2")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_2", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_2", TS[2]) == PSCOPF.FREE
    end

    @testset "limitable" begin
        generators = [lim1]
        ech = Dates.DateTime("2015-01-01T07:00:00")

        next_ech = Dates.DateTime("2015-01-01T10:45:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test ismissing(PSCOPF.get_commitment_firmness(firmness, "wind_1_0"))
        @test ismissing(PSCOPF.get_commitment_firmness(firmness, "wind_1_0", TS[1]))
        @test ismissing(PSCOPF.get_commitment_firmness(firmness, "wind_1_0", TS[2]))
        @test length(PSCOPF.get_power_level_firmness(firmness, "wind_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "wind_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "wind_1_0", TS[2]) == PSCOPF.FREE
    end

    #=
       10h30         12h            14h   14h30
    TS1-Delta        ECH            TS1    TS2
            |          |             |      |
             <---------------------->
                          3h30
                   |<---------------------->
           TS2-Delta
                 11h
    =#
    @testset "ech_late" begin
        generators = [gen1]
        ech = Dates.DateTime("2015-01-01T12:00:00")

        next_ech = Dates.DateTime("2015-01-01T13:00:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)

        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.DECIDED
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.DECIDED
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.DECIDED
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.DECIDED
    end

    #=
       10h30                      14h   14h30
    TS-Delta                       TS    TS2
         ECH
           |                        |     |
           |<---------------------->|     |
                           3h30           |
                  <---------------------->|
                11h
    =#
    @testset "ech_last_moment" begin
        generators = [gen1]
        ech = Dates.DateTime("2015-01-01T10:30:00")

        next_ech = Dates.DateTime("2015-01-01T10:30:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.FREE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.FREE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE

        next_ech = Dates.DateTime("2015-01-01T10:45:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE

        next_ech = Dates.DateTime("2015-01-01T13:00:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.TO_DECIDE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.TO_DECIDE

        next_ech = nothing
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.TO_DECIDE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.TO_DECIDE
    end

    #=
      7h             10h30                      14h   14h30
     ECH          TS-Delta                      TS1    TS2
       |                 |                        |     |
                          <---------------------->
                                     3h30
                               |<---------------------->
                       TS2-Delta
                            11h
    =#
    @testset "ech_early" begin
        generators = [gen1]
        ech = Dates.DateTime("2015-01-01T07:00:00")

        next_ech = Dates.DateTime("2015-01-01T10:30:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.FREE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.FREE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE

        next_ech = Dates.DateTime("2015-01-01T10:45:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE

        next_ech = Dates.DateTime("2015-01-01T13:00:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)
        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.TO_DECIDE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.TO_DECIDE
    end

    #=
      7h             10h30                      14h   14h30
     ECH            TS1-DP                      TS1    TS2
       |                 |                        |     |
       |                 |<---------------------->|     |
       |                 |           3h30               |
       |                 |     |<---------------------->
       |                 | TS2-DP
       |                 |   11h
       |          |      |
            TS1-DMO TS2-DMO
                10h   10h30

    =#
    @testset "two_generators" begin
        generators = [gen1, gen2]
        ech = Dates.DateTime("2015-01-01T07:00:00")

        next_ech = Dates.DateTime("2015-01-01T10:45:00")
        firmness = PSCOPF.compute_firmness(ech, next_ech, TS, generators)

        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_0")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_0", TS[2]) == PSCOPF.FREE

        @test length(PSCOPF.get_commitment_firmness(firmness, "fuel_1_1")) == 2
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_1", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_commitment_firmness(firmness, "fuel_1_1", TS[2]) == PSCOPF.TO_DECIDE
        @test length(PSCOPF.get_power_level_firmness(firmness, "fuel_1_1")) == 2
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_1", TS[1]) == PSCOPF.TO_DECIDE
        @test PSCOPF.get_power_level_firmness(firmness, "fuel_1_1", TS[2]) == PSCOPF.FREE

    end

end

max_stars_repo_name: klorel/pscopf

max_issues_repo_name: klorel/pscopf

max_forks_repo_name: klorel/pscopf


text:
## In this notebook, we'll look at least squares on biometric data

##
using Plots
pyplot()
theme(:dark)
##
# https://vincentarelbundock.github.io/Rdatasets/csv/carData/Davis.csv
using CSV
df = CSV.read(download("https://vincentarelbundock.github.io/Rdatasets/csv/carData/Davis.csv"))
X = Float64.([df[:weight] df[:height]])
# Filter the data
goodpts = X[:,1] .<= 115
Xf = X[goodpts,:]
##
scatter(Xf[:,1],Xf[:,2],label="",xlabel="weight (kg)", ylabel="height (cm)")
##
x = Xf[:,1]
A = [x ones(length(x))]
b = Xf[:,2]
ab = A\b # solve the least squares problem

##
using Printf
scatter(Xf[:,1],Xf[:,2],color=2,size=(300,300), label="")
plot!(x, x*ab[1] .+ ab[2], label="",color=5)
title!(@sprintf("height ≈ %.2f weight + %.2f    ",ab[1],ab[2]))
xlabel!("Weight (kg)")
ylabel!("Height (cm)")
savefig("weight-height-fit.pdf")
## Show the

## Show the quadratic surface
quadratic_leastsq(A,b) = x-> (0.5*norm(A*x - b)^2)
ezsurf(x, y, f) = begin
    X = repeat(x', length(y), 1)
    Y = repeat(y, 1, length(x))
    # Evaluate each f(x, y)
    Z = map((x,y) -> f([x,y]), X, Y)
    plot(x, y, Z, st=:surface)
end
ezsurf(-3:0.1:3,-50:0.5:250,
  quadratic_leastsq(A,b))
##
plot!(colorbar=false,size=(300,300),dpi=300)
anim = @animate for i=1:360
  plot!(camera=(i,30))
end
gif(anim, "leastsq-quadratic.gif")

##
## Show the quadratic surface with alpha-blending
quadratic_leastsq(A,b) = x-> (0.5*norm(A*x - b)^2)
ezsurf(x, y, f) = begin
    X = repeat(x', length(y), 1)
    Y = repeat(y, 1, length(x))
    # Evaluate each f(x, y)
    Z = map((x,y) -> f([x,y]), X, Y)
    plot()
    plot!(x, y, Z, st=:surface)
end
ezsurf(-3:0.1:3,-50:0.5:250,
  quadratic_leastsq(A,b))

##
## Show k random samples of the quadratic surface
plotlyjs()
quadratic_leastsq(A,b) = x-> (0.5*norm(A*x - b)^2)/size(A,1)
ezsurf!(x, y, f) = begin
    X = repeat(x', length(y), 1)
    Y = repeat(y, 1, length(x))
    # Evaluate each f(x, y)
    Z = map((x,y) -> f([x,y]), X, Y)
    plot!(x, y, Z, st=:surface, alpha=0.1)
end
orig = ezsurf(-3:0.25:3,-50:1:250,
  quadratic_leastsq(A,b))
nsamp = 25
k = 25
for i=1:k
  subset = randperm(size(A,1))[1:25] # choose 25 of 200 samples.
  ezsurf!(-3:0.1:3,-50:0.5:250,
    quadratic_leastsq(A[subset,:],b[subset,:]))
end
plot!() # get the plot to show
## Show k random samples of the quadratic surface
using Random
using LinearAlgebra
plotlyjs()
quadratic_leastsq(A,b) = x-> (0.5*norm(A*x - b)^2)/size(A,1)
ezsurf!(x, y, f) = begin
    X = repeat(x', length(y), 1)
    Y = repeat(y, 1, length(x))
    # Evaluate each f(x, y)
    Z = map((x,y) -> f([x,y]), X, Y)
    plot!(x, y, Z, st=:surface, alpha=0.4)
end
plot(framestyle=:none,colorbar=false,size=(300,300),dpi=300)
nsamp = 10
k = 25
for i=1:k
  subset = randperm(size(A,1))[1:nsamp] # choose 25 of 200 samples.
  ezsurf!(-3:0.25:3,-50:2:250,
    quadratic_leastsq(A[subset,:],b[subset,:]))
end
plot!() # get the plot to show
##
#plot!(colorbar=false,size=(300,300),dpi=300)
plot!(colorbar=false,size=(900,900))
anim = @animate for i=2:2:360
  plot!(camera=(i,30))
end
gif(anim, "leastsq-quadratic-samples.gif")

## Show the same thing with a log10
using Random
using LinearAlgebra
plotlyjs()
quadratic_leastsq(A,b) = x-> log10(0.5*norm(A*x - b)^2)/size(A,1)
plot(framestyle=:none,colorbar=false,size=(300,300),dpi=300)
nsamp = 10
k = 25
for i=1:k
  subset = randperm(size(A,1))[1:nsamp] # choose 25 of 200 samples.
  ezsurf!(-3:0.1:3,-50:0.5:250,
    quadratic_leastsq(A[subset,:],b[subset,:]))
end
plot!() # get the plot to show
##
#plot!(colorbar=false,size=(300,300),dpi=300)
plot!(colorbar=false,size=(900,900))
anim = @animate for i=2:2:360
  plot!(camera=(i,30))
end
gif(anim, "leastsq-quadratic-samples-log.gif")
##

ext: jl


text:
using WAV
using DSP

f, fs, nbits, opt = wavread("audio.wav")
# FFTW.set_num_threads(np) ?
F = fft(f)

freqs = [0 200 400 800 1600 3200]
nfreqs = length(freqs)
maxfreq = 4096
bands = Array{Array{Complex{Float64}}}(nfreqs)
n = length(F)

for i = 1:(nfreqs - 1)
    bands[i] = getindex(F, [((floor(freqs[i]/maxfreq * n / 2) + 1)):(floor(freqs[i + 1]/maxfreq * n / 2))])
end
bands[nfreqs] = getindex(F, [(floor(freqs[nfreqs]/maxfreq * n / 2 + 1)):(floor(n/2))])

max_stars_repo_name: broluwo/ciett

max_issues_repo_name: broluwo/ciett

max_forks_repo_name: broluwo/ciett


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

mutable struct UpdateDataLakeStoreAccountParameters <: SwaggerModel
    tags::Any # spec type: Union{ Nothing, Dict{String, String} } # spec name: tags
    properties::Any # spec type: Union{ Nothing, UpdateDataLakeStoreAccountProperties } # spec name: properties

    function UpdateDataLakeStoreAccountParameters(;tags=nothing, properties=nothing)
        o = new()
        validate_property(UpdateDataLakeStoreAccountParameters, Symbol("tags"), tags)
        setfield!(o, Symbol("tags"), tags)
        validate_property(UpdateDataLakeStoreAccountParameters, Symbol("properties"), properties)
        setfield!(o, Symbol("properties"), properties)
        o
    end
end # type UpdateDataLakeStoreAccountParameters

const _property_map_UpdateDataLakeStoreAccountParameters = Dict{Symbol,Symbol}(Symbol("tags")=>Symbol("tags"), Symbol("properties")=>Symbol("properties"))
const _property_types_UpdateDataLakeStoreAccountParameters = Dict{Symbol,String}(Symbol("tags")=>"Dict{String, String}", Symbol("properties")=>"UpdateDataLakeStoreAccountProperties")
Base.propertynames(::Type{ UpdateDataLakeStoreAccountParameters }) = collect(keys(_property_map_UpdateDataLakeStoreAccountParameters))
Swagger.property_type(::Type{ UpdateDataLakeStoreAccountParameters }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_UpdateDataLakeStoreAccountParameters[name]))}
Swagger.field_name(::Type{ UpdateDataLakeStoreAccountParameters }, property_name::Symbol) =  _property_map_UpdateDataLakeStoreAccountParameters[property_name]

function check_required(o::UpdateDataLakeStoreAccountParameters)
    true
end

function validate_property(::Type{ UpdateDataLakeStoreAccountParameters }, name::Symbol, val)
end


text:
Feature = Union{Real, AbstractString}
Features = Array{Feature, 1}
Data = Array{Features, 1}

export Feature, Features, Data

"""
    A Question is used to partition a dataset.

    This class just records a 'column number' (e.g., 0 for Color) and a
    'column value' (e.g., Green). The 'match' method is used to compare
    the feature value in an example to the feature value stored in the
    question. See the demo below.
"""
struct Question
    column::Int
    value::Feature
    function Question(column, value)
        new(column, value)
    end
end

export Question

abstract type Node end
"""
A Leaf node classifies data.

This holds a dictionary of class (e.g., "Apple") -> number of times
it appears in the rows from the training data that reach this leaf.
"""
struct Leaf <: Node
    predictions::Dict{AbstractString, Int64}
    function Leaf(rows::Data)
        predictions = class_counts(rows)
        new(predictions)
    end
end

"""
A Decision Node asks a question.

This holds a reference to the question, and to the two child nodes.
"""
struct Decision <: Node
    question::Question
    true_branch::Node
    false_branch::Node
    function Decision(question::Question,
                      true_branch::Node,
                      false_branch::Node)
        new(question, true_branch, false_branch)
    end
end

export Node, Leaf, Decision


text: # import MLDatasets


text:
using NiLang, NiLang.AD
using Test

@testset "check grad" begin
    for opm in [⊕, ⊖]
        @test check_grad(opm(identity), (Loss(1.0), 2.0); verbose=true)
        @test check_grad(opm(*), (Loss(1.0), 2.0, 2.0); verbose=true)
        @test check_grad(opm(^), (Loss(1.0), 2.0, 2); verbose=true)
        @test check_grad(opm(^), (Loss(1.0), 2.0, 2.0); verbose=true)
        @test check_grad(opm(abs), (Loss(1.0), -2.0); verbose=true)
        @test check_grad(opm(exp), (Loss(1.0), 2.0); verbose=true)
        @test check_grad(opm(log), (Loss(1.0), 2.0); verbose=true)
        @test check_grad(opm(sin), (Loss(1.0), 2.0); verbose=true)
        @test check_grad(opm(cos), (Loss(1.0), 2.0); verbose=true)
        @test check_grad(opm(/), (Loss(1.0), 2.0, 2.0); verbose=true)
    end
    @test check_grad(NEG, (Loss(1.0),); verbose=true)
    @test check_grad(ROT, (Loss(1.0), 2.0, 2.0); verbose=true)
    @test check_grad(ROT, (1.0, Loss(2.0), 2.0); verbose=true)
    @test check_grad(IROT, (Loss(1.0), 2.0, 2.0); verbose=true)
    @test check_grad(IROT, (1.0, Loss(2.0), 2.0); verbose=true)
end


text:
using Test
using SafeTestsets

@safetestset "Reference shapes tests" begin include("referenceshapes_test.jl") end

@safetestset "Domain tests" begin include("domain_test.jl") end

max_stars_repo_name: WaveProp/WavePropBase

max_issues_repo_name: WaveProp/WavePropBase

max_forks_repo_name: WaveProp/WavePropBase


text:
using Distributions
using Pathfinder
using Random
using Test

@testset "ELBO estimation" begin
    @testset "elbo_and_samples" begin
        σ_target = 0.08
        target_dist = Normal(0, σ_target)
        logp(x) = logpdf(target_dist, x[1])
        σs = [1e-3, 0.05, 0.8, 1.0, 1.1, 1.2, 5.0, 10.0]
        rng = MersenneTwister(42)
        @testset for σ in σs
            dist = Normal(0, σ)
            elbo, ϕ, logqϕ = @inferred Pathfinder.elbo_and_samples(
                rng, logp, dist, 1_000_000
            )
            # explicit elbo calculation
            r = σ / σ_target
            elbo_exp = (1 - r^2) / 2 + log(r)
            @test elbo ≈ elbo_exp rtol = 1e-2
            @test mean(logp.(eachcol(ϕ)) - logqϕ) ≈ elbo
        end
    end

    @testset "maximize_elbo" begin
        σ_target = 0.08
        target_dist = Normal(0, σ_target)
        logp(x) = logpdf(target_dist, x[1])
        σs = [1e-3, 0.05, σ_target, 1.0, 1.1, 1.2, 5.0, 10.0]
        dists = Normal.(0, σs)
        rng = MersenneTwister(42)
        lopt, elbo, ϕ, logqϕ = @inferred Pathfinder.maximize_elbo(rng, logp, dists, 100)
        @test lopt == 3
        @test elbo ≈ 0
    end
end


text:
module M1_1
function f(q::Vector{T}, q_dot::Vector{T}, xi::T) where T
    l1 = q[1]
    l2 = q[2]
    l3 = q[3]
    l1_dot = q_dot[1]
    l2_dot = q_dot[2]
    l3_dot = q_dot[3]

    1.3806522621004e+17*l1.^18 - 1.60065545335102e+18*l1.^17.*l2 - 8.21485647116353e+17*l1.^17.*l3 + 9.45494569700184e+15*l1.^17 + 9.37824823540379e+18*l1.^16.*l2.^2 + 7.83577706326508e+18*l1.^16.*l2.*l3 - 9.28303759341999e+16*l1.^16.*l2 + 2.95872947164765e+18*l1.^16.*l3.^2 - 3.18029991626426e+16*l1.^16.*l3 + 6.98362956528783e+15*l1.^16 - 3.68347640474837e+19*l1.^15.*l2.^3 - 3.65908602424017e+19*l1.^15.*l2.^2.*l3 + 4.43522907241177e+17*l1.^15.*l2.^2 - 2.54077238493916e+19*l1.^15.*l2.*l3.^2 + 2.06289724298222e+17*l1.^15.*l2.*l3 - 7.91889848342627e+16*l1.^15.*l2 - 7.18076310961731e+18*l1.^15.*l3.^3 + 5.84487552178296e+16*l1.^15.*l3.^2 - 3.41077122580316e+16*l1.^15.*l3 - 233793607153361.0*l1.^15 + 1.0820483759454e+20*l1.^14.*l2.^4 + 1.10579520304018e+20*l1.^14.*l2.^3.*l3 - 1.36838850451154e+18*l1.^14.*l2.^3 + 1.07152524912614e+20*l1.^14.*l2.^2.*l3.^2 - 4.22893934811355e+17*l1.^14.*l2.^2.*l3 + 4.49463089102775e+17*l1.^14.*l2.^2 + 5.4915970224221e+19*l1.^14.*l2.*l3.^3 - 3.09434586447333e+17*l1.^14.*l2.*l3.^2 + 3.02134632655923e+17*l1.^14.*l2.*l3 + 1.98390575212995e+15*l1.^14.*l2 + 1.32045993751291e+19*l1.^14.*l3.^4 + 3.43816207163712e+15*l1.^14.*l3.^3 + 1.06766736869272e+17*l1.^14.*l3.^2 + 607863378598739.0*l1.^14.*l3 - 132468346574870.0*l1.^14 - 2.51507726600378e+20*l1.^13.*l2.^5 - 2.37353371685459e+20*l1.^13.*l2.^4.*l3 + 2.99635824543167e+18*l1.^13.*l2.^4 - 3.0095437439064e+20*l1.^13.*l2.^3.*l3.^2 - 4.81342690029185e+17*l1.^13.*l2.^3.*l3 - 1.6947195767173e+18*l1.^13.*l2.^3 - 1.98448951614853e+20*l1.^13.*l2.^2.*l3.^3 + 2.88805614017511e+17*l1.^13.*l2.^2.*l3.^2 - 1.26287635895607e+18*l1.^13.*l2.^2.*l3 - 8.18277625036764e+15*l1.^13.*l2.^2 - 9.34627626673762e+19*l1.^13.*l2.*l3.^4 - 2.88805614017511e+17*l1.^13.*l2.*l3.^3 - 8.60794364302447e+17*l1.^13.*l2.*l3.^2 - 2.61848840011765e+15*l1.^13.*l2.*l3 + 1.3789396743782e+15*l1.^13.*l2 - 1.8585176087238e+19*l1.^13.*l3.^5 - 2.28637777763863e+17*l1.^13.*l3.^4 - 2.13391482686037e+17*l1.^13.*l3.^3 - 935174428613445.0*l1.^13.*l3.^2 + 499081570986659.0*l1.^13.*l3 + 3519658997501.61*l1.^13 + 4.78232475724381e+20*l1.^12.*l2.^6 + 3.68436973916698e+20*l1.^12.*l2.^5.*l3 - 4.76529263128893e+18*l1.^12.*l2.^5 + 6.39393825022315e+20*l1.^12.*l2.^4.*l3.^2 + 5.30680315757176e+18*l1.^12.*l2.^4.*l3 + 4.72167056515959e+18*l1.^12.*l2.^4 + 4.54712508554322e+20*l1.^12.*l2.^3.*l3.^3 + 1.39589380108463e+18*l1.^12.*l2.^3.*l3.^2 + 3.2871304746453e+18*l1.^12.*l2.^3.*l3 + 2.13687356938172e+16*l1.^12.*l2.^3 + 3.09219480922851e+20*l1.^12.*l2.^2.*l3.^4 + 3.17686175419262e+18*l1.^12.*l2.^2.*l3.^3 + 3.27784475884175e+18*l1.^12.*l2.^2.*l3.^2 - 46758721430676.2*l1.^12.*l2.^2.*l3 - 7.07202508447977e+15*l1.^12.*l2.^2 + 1.21240761326154e+20*l1.^12.*l2.*l3.^5 + 1.44402807008755e+18*l1.^12.*l2.*l3.^4 + 1.54986666970204e+18*l1.^12.*l2.*l3.^3 + 2.24441862867227e+15*l1.^12.*l2.*l3.^2 - 3.93806995623569e+15*l1.^12.*l2.*l3 - 23385653741789.2*l1.^12.*l2 + 2.0769731372755e+19*l1.^12.*l3.^6 + 6.37779064288669e+17*l1.^12.*l3.^5 + 3.05276339280265e+17*l1.^12.*l3.^4 - 467587214306723.0*l1.^12.*l3.^3 - 1.30279030323097e+15*l1.^12.*l3.^2 - 8338520980658.15*l1.^12.*l3 + 4016013172085.58*l1.^12 - 7.59238457459379e+20*l1.^11.*l2.^7 - 3.89142937668125e+20*l1.^11.*l2.^6.*l3 + 5.24663532131811e+18*l1.^11.*l2.^6 - 1.09999146791926e+21*l1.^11.*l2.^5.*l3.^2 - 1.70395312270331e+19*l1.^11.*l2.^5.*l3 - 1.02572123300015e+19*l1.^11.*l2.^5 - 7.35327068761165e+20*l1.^11.*l2.^4.*l3.^3 - 4.98189684180206e+18*l1.^11.*l2.^4.*l3.^2 - 5.62835257649039e+18*l1.^11.*l2.^4.*l3 - 3.81551166874286e+16*l1.^11.*l2.^4 - 6.5127311576983e+20*l1.^11.*l2.^3.*l3.^4 - 1.34775953208172e+19*l1.^11.*l2.^3.*l3.^3 - 8.36258505812447e+18*l1.^11.*l2.^3.*l3.^2 + 3.10477910299664e+16*l1.^11.*l2.^3.*l3 + 2.38591285298109e+16*l1.^11.*l2.^3 - 3.59353173407429e+20*l1.^11.*l2.^2.*l3.^5 - 5.99271649086335e+18*l1.^11.*l2.^2.*l3.^4 - 4.7369484344801e+18*l1.^11.*l2.^2.*l3.^3 + 5.33049424309666e+15*l1.^11.*l2.^2.*l3.^2 + 1.38086438475336e+16*l1.^11.*l2.^2.*l3 + 78259263481361.2*l1.^11.*l2.^2 - 1.26547873036733e+20*l1.^11.*l2.*l3.^6 - 3.46566736821013e+18*l1.^11.*l2.*l3.^5 - 2.26055195443658e+18*l1.^11.*l2.*l3.^4 + 1.23443024576975e+16*l1.^11.*l2.*l3.^3 + 9.86024803137302e+15*l1.^11.*l2.*l3.^2 + 12141642447757.2*l1.^11.*l2.*l3 - 34414010295218.0*l1.^11.*l2 - 1.84438294242929e+19*l1.^11.*l3.^7 - 9.62685380058369e+17*l1.^11.*l3.^6 - 2.76001641166066e+17*l1.^11.*l3.^5 + 3.41338666443908e+15*l1.^11.*l3.^4 + 1.95942473343314e+15*l1.^11.*l3.^3 + 15755788935124.7*l1.^11.*l3.^2 - 13881050551740.9*l1.^11.*l3 - 15435417289.7984*l1.^11 + 1.01940491607017e+21*l1.^10.*l2.^8 + 1.7726752237352e+20*l1.^10.*l2.^7.*l3 - 2.86742716774529e+18*l1.^10.*l2.^7 + 1.63553252203771e+21*l1.^10.*l2.^6.*l3.^2 + 3.47048079511042e+19*l1.^10.*l2.^6.*l3 + 1.79155354191358e+19*l1.^10.*l2.^6 + 7.79244446676221e+20*l1.^10.*l2.^5.*l3.^3 + 7.65334877146403e+18*l1.^10.*l2.^5.*l3.^2 + 5.63600238197717e+18*l1.^10.*l2.^5.*l3 + 4.49818900163067e+16*l1.^10.*l2.^5 + 1.10332795442878e+21*l1.^10.*l2.^4.*l3.^4 + 3.31404442085094e+19*l1.^10.*l2.^4.*l3.^3 + 1.64597557889265e+19*l1.^10.*l2.^4.*l3.^2 - 1.21853228048332e+17*l1.^10.*l2.^4.*l3 - 5.88628791294064e+16*l1.^10.*l2.^4 + 5.71831001714585e+20*l1.^10.*l2.^3.*l3.^5 + 1.62693829229864e+19*l1.^10.*l2.^3.*l3.^4 + 8.63770835934457e+18*l1.^10.*l2.^3.*l3.^3 - 3.54431108444496e+16*l1.^10.*l2.^3.*l3.^2 - 2.80574721550909e+16*l1.^10.*l2.^3.*l3 - 158786226719502.0*l1.^10.*l2.^3 + 3.84531098732033e+20*l1.^10.*l2.^2.*l3.^6 + 1.04692035081348e+19*l1.^10.*l2.^2.*l3.^5 + 6.44000255399745e+18*l1.^10.*l2.^2.*l3.^4 - 6.49946227886344e+16*l1.^10.*l2.^2.*l3.^3 - 3.36051930916874e+16*l1.^10.*l2.^2.*l3.^2 + 76841951133374.1*l1.^10.*l2.^2.*l3 + 143167821097244.0*l1.^10.*l2.^2 + 9.36708155517112e+19*l1.^10.*l2.*l3.^7 + 4.90969543829768e+18*l1.^10.*l2.*l3.^6 + 2.35799829712165e+18*l1.^10.*l2.*l3.^5 - 2.94112357798928e+16*l1.^10.*l2.*l3.^4 - 1.37266339176104e+16*l1.^10.*l2.*l3.^3 + 10866061334568.8*l1.^10.*l2.*l3.^2 + 91937370770558.3*l1.^10.*l2.*l3 - 42165042352.6198*l1.^10.*l2 + 1.44307302506765e+19*l1.^10.*l3.^8 + 9.35180083485273e+17*l1.^10.*l3.^7 + 1.04950401704453e+17*l1.^10.*l3.^6 - 7.24760182175421e+15*l1.^10.*l3.^5 - 1.97254682230363e+15*l1.^10.*l3.^4 - 9472370859047.87*l1.^10.*l3.^3 + 30917959710426.4*l1.^10.*l3.^2 + 162260118339.1*l1.^10.*l3 - 25868795592.3108*l1.^10 - 1.16583148796443e+21*l1.^9.*l2.^9 + 2.80882413602424e+20*l1.^9.*l2.^8.*l3 - 2.63277260635606e+18*l1.^9.*l2.^8 - 2.18053763151336e+21*l1.^9.*l2.^7.*l3.^2 - 5.12011095708187e+19*l1.^9.*l2.^7.*l3 - 2.56054027372355e+19*l1.^9.*l2.^7 - 3.70004423189357e+20*l1.^9.*l2.^6.*l3.^3 - 2.76772046766781e+18*l1.^9.*l2.^6.*l3.^2 - 8.30609045744765e+16*l1.^9.*l2.^6.*l3 - 2.48288810796869e+16*l1.^9.*l2.^6 - 1.49851853102291e+21*l1.^9.*l2.^5.*l3.^4 - 6.32484294698348e+19*l1.^9.*l2.^5.*l3.^3 - 2.70093706591686e+19*l1.^9.*l2.^5.*l3.^2 + 2.76437561098134e+17*l1.^9.*l2.^5.*l3 + 1.11856044022742e+17*l1.^9.*l2.^5 - 7.33167197716163e+20*l1.^9.*l2.^4.*l3.^5 - 1.87723649111382e+19*l1.^9.*l2.^4.*l3.^4 - 9.72086906851566e+18*l1.^9.*l2.^4.*l3.^3 + 5.82146081811869e+16*l1.^9.*l2.^4.*l3.^2 + 3.06729708299722e+16*l1.^9.*l2.^4.*l3 + 198659947442876.0*l1.^9.*l2.^4 - 4.97860560973349e+20*l1.^9.*l2.^3.*l3.^6 - 3.02283209338328e+19*l1.^9.*l2.^3.*l3.^5 - 1.15149182988773e+19*l1.^9.*l2.^3.*l3.^4 + 2.15090118581092e+17*l1.^9.*l2.^3.*l3.^3 + 7.73949738647062e+16*l1.^9.*l2.^3.*l3.^2 - 463933575241151.0*l1.^9.*l2.^3.*l3 - 385931671976189.0*l1.^9.*l2.^3 - 3.43318996033344e+20*l1.^9.*l2.^2.*l3.^7 - 7.72555017496841e+18*l1.^9.*l2.^2.*l3.^6 - 5.87441943771181e+18*l1.^9.*l2.^2.*l3.^5 + 7.2476018217542e+16*l1.^9.*l2.^2.*l3.^4 + 3.43795560850134e+16*l1.^9.*l2.^2.*l3.^3 - 109251160157348.0*l1.^9.*l2.^2.*l3.^2 - 271328194263225.0*l1.^9.*l2.^2.*l3 + 383250117097.918*l1.^9.*l2.^2 - 3.64160135387586e+19*l1.^9.*l2.*l3.^8 - 6.18869172894666e+18*l1.^9.*l2.*l3.^7 - 1.9082654881531e+18*l1.^9.*l2.*l3.^6 + 5.72326750311429e+16*l1.^9.*l2.*l3.^5 + 1.67972816306122e+16*l1.^9.*l2.*l3.^4 - 197715072544218.0*l1.^9.*l2.*l3.^3 - 190080398818965.0*l1.^9.*l2.*l3.^2 - 516521768819.594*l1.^9.*l2.*l3 + 160012176047.708*l1.^9.*l2 - 1.22674308389357e+19*l1.^9.*l3.^9 - 3.77338287362164e+17*l1.^9.*l3.^8 + 1.29671752315144e+17*l1.^9.*l3.^7 + 7.34111926461555e+15*l1.^9.*l3.^6 + 588156984881232.0*l1.^9.*l3.^5 + 1889749797316.19*l1.^9.*l3.^4 - 40185801999998.0*l1.^9.*l3.^3 - 218731157204.215*l1.^9.*l3.^2 + 96751556375.6087*l1.^9.*l3 - 288633524.968636*l1.^9 + 1.13901490129235e+21*l1.^8.*l2.^10 - 8.3483893965458e+20*l1.^8.*l2.^9.*l3 + 9.42400223835711e+18*l1.^8.*l2.^9 + 2.68014122311302e+21*l1.^8.*l2.^8.*l3.^2 + 5.62010567634968e+19*l1.^8.*l2.^8.*l3 + 3.02279042622145e+19*l1.^8.*l2.^8 - 6.26471918973075e+20*l1.^8.*l2.^7.*l3.^3 - 9.46869834528839e+18*l1.^8.*l2.^7.*l3.^2 - 1.15569684761763e+19*l1.^8.*l2.^7.*l3 - 2.73538520369433e+16*l1.^8.*l2.^7 + 2.08033842206562e+21*l1.^8.*l2.^6.*l3.^4 + 9.09015670120115e+19*l1.^8.*l2.^6.*l3.^3 + 3.94002958440667e+19*l1.^8.*l2.^6.*l3.^2 - 4.26860367940607e+17*l1.^8.*l2.^6.*l3 - 1.68455921243885e+17*l1.^8.*l2.^6 + 2.17677974975506e+20*l1.^8.*l2.^5.*l3.^5 + 1.25630442097617e+19*l1.^8.*l2.^5.*l3.^4 + 2.14803046294038e+18*l1.^8.*l2.^5.*l3.^3 - 3.57704218944643e+16*l1.^8.*l2.^5.*l3.^2 + 3.41790744940337e+15*l1.^8.*l2.^5.*l3 - 91983571384370.2*l1.^8.*l2.^5 + 9.64561382337457e+20*l1.^8.*l2.^4.*l3.^6 + 4.15880084185215e+19*l1.^8.*l2.^4.*l3.^5 + 1.84960572163466e+19*l1.^8.*l2.^4.*l3.^4 - 4.1451606548291e+17*l1.^8.*l2.^4.*l3.^3 - 1.42623560281992e+17*l1.^8.*l2.^4.*l3.^2 + 1.18487312291732e+15*l1.^8.*l2.^4.*l3 + 750367138845855.0*l1.^8.*l2.^4 + 1.10932740031378e+20*l1.^8.*l2.^3.*l3.^7 + 2.31044491214009e+19*l1.^8.*l2.^3.*l3.^6 + 5.71304669746353e+18*l1.^8.*l2.^3.*l3.^5 - 1.62720350578739e+17*l1.^8.*l2.^3.*l3.^4 - 4.1243802343065e+16*l1.^8.*l2.^3.*l3.^3 + 349367493778849.0*l1.^8.*l2.^3.*l3.^2 + 465034555132582.0*l1.^8.*l2.^3.*l3 - 1032290590454.32*l1.^8.*l2.^3 + 3.48476239140799e+20*l1.^8.*l2.^2.*l3.^8 + 4.61057533806526e+18*l1.^8.*l2.^2.*l3.^7 + 5.83820900425927e+18*l1.^8.*l2.^2.*l3.^6 - 1.05207123219013e+17*l1.^8.*l2.^2.*l3.^5 - 4.54048183711123e+16*l1.^8.*l2.^2.*l3.^4 + 609798637721503.0*l1.^8.*l2.^2.*l3.^3 + 529139910618788.0*l1.^8.*l2.^2.*l3.^2 + 1714460739944.91*l1.^8.*l2.^2.*l3 - 441275049323.524*l1.^8.*l2.^2 - 3.64160135387586e+19*l1.^8.*l2.*l3.^9 + 6.21963518759139e+18*l1.^8.*l2.*l3.^8 + 7.20897447977008e+17*l1.^8.*l2.*l3.^7 - 6.77533873530441e+16*l1.^8.*l2.*l3.^6 - 1.16045216369227e+16*l1.^8.*l2.*l3.^5 + 351493462300831.0*l1.^8.*l2.*l3.^4 + 215960302730936.0*l1.^8.*l2.*l3.^3 - 684428991045.206*l1.^8.*l2.*l3.^2 - 530107230518.642*l1.^8.*l2.*l3 + 4117838289.55255*l1.^8.*l2 + 1.44307302506765e+19*l1.^8.*l3.^10 - 3.77338287362164e+17*l1.^8.*l3.^9 - 2.3891532244108e+17*l1.^8.*l3.^8 - 3.50690410730042e+15*l1.^8.*l3.^7 + 1.06539466904603e+15*l1.^8.*l3.^6 + 12188886192690.1*l1.^8.*l3.^5 + 36949394742782.8*l1.^8.*l3.^4 + 312849555312.742*l1.^8.*l3.^3 - 180954378201.986*l1.^8.*l3.^2 - 3187796931.32027*l1.^8.*l3 - 123610910.937589*l1.^8 - 9.49445811342512e+20*l1.^7.*l2.^11 + 1.2356537029059e+21*l1.^7.*l2.^10.*l3 - 1.44196517284457e+19*l1.^7.*l2.^10 - 2.98968762329269e+21*l1.^7.*l2.^9.*l3.^2 - 4.52324602144568e+19*l1.^7.*l2.^9.*l3 - 2.95546141808913e+19*l1.^7.*l2.^9 + 1.87228553773066e+21*l1.^7.*l2.^8.*l3.^3 + 2.26196682693e+19*l1.^7.*l2.^8.*l3.^2 + 2.47844398824155e+19*l1.^7.*l2.^8.*l3 + 9.24219528163974e+16*l1.^7.*l2.^8 - 2.67811314828077e+21*l1.^7.*l2.^7.*l3.^4 - 1.11891546459356e+20*l1.^7.*l2.^7.*l3.^3 - 5.13238297940285e+19*l1.^7.*l2.^7.*l3.^2 + 4.75816749278521e+17*l1.^7.*l2.^7.*l3 + 2.03888245281702e+17*l1.^7.*l2.^7 + 4.57398976730297e+20*l1.^7.*l2.^6.*l3.^5 + 2.74365333316635e+19*l1.^7.*l2.^6.*l3.^4 + 1.45148282744523e+19*l1.^7.*l2.^6.*l3.^3 - 7.79935473463612e+16*l1.^7.*l2.^6.*l3.^2 - 8.08388415722778e+16*l1.^7.*l2.^6.*l3 - 190274182717284.0*l1.^7.*l2.^6 - 8.36203331663008e+20*l1.^7.*l2.^5.*l3.^6 - 7.9710349468833e+19*l1.^7.*l2.^5.*l3.^5 - 2.49273905346508e+19*l1.^7.*l2.^5.*l3.^4 + 6.84547681745042e+17*l1.^7.*l2.^5.*l3.^3 + 2.22265258562414e+17*l1.^7.*l2.^5.*l3.^2 - 1.97389090704181e+15*l1.^7.*l2.^5.*l3 - 1.1066273978478e+15*l1.^7.*l2.^5 - 4.99291659203167e+20*l1.^7.*l2.^4.*l3.^7 + 6.06491789436773e+18*l1.^7.*l2.^4.*l3.^6 - 4.62515333664467e+18*l1.^7.*l2.^4.*l3.^5 + 3.08607561442437e+16*l1.^7.*l2.^4.*l3.^4 + 9.38110101475782e+15*l1.^7.*l2.^4.*l3.^3 - 227832959938945.0*l1.^7.*l2.^4.*l3.^2 - 461675821403110.0*l1.^7.*l2.^4.*l3 + 1218645018709.2*l1.^7.*l2.^4 + 1.10932740031378e+20*l1.^7.*l2.^3.*l3.^8 - 3.33364194465927e+19*l1.^7.*l2.^3.*l3.^7 - 4.15739646893326e+18*l1.^7.*l2.^3.*l3.^6 + 3.38907212929513e+17*l1.^7.*l2.^3.*l3.^5 + 7.01939267962585e+16*l1.^7.*l2.^3.*l3.^4 - 1.74754612506825e+15*l1.^7.*l2.^3.*l3.^3 - 951529283603826.0*l1.^7.*l2.^3.*l3.^2 - 4422811763915.86*l1.^7.*l2.^3.*l3 + 695723644349.109*l1.^7.*l2.^3 - 3.43318996033344e+20*l1.^7.*l2.^2.*l3.^9 + 4.61057533806526e+18*l1.^7.*l2.^2.*l3.^8 - 4.87553472732424e+18*l1.^7.*l2.^2.*l3.^7 + 1.57109304007059e+16*l1.^7.*l2.^2.*l3.^6 + 3.00886794260032e+16*l1.^7.*l2.^2.*l3.^5 - 332005417516007.0*l1.^7.*l2.^2.*l3.^4 - 452357479790028.0*l1.^7.*l2.^2.*l3.^3 + 3218849215311.61*l1.^7.*l2.^2.*l3.^2 + 1352548196528.48*l1.^7.*l2.^2.*l3 - 13572189751.8586*l1.^7.*l2.^2 + 9.36708155517112e+19*l1.^7.*l2.*l3.^10 - 6.18869172894666e+18*l1.^7.*l2.*l3.^9 + 5.64250021938661e+17*l1.^7.*l2.*l3.^8 + 7.95165457015318e+16*l1.^7.*l2.*l3.^7 + 4.77778629942405e+15*l1.^7.*l2.*l3.^6 - 598814467024602.0*l1.^7.*l2.*l3.^5 - 204348913274851.0*l1.^7.*l2.*l3.^4 + 835771375203.72*l1.^7.*l2.*l3.^3 + 822870757117.889*l1.^7.*l2.*l3.^2 + 16497009471.5407*l1.^7.*l2.*l3 + 1517040881.19511*l1.^7.*l2 - 1.84438294242929e+19*l1.^7.*l3.^11 + 9.35180083485273e+17*l1.^7.*l3.^10 + 1.4707702187496e+17*l1.^7.*l3.^9 - 3.50690410730042e+15*l1.^7.*l3.^8 - 1.9027669589023e+15*l1.^7.*l3.^7 - 2763759078575.12*l1.^7.*l3.^6 - 18223648729196.8*l1.^7.*l3.^5 + 19200153214.1397*l1.^7.*l3.^4 + 208311770195.623*l1.^7.*l3.^3 + 25656313.3305438*l1.^7.*l3.^2 - 449413493.435909*l1.^7.*l3 + 11811015.0387734*l1.^7 + 6.71734294136156e+20*l1.^6.*l2.^12 - 1.31168351457004e+21*l1.^6.*l2.^11.*l3 + 1.54511003499368e+19*l1.^6.*l2.^11 + 2.96793022843935e+21*l1.^6.*l2.^10.*l3.^2 + 2.35376575424271e+19*l1.^6.*l2.^10.*l3 + 2.38557430901485e+19*l1.^6.*l2.^10 - 2.96839922900912e+21*l1.^6.*l2.^9.*l3.^3 - 2.30563148523979e+19*l1.^6.*l2.^9.*l3.^2 - 3.25959667226206e+19*l1.^6.*l2.^9.*l3 - 1.38125263106206e+17*l1.^6.*l2.^9 + 3.57748697773999e+21*l1.^6.*l2.^8.*l3.^4 + 1.0505304209887e+20*l1.^6.*l2.^8.*l3.^3 + 5.87121673362836e+19*l1.^6.*l2.^8.*l3.^2 - 3.672429981165e+17*l1.^6.*l2.^8.*l3 - 1.99267433879131e+17*l1.^6.*l2.^8 - 2.05086543889153e+21*l1.^6.*l2.^7.*l3.^5 - 5.71835115754671e+19*l1.^6.*l2.^7.*l3.^4 - 3.64323662415298e+19*l1.^6.*l2.^7.*l3.^3 + 1.70014711121924e+17*l1.^6.*l2.^7.*l3.^2 + 1.70537790298301e+17*l1.^6.*l2.^7.*l3 + 542405435574710.0*l1.^6.*l2.^7 + 1.95114110721369e+21*l1.^6.*l2.^6.*l3.^6 + 8.28872112230256e+19*l1.^6.*l2.^6.*l3.^5 + 3.70399010213265e+19*l1.^6.*l2.^6.*l3.^4 - 7.8947425263547e+17*l1.^6.*l2.^6.*l3.^3 - 3.06678579039327e+17*l1.^6.*l2.^6.*l3.^2 + 2.18032245052615e+15*l1.^6.*l2.^6.*l3 + 1.26998390672202e+15*l1.^6.*l2.^6 - 8.36203331663008e+20*l1.^6.*l2.^5.*l3.^7 - 5679.78666666667*l1.^6.*l2.^5.*l3.^6 - 9.42908401067517e+18*l1.^6.*l2.^5.*l3.^5 + 9.03378498040588e+16*l1.^6.*l2.^5.*l3.^4 + 9.45423173706997e+16*l1.^6.*l2.^5.*l3.^3 - 88156828044806.4*l1.^6.*l2.^5.*l3.^2 + 127331645449543.0*l1.^6.*l2.^5.*l3 + 126495127057.863*l1.^6.*l2.^5 + 9.64561382337457e+20*l1.^6.*l2.^4.*l3.^8 + 6.06491789436773e+18*l1.^6.*l2.^4.*l3.^7 + 1.29000863009655e+19*l1.^6.*l2.^4.*l3.^6 - 3.18146340614294e+17*l1.^6.*l2.^4.*l3.^5 - 1.30552530563379e+17*l1.^6.*l2.^4.*l3.^4 + 2.42537575549314e+15*l1.^6.*l2.^4.*l3.^3 + 1.32536142450383e+15*l1.^6.*l2.^4.*l3.^2 + 8347548965041.41*l1.^6.*l2.^4.*l3 - 593762477426.129*l1.^6.*l2.^4 - 4.97860560973349e+20*l1.^6.*l2.^3.*l3.^9 + 2.31044491214009e+19*l1.^6.*l2.^3.*l3.^8 - 3.38615351219764e+18*l1.^6.*l2.^3.*l3.^7 - 1.80675699608118e+17*l1.^6.*l2.^3.*l3.^6 + 7.29776269004023e+15*l1.^6.*l2.^3.*l3.^5 + 845426815574378.0*l1.^6.*l2.^3.*l3.^4 + 433278898460553.0*l1.^6.*l2.^3.*l3.^3 - 8913388774469.9*l1.^6.*l2.^3.*l3.^2 - 2374858533307.87*l1.^6.*l2.^3.*l3 + 18023560114.7082*l1.^6.*l2.^3 + 3.84531098732033e+20*l1.^6.*l2.^2.*l3.^10 - 7.72555017496841e+18*l1.^6.*l2.^2.*l3.^9 + 5.54899289548341e+18*l1.^6.*l2.^2.*l3.^8 + 1.57109304007059e+16*l1.^6.*l2.^2.*l3.^7 - 3.82831315485985e+16*l1.^6.*l2.^2.*l3.^6 + 422288214082793.0*l1.^6.*l2.^2.*l3.^5 + 468447135879348.0*l1.^6.*l2.^2.*l3.^4 + 1068432055327.98*l1.^6.*l2.^2.*l3.^3 - 1362599380111.57*l1.^6.*l2.^2.*l3.^2 - 57290547667.108*l1.^6.*l2.^2.*l3 - 6960627859.32645*l1.^6.*l2.^2 - 1.26547873036733e+20*l1.^6.*l2.*l3.^11 + 4.90969543829768e+18*l1.^6.*l2.*l3.^10 - 1.72215835483975e+18*l1.^6.*l2.*l3.^9 - 6.77533873530441e+16*l1.^6.*l2.*l3.^8 + 6.73203558170636e+15*l1.^6.*l2.*l3.^7 + 600373510607388.0*l1.^6.*l2.*l3.^6 + 93571512643511.1*l1.^6.*l2.*l3.^5 - 3853583692155.51*l1.^6.*l2.*l3.^4 - 967759884072.124*l1.^6.*l2.*l3.^3 + 19742533107.8547*l1.^6.*l2.*l3.^2 + 2825122914.2452*l1.^6.*l2.*l3 - 71526995.4062902*l1.^6.*l2 + 2.0769731372755e+19*l1.^6.*l3.^12 - 9.62685380058369e+17*l1.^6.*l3.^11 + 7.41559996812465e+16*l1.^6.*l3.^10 + 7.34111926461555e+15*l1.^6.*l3.^9 + 821113508760744.0*l1.^6.*l3.^8 - 2763759078575.08*l1.^6.*l3.^7 + 5576572659935.05*l1.^6.*l3.^6 - 80188875188.4644*l1.^6.*l3.^5 - 127480326357.114*l1.^6.*l3.^4 - 2924819719.68218*l1.^6.*l3.^3 + 309338161.727803*l1.^6.*l3.^2 + 44685717.5474171*l1.^6.*l3 + 4936471.19566631*l1.^6 - 3.99090686595394e+20*l1.^5.*l2.^13 + 1.07345796638641e+21*l1.^5.*l2.^12.*l3 - 1.26472791805168e+19*l1.^5.*l2.^12 - 2.51628679378898e+21*l1.^5.*l2.^11.*l3.^2 - 3.17686175419262e+18*l1.^5.*l2.^11.*l3 - 1.57381731698543e+19*l1.^5.*l2.^11 + 3.31603561625243e+21*l1.^5.*l2.^10.*l3.^3 + 1.14800231571961e+19*l1.^5.*l2.^10.*l3.^2 + 3.09309076748349e+19*l1.^5.*l2.^10.*l3 + 1.41819202099229e+17*l1.^5.*l2.^10 - 3.97114301738214e+21*l1.^5.*l2.^9.*l3.^4 - 8.01916921588621e+19*l1.^5.*l2.^9.*l3.^3 - 5.63030397506682e+19*l1.^5.*l2.^9.*l3.^2 + 1.69079536693311e+17*l1.^5.*l2.^9.*l3 + 1.56532485750635e+17*l1.^5.*l2.^9 + 2.97232813729099e+21*l1.^5.*l2.^8.*l3.^5 + 8.79413094683321e+19*l1.^5.*l2.^8.*l3.^4 + 5.10798540518479e+19*l1.^5.*l2.^8.*l3.^3 - 1.8221873741533e+17*l1.^5.*l2.^8.*l3.^2 - 2.18245683813449e+17*l1.^5.*l2.^8.*l3 - 758687299877560.0*l1.^5.*l2.^8 - 2.05086543889153e+21*l1.^5.*l2.^7.*l3.^6 - 1.24764025255565e+20*l1.^5.*l2.^7.*l3.^5 - 4.61645075641977e+19*l1.^5.*l2.^7.*l3.^4 + 8.07990706322017e+17*l1.^5.*l2.^7.*l3.^3 + 3.55970349187962e+17*l1.^5.*l2.^7.*l3.^2 - 1.6197045512798e+15*l1.^5.*l2.^7.*l3 - 1.14325611305333e+15*l1.^5.*l2.^7 + 4.57398976730297e+20*l1.^5.*l2.^6.*l3.^7 + 8.28872112230256e+19*l1.^5.*l2.^6.*l3.^6 + 1.94806744730535e+19*l1.^5.*l2.^6.*l3.^5 - 5.26316168423647e+17*l1.^5.*l2.^6.*l3.^4 - 2.15653720925927e+17*l1.^5.*l2.^6.*l3.^3 + 713971095298563.0*l1.^5.*l2.^6.*l3.^2 + 362996486416977.0*l1.^5.*l2.^6.*l3 - 2983929693632.71*l1.^5.*l2.^6 + 2.17677974975506e+20*l1.^5.*l2.^5.*l3.^8 - 7.9710349468833e+19*l1.^5.*l2.^5.*l3.^7 - 9.2136741743407e+18*l1.^5.*l2.^5.*l3.^6 + 7.54124659233882e+17*l1.^5.*l2.^5.*l3.^5 + 1.75813841554379e+17*l1.^5.*l2.^5.*l3.^4 - 3.51195826707754e+15*l1.^5.*l2.^5.*l3.^3 - 1.50373759814133e+15*l1.^5.*l2.^5.*l3.^2 - 9825960762530.14*l1.^5.*l2.^5.*l3 + 52744538540.011*l1.^5.*l2.^5 - 7.33167197716163e+20*l1.^5.*l2.^4.*l3.^9 + 4.15880084185216e+19*l1.^5.*l2.^4.*l3.^8 - 4.779017505455e+18*l1.^5.*l2.^4.*l3.^7 - 3.18146340614294e+17*l1.^5.*l2.^4.*l3.^6 - 1.78747513276862e+16*l1.^5.*l2.^4.*l3.^5 + 957040162978373.0*l1.^5.*l2.^4.*l3.^4 - 112455616055977.0*l1.^5.*l2.^4.*l3.^3 + 14417056222264.1*l1.^5.*l2.^4.*l3.^2 + 3316683309621.43*l1.^5.*l2.^4.*l3 + 2674670664.70942*l1.^5.*l2.^4 + 5.71831001714586e+20*l1.^5.*l2.^3.*l3.^10 - 3.02283209338328e+19*l1.^5.*l2.^3.*l3.^9 + 5.21154656431699e+18*l1.^5.*l2.^3.*l3.^8 + 3.38907212929513e+17*l1.^5.*l2.^3.*l3.^7 + 2.17497674885439e+15*l1.^5.*l2.^3.*l3.^6 - 2.19938530160657e+15*l1.^5.*l2.^3.*l3.^5 - 547228456622592.0*l1.^5.*l2.^3.*l3.^4 - 5859434992644.4*l1.^5.*l2.^3.*l3.^3 + 895210394592.385*l1.^5.*l2.^3.*l3.^2 + 121200424173.497*l1.^5.*l2.^3.*l3 + 17397122311.048*l1.^5.*l2.^3 - 3.59353173407429e+20*l1.^5.*l2.^2.*l3.^11 + 1.04692035081348e+19*l1.^5.*l2.^2.*l3.^10 - 5.51444198747906e+18*l1.^5.*l2.^2.*l3.^9 - 1.05207123219013e+17*l1.^5.*l2.^2.*l3.^8 + 3.22841591150828e+16*l1.^5.*l2.^2.*l3.^7 + 422288214082793.0*l1.^5.*l2.^2.*l3.^6 - 224944830187613.0*l1.^5.*l2.^2.*l3.^5 + 6640994170537.63*l1.^5.*l2.^2.*l3.^4 + 1662623681671.17*l1.^5.*l2.^2.*l3.^3 - 75314107781.8161*l1.^5.*l2.^2.*l3.^2 - 9464810175.82964*l1.^5.*l2.^2.*l3 + 144418440.203341*l1.^5.*l2.^2 + 1.21240761326154e+20*l1.^5.*l2.*l3.^12 - 3.46566736821013e+18*l1.^5.*l2.*l3.^11 + 2.17433852708709e+18*l1.^5.*l2.*l3.^10 + 5.72326750311429e+16*l1.^5.*l2.*l3.^9 - 1.36190785209043e+16*l1.^5.*l2.*l3.^8 - 598814467024602.0*l1.^5.*l2.*l3.^7 - 15638349616290.2*l1.^5.*l2.*l3.^6 + 2656397668215.05*l1.^5.*l2.*l3.^5 + 643546948836.742*l1.^5.*l2.*l3.^4 + 13931378138.4862*l1.^5.*l2.*l3.^3 + 14286509.1346517*l1.^5.*l2.*l3.^2 - 292546477.187813*l1.^5.*l2.*l3 - 33710099.7678427*l1.^5.*l2 - 1.8585176087238e+19*l1.^5.*l3.^13 + 6.3777906428867e+17*l1.^5.*l3.^12 - 2.42508351877539e+17*l1.^5.*l3.^11 - 7.24760182175421e+15*l1.^5.*l3.^10 + 974850745513829.0*l1.^5.*l3.^9 + 12188886192690.2*l1.^5.*l3.^8 - 2215648355110.64*l1.^5.*l3.^7 + 346732178631.811*l1.^5.*l3.^6 + 16972056770.8693*l1.^5.*l3.^5 - 5471208817.73882*l1.^5.*l3.^4 - 487562074.670557*l1.^5.*l3.^3 + 61144388.3234695*l1.^5.*l3.^2 + 5223539.06825786*l1.^5.*l3 + 169839.971161965*l1.^5 + 1.95717816717947e+20*l1.^4.*l2.^14 - 6.90685619791023e+20*l1.^4.*l2.^13.*l3 + 8.0865571924903e+18*l1.^4.*l2.^13 + 1.78001966686822e+21*l1.^4.*l2.^12.*l3.^2 - 7.73758374221914e+18*l1.^4.*l2.^12.*l3 + 8.32814778525283e+18*l1.^4.*l2.^12 - 2.91503601505726e+21*l1.^4.*l2.^11.*l3.^3 + 5.05409824530644e+18*l1.^4.*l2.^11.*l3.^2 - 2.19729146551759e+19*l1.^4.*l2.^11.*l3 - 1.08901062212036e+17*l1.^4.*l2.^11 + 3.93038933629301e+21*l1.^4.*l2.^10.*l3.^4 + 3.54508891206494e+19*l1.^4.*l2.^10.*l3.^3 + 4.35491669883574e+19*l1.^4.*l2.^10.*l3.^2 + 7.62167159319957e+15*l1.^4.*l2.^10.*l3 - 9.74550763688724e+16*l1.^4.*l2.^10 - 3.97114301738214e+21*l1.^4.*l2.^9.*l3.^5 - 6.11305216337064e+19*l1.^4.*l2.^9.*l3.^4 - 5.12169062347554e+19*l1.^4.*l2.^9.*l3.^3 + 4.88628638950525e+16*l1.^4.*l2.^9.*l3.^2 + 1.96762314621126e+17*l1.^4.*l2.^9.*l3 + 731096952836743.0*l1.^4.*l2.^9 + 3.57748697773999e+21*l1.^4.*l2.^8.*l3.^6 + 8.7941309468332e+19*l1.^4.*l2.^8.*l3.^5 + 5.0554747253888e+19*l1.^4.*l2.^8.*l3.^4 - 5.0008452570104e+17*l1.^4.*l2.^8.*l3.^3 - 3.37950078336592e+17*l1.^4.*l2.^8.*l3.^2 + 559838377454954.0*l1.^4.*l2.^8.*l3 + 804141510049980.0*l1.^4.*l2.^8 - 2.67811314828077e+21*l1.^4.*l2.^7.*l3.^7 - 5.71835115754671e+19*l1.^4.*l2.^7.*l3.^6 - 3.4087169430566e+19*l1.^4.*l2.^7.*l3.^5 + 4.76938958592858e+17*l1.^4.*l2.^7.*l3.^4 + 3.06831262242348e+17*l1.^4.*l2.^7.*l3.^3 - 488264103881596.0*l1.^4.*l2.^7.*l3.^2 - 679701101031792.0*l1.^4.*l2.^7.*l3 + 5572562115209.63*l1.^4.*l2.^7 + 2.08033842206562e+21*l1.^4.*l2.^6.*l3.^8 + 2.74365333316635e+19*l1.^4.*l2.^6.*l3.^7 + 2.29496731987561e+19*l1.^4.*l2.^6.*l3.^6 - 5.26316168423647e+17*l1.^4.*l2.^6.*l3.^5 - 2.62940149728079e+17*l1.^4.*l2.^6.*l3.^4 + 2.66844482317295e+15*l1.^4.*l2.^6.*l3.^3 + 1.49107691173465e+15*l1.^4.*l2.^6.*l3.^2 + 5884282249745.06*l1.^4.*l2.^6.*l3 + 560741632651.147*l1.^4.*l2.^6 - 1.49851853102291e+21*l1.^4.*l2.^5.*l3.^9 + 1.25630442097617e+19*l1.^4.*l2.^5.*l3.^8 - 1.30039165698294e+19*l1.^4.*l2.^5.*l3.^7 + 9.03378498040586e+16*l1.^4.*l2.^5.*l3.^6 + 1.38559700993156e+17*l1.^4.*l2.^5.*l3.^5 - 865977844620195.0*l1.^4.*l2.^5.*l3.^4 - 510545004793995.0*l1.^4.*l2.^5.*l3.^3 - 15579230202108.2*l1.^4.*l2.^5.*l3.^2 - 3958711325348.82*l1.^4.*l2.^5.*l3 - 49580825511.279*l1.^4.*l2.^5 + 1.10332795442878e+21*l1.^4.*l2.^4.*l3.^10 - 1.87723649111382e+19*l1.^4.*l2.^4.*l3.^9 + 1.11400510938396e+19*l1.^4.*l2.^4.*l3.^8 + 3.08607561442437e+16*l1.^4.*l2.^4.*l3.^7 - 9.95074134290265e+16*l1.^4.*l2.^4.*l3.^6 + 957040162978373.0*l1.^4.*l2.^4.*l3.^5 + 803080381973520.0*l1.^4.*l2.^4.*l3.^4 + 14597763546632.4*l1.^4.*l2.^4.*l3.^3 + 1119246366143.47*l1.^4.*l2.^4.*l3.^2 - 145747101952.496*l1.^4.*l2.^4.*l3 - 27913780594.0518*l1.^4.*l2.^4 - 6.5127311576983e+20*l1.^4.*l2.^3.*l3.^11 + 1.62693829229864e+19*l1.^4.*l2.^3.*l3.^10 - 7.96697105934834e+18*l1.^4.*l2.^3.*l3.^9 - 1.6272035057874e+17*l1.^4.*l2.^3.*l3.^8 + 5.61129926774757e+16*l1.^4.*l2.^3.*l3.^7 + 845426815574379.0*l1.^4.*l2.^3.*l3.^6 - 114375766395573.0*l1.^4.*l2.^3.*l3.^5 - 14354938079512.5*l1.^4.*l2.^3.*l3.^4 - 2653350863533.09*l1.^4.*l2.^3.*l3.^3 + 148947727040.482*l1.^4.*l2.^3.*l3.^2 + 24540883039.8593*l1.^4.*l2.^3.*l3 - 19294167.1662273*l1.^4.*l2.^3 + 3.09219480922851e+20*l1.^4.*l2.^2.*l3.^12 - 5.99271649086335e+18*l1.^4.*l2.^2.*l3.^11 + 5.19562965702239e+18*l1.^4.*l2.^2.*l3.^10 + 7.2476018217542e+16*l1.^4.*l2.^2.*l3.^9 - 4.14966428822435e+16*l1.^4.*l2.^2.*l3.^8 - 332005417516007.0*l1.^4.*l2.^2.*l3.^7 + 247277223501169.0*l1.^4.*l2.^2.*l3.^6 + 2371783632334.86*l1.^4.*l2.^2.*l3.^5 - 213105799053.365*l1.^4.*l2.^2.*l3.^4 - 74903606768.5274*l1.^4.*l2.^2.*l3.^3 - 10652783125.5571*l1.^4.*l2.^2.*l3.^2 + 748954798.39731*l1.^4.*l2.^2.*l3 + 107381741.687419*l1.^4.*l2.^2 - 9.34627626673762e+19*l1.^4.*l2.*l3.^13 + 1.44402807008755e+18*l1.^4.*l2.*l3.^12 - 1.95082062315268e+18*l1.^4.*l2.*l3.^11 - 2.94112357798929e+16*l1.^4.*l2.*l3.^10 + 1.70479964575201e+16*l1.^4.*l2.*l3.^9 + 351493462300831.0*l1.^4.*l2.*l3.^8 - 63014934773665.3*l1.^4.*l2.*l3.^7 - 3711276674215.42*l1.^4.*l2.*l3.^6 - 502613325079.226*l1.^4.*l2.*l3.^5 + 41768478102.128*l1.^4.*l2.*l3.^4 + 6303435278.93379*l1.^4.*l2.*l3.^3 - 348574180.29593*l1.^4.*l2.*l3.^2 - 47510144.1859241*l1.^4.*l2.*l3 - 194573.947544775*l1.^4.*l2 + 1.32045993751291e+19*l1.^4.*l3.^14 - 2.28637777763863e+17*l1.^4.*l3.^13 + 2.65509857803053e+17*l1.^4.*l3.^12 + 3.41338666443908e+15*l1.^4.*l3.^11 - 2.19096518531071e+15*l1.^4.*l3.^10 + 1889749797316.17*l1.^4.*l3.^9 + 9159058014714.05*l1.^4.*l3.^8 - 123106864725.952*l1.^4.*l3.^7 + 68677648628.3234*l1.^4.*l3.^6 - 853072418.240635*l1.^4.*l3.^5 - 894630503.235437*l1.^4.*l3.^4 + 43065433.8958886*l1.^4.*l3.^3 + 12784871.3168658*l1.^4.*l3.^2 + 626594.06836453*l1.^4.*l3 + 92763.1136368584*l1.^4 - 7.69390145230899e+19*l1.^3.*l2.^15 + 3.44602576540088e+20*l1.^3.*l2.^14.*l3 - 3.9917061651706e+18*l1.^3.*l2.^14 - 1.00196623479682e+21*l1.^3.*l2.^13.*l3.^2 + 8.66416842052532e+18*l1.^3.*l2.^13.*l3 - 3.42176510076508e+18*l1.^3.*l2.^13 + 1.94079018235802e+21*l1.^3.*l2.^12.*l3.^3 - 1.24667756717559e+19*l1.^3.*l2.^12.*l3.^2 + 1.15896250377631e+19*l1.^3.*l2.^12.*l3 + 6.28904803242542e+16*l1.^3.*l2.^12 - 2.91503601505726e+21*l1.^3.*l2.^11.*l3.^4 - 4.62088982428017e+18*l1.^3.*l2.^11.*l3.^3 - 2.58562635547151e+19*l1.^3.*l2.^11.*l3.^2 - 7.93027915464201e+16*l1.^3.*l2.^11.*l3 + 4.67292386574698e+16*l1.^3.*l2.^11 + 3.31603561625242e+21*l1.^3.*l2.^10.*l3.^5 + 3.54508891206494e+19*l1.^3.*l2.^10.*l3.^4 + 3.68841371285331e+19*l1.^3.*l2.^10.*l3.^3 + 6.45270355743277e+16*l1.^3.*l2.^10.*l3.^2 - 1.27582554581526e+17*l1.^3.*l2.^10.*l3 - 507185223727228.0*l1.^3.*l2.^10 - 2.96839922900912e+21*l1.^3.*l2.^9.*l3.^6 - 8.01916921588621e+19*l1.^3.*l2.^9.*l3.^5 - 4.06131323189411e+19*l1.^3.*l2.^9.*l3.^4 + 2.28182560581681e+17*l1.^3.*l2.^9.*l3.^3 + 2.45040894741202e+17*l1.^3.*l2.^9.*l3.^2 + 195825322746901.0*l1.^3.*l2.^9.*l3 - 432740234382988.0*l1.^3.*l2.^9 + 1.87228553773066e+21*l1.^3.*l2.^8.*l3.^7 + 1.0505304209887e+20*l1.^3.*l2.^8.*l3.^6 + 3.19930610033822e+19*l1.^3.*l2.^8.*l3.^5 - 5.0008452570104e+17*l1.^3.*l2.^8.*l3.^4 - 2.84324943441848e+17*l1.^3.*l2.^8.*l3.^3 + 88936349836200.0*l1.^3.*l2.^8.*l3.^2 + 638438341019966.0*l1.^3.*l2.^8.*l3 - 5948659234051.3*l1.^3.*l2.^8 - 6.26471918973076e+20*l1.^3.*l2.^7.*l3.^8 - 1.11891546459356e+20*l1.^3.*l2.^7.*l3.^7 - 1.903486759933e+19*l1.^3.*l2.^7.*l3.^6 + 8.07990706322016e+17*l1.^3.*l2.^7.*l3.^5 + 2.58327311890806e+17*l1.^3.*l2.^7.*l3.^4 - 2.09478765032511e+15*l1.^3.*l2.^7.*l3.^3 - 1.1907972513037e+15*l1.^3.*l2.^7.*l3.^2 + 1066173213773.39*l1.^3.*l2.^7.*l3 - 786232034534.438*l1.^3.*l2.^7 - 3.70004423189357e+20*l1.^3.*l2.^6.*l3.^9 + 9.09015670120115e+19*l1.^3.*l2.^6.*l3.^8 + 5.16888838800707e+18*l1.^3.*l2.^6.*l3.^7 - 7.89474252635471e+17*l1.^3.*l2.^6.*l3.^6 - 1.47748190433768e+17*l1.^3.*l2.^6.*l3.^5 + 2.66844482317294e+15*l1.^3.*l2.^6.*l3.^4 + 811245870214656.0*l1.^3.*l2.^6.*l3.^3 + 9369674768500.04*l1.^3.*l2.^6.*l3.^2 + 3842970502695.42*l1.^3.*l2.^6.*l3 + 87346918733.842*l1.^3.*l2.^6 + 7.79244446676222e+20*l1.^3.*l2.^5.*l3.^10 - 6.32484294698348e+19*l1.^3.*l2.^5.*l3.^9 + 3.19574839536361e+18*l1.^3.*l2.^5.*l3.^8 + 6.84547681745042e+17*l1.^3.*l2.^5.*l3.^7 + 5.14728805860228e+16*l1.^3.*l2.^5.*l3.^6 - 3.51195826707754e+15*l1.^3.*l2.^5.*l3.^5 - 735854389118522.0*l1.^3.*l2.^5.*l3.^4 - 17718353154318.7*l1.^3.*l2.^5.*l3.^3 - 3330979831641.33*l1.^3.*l2.^5.*l3.^2 + 84152707724.1891*l1.^3.*l2.^5.*l3 + 30061498887.502*l1.^3.*l2.^5 - 7.35327068761165e+20*l1.^3.*l2.^4.*l3.^11 + 3.31404442085094e+19*l1.^3.*l2.^4.*l3.^10 - 7.03359853208103e+18*l1.^3.*l2.^4.*l3.^9 - 4.1451606548291e+17*l1.^3.*l2.^4.*l3.^8 + 2.24049174984686e+16*l1.^3.*l2.^4.*l3.^7 + 2.42537575549314e+15*l1.^3.*l2.^4.*l3.^6 + 119494762439087.0*l1.^3.*l2.^4.*l3.^5 + 19578509174535.6*l1.^3.*l2.^4.*l3.^4 + 3652395435121.81*l1.^3.*l2.^4.*l3.^3 - 183109108240.103*l1.^3.*l2.^4.*l3.^2 - 41071142866.716*l1.^3.*l2.^4.*l3 - 362815620.811996*l1.^3.*l2.^4 + 4.54712508554322e+20*l1.^3.*l2.^3.*l3.^12 - 1.34775953208172e+19*l1.^3.*l2.^3.*l3.^11 + 6.14362124895914e+18*l1.^3.*l2.^3.*l3.^10 + 2.15090118581092e+17*l1.^3.*l2.^3.*l3.^9 - 4.0715243525529e+16*l1.^3.*l2.^3.*l3.^8 - 1.74754612506825e+15*l1.^3.*l2.^3.*l3.^7 - 12453049895327.0*l1.^3.*l2.^3.*l3.^6 - 8136347279685.87*l1.^3.*l2.^3.*l3.^5 - 692537148333.141*l1.^3.*l2.^3.*l3.^4 + 183904453953.35*l1.^3.*l2.^3.*l3.^3 + 29743486332.716*l1.^3.*l2.^3.*l3.^2 - 995109996.299255*l1.^3.*l2.^3.*l3 - 190466946.678769*l1.^3.*l2.^3 - 1.98448951614853e+20*l1.^3.*l2.^2.*l3.^13 + 3.17686175419262e+18*l1.^3.*l2.^2.*l3.^12 - 3.60424362365678e+18*l1.^3.*l2.^2.*l3.^11 - 6.49946227886345e+16*l1.^3.*l2.^2.*l3.^10 + 3.24664029285597e+16*l1.^3.*l2.^2.*l3.^9 + 609798637721503.0*l1.^3.*l2.^2.*l3.^8 - 131965023997899.0*l1.^3.*l2.^2.*l3.^7 + 4199186450010.01*l1.^3.*l2.^2.*l3.^6 + 432257194557.062*l1.^3.*l2.^2.*l3.^5 - 115312300264.137*l1.^3.*l2.^2.*l3.^4 - 13420330778.3247*l1.^3.*l2.^2.*l3.^3 + 953750124.141818*l1.^3.*l2.^2.*l3.^2 + 136872113.618105*l1.^3.*l2.^2.*l3 - 750263.950278581*l1.^3.*l2.^2 + 5.4915970224221e+19*l1.^3.*l2.*l3.^14 - 2.88805614017511e+17*l1.^3.*l2.*l3.^13 + 1.25783875747019e+18*l1.^3.*l2.*l3.^12 + 1.23443024576975e+16*l1.^3.*l2.*l3.^11 - 1.34442892170828e+16*l1.^3.*l2.*l3.^10 - 197715072544218.0*l1.^3.*l2.*l3.^9 + 65195199532310.6*l1.^3.*l2.*l3.^8 + 835771375203.718*l1.^3.*l2.*l3.^7 + 209034758909.613*l1.^3.*l2.*l3.^6 + 16240446338.2353*l1.^3.*l2.*l3.^5 - 208409156.772756*l1.^3.*l2.*l3.^4 - 369083560.200804*l1.^3.*l2.*l3.^3 - 49030174.8364682*l1.^3.*l2.*l3.^2 - 2153504.87706336*l1.^3.*l2.*l3 - 327426.714568772*l1.^3.*l2 - 7.18076310961731e+18*l1.^3.*l3.^15 + 3.43816207163708e+15*l1.^3.*l3.^14 - 1.78691956675214e+17*l1.^3.*l3.^13 - 467587214306723.0*l1.^3.*l3.^12 + 2.01318189266048e+15*l1.^3.*l3.^11 - 9472370859047.89*l1.^3.*l3.^10 - 11188275704668.4*l1.^3.*l3.^9 + 170542537372.65*l1.^3.*l3.^8 - 72991577936.1836*l1.^3.*l3.^7 - 4079353819.55673*l1.^3.*l3.^6 + 850623608.978224*l1.^3.*l3.^5 + 69928031.2764923*l1.^3.*l3.^4 - 1864684.29379108*l1.^3.*l3.^3 - 522711.367556726*l1.^3.*l3.^2 - 37991.0309839528*l1.^3.*l3 + 845.206349206349*l1.^3 + 2.31139995715999e+19*l1.^2.*l2.^16 - 1.29196727131924e+20*l1.^2.*l2.^15.*l3 + 1.47153336666065e+18*l1.^2.*l2.^15 + 4.34777633458962e+20*l1.^2.*l2.^14.*l3.^2 - 5.18818656610028e+18*l1.^2.*l2.^14.*l3 + 1.03017060414577e+18*l1.^2.*l2.^14 - 1.00196623479682e+21*l1.^2.*l2.^13.*l3.^3 + 1.12634189466829e+19*l1.^2.*l2.^13.*l3.^2 - 4.33571147161073e+18*l1.^2.*l2.^13.*l3 - 2.67927473797752e+16*l1.^2.*l2.^13 + 1.78001966686823e+21*l1.^2.*l2.^12.*l3.^4 - 1.24667756717559e+19*l1.^2.*l2.^12.*l3.^3 + 1.1029766129526e+19*l1.^2.*l2.^12.*l3.^2 + 6.9623736210271e+16*l1.^2.*l2.^12.*l3 - 1.63731235407023e+16*l1.^2.*l2.^12 - 2.51628679378898e+21*l1.^2.*l2.^11.*l3.^5 + 5.05409824530644e+18*l1.^2.*l2.^11.*l3.^4 - 1.85258967026386e+19*l1.^2.*l2.^11.*l3.^3 - 1.18393082662462e+17*l1.^2.*l2.^11.*l3.^2 + 5.79921161251011e+16*l1.^2.*l2.^11.*l3 + 255352441362365.0*l1.^2.*l2.^11 + 2.96793022843935e+21*l1.^2.*l2.^10.*l3.^6 + 1.1480023157196e+19*l1.^2.*l2.^10.*l3.^5 + 2.33906581451469e+19*l1.^2.*l2.^10.*l3.^4 + 6.45270355743277e+16*l1.^2.*l2.^10.*l3.^3 - 1.29039725169923e+17*l1.^2.*l2.^10.*l3.^2 - 437075506246793.0*l1.^2.*l2.^10.*l3 + 170964780025457.0*l1.^2.*l2.^10 - 2.98968762329269e+21*l1.^2.*l2.^9.*l3.^7 - 2.30563148523979e+19*l1.^2.*l2.^9.*l3.^6 - 2.23482864137358e+19*l1.^2.*l2.^9.*l3.^5 + 4.88628638950524e+16*l1.^2.*l2.^9.*l3.^4 + 1.86353455412083e+17*l1.^2.*l2.^9.*l3.^3 + 567869814093549.0*l1.^2.*l2.^9.*l3.^2 - 383678483519268.0*l1.^2.*l2.^9.*l3 + 4162292037951.47*l1.^2.*l2.^9 + 2.68014122311302e+21*l1.^2.*l2.^8.*l3.^8 + 2.26196682693e+19*l1.^2.*l2.^8.*l3.^7 + 1.73234338551178e+19*l1.^2.*l2.^8.*l3.^6 - 1.8221873741533e+17*l1.^2.*l2.^8.*l3.^5 - 2.05903339846073e+17*l1.^2.*l2.^8.*l3.^4 + 88936349836199.0*l1.^2.*l2.^8.*l3.^3 + 750045631533584.0*l1.^2.*l2.^8.*l3.^2 - 5655009831952.7*l1.^2.*l2.^8.*l3 + 574967370952.717*l1.^2.*l2.^8 - 2.18053763151336e+21*l1.^2.*l2.^7.*l3.^9 - 9.46869834528839e+18*l1.^2.*l2.^7.*l3.^8 - 1.14784909479247e+19*l1.^2.*l2.^7.*l3.^7 + 1.70014711121925e+17*l1.^2.*l2.^7.*l3.^6 + 1.73797937814058e+17*l1.^2.*l2.^7.*l3.^5 - 488264103881597.0*l1.^2.*l2.^7.*l3.^4 - 805921111510252.0*l1.^2.*l2.^7.*l3.^3 + 1531494574021.93*l1.^2.*l2.^7.*l3.^2 - 2810613019956.53*l1.^2.*l2.^7.*l3 - 85435523390.7163*l1.^2.*l2.^7 + 1.63553252203771e+21*l1.^2.*l2.^6.*l3.^10 - 2.76772046766781e+18*l1.^2.*l2.^6.*l3.^9 + 8.04035181114279e+18*l1.^2.*l2.^6.*l3.^8 - 7.79935473463614e+16*l1.^2.*l2.^6.*l3.^7 - 1.28096864349185e+17*l1.^2.*l2.^6.*l3.^6 + 713971095298563.0*l1.^2.*l2.^6.*l3.^5 + 814697526737314.0*l1.^2.*l2.^6.*l3.^4 + 7661990553218.89*l1.^2.*l2.^6.*l3.^3 + 4183482328870.46*l1.^2.*l2.^6.*l3.^2 + 33237753919.7217*l1.^2.*l2.^6.*l3 - 21852569500.959*l1.^2.*l2.^6 - 1.09999146791926e+21*l1.^2.*l2.^5.*l3.^11 + 7.65334877146404e+18*l1.^2.*l2.^5.*l3.^10 - 6.45198061469378e+18*l1.^2.*l2.^5.*l3.^9 - 3.57704218944643e+16*l1.^2.*l2.^5.*l3.^8 + 8.76535474500108e+16*l1.^2.*l2.^5.*l3.^7 - 88156828044803.9*l1.^2.*l2.^5.*l3.^6 - 555189021334527.0*l1.^2.*l2.^5.*l3.^5 - 14298467040647.3*l1.^2.*l2.^5.*l3.^4 - 4885980914160.34*l1.^2.*l2.^5.*l3.^3 + 67501760372.6651*l1.^2.*l2.^5.*l3.^2 + 45535510646.6314*l1.^2.*l2.^5.*l3 + 690688545.507477*l1.^2.*l2.^5 + 6.39393825022315e+20*l1.^2.*l2.^4.*l3.^12 - 4.98189684180206e+18*l1.^2.*l2.^4.*l3.^11 + 5.37487960575866e+18*l1.^2.*l2.^4.*l3.^10 + 5.82146081811869e+16*l1.^2.*l2.^4.*l3.^9 - 6.33751720181316e+16*l1.^2.*l2.^4.*l3.^8 - 227832959938944.0*l1.^2.*l2.^4.*l3.^7 + 415608590832031.0*l1.^2.*l2.^4.*l3.^6 + 11428608845522.2*l1.^2.*l2.^4.*l3.^5 + 3111103306787.0*l1.^2.*l2.^4.*l3.^4 - 154245755743.239*l1.^2.*l2.^4.*l3.^3 - 50949479889.1892*l1.^2.*l2.^4.*l3.^2 + 384774728.194553*l1.^2.*l2.^4.*l3 + 208668985.470149*l1.^2.*l2.^4 - 3.00954374390641e+20*l1.^2.*l2.^3.*l3.^13 + 1.39589380108464e+18*l1.^2.*l2.^3.*l3.^12 - 3.65151541595834e+18*l1.^2.*l2.^3.*l3.^11 - 3.54431108444495e+16*l1.^2.*l2.^3.*l3.^10 + 4.19972816971451e+16*l1.^2.*l2.^3.*l3.^9 + 349367493778850.0*l1.^2.*l2.^3.*l3.^8 - 239287238706086.0*l1.^2.*l2.^3.*l3.^7 - 7490318595068.97*l1.^2.*l2.^3.*l3.^6 - 1890157175040.73*l1.^2.*l2.^3.*l3.^5 + 137402386041.736*l1.^2.*l2.^3.*l3.^4 + 35986704794.6165*l1.^2.*l2.^3.*l3.^3 - 991101926.213895*l1.^2.*l2.^3.*l3.^2 - 250171590.800596*l1.^2.*l2.^3.*l3 + 1965526.656554*l1.^2.*l2.^3 + 1.07152524912614e+20*l1.^2.*l2.^2.*l3.^14 + 2.88805614017511e+17*l1.^2.*l2.^2.*l3.^13 + 1.81690114559439e+18*l1.^2.*l2.^2.*l3.^12 + 5.33049424309665e+15*l1.^2.*l2.^2.*l3.^11 - 2.2411939494483e+16*l1.^2.*l2.^2.*l3.^10 - 109251160157348.0*l1.^2.*l2.^2.*l3.^9 + 141190437770387.0*l1.^2.*l2.^2.*l3.^8 + 2365007107671.06*l1.^2.*l2.^2.*l3.^7 + 668358330259.531*l1.^2.*l2.^2.*l3.^6 - 54532493984.0744*l1.^2.*l2.^2.*l3.^5 - 15603822945.7885*l1.^2.*l2.^2.*l3.^4 + 792574539.858195*l1.^2.*l2.^2.*l3.^3 + 177880577.533824*l1.^2.*l2.^2.*l3.^2 + 2379408.52802636*l1.^2.*l2.^2.*l3 + 444804.891240446*l1.^2.*l2.^2 - 2.54077238493915e+19*l1.^2.*l2.*l3.^15 - 3.09434586447333e+17*l1.^2.*l2.*l3.^14 - 5.68642751749348e+17*l1.^2.*l2.*l3.^13 + 2.24441862867226e+15*l1.^2.*l2.*l3.^12 + 7.7481079135556e+15*l1.^2.*l2.*l3.^11 + 10866061334568.8*l1.^2.*l2.*l3.^10 - 53930608270756.6*l1.^2.*l2.*l3.^9 - 1111350044865.48*l1.^2.*l2.*l3.^8 - 259544323123.411*l1.^2.*l2.*l3.^7 + 22051601307.6038*l1.^2.*l2.*l3.^6 + 5901809098.65114*l1.^2.*l2.*l3.^5 - 348574180.29593*l1.^2.*l2.*l3.^4 - 66280999.0918247*l1.^2.*l2.*l3.^3 + 1474144.9924155*l1.^2.*l2.*l3.^2 + 91418.2036710431*l1.^2.*l2.*l3 - 187.823633156967*l1.^2.*l2 + 2.95872947164765e+18*l1.^2.*l3.^16 + 5.84487552178296e+16*l1.^2.*l3.^15 + 7.84631518274452e+16*l1.^2.*l3.^14 - 935174428613445.0*l1.^2.*l3.^13 - 1.14021791655302e+15*l1.^2.*l3.^12 + 15755788935124.6*l1.^2.*l3.^11 + 8761841675829.04*l1.^2.*l3.^10 + 18447206029.2716*l1.^2.*l3.^9 + 57912038877.8131*l1.^2.*l3.^8 - 2283411886.41854*l1.^2.*l3.^7 - 1341008445.016*l1.^2.*l3.^6 + 61144388.3234695*l1.^2.*l3.^5 + 18251829.6119028*l1.^2.*l3.^4 + 169839.971161965*l1.^2.*l3.^3 + 17016.5000979816*l1.^2.*l3.^2 + 1721.71663727219*l1.^2.*l3 + 315.168959435626*l1.^2 - 4.8090190002e+18*l1.*l2.^17 + 3.30670379789799e+19*l1.*l2.^16.*l3 - 3.68742882183072e+17*l1.*l2.^16 - 1.29196727131924e+20*l1.*l2.^15.*l3.^2 + 1.84285487039745e+18*l1.*l2.^15.*l3 - 2.02922863756319e+17*l1.*l2.^15 + 3.44602576540088e+20*l1.*l2.^14.*l3.^3 - 5.18818656610028e+18*l1.*l2.^14.*l3.^2 + 1.03462461681744e+18*l1.*l2.^14.*l3 + 7.66843031463025e+15*l1.*l2.^14 - 6.90685619791023e+20*l1.*l2.^13.*l3.^4 + 8.66416842052532e+18*l1.*l2.^13.*l3.^3 - 3.00890658363976e+18*l1.*l2.^13.*l3.^2 - 3.0673721258521e+16*l1.*l2.^13.*l3 + 3.7679869572501e+15*l1.*l2.^13 + 1.07345796638641e+21*l1.*l2.^12.*l3.^5 - 7.73758374221914e+18*l1.*l2.^12.*l3.^4 + 5.84013718988892e+18*l1.*l2.^12.*l3.^3 + 6.9623736210271e+16*l1.*l2.^12.*l3.^2 - 1.68024610730944e+16*l1.*l2.^12.*l3 - 84731656537169.5*l1.*l2.^12 - 1.31168351457004e+21*l1.*l2.^11.*l3.^6 - 3.17686175419262e+18*l1.*l2.^11.*l3.^5 - 8.38963453759149e+18*l1.*l2.^11.*l3.^4 - 7.93027915464202e+16*l1.*l2.^11.*l3.^3 + 4.36733526805572e+16*l1.*l2.^11.*l3.^2 + 255210710127566.0*l1.*l2.^11.*l3 - 45065313224835.7*l1.*l2.^11 + 1.2356537029059e+21*l1.*l2.^10.*l3.^7 + 2.35376575424271e+19*l1.*l2.^10.*l3.^6 + 9.11109495343344e+18*l1.*l2.^10.*l3.^5 + 7.62167159319958e+15*l1.*l2.^10.*l3.^4 - 7.50804219515317e+16*l1.*l2.^10.*l3.^3 - 437075506246794.0*l1.*l2.^10.*l3.^2 + 141671455393798.0*l1.*l2.^10.*l3 - 1817614504271.86*l1.*l2.^10 - 8.3483893965458e+20*l1.*l2.^9.*l3.^8 - 4.52324602144568e+19*l1.*l2.^9.*l3.^7 - 7.54786329926233e+18*l1.*l2.^9.*l3.^6 + 1.69079536693311e+17*l1.*l2.^9.*l3.^5 + 9.48507027106992e+16*l1.*l2.^9.*l3.^4 + 195825322746901.0*l1.*l2.^9.*l3.^3 - 309398985244797.0*l1.*l2.^9.*l3.^2 + 4583942461477.67*l1.*l2.^9.*l3 - 241798590379.451*l1.*l2.^9 + 2.80882413602424e+20*l1.*l2.^8.*l3.^9 + 5.62010567634968e+19*l1.*l2.^8.*l3.^8 + 4.40508790414506e+18*l1.*l2.^8.*l3.^7 - 3.672429981165e+17*l1.*l2.^8.*l3.^6 - 8.76234777708895e+16*l1.*l2.^8.*l3.^5 + 559838377454953.0*l1.*l2.^8.*l3.^4 + 416548559649484.0*l1.*l2.^8.*l3.^3 - 5228088778132.43*l1.*l2.^8.*l3.^2 + 1346144038219.31*l1.*l2.^8.*l3 + 47983720006.4526*l1.*l2.^8 + 1.7726752237352e+20*l1.*l2.^7.*l3.^10 - 5.12011095708187e+19*l1.*l2.^7.*l3.^9 - 1.1389512094318e+18*l1.*l2.^7.*l3.^8 + 4.75816749278521e+17*l1.*l2.^7.*l3.^7 + 5.70989860328558e+16*l1.*l2.^7.*l3.^6 - 1.6197045512798e+15*l1.*l2.^7.*l3.^5 - 430257035093422.0*l1.*l2.^7.*l3.^4 - 72282929747.3541*l1.*l2.^7.*l3.^3 - 2810941947050.51*l1.*l2.^7.*l3.^2 - 71093644238.9415*l1.*l2.^7.*l3 + 9942481247.69766*l1.*l2.^7 - 3.89142937668124e+20*l1.*l2.^6.*l3.^11 + 3.47048079511042e+19*l1.*l2.^6.*l3.^10 - 1.21708677139263e+18*l1.*l2.^6.*l3.^9 - 4.26860367940607e+17*l1.*l2.^6.*l3.^8 - 1.8423384361159e+16*l1.*l2.^6.*l3.^7 + 2.18032245052614e+15*l1.*l2.^6.*l3.^6 + 288121401913927.0*l1.*l2.^6.*l3.^5 + 8730422608546.91*l1.*l2.^6.*l3.^4 + 3818081685917.5*l1.*l2.^6.*l3.^3 + 21692412920.9762*l1.*l2.^6.*l3.^2 - 29741398315.3598*l1.*l2.^6.*l3 - 577375287.509136*l1.*l2.^6 + 3.68436973916698e+20*l1.*l2.^5.*l3.^12 - 1.70395312270331e+19*l1.*l2.^5.*l3.^11 + 2.20493989317309e+18*l1.*l2.^5.*l3.^10 + 2.76437561098134e+17*l1.*l2.^5.*l3.^9 - 9.74075768083499e+15*l1.*l2.^5.*l3.^8 - 1.97389090704181e+15*l1.*l2.^5.*l3.^7 - 117770982794743.0*l1.*l2.^5.*l3.^6 - 13241329193092.4*l1.*l2.^5.*l3.^5 - 3111165759425.99*l1.*l2.^5.*l3.^4 + 103779787422.056*l1.*l2.^5.*l3.^3 + 44733340864.2493*l1.*l2.^5.*l3.^2 + 313396969.440377*l1.*l2.^5.*l3 - 134997343.550572*l1.*l2.^5 - 2.37353371685459e+20*l1.*l2.^4.*l3.^13 + 5.30680315757176e+18*l1.*l2.^4.*l3.^12 - 2.05334668463985e+18*l1.*l2.^4.*l3.^11 - 1.21853228048332e+17*l1.*l2.^4.*l3.^10 + 2.03725873992467e+16*l1.*l2.^4.*l3.^9 + 1.18487312291732e+15*l1.*l2.^4.*l3.^8 - 23826994106446.1*l1.*l2.^4.*l3.^7 + 11335996341783.3*l1.*l2.^4.*l3.^6 + 1626213603446.21*l1.*l2.^4.*l3.^5 - 180383124948.732*l1.*l2.^4.*l3.^4 - 39465567255.6065*l1.*l2.^4.*l3.^3 + 505656416.40727*l1.*l2.^4.*l3.^2 + 247843099.286578*l1.*l2.^4.*l3 - 1470847.12889779*l1.*l2.^4 + 1.10579520304018e+20*l1.*l2.^3.*l3.^14 - 4.81342690029185e+17*l1.*l2.^3.*l3.^13 + 1.3102835703341e+18*l1.*l2.^3.*l3.^12 + 3.10477910299664e+16*l1.*l2.^3.*l3.^11 - 1.68577803492885e+16*l1.*l2.^3.*l3.^10 - 463933575241151.0*l1.*l2.^3.*l3.^9 + 67100916806880.9*l1.*l2.^3.*l3.^8 - 5561267907436.6*l1.*l2.^3.*l3.^7 - 295049374982.657*l1.*l2.^3.*l3.^6 + 143136572071.113*l1.*l2.^3.*l3.^5 + 19634614215.2622*l1.*l2.^3.*l3.^4 - 1102560385.82167*l1.*l2.^3.*l3.^3 - 249625944.291303*l1.*l2.^3.*l3.^2 - 1233400.95562281*l1.*l2.^3.*l3 - 241434.526966708*l1.*l2.^3 - 3.65908602424017e+19*l1.*l2.^2.*l3.^15 - 4.22893934811355e+17*l1.*l2.^2.*l3.^14 - 5.81920363615431e+17*l1.*l2.^2.*l3.^13 - 46758721430668.3*l1.*l2.^2.*l3.^12 + 8.71904542827763e+15*l1.*l2.^2.*l3.^11 + 76841951133374.0*l1.*l2.^2.*l3.^10 - 52472654188346.4*l1.*l2.^2.*l3.^9 + 1714460739944.91*l1.*l2.^2.*l3.^8 - 127868667430.255*l1.*l2.^2.*l3.^7 - 66526820466.1044*l1.*l2.^2.*l3.^6 - 4379457368.6952*l1.*l2.^2.*l3.^5 + 869836486.610027*l1.*l2.^2.*l3.^4 + 127092449.259229*l1.*l2.^2.*l3.^3 - 1775899.50428579*l1.*l2.^2.*l3.^2 - 191184.124371285*l1.*l2.^2.*l3 - 3881.68841857731*l1.*l2.^2 + 7.83577706326508e+18*l1.*l2.*l3.^16 + 2.06289724298222e+17*l1.*l2.*l3.^15 + 1.63119260099674e+17*l1.*l2.*l3.^14 - 2.61848840011765e+15*l1.*l2.*l3.^13 - 2.73778020005678e+15*l1.*l2.*l3.^12 + 12141642447757.2*l1.*l2.*l3.^11 + 21189294900056.6*l1.*l2.*l3.^10 - 137036387646.015*l1.*l2.*l3.^9 + 107714420281.681*l1.*l2.*l3.^8 + 13033407171.9171*l1.*l2.*l3.^7 - 832502217.971775*l1.*l2.*l3.^6 - 292546477.187813*l1.*l2.*l3.^5 - 29377890.9540165*l1.*l2.*l3.^4 + 616700.477811406*l1.*l2.*l3.^3 + 91418.2036710431*l1.*l2.*l3.^2 - 2504.31510875955*l1.*l2.*l3 - 794.141798941799*l1.*l2 - 8.21485647116353e+17*l1.*l3.^17 - 3.18029991626426e+16*l1.*l3.^16 - 2.10662094153716e+16*l1.*l3.^15 + 607863378598739.0*l1.*l3.^14 + 381740453330136.0*l1.*l3.^13 - 8338520980658.15*l1.*l3.^12 - 3507268871126.18*l1.*l3.^11 + 19953100399.0076*l1.*l3.^10 - 25488521064.5683*l1.*l3.^9 - 878728731.571182*l1.*l3.^8 + 531840271.483507*l1.*l3.^7 + 31254418.8571152*l1.*l3.^6 - 1974797.57357581*l1.*l3.^5 - 412232.939713507*l1.*l3.^4 - 40077.9602412524*l1.*l3.^3 + 782.59847148736*l1.*l3.^2 + 178.184126984127*l1.*l3 + 2.15703703703704*l1 + 5.53436344864651e+17*l2.^18 - 4.8090190002e+18*l2.^17.*l3 + 5.15724310745555e+16*l2.^17 + 2.31139995715999e+19*l2.^16.*l3.^2 - 3.68742882183072e+17*l2.^16.*l3 + 1.915297717596e+16*l2.^16 - 7.69390145230899e+19*l2.^15.*l3.^3 + 1.47153336666065e+18*l2.^15.*l3.^2 - 1.11807744569618e+17*l2.^15.*l3 - 1.24244602658643e+15*l2.^15 + 1.95717816717947e+20*l2.^14.*l3.^4 - 3.9917061651706e+18*l2.^14.*l3.^3 + 3.46807210245514e+17*l2.^14.*l3.^2 + 7.66843031463025e+15*l2.^14.*l3 - 428385767786077.0*l2.^14 - 3.99090686595394e+20*l2.^13.*l3.^5 + 8.0865571924903e+18*l2.^13.*l3.^4 - 6.75004225220867e+17*l2.^13.*l3.^3 - 2.67927473797752e+16*l2.^13.*l3.^2 + 2.33775944680111e+15*l2.^13.*l3 + 16251848256920.2*l2.^13 + 6.71734294136156e+20*l2.^12.*l3.^6 - 1.26472791805168e+19*l2.^12.*l3.^5 + 8.38546901702678e+17*l2.^12.*l3.^4 + 6.28904803242542e+16*l2.^12.*l3.^3 - 7.07664472278389e+15*l2.^12.*l3.^2 - 84731656537169.6*l2.^12.*l3 + 6330215966579.14*l2.^12 - 9.49445811342512e+20*l2.^11.*l3.^7 + 1.54511003499368e+19*l2.^11.*l3.^6 - 4.79787072850844e+17*l2.^11.*l3.^5 - 1.08901062212036e+17*l2.^11.*l3.^4 + 1.43162445339773e+16*l2.^11.*l3.^3 + 255352441362365.0*l2.^11.*l3.^2 - 27980862944724.5*l2.^11.*l3 + 437462314408.431*l2.^11 + 1.13901490129234e+21*l2.^10.*l3.^8 - 1.44196517284457e+19*l2.^10.*l3.^7 - 4.81329300790995e+17*l2.^10.*l3.^6 + 1.41819202099229e+17*l2.^10.*l3.^5 - 2.14448756867667e+16*l2.^10.*l3.^4 - 507185223727228.0*l2.^10.*l3.^3 + 76684065667201.6*l2.^10.*l3.^2 - 1912485849565.26*l2.^10.*l3 + 48490402028.5775*l2.^10 - 1.16583148796442e+21*l2.^9.*l3.^9 + 9.4240022383571e+18*l2.^9.*l3.^8 + 1.63433160282822e+18*l2.^9.*l3.^7 - 1.38125263106206e+17*l2.^9.*l3.^6 + 2.48944067685093e+16*l2.^9.*l3.^5 + 731096952836743.0*l2.^9.*l3.^4 - 142493131039121.0*l2.^9.*l3.^3 + 4494341746478.35*l2.^9.*l3.^2 - 342822967717.71*l2.^9.*l3 - 14957630671.708*l2.^9 + 1.01940491607017e+21*l2.^8.*l3.^10 - 2.63277260635606e+18*l2.^8.*l3.^9 - 2.31224074718622e+18*l2.^8.*l3.^8 + 9.24219528163973e+16*l2.^8.*l3.^7 - 2.35806830797019e+16*l2.^8.*l3.^6 - 758687299877561.0*l2.^8.*l3.^5 + 205372081052732.0*l2.^8.*l3.^4 - 6660194323751.76*l2.^8.*l3.^3 + 1037273962974.05*l2.^8.*l3.^2 + 50292788206.2017*l2.^8.*l3 - 2351175976.11615*l2.^8 - 7.5923845745938e+20*l2.^7.*l3.^11 - 2.86742716774529e+18*l2.^7.*l3.^10 + 2.16161313037133e+18*l2.^7.*l3.^9 - 2.73538520369433e+16*l2.^7.*l3.^8 + 1.93089306917034e+16*l2.^7.*l3.^7 + 542405435574711.0*l2.^7.*l3.^6 - 233975383701887.0*l2.^7.*l3.^5 + 6426404222850.17*l2.^7.*l3.^4 - 2031768127558.6*l2.^7.*l3.^3 - 91208193890.0891*l2.^7.*l3.^2 + 10566803093.8877*l2.^7.*l3 + 254981479.898429*l2.^7 + 4.78232475724381e+20*l2.^6.*l3.^12 + 5.24663532131811e+18*l2.^6.*l3.^11 - 1.40797310150712e+18*l2.^6.*l3.^10 - 2.48288810796869e+16*l2.^6.*l3.^9 - 1.47509531290267e+16*l2.^6.*l3.^8 - 190274182717283.0*l2.^6.*l3.^7 + 221003094260555.0*l2.^6.*l3.^6 - 3553157765393.09*l2.^6.*l3.^5 + 2762045787636.24*l2.^6.*l3.^4 + 96583191532.8383*l2.^6.*l3.^3 - 24127237953.8929*l2.^6.*l3.^2 - 604237884.88974*l2.^6.*l3 + 45244289.0167598*l2.^6 - 2.51507726600378e+20*l2.^5.*l3.^13 - 4.76529263128893e+18*l2.^5.*l3.^12 + 5.94797998422274e+17*l2.^5.*l3.^11 + 4.49818900163067e+16*l2.^5.*l3.^10 + 1.08481391828629e+16*l2.^5.*l3.^9 - 91983571384370.6*l2.^5.*l3.^8 - 172621856482067.0*l2.^5.*l3.^7 - 15811890882.2366*l2.^5.*l3.^6 - 2766026454625.83*l2.^5.*l3.^5 - 55353496010.6518*l2.^5.*l3.^4 + 34967767712.0991*l2.^5.*l3.^3 + 730982441.578382*l2.^5.*l3.^2 - 136424419.036417*l2.^5.*l3 + 6595.72703541596*l2.^5 + 1.0820483759454e+20*l2.^4.*l3.^14 + 2.99635824543167e+18*l2.^4.*l3.^13 - 9.7917562671199e+16*l2.^4.*l3.^12 - 3.81551166874286e+16*l2.^4.*l3.^11 - 7.32888836639421e+15*l2.^4.*l3.^10 + 198659947442877.0*l2.^4.*l3.^9 + 112475517988272.0*l2.^4.*l3.^8 + 1930180108409.66*l2.^4.*l3.^7 + 2035675485574.75*l2.^4.*l3.^6 + 1520136564.83485*l2.^4.*l3.^5 - 34515167021.0271*l2.^4.*l3.^4 - 403109516.882902*l2.^4.*l3.^3 + 222047818.149942*l2.^4.*l3.^2 + 1472496.06065665*l2.^4.*l3 + 10944.7845493936*l2.^4 - 3.68347640474837e+19*l2.^3.*l3.^15 - 1.36838850451154e+18*l2.^3.*l3.^14 - 5.97042370531174e+16*l2.^3.*l3.^13 + 2.13687356938172e+16*l2.^3.*l3.^12 + 4.10134172455169e+15*l2.^3.*l3.^11 - 158786226719502.0*l2.^3.*l3.^10 - 58841911860807.7*l2.^3.*l3.^9 - 1886132698094.87*l2.^3.*l3.^8 - 1096231034555.83*l2.^3.*l3.^7 + 26105298813.83*l2.^3.*l3.^6 + 23641576819.2938*l2.^3.*l3.^5 - 32725465.856529*l2.^3.*l3.^4 - 214643284.321312*l2.^3.*l3.^3 - 804678.698320765*l2.^3.*l3.^2 + 228124.555925708*l2.^3.*l3 + 4570.37507348618*l2.^3 + 9.37824823540379e+18*l2.^2.*l3.^16 + 4.43522907241177e+17*l2.^2.*l3.^15 + 5.04629452218332e+16*l2.^2.*l3.^14 - 8.18277625036765e+15*l2.^2.*l3.^13 - 1.7084451815603e+15*l2.^2.*l3.^12 + 78259263481361.2*l2.^2.*l3.^11 + 23534824436315.8*l2.^2.*l3.^10 + 952478188858.286*l2.^2.*l3.^9 + 409025281011.401*l2.^2.*l3.^8 - 21653928450.9804*l2.^2.*l3.^7 - 10885642919.0041*l2.^2.*l3.^6 + 184712336.274247*l2.^2.*l3.^5 + 129690289.355843*l2.^2.*l3.^4 + 288563.057799454*l2.^2.*l3.^3 - 253272.945326278*l2.^2.*l3.^2 - 2003.45208700764*l2.^2.*l3 + 586.94885361552*l2.^2 - 1.60065545335102e+18*l2.*l3.^17 - 9.28303759341999e+16*l2.*l3.^16 - 1.67212741463872e+16*l2.*l3.^15 + 1.98390575212995e+15*l2.*l3.^14 + 461443554222984.0*l2.*l3.^13 - 23385653741789.2*l2.*l3.^12 - 6374657558478.38*l2.*l3.^11 - 279343405586.106*l2.*l3.^10 - 96391683449.3493*l2.*l3.^9 + 8735974689.05072*l2.*l3.^8 + 3122616492.30457*l2.*l3.^7 - 111820891.477196*l2.*l3.^6 - 45798268.5891143*l2.*l3.^5 + 151701.72181457*l2.*l3.^4 + 140045.439066344*l2.*l3.^3 + 751.294532627866*l2.*l3.^2 - 371.538624338624*l2.*l3 + 1.23259259259259*l2 + 1.3806522621004e+17*l3.^18 + 9.45494569700184e+15*l3.^17 + 2.26430371962935e+15*l3.^16 - 233793607153361.0*l3.^15 - 58551401016888.8*l3.^14 + 3519658997501.61*l3.^13 + 841271788776.435*l3.^12 + 32000255356.899*l3.^11 + 11225908701.4963*l3.^10 - 1443167624.84318*l3.^9 - 435771834.032614*l3.^8 + 25242313.7290753*l3.^7 + 7958513.40098424*l3.^6 - 3297.86351770806*l3.^5 - 25148.3894005705*l3.^4 - 93.9118165784833*l3.^3 + 103.867372134039*l3.^2 + 2.15703703703704*l3 + 0.457851851851852
end
end


text:
using StructuralEquationModels, Distributions, Random, Optim, LineSearches
import StructuralEquationModels as SEM
include("helper.jl")

x = Symbol.("x".*string.(1:13))

S = [:x1 0 0 0 0 0 0 0
     0 :x2 0 0 0 0 0 0
     0 0 :x3 0 0 0 0 0
     0 0 0 :x4 0 0 0 0
     0 0 0 0 :x5 0 0 0
     0 0 0 0 0 :x6 0 0
     0 0 0 0 0 0 :x7 :x9
     0 0 0 0 0 0 :x9 :x8]

F = [1.0 0 0 0 0 0 0 0
     0 1.0 0 0 0 0 0 0
     0 0 1.0 0 0 0 0 0
     0 0 0 1.0 0 0 0 0
     0 0 0 0 1.0 0 0 0
     0 0 0 0 0 1.0 0 0]

A = [0 0 0 0 0 0 1.0   0
     0 0 0 0 0 0 :x10 0
     0 0 0 0 0 0 :x11 0
     0 0 0 0 0 0 0    1.0
     0 0 0 0 0 0 0    :x12
     0 0 0 0 0 0 0    :x13
     0 0 0 0 0 0 0    0
     0 0 0 0 0 0 0    0]

ram_matrices = RAMMatrices(;A = A, S = S, F = F, parameters = x, colnames = nothing)

true_val = [repeat([1], 8)
            0.4
            repeat([0.8], 4)]

start_val = [repeat([1], 9)
             repeat([0.5], 4)]

imply_ml = RAMSymbolic(;specification = ram_matrices, start_val = start_val)

imply_ml.Σ_function(imply_ml.Σ, true_val)

true_dist = MultivariateNormal(imply_ml.Σ)

Random.seed!(1234)
x = transpose(rand(true_dist, 100000))
semobserved = SemObsCommon(data = x)

loss_ml = SemLoss(SEM.SemML(;observed = semobserved, n_par = length(start_val)))

diff =
    SemDiffOptim(
        BFGS(;linesearch = BackTracking(order=3), alphaguess = InitialHagerZhang()),# m = 100),
        Optim.Options(
            ;f_tol = 1e-10,
            x_tol = 1.5e-8))

model_ml = Sem(semobserved, imply_ml, loss_ml, diff)
model_ml(true_val, true, false, false)
solution_ml = sem_fit(model_ml)

@test isapprox(true_val, solution(solution_ml); atol = .05)


text:
include(joinpath(DFC.DEPS_DIR, "elkflags.jl"))

struct ElkFlagInfo{T}
    name::Symbol
    default::Union{T,Nothing}  #check again v0.7 Some
    description::String
end
ElkFlagInfo() = ElkFlagInfo{Nothing}(:error, "")
Base.eltype(x::ElkFlagInfo{T}) where {T} = T

struct ElkControlBlockInfo <: AbstractBlockInfo
    name::Symbol
    flags::Vector{<:ElkFlagInfo}
    description::String
end

const ELK_CONTROLBLOCKS = _ELK_CONTROLBLOCKS()

function elk_flaginfo(flag::Symbol)
    for b in ELK_CONTROLBLOCKS
        for f in b.flags
            if f.name == flag
                return f
            end
        end
    end
end

elk_block_info(name::Symbol) = getfirst(x -> x.name == name, ELK_CONTROLBLOCKS)

function elk_block_variable(flag_name::Symbol)
    for b in ELK_CONTROLBLOCKS
        for f in b.flags
            if f.name == flag_name
                return b
            end
        end
    end
end

flagtype(::Calculation{Elk}, flag::Symbol) = eltype(elk_flaginfo(flag))

infilename(c::Calculation{Elk}) = "elk.in"
isbands(c::Calculation{Elk}) = c.name == "20"
isnscf(c::Calculation{Elk}) = c.name == "elk2wannier" #nscf == elk2wan??
isscf(c::Calculation{Elk}) = c.name ∈ ["0", "1"]


text:
using Cambrian

@testset "Configuration parsing" begin
    cfg_filename = string(@__DIR__, "/../cfg/oneplus.yaml")
    cfg = get_config(cfg_filename)

    @test cfg.n_population == 5
    @test cfg.d_fitness == 1
    @test cfg.save_gen == 0
    @test cfg.n_genes == 10
    @test cfg.n_gen == 10
    @test cfg.seed == 0
    @test cfg.m_rate == 0.3
    @test cfg.n_elite == 1
    @test cfg.log_gen == 0
    @test haskey(cfg, :id)

    default_id = cfg.id
    my_custom_id = "custom_id"
    my_custom_arg = 0x01
    cfg = get_config(cfg_filename, custom_arg=0x01, id=my_custom_id)
    @test cfg.id == my_custom_id
    @test cfg.id != default_id
    @test haskey(cfg, :custom_arg)
    @test cfg.custom_arg == my_custom_arg
end


text:
# work_hours.jl
#
#   Calculate time spent working
#
# Jeremy Rüffer
# Thünen Institut
# Institut für Agrarklimaschutz
# Junior Research Group NITROSPHERE
# Julia 1.4.0
# 30.03.2020
# Last Edit: 02.04.2020

# include("D:\\Code\\Julia\\Jeremy\\work_hours.jl")

"# work_hours(times...,diffs::Bool=false)

`work_hours(\"8:21\",\"12:16\",\"13:20\",\"15:45\",\"16:30\",\"19:00\")` Calculate total work hours\n
* **time...**::String = List of times as strings in H:MM or HH:MM format

====  Summing Time Periods  ====\n
\t08:21:00 -> 12:16:00\n
\t13:20:00 -> 15:45:00\n
\t16:30:00 -> 19:00:00\n

Total: 08:50:00,  +1 hour, 2 minutes

---

#### Keywords:\n
* diffs::Bool = Show each time difference, False is default
* goal::Time = Target working ours, Time(7,48) is default\n\n"
function work_hours(times...;diffs::Bool=false,goal::Time=Time(7,48))
	#################
	##  Constants  ##
	#################
	dfmt = Dates.DateFormat("HH:MM")

	##############
	##  Checks  ##
	##############
	for test = 1:1:length(times)
		# Check that each input is a string
		isa(times[test],String) ? nothing : error("All input times must be strings")

		# Check that each input matches H:MM or HH:MM formats
		match(r"^[0-2]?[0-9]\:[0-5][0-9]",times[test]) == nothing ? error(times[test] * " is not of the form H:MM or HH:MM") : nothing
	end

	#################
	##  Calculate  ##
	#################
	println("====  Summing Time Periods  ====")
	isodd(length(times)) ? endTime = length(times) - 1 : endTime = length(times)
	sumTime = Time(0)
	for t=1:2:endTime
		dt = Time(times[t+1],dfmt) - Time(times[t],dfmt)
		if diffs
			dtString = ",\tdt = " * string(Time(dt))
		else
			dtString = ""
		end
		println("\t" * string(Time(times[t],dfmt)) * " -> " * string(Time(times[t+1],dfmt)) * dtString)
		sumTime += dt
	end

	# Odd number of times given
	if isodd(length(times))
		checkoutTime = Time(Time(times[end]).instant + goal.instant - sumTime.instant)
		println("\t" * string(Time(times[end],dfmt)) * " -> " * string(checkoutTime) * " (assuming a full work day)")
	end

	# Final Numbers
		if goal-sumTime > Nanosecond(0)
		println("\nTotal: " * string(sumTime) *",  " * string(Dates.canonicalize(Dates.CompoundPeriod(goal-sumTime))) * " remaining")
	else
		println("\nTotal: " * string(sumTime) * ",  +" * string(Dates.canonicalize(Dates.CompoundPeriod(sumTime-goal))))
	end
end


text:
struct Line{Tv}
    a::Tv
    b::Tv
end

@inline (p::Line)(x) = p.a + p.b * x

model_SparseMatrix1DVBC_blocks() = AffineNetCostModel(0, 0, 0, 1)

model_SparseMatrix1DVBC_memory(Tv, Ti) = ColumnBlockComponentCostModel{Int}(3 * sizeof(Ti), Line(sizeof(Ti), sizeof(Tv)))

model_SparseMatrix1DVBC_TrSpMV_time(W, Tv, Ti, Tu; kwargs...) = ColumnBlockComponentCostModel{Float64}(model_SparseMatrix1DVBC_TrSpMV_time_params(W, Tv, Ti, Tu; kwargs...)...)

@memoize DiskCache(joinpath(@get_scratch!("autotune"), "1DVBC_TrSpMV_timings")) function model_SparseMatrix1DVBC_TrSpMV_time_data(W, Tv, Ti, Tu; cache=:L2Cache, exceed=false, arch=arch_id())
    @info "collecting data for $(SparseMatrix1DVBC{W, Tv, Ti})' * $(Vector{Tu})..."
    @assert arch == arch_id()

    T = Float64[]
    ms = Int[]
    ns = Int[]
    Ls = Int[]
    ws = Int[]
    qs = Int[]

    _params = nothing
    for w in W:-1:1
        ts = Float64[]

        # Memory Usage (Up To Constants)
        # Ti * L, B.Φ
        # Ti * L, B.pos
        # Ti * L, B.ofs
        # Tu * n, x
        # Tu * m, y
        # Ti * q, B.idx
        # Tv * q * w, B.val
        # Assumptions
        # d = 8
        # n = L * w
        # m = n
        # q = L * d
        # Total Usage
        # ((3 + d) Ti + 2 w Tu + d w Tv)L
        if exceed
            d = 8
            C = first(filter(t->t.type_ == cache, collect(Hwloc.topology_load()))).attr.size * 2
            L₀ = ceil(Int, C/((3 + d) * sizeof(Ti) + (2 * w) * sizeof(Tu) + (d * w) * sizeof(Tv)))
            n₀ = L₀ * w
            m₀ = n₀
            q₀ = L₀ * d
            space = ((m₀, L₀, q₀), (m₀, 2L₀, q₀), (2m₀, L₀, q₀), (m₀, L₀, 2q₀))
        else
            d = 8
            C = first(filter(t->t.type_ == cache, collect(Hwloc.topology_load()))).attr.size / 2
            L₀ = floor(Int, C/((3 + d) * sizeof(Ti) + (2 * w) * sizeof(Tu) + (d * w) * sizeof(Tv)))
            n₀ = L₀ * w
            m₀ = n₀
            q₀ = L₀ * d
            space = ((m₀, L₀, q₀), (m₀, fld(L₀, 2), q₀), (fld(m₀, 2), L₀, q₀), (m₀, L₀, fld(q₀, 2)))
        end
        @assert L₀ >= 4

        for (m, L, q) in space
            n = w * L
            _q = 0
            A_ILh = Set{Tuple{Int, Int}}()
            A_I = Int[]
            A_J = Int[]
            A_V = Tv[]
            while _q < q
                i, l = (rand(1:m), rand(1:L))
                if !((i, l) in A_ILh)
                    push!(A_ILh, (i, l))
                    for j = l * w - w + 1:l * w
                        push!(A_I, i)
                        push!(A_J, j)
                        push!(A_V, rand(Tv))
                    end
                    _q += 1
                end
            end
            A = sparse(A_I, A_J, A_V, m, n)
            B = SparseMatrix1DVBC{W}(A, pack_stripe(A, EquiChunker(w)))
            x = ones(Tu, m)
            y = ones(Tu, n)

            _bench = @benchmarkable mul!($y, $B', $x)
            if _params === nothing
                tune!(_bench)
                _params = params(_bench)
                @info "params" _params
            end
            loadparams!(_bench, _params)
            t = time(run(_bench))

            push!(ms, m)
            push!(ns, n)
            push!(Ls, L)
            push!(ws, w)
            push!(qs, q)
            push!(T, t)
            @info "w: $w m: $m n: $n L: $L q: $q t: $t"
        end
    end
    @info "done!"
    return (ms, ns, Ls, ws, qs, T)
end

@memoize DiskCache(joinpath(@get_scratch!("autotune"), "1DVBC_TrSpMV_time_params")) function model_SparseMatrix1DVBC_TrSpMV_time_params(W, Tv, Ti, Tu; cache=:L2Cache, exceed=false, arch=arch_id())
    @info "calculating cost model for $(SparseMatrix1DVBC{W, Tv, Ti})' * $(Vector{Tu})..."
    (ms, ns, Ls, ws, qs, T) = model_SparseMatrix1DVBC_TrSpMV_time_data(W, Tv, Ti, Tu; cache = cache, exceed = exceed, arch = arch)
    d = Vector{Float64}[]
    for i = 1:length(T) #Create one-hot representation
        d_row = ms[i]
        d_col = zeros(W)
        d_col[ws[i]] = Ls[i]
        d_block = zeros(W)
        d_block[ws[i]] = qs[i]
        push!(d, [d_row; d_col; d_block])
    end
    D = permutedims(reduce(hcat, d))
    P = qr(Diagonal(1 ./ T) * D, Val(true)) \ ones(length(T))
    α_row = P[1]
    α_col = P[2:1 + W]
    β_col = P[2 + W:end]

    #monotonize
    for w = 2:W
        α_col[w] = max(α_col[w], α_col[w - 1])
        β_col[w] = max(β_col[w], β_col[w - 1])
    end

    @info "results" α_row α_col β_col
    @info "done!"
    return (α_col, β_col)
end

model_SparseMatrixVBC_blocks() = BlockComponentCostModel{Int}(0, 0, (1,), (1, ))

model_SparseMatrixVBC_memory(Tv, Ti) = BlockComponentCostModel{Int}(sizeof(Ti), 3 * sizeof(Ti), (Line(1, 0), Line(0, 1)), (Line(sizeof(Ti), 0), Line(0, sizeof(Tv))))

model_SparseMatrixVBC_TrSpMV_time(R, U, W, Tv, Ti, Tu; kwargs...) = BlockComponentCostModel{Float64}(model_SparseMatrixVBC_TrSpMV_time_params(R, U, W, Tv, Ti, Tu; kwargs...)...)

@memoize DiskCache(joinpath(@get_scratch!("autotune"), "VBC_TrSpMV_timings")) function model_SparseMatrixVBC_TrSpMV_time_data(U, W, Tv, Ti, Tu; cache=:L2Cache, exceed=false, arch=arch_id())
    @info "collecting data for $(SparseMatrixVBC{U, W, Tv, Ti})' * $(Vector{Tu})..."
    @assert arch == arch_id()

    T = Float64[]
    ms = Int[]
    ns = Int[]
    Ks = Int[]
    Ls = Int[]
    us = Int[]
    ws = Int[]
    qs = Int[]

    _params = nothing
    for u in U:-1:1
        for w in W:-1:1
            # Memory Usage (Up To Constants)
            # Ti * K, B.Π
            # Ti * L, B.Φ
            # Ti * L, B.pos
            # Ti * L, B.ofs
            # Tu * n, x
            # Tu * m, y
            # Ti * q, B.idx
            # Tv * q * u * w, B.val
            # Assumptions
            # d = 8
            # m = K * u
            # n = L * w
            # m = n
            # q = L * d
            # Total Usage
            # ((3 + (w/u) + d) Ti + 2 w Tu + d u w Tv)L < C/2
            if exceed
                d = 8
                C = first(filter(t->t.type_ == cache, collect(Hwloc.topology_load()))).attr.size * 2
                L₀ = ceil(Int, C/((3 + d + (w/u)) * sizeof(Ti) + (2 * w) * sizeof(Tu) + (d * u * w) * sizeof(Tv)))
                n₀ = L₀ * w
                K₀ = cld(n₀, u)
                m₀ = K₀ * u
                q₀ = L₀ * d
                space = ((K₀, L₀, q₀), (K₀, 2L₀, q₀), (2K₀, L₀, q₀), (K₀, L₀, 2q₀))
            else
                d = 8
                C = first(filter(t->t.type_ == cache, collect(Hwloc.topology_load()))).attr.size / 2
                L₀ = floor(Int, C/((3 + d + (w/u)) * sizeof(Ti) + (2 * w) * sizeof(Tu) + (d * u * w) * sizeof(Tv)))
                n₀ = L₀ * w
                K₀ = fld(n₀, u)
                m₀ = K₀ * u
                q₀ = L₀ * d
                space = ((K₀, L₀, q₀), (K₀, fld(L₀, 2), q₀), (fld(K₀, 2), L₀, q₀), (K₀, L₀, fld(q₀, 2)))
            end

            @assert L₀ >= 4
            @assert K₀ >= 4

            for (K, L, q) in space
                (m, n) = (u * K, w * L)
                _q = 0
                A_KLh = Set{Tuple{Int, Int}}()
                A_I = Int[]
                A_J = Int[]
                A_V = Tv[]
                while _q < q
                    k, l = (rand(1:K), rand(1:L))
                    if !((k, l) in A_KLh)
                        push!(A_KLh, (k, l))
                        for i = k * u - u + 1: k * u, j = l * w - w + 1:l * w
                            push!(A_I, i)
                            push!(A_J, j)
                            push!(A_V, rand(Tv))
                        end
                        _q += 1
                    end
                end
                A = sparse(A_I, A_J, A_V, m, n)
                B = SparseMatrixVBC{U, W}(A, pack_stripe(A', EquiChunker(u)), pack_stripe(A, EquiChunker(w)))
                x = ones(Tu, m)
                y = ones(Tu, n)

                _bench = @benchmarkable mul!($y, $B', $x)
                if _params === nothing
                    tune!(_bench)
                    _params = params(_bench)
                    @info "params" _params
                end
                loadparams!(_bench, _params)
                t = time(run(_bench))

                push!(ms, m)
                push!(ns, n)
                push!(Ks, K)
                push!(Ls, L)
                push!(us, u)
                push!(ws, w)
                push!(qs, q)
                push!(T, t)
                @info "u: $u w: $w m: $m n: $n K: $K L: $L q: $q t: $t"
            end
        end
    end
    @info "done!"
    return (ms, ns, Ks, Ls, us, ws, qs, T)
end

@memoize DiskCache(joinpath(@get_scratch!("autotune"), "VBC_TrSpMV_time_params")) function model_SparseMatrixVBC_TrSpMV_time_params(R, U, W, Tv, Ti, Tu; cache=:L2Cache, exceed=false, arch=arch_id())
    @info "calculating cost model for $(SparseMatrixVBC{U, W, Tv, Ti})' * $(Vector{Tu})..."
    (ms, ns, Ks, Ls, us, ws, qs, T) = model_SparseMatrixVBC_TrSpMV_time_data(U, W, Tv, Ti, Tu; cache = cache, exceed = exceed, arch = arch)
    d = Vector{Float64}[]
    for i = 1:length(T) #Create one-hot representation
        d_row = zeros(U)
        d_row[us[i]] = Ks[i]
        d_col = zeros(W)
        d_col[ws[i]] = Ls[i]
        d_block = zeros(U, W)
        d_block[us[i], ws[i]] = qs[i]
        push!(d, [d_row; d_col; reshape(d_block, :)])
    end
    D = permutedims(reduce(hcat, d))
    P = qr(Diagonal(1 ./ T) * D, Val(true)) \ ones(length(T))
    α_row = [P[1:U]...,]
    α_col = [P[U + 1:U + W]...,]
    β = collect(reshape(P[U + W + 1:end], U, W))

    #monotonize
    for w = 2:W
        β[1, w] = max(β[1, w], β[1, w - 1])
    end
    for u = 2:U
        β[u, 1] = max(β[u, 1], β[u - 1, 1])
        for w = 2:W
            β[u, w] = max(β[u, w], β[u - 1, w - 1], β[u, w - 1])
        end
    end

    F = svd(β)
    β_row = ((F.U[:,r] for r = 1:R)...,)
    β_col = ((F.S[r] * F.V[:,r] for r = 1:R)...,)

    β_reconstruct = [sum(β_row[r][u] * β_col[r][w] for r = 1:R) for u = 1:U, w = 1:W]
    β_error = maximum((β_reconstruct .- β)./β)
    @info "raw" β_error β β_reconstruct

    @info "results" α_row α_col β_row β_col
    @info "done!"
    return (α_row, α_col, β_row, β_col)
end


text:
using Compat: contains
using Wrangling
using Test

@testset "Wrangling.jl" begin
    include("symbol_searching.jl")
end


text:
module Day08
export part1, part2

parse_image(image) = [parse(Int, c) for c in image]

layer(image, n, i) = view(image, n*(i-1)+1:n*i)

layers(image, n) = let (nLayers, rem) = divrem(length(image), n)
    @assert rem == 0
    (layer(image, n, i) for i in 1:nLayers)
end

function checksum(image, n)
    image = parse_image(image)

    (cmin, imin) = findmin(count.(x->x==0, layers(image, n)))

    layerMin = layer(image, n, imin)
    @assert count(x->x==0, layerMin) == cmin

    count(x->x==1, layerMin) * count(x->x==2, layerMin)
end

function decode(image, a, b)
    image = parse_image(image)
    n = a*b

    im = fill(2, (a, b))
    for l in layers(image, n)
        for i in eachindex(im)
            im[i]==2 && (im[i]=l[i])
        end
    end

    im
end

part1() = checksum(readline("input08.dat"), 25*6)

function part2()
    image = decode(readline("input08.dat"), 25, 6)
    image = map(image) do x
        x==0 ? ' ' : 'O'
    end
    reduce(*, String(image[:,i])*"\n" for i in 1:size(image, 2))
end

end


text:
workspace()

include("file_io/read_key.jl")
include("file_io/read_input.jl")
include("file_io/read_data.jl")
include("file_io/read_output.jl")
include("file_io/write_key.jl")
include("file_io/write_output.jl")
include("estimate.jl")

foo = @__FILE__
@eval @everywhere f = $foo
@everywhere (program_file_dir, program_file_name) = splitdir(f)
@everywhere include(joinpath(program_file_dir, "simulate.jl"))
@everywhere include(joinpath(program_file_dir, "distance.jl"))
@everywhere include(joinpath(program_file_dir, "rand_weighted_index.jl"))
@everywhere include(joinpath(program_file_dir, "position_periodic.jl"))
@everywhere include(joinpath(program_file_dir, "displace.jl"))
@everywhere include(joinpath(program_file_dir, "rand_poisson.jl"))
@everywhere include(joinpath(program_file_dir, "normpdf.jl"))

function run_part_conc_spt_abc()
	# Start time.
	t_start_ns::Int64 = convert(Int64, time_ns())

	# Inititalization of random number generation device.
	random_seed::Int64 = convert(Int64, time_ns())
	srand(random_seed)

	# Change current folder to the folder where this script lies.
	(program_file_dir::String, program_file_name::String) = splitdir(PROGRAM_FILE)
	program_file_dir = abspath(program_file_dir)
	cd(program_file_dir)

	# Assert that input is file and store path.
	input_file_path::String = ""
	if isfile(ARGS[1])
		input_file_path = ARGS[1]
	else
		println("No input file specified or specified input file does not exist. Aborting.")
		return -1
	end

	# Read input.
	(	data_file_path::String,
		model::String,
		number_of_components::Int64,
		Lx::Float64,
		Ly::Float64,
		Lz::Float64,
		kmin::Int64,
		number_of_de_bins::Int64,
		ub_de::Float64,
		lb_m::Float64,
		ub_m::Float64,
		lb_c::Float64,
		ub_c::Float64,
		lb_az::Float64,
		ub_az::Float64,
		number_of_abc_samples::Int64,
		gamma_initial::Float64,
		gamma_adaptive::Bool,
		delta_gamma::Float64,
		weighting_scheme::String,
		ub_average_number_of_trials::Int64,
		output_file_path::String) = read_input(input_file_path)

	# Read data.
	(	ax::Float64,
		ay::Float64,
		number_of_frames::Array{Int64, 1},
		deltat::Float64,
		K::Array{Int64, 1},
		DE::Array{Float64, 1}) = read_data(data_file_path)

	# Run ABC.
	(	m::Array{Float64, 2},
		c::Array{Float64, 2},
		az::Array{Float64, 2},
		dist::Array{Float64, 1},
		w::Array{Float64, 1},
		gamma::Float64,
		number_of_iterations::Int64,
		number_of_simulations::Int64) = estimate(	model,
										number_of_components,
										Lx,
										Ly,
										Lz,
										kmin,
										number_of_de_bins,
										ub_de,
										lb_m,
										ub_m,
										lb_c,
										ub_c,
										lb_az,
										ub_az,
										number_of_abc_samples,
										gamma_initial,
										gamma_adaptive,
										delta_gamma,
										weighting_scheme,
										ub_average_number_of_trials,
										ax,
										ay,
										number_of_frames,
										deltat,
										K,
										DE)

	t_exec_ns::Int64 = convert(Int64, time_ns()) - t_start_ns
	t_exec::Float64 = convert(Float64, t_exec_ns) / 1e9
	write_output(	output_file_path,
					model,
					number_of_components,
					number_of_abc_samples,
					m,
					c,
					az,
					dist,
					w,
					weighting_scheme,
					gamma,
					t_exec,
					number_of_iterations,
					number_of_simulations)
	println(join(("Output written to ", output_file_path, ".")))

	(	model,
		number_of_components,
		number_of_abc_samples,
		m,
		c,
		az,
		dist,
		w,
		weighting_scheme,
		gamma,
		t_exec,
		number_of_iterations,
		number_of_simulations) = read_output(output_file_path)

	return 0
end

run_part_conc_spt_abc()


text:
module AtomicMass
using JuliaDB

srcdir= @__DIR__
pt=load(srcdir * "/atomicmass.db");

function _atomicmass(s::T) where T<:AbstractString
    filter(x->x.Symbol==s, pt)[1].m
end
function _atomicmass(s::T1, A::T2) where {T1<:AbstractString , T2<:Integer}
    filter(x->(x.Symbol==s && x.A==A), pt)[1].m
end
function _atomicmass(Z::T) where T<:Integer
    filter(x->x.Z==Z, pt)[1].m
end
function _atomicmass(Z::T, A::T) where T <: Integer
    filter(x->(x.Z==Z && x.A==A), pt)[1].m
end

"""
    atomicmass(s::T) where T<:AbstractString

Return the mass of the isotope in Dalton.

If mass number is unspecified, return the mass of the most abundant species.

# Examples
```julia-repl
julia> atomicmass("H-2")
2.01410177812

julia> atomicmass("H2")
2.01410177812

julia> atomicmass("D")
2.01410177812

julia> atomicmass("H")
1.00782503223
```
"""
function atomicmass(s::T) where T<:AbstractString
    elem=match(r"[[:alpha:]]{1,3}", s)
    if elem !== nothing
        name=titlecase(elem.match)
        massnumber=match(r"[[:digit:]]{1,3}", s)
        if massnumber !==nothing
            A=parse(Int, massnumber.match)
            return _atomicmass(name, A)
        else
            return _atomicmass(name)
        end
    end
    return nothing
end

export atomicmass
end # module