text:
# generic methods
function subspace_mul_generic!(S::AbstractVector{T}, indices, U::AbstractMatrix, subspace, offset=0) where {T}
    D = StrideArrays.static_length(indices)
    y = U isa Diagonal ? nothing : StrideArray{T}(undef, (D, ))
    if D == 4
        # TODO:
        # this "if" branch is pre-empted by "if size(U, 1) == 4" in subspace_mul!
        # making subspace_mul_kernel_generic_4x4! redundant
        # Should we keep subspace_mul4x4! or subspace_mul_kernel_generic_4x4! ?
        for k in subspace
            subspace_mul_kernel_generic_4x4!(S, y, indices, U, k, offset)
        end
    else
        for k in subspace
            subspace_mul_kernel_generic!(S, y, indices, U, k, offset)
        end
    end
    return S
end

function subspace_mul_generic!(S::AbstractMatrix{T}, indices, U::AbstractMatrix, subspace, offset=0) where {T}
    D = StrideArrays.static_length(indices)
    y = U isa Diagonal ? nothing : StrideArray{T}(undef, (D, ))
    if D == 4
        for k in subspace, b in axes(S, 1)
            subspace_mul_kernel_generic_4x4!(S, y, indices, U, k, b, offset)
        end
    else
        for k in subspace, b in axes(S, 1)
            subspace_mul_kernel_generic!(S, y, indices, U, k, b, offset)
        end
    end
    return S
end

# specialization on Complex{<:Base.HWReal}
@inline split_op(U::AbstractMatrix{<:Real}, indices) = U

# NOTE:
# Each element of the complex Diagonal matrix U is used only once in the kernel.
# Therefore, in order to avoid unnecessary memory allocations,
# we do not split U into two (1-dimensional) StrideArrays.
@inline split_op(U::Diagonal{<:Complex}, indices) = U

@inline function split_op(U::AbstractMatrix{Complex{T}}, indices) where {T <: Real}
    D = ArrayInterface.static_length(indices)
    U_re = StrideArray{T}(undef, (D, D))
    U_im = StrideArray{T}(undef, (D, D))
    @inbounds @simd ivdep for i in 1:length(U)
        U_re[i] = real(U[i])
        U_im[i] = imag(U[i])
    end
    return U_re, U_im
end

function subspace_mul_generic!(S::Vector{Complex{T}}, indices, U::AbstractMatrix, subspace, offset=0) where {T <: Base.HWReal}
    D = StrideArrays.static_length(indices)
    y = U isa Diagonal ? (nothing, nothing) : (StrideArray{T}(undef, (D, )), StrideArray{T}(undef, (D, )))
    U = split_op(U, indices)
    Sr = reinterpret(reshape, T, S)
    for k in subspace
        subspace_mul_kernel_complex!(Sr, y, indices, U, k, offset)
    end
    return S
end

function subspace_mul_generic!(S::Matrix{Complex{T}}, indices, U::AbstractMatrix, subspace, offset=0) where {T <: Base.HWReal}
    D = StrideArrays.static_length(indices)
    C = U isa Diagonal ? (nothing, nothing) : (StrideArray{T}(undef, (D, StaticInt{8}())), StrideArray{T}(undef, (D, StaticInt{8}())))
    U = split_op(U, indices)

    Sr = reinterpret(reshape, T, S)
    Bmax = size(S,1)
    for k in subspace, _b ∈ 0:(Bmax-1) >>> 3
        subspace_mul_kernel_complex!(Sr, C, indices, U, k, _b, Bmax, offset)
    end
    return S
end

# NOTE:
# to reduce repetitive code, we should specialize for Diagonal at "kernel" level
#
# function subspace_mul_generic!(S::AbstractVector{T}, indices, U::Diagonal{N, Vector{N}}, subspace, offset = 0) where {T, N}
#     D = StrideArrays.static_length(indices)
#     if D == 4
#         for k in subspace
#             subspace_mul_kernel_diagonal_4x4!(S, indices, U, k, offset)
#         end
#     else
#         for k in subspace
#             subspace_mul_kernel_diagonal!(S, indices, U, k, offset)
#         end
#     end
#     return S
# end

function threaded_subspace_mul_generic!(S::AbstractVecOrMat, indices, U::AbstractMatrix, subspace, offset=0)
    nthreads = Threads.nthreads()
    space = CartesianSpace(S, subspace)
    @batch for tid in 1:nthreads
        range = schedule_task(space, tid, nthreads)
        subspace_mul_generic_task!(S, indices, U, subspace, range, offset)
    end
    return S
end

function threaded_subspace_mul_generic!(S::VecOrMat{Complex{T}}, indices, U::AbstractMatrix, subspace, offset=0) where {T <: Base.HWReal}
    nthreads = Threads.nthreads()
    space = CartesianSpace(S, subspace)
    Sr = reinterpret(reshape, T, S)
    U = split_op(U, indices)

    @batch for tid in 1:nthreads
        range = schedule_task(space, tid, nthreads)
        subspace_mul_complex_task!(Sr, indices, U, subspace, range, offset)
    end
    return S
end


text:
# Offset between 0-based indexing and 1-based indexing
const OFFSET = 1

mutable struct Grid{T}
    w::Int
    h::Int
    data::Vector{T}

    function Grid{T}() where T

        w = 0
        h = 0
        data = []

        new{T}(
            w,
            h,
            data,
        )
    end
end

function resize(grid::Grid{T}, width::Int, height::Int) where T

    grid.w = width
    grid.h = height
    empty!(grid.data)
    resize!(grid.data, width * height)
    fill!(grid.data, zero(T))
    return nothing
end

function contains(grid::Grid{T}, x::Int, y::Int) where T

    return 0 <= y && y < grid.h && 0 <= x && x < grid.w
end

function get(grid::Grid{T}, x::Int, y::Int) where T

    return grid.data[y * grid.w + x + OFFSET]
end

function set(grid::Grid{T}, x::Int, y::Int, v::T) where T

    grid.data[y * grid.w + x + OFFSET] = v
    return nothing
end

ext: jl


text:
export crossEntropy,∂crossEntropy

function crossEntropy(obj,pre)
  cost=-sum(obj.*log(pre))/size(pre)[end]
end
function ∂crossEntropy(obj,pre)
  ∂pre_L=-obj./pre
end


text:
# Autogenerated wrapper script for SLICOT_jll for x86_64-w64-mingw32-libgfortran4
export libslicot

using libblastrampoline_jll
using CompilerSupportLibraries_jll
JLLWrappers.@generate_wrapper_header("SLICOT")
JLLWrappers.@declare_library_product(libslicot, "libslicot.dll")
function __init__()
    JLLWrappers.@generate_init_header(libblastrampoline_jll, CompilerSupportLibraries_jll)
    JLLWrappers.@init_library_product(
        libslicot,
        "bin\\libslicot.dll",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@generate_init_footer()
end  # __init__()


text:
# An infinite number of mathematicians walk into a bar...

using Canvas
using Color

colors = distinguishable_colors(9)

box(w, h, n) =
    empty |> fillcolor(colors[n % 9 + 1]) |> size(w, h)

cut(w, h, ::(Canvas.Vertical, Bool)) =
    (w, h/2)
cut(w, h, ::Any) =
    (w/2, h)

stack(w, h, d, n) =
    n == 0 ?
        empty :
        flow(d[1][1], [ box(cut(w, h, d[1])..., n),
            stack(cut(w, h, d[1])..., vcat(d[2:end], d[1]), n-1)], reverse=d[1][2])

directions = [
    (vertical, false),
    (horizontal, true),
    (vertical, true),
    (horizontal, false)
]

main(win) = inset(middle,
             size(100vw, 100vh, empty),
             stack(80vmin, 80vmin, directions, 14))


text:
module Utils

# For compiling
export ForwardLoss, Actualizer, actualize, @closure

# Exports from ioconfig
export IOConfig, setindex, TensorLocation, DRAM, PMEM

# Export from metagraph
export MetaGraph, inedges, outedges, getmeta, rem_edge!

# Export fron ngraph
export  insert_move_node!,
        hasprofile,
        ismemory_intensive,
        ismove,
        ismoveasync,
        ismovesync,
        isconstant,
        isparam,
        isresult,
        input_tensors,
        output_tensors,
        make_persistent,
        CallbackChain,
        callback!,
        CompilerExit

# Reexport some stuff from nGraph
export TensorDescriptor, NodeDescriptor, inputs, outputs, description

# Ratios
export getratio, ratio_string, footprint, compare_ratio

# Random
export approx_one, find_vertex, find_edge, findonly, dict_push!, vflatten

import LightGraphs
import JuMP
import Flux

# Import all of nGraph plus some commonly used names
#
# The commonly used names will be reexported so all dependencies on the local Utils module
# will have those as well
import nGraph
import nGraph: TensorDescriptor, NodeDescriptor, inputs, outputs, description

using DocStringExtensions

include("ioconfig.jl")
include("metagraph.jl")
include("ngraph.jl")
include("ratio.jl")

# Memory Allocator Model
include("allocator.jl")

#####
##### Compile and create a model
#####

struct ForwardLoss{T,F}
    forward::T
    loss::F
end

(F::ForwardLoss)(x, y) = F.loss(F.forward(x), y)
Flux.@functor ForwardLoss (forward,)

"""
Return type for `AutoTM` compatible functions.

$(FIELDS)
"""
struct Actualizer
    "Function to convert to ngraph."
    f

    "Arguements to pass to `f`."
    args::Tuple

    "Keyword arguments to pass to `nGraph.compile`"
    kw::NamedTuple
    Actualizer(f, x...; kw...) = new(f, x, (;kw...))
end

"""
$(SIGNATURES)

Convert `f` to an ngraph executable running on `backend`. Argument `f` must be callable
with no arguments and return an [`Actualizer`](@ref).

Keyword Arguments
-----------------
* `env`: Tuple of environmental variable pairs to be forwared to `withenv` when compiling `f`.

* `nkw`: Extra keyword or keyword overrides to pass to `nGraph.compile`.
"""
actualize(backend, f; env = (), nkw...) = actualize(backend, f(); env = env, nkw...)
function actualize(backend, A::Actualizer; env = (), nkw...)
    return withenv(env...) do
        nGraph.compile(backend, A.f, A.args...; A.kw..., nkw...)
    end
end

"""
$(SIGNATURES)

A macro that wraps an expression in a closure for deferred calling.

julia> y = 2
2

julia> f = AutoTM.@closure y + 2;

julia> f()
4
"""
macro closure(expr)
    return :(() -> $(esc(expr)))
end

"""
$(SIGNATURES)

Return `true` if `x` is approximately equal to 1. Works on standard variables and
`JuMP.VariableRef`.
"""
approx_one(x; atol = 1e-3) = isapprox(x, one(x); atol = atol)
approx_one(x::JuMP.VariableRef; kw...) = approx_one(JuMP.value(x); kw...)

"""
$(SIGNATURES)

Find the first element of `x` iterator `itr` where `f(x) == true` and make sure that `x`
is the only element of `itr` with this property.

Return the index of `x`.
"""
function findonly(f, itr)
    indices = findall(f, itr)
    if length(indices) != 1
        throw(ArgumentError("Expected to find just one valid index. Instead, found $(length(indices))"))
    end
    return first(indices)
end

"""
$(SIGNATURES)

Check if Dict `d` has key `k`. If so, push `v` to `d[k]`. Otherwise, initialize `d[k]`
to a `[v]`.
"""
dict_push!(d, k, v) = haskey(d, k) ? push!(d[k], v) : (d[k] = [v])

"""
$(SIGNATURES)

Variadic version of `Iterators.flatten`.
"""
vflatten(x...) = Iterators.flatten(x)

end

max_stars_repo_name: darchr/AutoTM

max_issues_repo_name: darchr/AutoTM

max_forks_repo_name: darchr/AutoTM


text:
@testset "nitty_gritty_promote_rules" begin
    onetomrange_type = typeof(DynamicAxis(10))

    onetorange_type = typeof(OneTo(10))
    steprange_type = typeof(StepRange(1, 1, 2))
    steprangelen_type = typeof(StepRangeLen(1, 2, 3))
    unitrange_type = typeof(UnitRange(1, 2))

    @testset "promote_rule" begin
        # within type promotion
        @test promote_rule(onetomrange_type, typeof(DynamicAxis(5))) <: DynamicAxis

        @test promote_rule(onetomrange_type, onetorange_type) <: DynamicAxis
        @test promote_rule(onetorange_type, onetomrange_type) <: DynamicAxis

        @test promote_rule(onetorange_type, onetomrange_type) <: DynamicAxis
        @test promote_rule(onetomrange_type, onetorange_type) <: DynamicAxis

        @test promote_rule(onetorange_type, unitrange_type) <: UnitRange{Int}
        @test promote_rule(unitrange_type, onetorange_type) <: UnitRange{Int}

    end

    @testset "lower_rangetype" begin
        @test StaticRanges.lower_rangetype(onetomrange_type) <: DynamicAxis
        @test StaticRanges.lower_rangetype(onetorange_type) <: DynamicAxis

    end

end


text:
abstract type Product end

for s in (:Limestone, :IronOre, :CopperOre, :CateriumOre, :Coal, :RawQuartz, :Sulfur, :Bauxite, :SAMOre, :Uranium, :Water, :CrudeOil, :AlienCarapace, :AlienOrgans, :GreenPowerSlug, :YellowPowerSlug, :PurplePowerSlug, :HeavyOilResidue, :Fuel, :LiquidBiofuel, :Turbofuel, :AluminaSolution, :SulfuricAcid, :Concrete, :IronIngot, :CopperIngot, :CateriumIngot, :SteelIngot, :AluminumIngot, :QuartzCrystal, :PolymerResin, :PetroleumCoke, :AluminumScrap, :Silica, :BlackPowder, :Wire, :Cable, :IronRod, :Screw, :IronPlate, :ReinforcedIronPlate, :CopperSheet, :AlcladAluminumSheet, :Plastic, :Rubber, :PackagedWater, :SteelPipe, :SteelBeam, :EncasedIndustrialBeam, :FlowerPetals, :CrystalOscillator, :EmptyCanister, :Fabric, :ModularFrame, :HeavyModularFrame, :Rotor, :Stator, :Motor, :Quickwire, :CircuitBoard, :Computer, :AILimiter, :HighSpeedConnector, :Supercomputer, :Battery, :HeatSink, :RadioControlUnit, :TurboMotor, :ElectromagneticControlRod, :UraniumPellet, :EncasedUraniumCell, :Beacon, :CompactedCoal, :Leaves, :Mycelia, :Wood, :Biomass, :PackagedOil, :PackagedHeavyOilResidue, :SolidBiofuel, :PackagedFuel, :PackagedLiquidBiofuel, :PackagedTurbofuel, :NuclearFuelRod, :Nobelisk, :GasFilter, :ColorCartridge, :RifleCartridge, :SpikedRebar, :IodineInfusedFilter, :PowerShard, :FICSITCoupon, :SmartPlating, :VersatileFramework, :AutomatedWiring, :ModularEngine, :AdaptiveControlUnit)
    @eval struct $s <: Product end
    @eval export $s
end


text:
module EndyIndexes

export EndBasedIdx, StartBasedIdx, EndyRangeIdx

######## Single Indices #######
struct EndBasedIdx
    v::Int
end
EndBasedIdx() = EndBasedIdx(0)

struct StartBasedIdx
    v::Int
end
StartBasedIdx() = StartBasedIdx(0)

const EndySingleIndex = Union{StartBasedIdx, EndBasedIdx}

####### Range Indices #######
const EndyRangeElType = Union{EndySingleIndex, Int}
struct EndyRangeIdx{FT, TT} <: AbstractVector{Int} where {FT<:EndyRangeElType, TT<:EndyRangeElType}
    from::FT # from
    to::TT   # to
end

####### Union Catchall #######
const EndyIndex = Union{EndySingleIndex, EndyRangeIdx}

####### Indexing Operations #######
idx_from_axis(ax, idx::EndBasedIdx)   = lastindex(ax)  - idx.v
idx_from_axis(ax, idx::StartBasedIdx) = firstindex(ax) + idx.v
idx_from_axis(ax, idx::Int)           = idx
idx_from_axis(ax, idxs::EndyRangeIdx) =
    idx_from_axis(ax, idxs.from):idx_from_axis(ax, idxs.to)

Base.to_indices(a, _axes, idxss::Tuple{Vararg{EndyIndex}}) =
    ((idx_from_axis(ax, idx) for (ax, idx) in zip(_axes, idxss))...,)

####### Input Conveniences #######
# enables writing e.g. `end_-4`, `end_-9`, `start_+2`, `start_+6`
Base.:-(idx::EndBasedIdx, i::Int)   =   EndBasedIdx(idx.v + i)
Base.:+(idx::StartBasedIdx, i::Int) = StartBasedIdx(idx.v + i)

# enables writing e.g. `end_-9:end_-3` `end_-5:end_` `2:end_-1`, `start_+2:10`
(::Base.Colon)(from::EndySingleIndex, to::EndySingleIndex) = EndyRangeIdx(from, to)
(::Base.Colon)(from::EndySingleIndex, to::Int) = EndyRangeIdx(from, to)
(::Base.Colon)(from::Int, to::EndySingleIndex) = EndyRangeIdx(from, to)

####### Display #######
idx_value_str(idx::EndBasedIdx)  = idx.v==0 ? "" : "-$(idx.v)"
idx_value_str(idx::StartBasedIdx) = idx.v==0 ? "" : "+$(idx.v)"
Base.show(io::IO, idx::EndBasedIdx)   = print(io,   "end$(idx_value_str(idx))")
Base.show(io::IO, idx::StartBasedIdx) = print(io, "start$(idx_value_str(idx))")
Base.show(io::IO, idxs::EndyRangeIdx) = (show(io, idxs.from); print(io, ":"); show(io, idxs.to))

# Not needed?
# Base.to_index(a::AbstractArray, idx::EndBasedIdx)   = idx_from_axis(a, idx)
# Base.to_index(a::AbstractArray, idxs::EndyRangeIdx) = idx_from_axis(a, idx)
# Base.:+(idx::EndBasedIdx, i::Int) = EndBasedIdx(idx.v - i)
# Base.isless(i1::EndBasedIdx, i2::EndBasedIdx) = i1.v > i2.v
# Base.size(r::EndyRangeIdx) = (r.from.v - r.to.v + 1,)
# Base.length(r::EndyRangeIdx) = r.from.v - r.to.v + 1
# Base.first(r::EndyRangeIdx) = r.from
# Base.last(r::EndyRangeIdx) = r.to

end # module


text:
function _make_digital_output()

end

function ttl_cb(widget::Ptr,user_data::Tuple{Gui_Handles,RHD2000})

    han, rhd = user_data

    visible(han.b["digital_out_window"],true)
    nothing
end

function stim_update_cb(widget::Ptr,user_data::Tuple{Gui_Handles,FPGA})

    han, fpga = user_data

end

function update_ttl_from_gui(han,fpga)

    c=channel
    d=fpga[1].d[c]

    update_ttl_trigger(han,d)

    if get_gtk_property(han.b["pulse_burst_combo"],:value,Int)==0 #pulse
        update_ttl_pulse(han,d)
    else
         update_ttl_burst(han,d)
    end

end

function update_ttl_trigger(han,d)

    #Trigger source

    if get_gtk_property(han.b["edge_trigger_combo"],:value,Int) == 0
        d.edgeTriggered = 0 #Edge Triggered
    else
        d.edgeTriggered = 1 #Level triggered
    end

    if get_gtk_property(han.b["high_low_trigger_combo"],:value,Int) == 0
        d.triggerOnLow = 0 #Trigger on High
    else
        d.triggerOnLow = 1 #Trigger on Low
    end

end

function update_ttl_pulse(han,d)

    pw = get_gtk_property(han.b["pulse_duration_train_sb"],:value,Int) #us
    period = get_gtk_property(han.b["pulse_period_train_sb"],:value,Int) * 1000 #convert ms to us

    d.pulseOrTrain = 0
    d.numPulses = 1
    d.firstPhaseDuration = pw
    d.refractoryPeriod = period - pw
    d.pulseTrainPeriod = period - pw

end

function update_ttl_burst(han,d)

    pw = get_gtk_property(han.b["pulse_duration_burst_sb"],:value,Int) #us
    period = get_gtk_property(han.b["pulse_period_burst_sb"]) * 1000 #convert ms to us
    num_pulses = get_gtk_property(han.b["num_pulses_sb"],:value,Int)

    d.pulseOrTrain = 1
    d.numPulses = num_pulses

    d.firstPhaseDuration = pw
    d.pulseTrainPeriod = period

    if get_gtk_property(han.b["repeat_burst_checkbox"],:active,Bool)
        d.refractoryPeriod = get_gtk_property(han.b["burst_period_burst_sb"],:value,Int) * 1000 #ms to us
        d.repeatBurst=true
    else
        #this effectively sets how long until next stimulation. don't want it to be too long
        d.refractoryPeriod = 1e6 * 10
    end
end


text:
function FPU(omega)

# returns functions for the fast potential, the slow potential, kineticTerm, Lagragian, Hamiltonian and Oscillatory Energy
# of the FPUT problem, when provided with the stiffness parameter omega

# FPUT problem: see I.5.1 A Fermi–Pasta–Ulam Problem in Geometric Numerical Integration by Hairer, Lubich, Wanner (2006)

    function fastPotential(qf)
    omega^2/2*sum(qf.^2)
    end

    function slowPotential(qs,qf)
        qd= qs-qf
        1/4*(qd[1]^4 + sum((qd[2:end]-qs[1:end-1]-qf[1:end-1]).^4) + qd[end]^4)
    end

    function kineticTerm(qsdot,qfdot)
        1/2*(sum(qsdot.^2)+sum(qfdot.^2))
    end

    function L(qs,qf,qsdot,qfdot)
        kineticTerm(qsdot,qfdot)-slowPotential(qs,qf)-fastPotential(qf)
    end

    function Hamiltonian(qs,qf,qsdot,qfdot)
        kineticTerm(qsdot,qfdot)+slowPotential(qs,qf)+fastPotential(qf)
    end

    function OscillatoryEnergy(qf,pf)
    # adiabatic invariant
        return sum(1/2*(pf.^2 .+omega^2*qf.^2),dims=1)
    end

    return fastPotential, slowPotential, kineticTerm, L, Hamiltonian, OscillatoryEnergy

end

max_stars_repo_name: Christian-Offen/MultiRate

max_issues_repo_name: Christian-Offen/MultiRate

max_forks_repo_name: Christian-Offen/MultiRate


text:
raw_schedule = [
0.  34.727005414827154  0.8056959494974882
0.001  34.66822643449638  0.8077770020784474
0.002  34.6093858052927  0.8098504783923693
0.003  34.55048303217111  0.8119165956523561
0.004  34.49151762008658  0.8139755710715088
0.005  34.43248907399413  0.8160276218629292
0.006  34.37339689884872  0.8180729652397188
0.007  34.314240599605355  0.8201118184149795
0.008  34.25501968122043  0.8221443986017473
0.009  34.195733648646105  0.8241709230132558
0.01  34.13638200683877  0.8261916088625434
0.011  34.07696426075346  0.8282066733627043
0.012  34.01747991534516  0.8302163337268439
0.013  33.95792847556884  0.8322208071680633
0.014  33.89830944637832  0.834220310899517
0.015  33.83862233273099  0.8362150621342
0.016  33.77886663958063  0.838205278085268
0.017  33.71904187188221  0.8401911759658226
0.018  33.659147534590744  0.842172972988965
0.019  33.59918313266121  0.8441508863677968
0.02  33.5391481710486  0.8461251333154198
0.021  33.47904215470791  0.8480959310449357
0.022  33.418864588592875  0.8500634967694906
0.023  33.35861497766103  0.852028047702095
0.024  33.29829282686607  0.853989801055897
0.025  33.23789764116299  0.8559489740439975
0.026  33.177428925506774  0.8579057838794988
0.027  33.11688618485351  0.8598604477754629
0.028  33.05626892415599  0.8618131829450708
0.029  32.9955766483703  0.8637642066013838
0.03  32.934808862451455  0.8657137359575036
0.031  32.87396507135443  0.8676619882265316
0.032  32.81304478003422  0.8696091806215693
0.033  32.75204749344582  0.8715555303557186
0.034  32.69097271654422  0.8735012546420806
0.035  32.62981995428441  0.8754465706937572
0.036  32.56858871162137  0.87739169572385
0.037  32.50727849351074  0.8793368469454311
0.038  32.445888804906225  0.8812822415716614
0.039  32.384419150763456  0.8832280968156124
0.04  32.32286903603743  0.8851746298903858
0.041  32.261237965683144  0.8871220580090828
0.042  32.199525444655585  0.8890705983848054
0.043  32.13773097790974  0.891020468230655
0.044  32.07585407040009  0.8929718847597561
0.045  32.013894227082666  0.8949250651851635
0.046  31.951850952911933  0.8968802267200023
0.047  31.88972375284288  0.8988375865773744
0.048  31.827512131830492  0.9007973619703814
0.049  31.765215594829762  0.9027597701121247
0.05  31.70283364679569  0.9047250282157057
0.051  31.64036579268326  0.9066933534942264
0.052  31.577811537447463  0.9086649631607879
0.053  31.51517038604283  0.9106400744285087
0.054  31.45244184342529  0.9126189045104562
0.055  31.38962541454935  0.9146016706197497
0.056  31.326720604370017  0.9165885899694903
0.057  31.263726917842266  0.9185798797727797
0.058  31.200643859921094  0.9205757572427197
0.059  31.137470935561602  0.9225764395924045
0.06  31.074207649718797  0.924582144034944
0.061  31.010853507347292  0.9265930877834448
0.062  30.947408013402324  0.9286094880510021
0.063  30.883870672838896  0.9306315620507177
0.064  30.820240990611993  0.9326595269956931
0.065  30.7565184716766  0.9346936000990296
0.066  30.69270262098771  0.936733998573829
0.067  30.628792943500322  0.938780939633193
0.068  30.564788944169422  0.9408346404902227
0.069  30.500690127949994  0.9428953183580201
0.07  30.43649599979704  0.9449631904496866
0.071  30.372206064665544  0.9470384739783235
0.072  30.3078198275105  0.9491213861570328
0.073  30.243336793286897  0.951212144198916
0.074  30.178756466949725  0.9533109653170743
0.075  30.11407835345398  0.9554180667246093
0.076  30.049301957754647  0.9575336656346232
0.077  29.98442678480672  0.9596579792602169
0.078  29.91945233956519  0.961791224814492
0.079  29.854378126985043  0.9639336195105505
0.08  29.789203652021275  0.9660853805614934
0.081  29.72392841962888  0.9682467251804227
0.082  29.65855193476284  0.9704178705804397
0.083  29.59307370237815  0.9725990339746462
0.084  29.527493227429805  0.9747904325761436
0.085  29.461810014872786  0.9769922835980334
0.086  29.396023569662095  0.9792048042534173
0.087  29.330133396752714  0.9814282117553969
0.088  29.264139001099643  0.9836627233170733
0.089  29.19803988765786  0.9859085561515488
0.09  29.131835561382367  0.9881659274719243
0.091  29.06552552722815  0.9904350544913019
0.092  28.999109290150205  0.9927161544227826
0.093  28.932586355103517  0.9950094444794685
0.094  28.86595622704308  0.9973151418744608
0.095  28.799218410923878  0.9996334638208614
0.096  28.732372411700908  1.0019646275317713
0.097  28.665417734329164  1.0043088502202926
0.098  28.598353883763632  1.0066663490995265
0.099  28.531180364959305  1.009037341382575
0.1  28.46389668287117  1.0114220442825392
0.101  28.396502342454223  1.013820675012521
0.102  28.328996848663454  1.0162334507856214
0.103  28.261379706453845  1.0186605888149427
0.104  28.193650420780404  1.021102306313586
0.105  28.125808496598104  1.0235588204946529
0.106  28.05785343886195  1.0260303485712452
0.107  27.989784752526926  1.028517107756464
0.108  27.921601942548023  1.0310193152634115
0.109  27.853304513880232  1.033537188305189
0.11  27.78489197147854  1.0360709440948979
0.111  27.71636382029795  1.0386207998456396
0.112  27.647719565293443  1.0411869727705159
0.113  27.57895871142001  1.0437696800826286
0.114  27.510080763632644  1.0463691389950789
0.115  27.441085226886337  1.0489855667209682
0.116  27.37197160613608  1.0516191804733988
0.117  27.30273940633686  1.0542701974654716
0.118  27.233388132443668  1.0569388349102882
0.119  27.163917289411497  1.0596253100209503
0.12  27.094326382195348  1.0623298400105596
0.121  27.024614915750192  1.0650526420922177
0.122  26.95478239503103  1.067793933479026
0.123  26.88482832499286  1.070553931384086
0.124  26.81475221059066  1.073332853020499
0.125  26.744553556779422  1.076130915601367
0.126  26.67423186851415  1.0789483363397916
0.127  26.60378665074982  1.0817853324488742
0.128  26.533217408441434  1.0846421211417163
0.129  26.462523646543975  1.0875189196314197
0.13  26.391704870012433  1.0904159451310853
0.131  26.32076058380181  1.0933334148538154
0.132  26.249690292867083  1.0962715460127113
0.133  26.178493540968184  1.0992304767038348
0.134  26.107169798139264  1.1022104953382879
0.135  26.035718549353494  1.1052118598688885
0.136  25.964139290536373  1.108234805918429
0.137  25.8924315176134  1.1112795691097024
0.138  25.82059472651006  1.1143463850655004
0.139  25.748628457640333  1.117435380205104
0.14  25.67653215469547  1.1205469183679508
0.141  25.604305304876398  1.1236812565925762
0.142  25.531947395833264  1.1268386508148047
0.143  25.45945791521623  1.1300193569704606
0.144  25.386836358385995  1.133223606199629
0.145  25.31408223461035  1.136451584919504
0.146  25.241194993851717  1.1397036702631924
0.147  25.168174116781117  1.1429801406102496
0.148  25.09501908406956  1.146281274340231
0.149  25.02172937638806  1.149607349832693
0.15  24.948304487380792  1.1529585894625685
0.151  24.87474390134269  1.156335255965071
0.152  24.80104707426426  1.1597377342645792
0.153  24.727213481064368  1.1631663275724222
0.154  24.653242596661894  1.1666213390999296
0.155  24.5791338959757  1.1701030720584313
0.156  24.50488686667663  1.173611736437935
0.157  24.430500976737978  1.1771476862243797
0.158  24.355975689202765  1.1807113114457073
0.159  24.281310475226533  1.1843029428245244
0.16  24.20650480596483  1.187922911083437
0.161  24.131558152573188  1.191571546945051
0.162  24.056469994193275  1.195249043933526
0.163  23.98123979432091  1.1989558643625207
0.164  23.90586702055133  1.2026924001191452
0.165  23.830351142263492  1.2064590124470507
0.166  23.754691628836355  1.2102560625898884
0.167  23.678887949505903  1.2140839065227937
0.168  23.602939568958355  1.2179427325577203
0.169  23.526845962354  1.2218331149858472
0.17  23.45060659999185  1.2257554489559972
0.171  23.37422095217093  1.2297101296169926
0.172  23.297688489190257  1.2336975521176556
0.173  23.22100867602277  1.2377180620663595
0.174  23.144180972210684  1.241771954557535
0.175  23.06720486914447  1.2458598209220435
0.176  22.990079841177714  1.2499820940223818
0.177  22.91280536266402  1.2541392067210466
0.178  22.83538090795698  1.2583315918805347
0.179  22.75780593213587  1.2625595789655133
0.18  22.680079908123354  1.2668235931622374
0.181  22.602202342274992  1.2711242390088404
0.182  22.524172716774178  1.2754619913709853
0.183  22.4459905138043  1.279837325114335
0.184  22.36765521554874  1.2842507151045524
0.185  22.28916625985834  1.2887024680288155
0.186  22.21052315722001  1.2931931661240892
0.187  22.131725426221514  1.2977234223585055
0.188  22.05277256139281  1.3022937584352743
0.189  21.97366405726386  1.306904696057605
0.19  21.894399408364613  1.3115567569287079
0.191  21.814978025917117  1.316250217429842
0.192  21.735399488877263  1.3209858478784826
0.193  21.655663323644713  1.3257642638265097
0.194  21.575769042505925  1.3305860392657747
0.195  21.495716157747342  1.3354517481881285
0.196  21.41550417284562  1.3403619432544707
0.197  21.335132487602944  1.3453169261011988
0.198  21.254600761310112  1.3503176266582473
0.199  21.17390853038827  1.355364677354233
0.2  21.09305533125857  1.360458710617774
0.201  21.01204070034216  1.3656003588774883
0.202  20.930864125849265  1.370790155063157
0.203  20.849525074269724  1.3760285872774791
0.204  20.76802324048198  1.3813166149769949
0.205  20.686358192581945  1.3866549359614413
0.206  20.60452949866553  1.392044248030555
0.207  20.522536726828648  1.3974852489840732
0.208  20.440379336670546  1.4029784413987585
0.209  20.35805690705264  1.4085245424452164
0.21  20.275569164013618  1.4141245341167883
0.211  20.192915716325206  1.4197791874030405
0.212  20.11009617275912  1.4254892732935414
0.213  20.02711014208709  1.4312555627778574
0.214  19.943957039335178  1.4370785159063793
0.215  19.86063661321194  1.4429591282509635
0.216  19.77714861253295  1.448898395555239
0.217  19.693492697163705  1.454897170808318
0.218  19.609668526969692  1.4609563069993128
0.219  19.525675761816405  1.467076657117335
0.22  19.441513751090888  1.4732586249705368
0.221  19.357182484822523  1.4795035412086577
0.222  19.27268172360224  1.4858124045441385
0.223  19.188011190827552  1.4921861598802726
0.224  19.103170609895972  1.4986257521203508
0.225  19.01815965940502  1.5051320669566715
0.226  18.932977733737225  1.5117056144418368
0.227  18.84762501608997  1.5183479471848789
0.228  18.762101307831962  1.5250601131416315
0.229  18.6764064103319  1.5318431602679272
0.23  18.590540124958498  1.538698136519599
0.231  18.504502088875803  1.545625889961647
0.232  18.41829193622956  1.552627264984798
0.233  18.331909924171907  1.5597038643825611
0.234  18.245355948979576  1.5668568516449308
0.235  18.158629906929313  1.574087390261902
0.236  18.071731694297867  1.5813966437234697
0.237  17.984660878135987  1.588785403627471
0.238  17.897417436345133  1.5962549256668013
0.239  17.810001686768764  1.60380684953126
0.24  17.722413640302285  1.6114424681835475
0.241  17.634653307841095  1.6191630745863648
0.242  17.5467207002806  1.6269699617024111
0.243  17.458615279072873  1.634863843750361
0.244  17.37033749341215  1.6428464753653387
0.245  17.281887702781745  1.6509195166874278
0.246  17.19326605570348  1.6590844056450864
0.247  17.104472700699176  1.6673425801667725
0.248  17.01550778629066  1.6756954781809443
0.249  16.926370626564495  1.6841437140928286
0.25  16.837062295933414  1.692689639613783
0.251  16.74758316887801  1.7013349156761373
0.252  16.65793355814749  1.7100811422881144
0.253  16.568113776491074  1.718929919457937
0.254  16.47812398383688  1.727882705429819
0.255  16.387963756559987  1.7369404171168055
0.256  16.297634518880557  1.7461056855796881
0.257  16.207136778479846  1.7553802916547847
0.258  16.11647104303909  1.7647660161784138
0.259  16.025637820239545  1.7742646399868935
0.26  15.934637171361686  1.7838775541489724
0.261  15.84346930102512  1.793606274887635
0.262  15.752135776853851  1.8034535085109618
0.263  15.660637336894778  1.8134212369952782
0.264  15.568974719194781  1.8235114423169099
0.265  15.47714866180075  1.8337261064521808
0.266  15.385159069740748  1.8440665258486104
0.267  15.293006995021447  1.8545349408542078
0.268  15.200694115847767  1.865134107143795
0.269  15.108221441022625  1.8758662295110602
0.27  15.015589979348945  1.8867335127496916
0.271  14.922800739629638  1.8977381616533766
0.272  14.82985340208322  1.9088813520852022
0.273  14.736750126077608  1.9201661799012004
0.274  14.643492657171626  1.931595420480337
0.275  14.55008232113326  1.943171524091899
0.276  14.456520443730492  1.954896941005175
0.277  14.362808350731306  1.9667741214894534
0.278  14.26894542237749  1.9788041000167365
0.279  14.1749352265735  1.9909909585026735
0.28  14.080779519334053  2.0033374603154743
0.281  13.986479995339705  2.0158463241892894
0.282  13.89203834927101  2.0285202688582684
0.283  13.797455851511103  2.0413617242741444
0.284  13.702732772206366  2.054372439614355
0.285  13.607873158027378  2.0675567344084307
0.286  13.512879130868223  2.0809176181576676
0.287  13.417752812622977  2.094458100363365
0.288  13.322496325185716  2.1081811905268193
0.289  13.227110735415957  2.1220892313561497
0.29  13.131597737891573  2.1361849622842333
0.291  13.035961618227114  2.1504727603069393
0.292  12.94020499018551  2.1649559457919607
0.293  12.844330467529682  2.1796378391069884
0.294  12.748340664022557  2.1945217606197156
0.295  12.652236349442337  2.209609959433994
0.296  12.556021040861994  2.224906280695934
0.297  12.459699188118858  2.240415111441566
0.298  12.363273967142359  2.25614009862949
0.299  12.266748553861918  2.272084889218307
0.3  12.170126124206966  2.2882531301666176
0.301  12.073407054122491  2.3046469981414397
0.302  11.976597118373821  2.321271504768442
0.303  11.879700842315987  2.3381310055991267
0.304  11.782722039716191  2.355229482525206
0.305  11.685664524341622  2.3725709174383938
0.306  11.588532078842807  2.3901592778215366
0.307  11.491324693705375  2.407996775160266
0.308  11.394050759332318  2.4260895106000575
0.309  11.296714806164065  2.4444417978948243
0.31  11.199321364641035  2.4630579507984818
0.311  11.101874965203654  2.4819422830649454
0.312  11.0043791808731  2.5010987331899246
0.313  10.906836240022093  2.5205307126373615
0.314  10.809254900459171  2.540244192068073
0.315  10.711640489062285  2.5602437973977725
0.316  10.613998332709384  2.580534154542173
0.317  10.516333758278419  2.6011198894169887
0.318  10.418650039685957  2.622004994540488
0.319  10.320952135719004  2.6431939822617765
0.32  10.223249036404946  2.6646926086831875
0.321  10.125546941639831  2.6865057690715464
0.322  10.027852051319707  2.7086383586936797
0.323  9.930170565340624  2.731095272816413
0.324  9.832505407156159  2.7538807248326314
0.325  9.734864708813953  2.7770000121171905
0.326  9.63725754816561  2.800458628880098
0.327  9.539691065855019  2.824261666171089
0.328  9.442172402526063  2.8484142150398952
0.329  9.34470869882263  2.872921366536252
0.33  9.247302544547683  2.897787830750859
0.331  9.149965562925097  2.923019073978237
0.332  9.052706786169432  2.948620345614883
0.333  8.955534347061494  2.974596819764086
0.334  8.858456378382085  3.000953670529134
0.335  8.761480755378555  3.0276960915265665
0.336  8.664610629030701  3.05482963432959
0.337  8.567860435097527  3.0823589954662842
0.338  8.47123932394832  3.110289271937493
0.339  8.374756445952363  3.13862556074406
0.34  8.278420951478942  3.16737295888683
0.341  8.182240572891484  3.196536974258415
0.342  8.086222002395653  3.2261234161551697
0.343  7.99037952570698  3.2561358935223685
0.344  7.894723298318271  3.286579212108898
0.345  7.799263475722334  3.317458177663644
0.346  7.704010213411975  3.348777595935491
0.347  7.608971258328116  3.3805437098188404
0.348  7.51415679018183  3.412761310611915
0.349  7.419580723963105  3.445432960829997
0.35  7.325254156891662  3.4785629043081427
0.351  7.231188186187228  3.512155384881405
0.352  7.137393909069528  3.546214646384836
0.353  7.043879424991829  3.580748191592767
0.354  6.950657865563053  3.6157580527100404
0.355  6.857742648260683  3.6512459511673585
0.356  6.7651456839008475  3.6872152463208425
0.357  6.672878883299668  3.723669297526617
0.358  6.580954157273271  3.7606114641408035
0.359  6.48938050614634  3.7980510544395587
0.36  6.3981728595349985  3.8359852574809086
0.361  6.30734416109385  3.8744153215433084
0.362  6.216906930167915  3.913343362175842
0.363  6.126873686102214  3.9527714949275974
0.364  6.037256800605488  3.9927025809224426
0.365  5.948067371376817  4.033145915132944
0.366  5.859319832537053  4.0740939433401016
0.367  5.771027022518938  4.115547169674974
0.368  5.68320177975522  4.157506098268621
0.369  5.59585694267864  4.199971233252103
0.37  5.509005439051161  4.242946227426414
0.371  5.4226602176580325  4.286435474620084
0.372  5.336833846063042  4.3304299313940575
0.373  5.2515391075258675  4.374928157142935
0.374  5.166788785306181  4.419928711261316
0.375  5.082595662663664  4.4654301531438
0.376  4.998973912355567  4.5114370933798265
0.377  4.915936079681104  4.557947055057666
0.378  4.833493043142136  4.604950302443638
0.379  4.751657083097645  4.652443204824105
0.38  4.670440479906614  4.700422131485435
0.381  4.589855513928025  4.7488834517139935
0.382  4.509918348800083  4.797832435708441
0.383  4.430638319850866  4.847258702413415
0.384  4.352025064882838  4.8971525640788345
0.385  4.2740898648080865  4.947508099146487
0.386  4.196844000538697  4.998319386058156
0.387  4.120298752986753  5.049580503255628
0.388  4.044472905530812  5.1012964798172815
0.389  3.9693695961091047  5.153449508660606
0.39  3.8949978631128728  5.206030395033049
0.391  3.821367480185807  5.259031017360106
0.392  3.748488220971597  5.31244325406727
0.393  3.676371188202051  5.366260257532147
0.394  3.6050340921359467  5.420481513552088
0.395  3.5344752256219456  5.47508789602786
0.396  3.4647023849835255  5.530069388092073
0.397  3.395723366544165  5.585415972877334
0.398  3.327545966627343  5.6411176335162505
0.399  3.2601822916809753  5.697166894086259
0.4  3.1936438042103474  5.753555899041722
0.401  3.127927191837108  5.810268082609552
0.402  3.063037891706227  5.867292037117401
0.403  2.998981340962676  5.924616354892918
0.404  2.9357629767514264  5.9822296282637595
0.405  2.8733959725124376  6.04012264683441
0.406  2.811883365386968  6.098283321279024
0.407  2.7512212540183003  6.156697591586696
0.408  2.6914124686684686  6.21535330967336
0.409  2.6324598395995062  6.274238327454943
0.41  2.5743661970734473  6.333340496847376
0.411  2.517145364799614  6.392647788556769
0.412  2.460791044512701  6.452147955860349
0.413  2.4052995118397127  6.51182877984764
0.414  2.3506709060516924  6.571678083356955
0.415  2.296905366419685  6.631683689226597
0.416  2.2440030322147346  6.691833420294876
0.417  2.1919775042002976  6.752111758176576
0.418  2.140813710659674  6.812510301168811
0.419  2.0905084632864126  6.8730176980346664
0.42  2.0410592980522217  6.933622417767031
0.421  1.9924637509288063  6.9943129293587925
0.422  1.944721437817617  7.055076644675478
0.423  1.8978383213218637  7.115897749862102
0.424  1.851798699055617  7.176771442326322
0.425  1.806597747405777  7.237687390323478
0.426  1.7622306427592431  7.298635262108912
0.427  1.7186925615029152  7.3596047259379676
0.428  1.6759827376706704  7.420582247735821
0.429  1.6340985564249846  7.481555752572986
0.43  1.5930262047091144  7.54252200325164
0.431  1.5527588643785801  7.603472242128572
0.432  1.5132897172889015  7.664397711560581
0.433  1.4746119452955992  7.7252896539044515
0.434  1.4367236592505528  7.786133752187222
0.435  1.3996159149601843  7.846923646699699
0.436  1.3632766471003324  7.907656498001898
0.437  1.327697483405406  7.968325301316936
0.438  1.292870051609816  8.028923051867931
0.439  1.2587859794479717  8.089442744878001
0.44  1.22544155096932  8.149869866036575
0.441  1.1928242233422746  8.210204136702268
0.442  1.1609232036309574  8.270442456066233
0.443  1.1297290326828846  8.330579572242806
0.444  1.099232251345572  8.390610233346328
0.445  1.0694234004665357  8.450529187491135
0.446  1.040296428112451  8.510322520504003
0.447  1.0118378839369362  8.569995127445399
0.448  0.984037629913841  8.62954348235295
0.449  0.9568855715721692  8.688963948532562
0.45  0.9303716144409246  8.748252889290137
0.451  0.9044859155597615  8.807405151711976
0.452  0.879219101770911  8.866412750702624
0.453  0.8545598301307137  8.925279575924105
0.454  0.8304977755459794  8.984003380976878
0.455  0.8070226129235178  9.042581919461416
0.456  0.7841240171701388  9.101012944978187
0.457  0.7617914226536977  9.15929168701306
0.458  0.7400144334012451  9.217415155384128
0.459  0.7187831862819398  9.275385951330419
0.46  0.6980874635238213  9.33320295463623
0.461  0.6779170473549284  9.390865045085864
0.462  0.6582617200033  9.448371102463618
0.463  0.6391100104131039  9.50571710143639
0.464  0.6204523749266274  9.562903484388206
0.465  0.6022797729487429  9.619931859804332
0.466  0.584582358085717  9.676801968325394
0.467  0.567350283943816  9.733513550592026
0.468  0.5505737041293062  9.79006634724485
0.469  0.5342402527297756  9.846457321815887
0.47  0.5183424901538606  9.902688867814204
0.471  0.5028717045967013  9.958761976467128
0.472  0.4878186118321057  10.01467700805758
0.473  0.4731739276338816  10.070434322868476
0.474  0.4589282707541595  10.126034222474829
0.475  0.4450688297977054  10.181474932866283
0.476  0.43159064959130483  10.236759433839747
0.477  0.4184851334211613  10.291888501692531
0.478  0.40574368457347787  10.346862912721948
0.479  0.39335770633445805  10.401683443225304
0.48  0.3813176183954223  10.456350539156855
0.481  0.36961279289743043  10.510864294648242
0.482  0.3582385810036336  10.565226811902097
0.483  0.34718714296513525  10.619439121444477
0.484  0.33645063903303896  10.673502253801436
0.485  0.3260212294584482  10.727417239499024
0.486  0.3158891594535087  10.781184784910144
0.487  0.3060464224611288  10.834805892325706
0.488  0.2964883874191137  10.888282135396961
0.489  0.2872079969790268  10.941614677084642
0.49  0.2781981937924318  10.994804680349482
0.491  0.26945192051089223  11.047853308152218
0.492  0.2609593498075843  11.100761560972524
0.493  0.25271517603876403  11.153530704522419
0.494  0.24471463613093108  11.206162036339945
0.495  0.23695144713381835  11.258656764810393
0.496  0.2294193260971587  11.311016098319051
0.497  0.22211199007068505  11.36324124525121
0.498  0.21501968073478292  11.415333476312071
0.499  0.2081396248048873  11.467293936952014
0.5  0.20146688321518685  11.519123811457959
0.501  0.1949959158772052  11.57082429489428
0.502  0.1887211827024658  11.622396582325365
0.503  0.1826368996415142  11.673841886464778
0.504  0.17673426416180188  11.725161638396129
0.505  0.1710119817300798  11.776356726042088
0.506  0.16546520777753576  11.827428294150145
0.507  0.16008909773535734  11.87837748746781
0.508  0.15487880703473222  11.929205450742572
0.509  0.14982852727535534  11.979913436318846
0.51  0.14493198329725016  12.030502748647564
0.511  0.14018753687823762  12.080974174537097
0.512  0.1355909826440476  12.131328787378736
0.513  0.13113811522040988  12.18156766056377
0.514  0.12682472923305435  12.231691867483494
0.515  0.12264508488809242  12.281702697016216
0.516  0.11859511225368867  12.331601203532301
0.517  0.11467285948883087  12.381388143946921
0.518  0.11087469950942196  12.431064510438887
0.519  0.1071970052313648  12.480631295187013
0.52  0.10363614957056232  12.530089490370107
0.521  0.10018655289523752  12.579440404046988
0.522  0.0968459877987798  12.628684801958897
0.523  0.09361225096001301  12.677823445950594
0.524  0.09048223207523579  12.726857244596983
0.525  0.08745282084074678  12.77578710647298
0.526  0.08452090695284467  12.824613940153501
0.527  0.0816811536206815  12.873339050427417
0.528  0.07893281090006539  12.921962925832458
0.529  0.07627349928117795  12.9704863448953
0.53  0.07370056529656209  13.018910134894673
0.531  0.07121135547876073  13.067235123109311
0.532  0.06880299211952515  13.115462179549707
0.533  0.06647112097615365  13.163592455597588
0.534  0.06421545391428991  13.21162632778927
0.535  0.06203373767252413  13.259564547139465
0.536  0.05992371898944648  13.307407864662878
0.537  0.057883144603647116  13.355157031374207
0.538  0.055909164133741016  13.402812918170701
0.539  0.05399890064326686  13.450376401281009
0.54  0.05215177671859603  13.497847895263346
0.541  0.05036588707115465  13.545228081270634
0.542  0.048639326412368865  13.592517640455785
0.543  0.0469701894536648  13.639717253971725
0.544  0.04535571230717563  13.686827782992058
0.545  0.043794194445713516  13.733849865737819
0.546  0.04228483955328001  13.780783950845994
0.547  0.04082604271582122  13.82763065649062
0.548  0.03941619901928326  13.874390600845718
0.549  0.03805370354961223  13.921064402085324
0.55  0.03673592582822926  13.967652901863646
0.551  0.03546207402816911  14.014156541175366
0.552  0.0342311997706447  14.060575795129289
0.553  0.033041955906684774  14.106911225729998
0.554  0.03189299528731808  14.153163394982084
0.555  0.03078297076357336  14.199332864890128
0.556  0.029709419896759227  14.245420449603204
0.557  0.028672229682059493  14.291426432110825
0.558  0.02767035890629417  14.337351305251667
0.559  0.02670268049374096  14.383195581276205
0.56  0.025768067368677577  14.428959772434904
0.561  0.024865248562981536  14.474644424766678
0.562  0.023992385186331424  14.520250217668483
0.563  0.023149418555562823  14.565777412513572
0.564  0.02233540853494591  14.611226477655649
0.565  0.021549414988750893  14.656597881448404
0.566  0.020790497781247953  14.701892092245538
0.567  0.020057412600390727  14.74710965277024
0.568  0.019349006483365988  14.792251083411282
0.569  0.01866506900742845  14.837316674111438
0.57  0.018004818159369843  14.882306854564293
0.571  0.017367471925981894  14.927222054463424
0.572  0.01675224829405634  14.972062703502422
0.573  0.01615795727641509  15.016829335645772
0.574  0.015583967263767156  15.061522342146489
0.575  0.015029960642345854  15.106142034005902
0.576  0.014495288603586608  15.150688806872852
0.577  0.01397930233892489  15.195163056396177
0.578  0.013481353039796015  15.239565178224732
0.579  0.013000324521692431  15.2838956934147
0.58  0.012535970650901309  15.328154889568316
0.581  0.012087904226104463  15.37234309213938
0.582  0.011655588303373508  15.416460666760969
0.583  0.011238485938780048  15.460507979066158
0.584  0.010836060188395688  15.504485394688022
0.585  0.010447282211860896  15.54839341877238
0.586  0.01007218056849758  15.592232256563031
0.587  0.009710328700259589  15.636002242385164
0.588  0.009361283168886264  15.679703715351565
0.589  0.009024600536116948  15.723337014575023
0.59  0.008699760923082481  15.766902502172025
0.591  0.00838605816212327  15.810400596319953
0.592  0.008083479751532856  15.853831506447499
0.593  0.007791660337876942  15.897195548168966
0.594  0.007510234567721232  15.940493037098648
0.595  0.007238837087631433  15.983724288850848
0.596  0.006976964184226704  16.026889663554492
0.597  0.006724192119097789  16.069989495608127
0.598  0.006480442065152995  16.113024008441727
0.599  0.006245413600206976  16.155993496779214
0.6  0.006018806302074389  16.198898255344506
0.601  0.005800319748569886  16.241738578861533
0.602  0.005589477804104229  16.2845148229365
0.603  0.005386064850047988  16.32722725291006
0.604  0.005189956920589852  16.369876102366415
0.605  0.005000907389145144  16.41246164739004
0.606  0.004818669629129187  16.454984164065426
0.607  0.0046429970139573035  16.497443928477043
0.608  0.0044734476169707  16.539841289770816
0.609  0.004309955289896024  16.582176456514585
0.61  0.004152368453095489  16.624449669235922
0.611  0.0040004851062267225  16.666661187324706
0.612  0.003854103248947353  16.708811270170806
0.613  0.0037130198105634676  16.750900177601636
0.614  0.00357683579287746  16.792928249534135
0.615  0.0034455841769956913  16.83489564930451
0.616  0.0033190996844160393  16.8768026212918
0.617  0.003197217036636382  16.918649409875062
0.618  0.0030797709551545964  16.960436259433326
0.619  0.00296656013378125  17.002163430440888
0.62  0.0028573307134610922  17.043831206849855
0.621  0.0027520788036535355  17.085439760939742
0.622  0.0026506694543636583  17.12698932354042
0.623  0.002552967715596539  17.16848012548179
0.624  0.0024588386373572556  17.20991239759372
0.625  0.0023680889490952563  17.251286399402076
0.626  0.002280572421797686  17.292602367286467
0.627  0.0021962591388842707  17.33386048039624
0.628  0.002115039100075253  17.375060957285058
0.629  0.002036802305090878  17.41620401650657
0.63  0.0019614387536513885  17.45728987661443
0.631  0.0018887676822013273  17.498318794889958
0.632  0.0018187203655024191  17.53929096729761
0.633  0.0017512494943629341  17.580206578081157
0.634  0.0016862654670193066  17.62106583463044
0.635  0.0016236786817079721  17.661868944335325
0.636  0.001563399536665366  17.702616114585663
0.637  0.0015052617266879576  17.743307599366513
0.638  0.0014492509180005005  17.78394356034453
0.639  0.001395309722875948  17.824524185340422
0.64  0.0013433653107178581  17.865049671556033
0.641  0.0012933448509297887  17.905520216193196
0.642  0.0012451722408246347  17.945936018681596
0.643  0.0011987071618163052  17.986297322173332
0.644  0.0011539618299657624  18.026604265964885
0.645  0.0011108771161026502  18.066857037929264
0.646  0.0010693938910566133  18.107055825939472
0.647  0.001029453025657296  18.147200817868512
0.648  0.0009909798286760303  18.187292213557324
0.649  0.000953887581851434  18.227330222096175
0.65  0.0009181742381057546  18.26731498745935
0.651  0.0008837918111839785  18.307246688950446
0.652  0.000850692314831092  18.34712550587306
0.653  0.0008188277627920815  18.386951617530787
0.654  0.000788126948194557  18.426725223310452
0.655  0.0007585418415645352  18.466446502553023
0.656  0.0007300610279881612  18.506115602932013
0.657  0.000702645650287729  18.545732695855396
0.658  0.0006762568512855329  18.58529795273114
0.659  0.0006508557738038669  18.624811544967226
0.66  0.0006263762308831846  18.664273670752923
0.661  0.0006027977553162366  18.703684483475303
0.662  0.0005801028272104475  18.743044133633287
0.663  0.0005582600344044592  18.782352785339235
0.664  0.0005372379647369138  18.821610602705523
0.665  0.0005170052060464536  18.860817749844532
0.666  0.0004975017824247155  18.899974423107572
0.667  0.00047872581074175644  18.939080753278596
0.668  0.00046065612877850076  18.9781368929012
0.669  0.00044326731316325006  19.017142999328424
0.67  0.0004265339405243058  19.056099229913286
0.671  0.0004104283874675046  19.09500574482419
0.672  0.00039490322474513716  19.133862729575096
0.673  0.0003799625345332015  19.172670303760757
0.674  0.0003655857996231153  19.211428618455795
0.675  0.0003517525028062963  19.2501378247348
0.676  0.0003384421268741622  19.288798073672393
0.677  0.00032562780194657663  19.327409525724978
0.678  0.0003132809737047364  19.36597234383659
0.679  0.00030140061179964  19.4044866503031
0.68  0.0002899701572988128  19.44295259035343
0.681  0.0002789730512697805  19.481370309216494
0.682  0.00026839273478006844  19.519739952121217
0.683  0.0002582037376095787  19.558061679292592
0.684  0.00024839093596428446  19.596335633544463
0.685  0.00023895009395549246  19.63456193936829
0.686  0.0002298678942860569  19.672740736537904
0.687  0.00022113101965883202  19.710872164827133
0.688  0.00021272615277667214  19.74895636400981
0.689  0.00020463997634243144  19.786993473859763
0.69  0.0001968591730589642  19.82498363415083
0.691  0.0001893704256291247  19.86292698465683
0.692  0.00018216041675576716  19.900823665151602
0.693  0.00017521582914174587  19.938673815408972
0.694  0.00016852334548991504  19.976477575202775
0.695  0.00016206964850312897  20.01423508430684
0.696  0.00015584142088424186  20.051946482494987
0.697  0.000149825345336108  20.089611909541063
0.698  0.00014400810456158164  20.127231505218894
0.699  0.00013837638126351705  20.164805409302296
0.7  0.00013291685814476842  20.20233376156512
0.701  0.0001276162179081901  20.239816701781187
0.702  0.00012246114325663624  20.277254369724325
0.703  0.00011743831689296115  20.314646905168367
0.704  0.00011253442152001966  20.35199444788714
0.705  0.00010773613984066483  20.389297137654484
0.706  0.00010303015455775156  20.426555114244223
0.707  0.00009840314837413408  20.46376851743019
0.708  0.00009384180399266662  20.50093748698621
0.709  0.00008933280411620345  20.538062162686117
0.71  0.0000848628314475988  20.575142684303746
0.711  0.00008041856868970697  20.612179191612917
0.712  0.00007598669854538217  20.649171824387473
0.713  0.00007155390371747868  20.68612072240123
0.714  0.00006710686690885074  20.723026025428034
0.715  0.00006263227082235261  20.759887873241702
0.716  0.00005811679816083854  20.796706405616078
0.717  0.00005354713162716278  20.833481762324983
0.718  0.00004890995392417961  20.870214083142244
0.719  0.00004419194775474323  20.906903507841697
0.72  0.000039379795821707955  20.94355017619717
0.721  0.000034460180827928  20.980154227982503
0.722  0.000029419785476257622  21.016715802971518
0.723  0.000024245292469551076  21.05323504093804
0.724  0.000018923384510662627  21.08971208165591
0.725  0.000013440744302446531  21.126147064898955
0.726  7.78405454775703e-6  21.16254013044101
0.727  1.9399979494483825e-6  21.198891418055894
0.728  0  21.235201067517444
0.729  0  21.271469218599492
0.73  0  21.307696011075866
0.731  0  21.343881584720396
0.732  0  21.380026079306916
0.733  0  21.416129634609256
0.734  0  21.452192390401244
0.735  0  21.48821448645671
0.736  0  21.524196062549485
0.737  0  21.5601372584534
0.738  0  21.596038213942283
0.739  0  21.631899068789966
0.74  0  21.66771996277029
0.741  0  21.70350103565707
0.742  0  21.73924242722414
0.743  0  21.774944277245336
0.744  0  21.810606725494488
0.745  0  21.846229911745418
0.746  0  21.881813975771962
0.747  0  21.91735905734795
0.748  0  21.952865296247218
0.749  0  21.98833283224359
0.75  0  22.0237618051109
0.751  0  22.059152354622974
0.752  0  22.094504620553643
0.753  0  22.129818742676743
0.754  0  22.165094860766104
0.755  0  22.200333114595544
0.756  0  22.23553364393891
0.757  0  22.270696588570026
0.758  0  22.30582208826272
0.759  0  22.34091028279082
0.76  0  22.375961311928165
0.761  0  22.41097531544858
0.762  0  22.4459524331259
0.763  0  22.480892804733948
0.764  0  22.515796570046557
0.765  0  22.550663868837564
0.766  0  22.58549484088079
0.767  0  22.620289625950075
0.768  0  22.655048363819244
0.769  0  22.68977119426212
0.77  0  22.72445825705255
0.771  0  22.75910969196435
0.772  0  22.793725638771363
0.773  0  22.828306237247407
0.774  0  22.86285162716632
0.775  0  22.897361948301935
0.776  0  22.93183734042807
0.777  0  22.96627794331857
0.778  0  23.000683896747255
0.779  0  23.03505534048796
0.78  0  23.069392414314517
0.781  0  23.10369525800075
0.782  0  23.137964011320502
0.783  0  23.172198814047587
0.784  0  23.20639980595585
0.785  0  23.240567126819112
0.786  0  23.27470091641121
0.787  0  23.308801314505967
0.788  0  23.34286846087722
0.789  0  23.376902495298797
0.79  0  23.410903557544533
0.791  0  23.444871787388244
0.792  0  23.478807324603775
0.793  0  23.51271030896495
0.794  0  23.54658088024561
0.795  0  23.58041917821957
0.796  0  23.614225342660674
0.797  0  23.647999513342736
0.798  0  23.681741830039606
0.799  0  23.715452432525094
0.8  0  23.74913146057305
0.801  0  23.782779053957295
0.802  0  23.816395352451657
0.803  0  23.849980495829968
0.804  0  23.883534623866066
0.805  0  23.917057876333775
0.806  0  23.95055039300692
0.807  0  23.98401231365934
0.808  0  24.017443778064862
0.809  0  24.050844925997325
0.81  0  24.084215897230543
0.811  0  24.11755683153836
0.812  0  24.1508678686946
0.813  0  24.184149148473097
0.814  0  24.21740081064768
0.815  0  24.250622994992177
0.816  0  24.283815841280415
0.817  0  24.31697948928624
0.818  0  24.35011407878347
0.819  0  24.383219749545933
0.82  0  24.416296641347472
0.821  0  24.449344893961907
0.822  0  24.482364647163074
0.823  0  24.515356040724797
0.824  0  24.548319214420914
0.825  0  24.581254308025247
0.826  0  24.614161461311635
0.827  0  24.6470408140539
0.828  0  24.67989250602588
0.829  0  24.712716677001403
0.83  0  24.7455134667543
0.831  0  24.7782830150584
0.832  0  24.811025461687535
0.833  0  24.843740946415533
0.834  0  24.876429609016228
0.835  0  24.909091589263443
0.836  0  24.94172702693102
0.837  0  24.97433606179278
0.838  0  25.00691883362256
0.839  0  25.039475482194188
0.84  0  25.072006147281492
0.841  0  25.104510968658303
0.842  0  25.13699008609845
0.843  0  25.169443639375775
0.844  0  25.20187176826409
0.845  0  25.23427461253724
0.846  0  25.266652311969054
0.847  0  25.299005006333356
0.848  0  25.331332835403977
0.849  0  25.363635938954754
0.85  0  25.395914456759506
0.851  0  25.428168528592078
0.852  0  25.46039829422629
0.853  0  25.492603893435984
0.854  0  25.52478546599497
0.855  0  25.556943151677096
0.856  0  25.58907709025619
0.857  0  25.621187421506075
0.858  0  25.653274285200588
0.859  0  25.685337821113563
0.86  0  25.717378169018822
0.861  0  25.749395468690192
0.862  0  25.781389859901516
0.863  0  25.813361482426618
0.864  0  25.845310476039327
0.865  0  25.877236980513477
0.866  0  25.909141135622896
0.867  0  25.941023081141413
0.868  0  25.972882956842867
0.869  0  26.00472090250108
0.87  0  26.03653705788988
0.871  0  26.06833156278311
0.872  0  26.100104556954584
0.873  0  26.131856180178143
0.874  0  26.16358657222762
0.875  0  26.19529587287684
0.876  0  26.22698422189963
0.877  0  26.25865175906983
0.878  0  26.29029862416127
0.879  0  26.321924956947765
0.88  0  26.353530897203168
0.881  0  26.385116584701287
0.882  0  26.416682159215966
0.883  0  26.448227760521032
0.884  0  26.47975352839032
0.885  0  26.511259602597658
0.886  0  26.54274612291687
0.887  0  26.574213229121796
0.888  0  26.605661060986254
0.889  0  26.63708975828409
0.89  0  26.66849946078912
0.891  0  26.69989030827519
0.892  0  26.731262440516115
0.893  0  26.762615997285735
0.894  0  26.79395111835788
0.895  0  26.82526794350638
0.896  0  26.85656661250506
0.897  0  26.887847265127757
0.898  0  26.919110041148294
0.899  0  26.95035508034051
0.9  0  26.981582522478227
0.901  0  27.012792507335288
0.902  0  27.04398517468551
0.903  0  27.075160664302736
0.904  0  27.106319115960773
0.905  0  27.137460669433484
0.906  0  27.16858546449468
0.907  0  27.199693640918188
0.908  0  27.23078533847785
0.909  0  27.26186069694749
0.91  0  27.292919856100944
0.911  0  27.323962955712037
0.912  0  27.354990135554605
0.913  0  27.386001535402468
0.914  0  27.416997295029468
0.915  0  27.447977554209427
0.916  0  27.478942452716176
0.917  0  27.509892130323557
0.918  0  27.540826726805385
0.919  0  27.571746381935498
0.92  0  27.60265123548773
0.921  0  27.6335414272359
0.922  0  27.664417096953855
0.923  0  27.695278384415413
0.924  0  27.726125429394408
0.925  0  27.75695837166467
0.926  0  27.78777735100003
0.927  0  27.818582507174316
0.928  0  27.849373979961356
0.929  0  27.880151909134998
0.93  0  27.91091643446905
0.931  0  27.941667695737355
0.932  0  27.972405832713736
0.933  0  28.00313098517203
0.934  0  28.033843292886072
0.935  0  28.064542895629682
0.936  0  28.095229933176693
0.937  0  28.125904545300934
0.938  0  28.156566871776246
0.939  0  28.187217052376443
0.94  0  28.21785522687537
0.941  0  28.248481535046846
0.942  0  28.279096116664714
0.943  0  28.309699111502795
0.944  0  28.340290659334922
0.945  0  28.370870899934925
0.946  0  28.401439973076638
0.947  0  28.431998018533886
0.948  0  28.4625451760805
0.949  0  28.493081585490312
0.95  0  28.523607386537154
0.951  0  28.554122718994854
0.952  0  28.584627722637247
0.953  0  28.615122537238157
0.954  0  28.64560730257142
0.955  0  28.67608215841086
0.956  0  28.706547244530313
0.957  0  28.737002700703616
0.958  0  28.76744866670458
0.959  0  28.797885282307057
0.96  0  28.82831268728486
0.961  0  28.858731021411828
0.962  0  28.889140424461786
0.963  0  28.919541036208578
0.964  0  28.949932996426025
0.965  0  28.980316444887954
0.966  0  29.010691521368198
0.967  0  29.04105836564059
0.968  0  29.07141711747896
0.969  0  29.10176791665714
0.97  0  29.132110902948956
0.971  0  29.16244621612824
0.972  0  29.192773995968818
0.973  0  29.22309438224454
0.974  0  29.253407514729208
0.975  0  29.28371353319667
0.976  0  29.314012577420755
0.977  0  29.344304787175286
0.978  0  29.374590302234104
0.979  0  29.40486926237103
0.98  0  29.435141807359905
0.981  0  29.46540807697455
0.982  0  29.495668210988796
0.983  0  29.52592234917648
0.984  0  29.556170631311428
0.985  0  29.586413197167467
0.986  0  29.616650186518438
0.987  0  29.646881739138163
0.988  0  29.677107994800476
0.989  0  29.7073290932792
0.99  0  29.737545174348174
0.991  0  29.76775637778122
0.992  0  29.797962843352185
0.993  0  29.82816471083488
0.994  0  29.858362120003154
0.995  0  29.888555210630816
0.996  0  29.918744122491717
0.997  0  29.948928995359672
0.998  0  29.979109969008526
0.999  0  30.0092871832121
1.  0  30.039460777744218
]

s_grid = range(0,1,length=1001)
# A and B are interpolated functions of the raw schedules
A = construct_interpolations(s_grid, raw_schedule[:,2])
B = construct_interpolations(s_grid, raw_schedule[:,3])
dA(s) = gradient(A, s)
dB(s) = gradient(B, s)


text:
#######################################################
### Goole Polyline Algorithm Format encoder/decoder ###
#######################################################

"""
Encode single coordinate (multiplied by 1e5 and rounded)
in Google Polyline Algorithm Format

**Arguments**
* `val` : single coordinate (multiplied by 1e5 and rounded)

"""
function encode_one(val::Int)
    val <<= 1
    val = val < 0 ? ~val : val
    res = ""
    while val >= 0x20
        res *= Char((0x20 | (val & 0x1f)) + 63)
        val >>= 5
    end
    res *= Char(val + 63)
end

"""
Encode coordinates in Google Polyline Algorithm Format

**Arguments**
* `coords` : coordinates in LLA system stored as a tuple

"""
function encode(coords::Tuple{Float64,Float64}...)
    prev_lat, prev_lon = 0,0
    res = ""
    for coord in coords
        lat,lon = trunc(Int, coord[1] *1e5), trunc(Int, coord[2]  *1e5)
        res *= OpenStreetMapX.encode_one(lat - prev_lat) * encode_one(lon - prev_lon)
        prev_lat, prev_lon = lat,lon
    end
    return res
end

"""
Decode single coordinate

**Arguments**
* `polyline` : coordinates in Google Polyline Algorithm Format stored as an array of characters
* `index` : position of each single coordinate in polyline array

"""
function decode_one(polyline::Array{Char,1}, index::Int)
    byte = nothing
    res = 0
    shift = 0
    while isa(byte, Nothing) || byte >= 0x20
        byte = Int(polyline[index]) - 63
        index += 1
        res |= (byte & 0x1f) << shift
        shift += 5
    end
    res = Bool(res & 1) ? ~(res >> 1) : (res >> 1)
    return res, index
end

"""
Decode coordinates in Google Polyline Algorithm Format

**Arguments**
* `polyline` : string containing coordinates in Polyline Algorithm Format

"""
function decode(polyline::String)
    polyline = collect(polyline)
    coords = Tuple{Float64,Float64}[]
    index = 1
    lat, lon = 0.0,0.0
    while index < length(polyline)
        lat_change, index = OpenStreetMapX.decode_one(polyline,index)
        lon_change, index = OpenStreetMapX.decode_one(polyline,index)
        lat += lat_change
        lon += lon_change
        push!(coords, (lat/1e5,lon/1e5))
    end
    return coords
end


text:
using Simulacoes
using Test
function isapprox(x ::Tuple, y::Tuple)
  for i in 1:length(x)
    if ! (x[i] ≈ y[i])
      return false
    end
    return true
  end
end

function isapprox(x ::Array, y::Array)
  for i in 1:length(x)
    if ! (x[i] ≈ y[i])
      return false
    end
    return true
  end
end

@testset "Distance function" begin

   p1 = [ 0, 0 ]
   p2 = [ 12, 12 ]
   side = 10
   @test Simulacoes.minimg(p1,p2,10)[1] ≈ sqrt(8)
   p2 = [ 17, 17 ]
   @test Simulacoes.minimg(p1,p2,10)[1] ≈ sqrt(18)

end

@testset "Potential Energy" begin

  data = Data()

  @test Simulacoes.upair(π,data) ≈ -0.0003250451775148634

  p = initial_point(data)
    @test utotal(p,data) ≈ -7472.164849146468

end

@testset "LJ Simulation" begin

  data = Data()
  p = initial_point(data)
  first_atom, next_atom = initiate_list(data, p)
  gen_lists!(data, p, first_atom, next_atom)
  @test lj_pot(p,  data, first_atom, next_atom) ≈ -7472.164849146468
end

@testset "LJ - Parallel Simulation" begin

  data = Data()
  p = initial_point(data)
  first_atom, next_atom = initiate_list(data, p)
  gen_lists!(data, p, first_atom, next_atom)
  @test lj_pot_parallel(p,  data, first_atom, next_atom) ≈ -7472.164849146468

end

@testset "Forces" begin
  data = Data()
  p = initial_point(data)
  first_atom, next_atom = initiate_list(data, p)
  gen_lists!(data, p, first_atom, next_atom)
  forces_list = [[0.0,0.0] for i=1:length(p)]

  r, delta_x, delta_y = minimg(p[1], p[2], data.side)
  @test upair(r, data) ≈ -0.2955814601750326
  @test isapprox(force_pair(delta_x, delta_y, r, data), (0.026979429768742007, 1.7345026569041166))
  u = lj_force!(p,  data, first_atom, next_atom, forces_list)
  @test isapprox(forces_list[1], [2.9749744219446326, 1.730790463586403])
  @test isapprox(forces_list[10000], [-3.1208157043186255, -2.051342533620307])
  @test u ≈ -7472.164849146468
  println("Soma das forças:")
  println(sum(forces_list))
end


text:
#= trotterinfo to build quantumspinsystem
	TrotterInfo(trotterparameter, trotteriteration)
	getTrotterparameter(trotterinfo::TrotterInfo)
	getTrotteriteration(trotterinfo::TrotterInfo)
	getTrotterlayers(trotterinfo::TrotterInfo)
	getBeta(trotterinfo::TrotterInfo)
	getTemperature(trotterinfo::TrotterInfo)
	setTrotterparameter!{T}(trotterinfo::TrotterInfo, trotterparameter::T)
	setTrotterIteration!(trotterinfo::TrotterInfo, trotteriteration::Int)
	---
	iteration2layer(iteration::Int)
=#
type TrotterInfo{T}
	trotterparameter::T
	trotteriteration::Int
end

#---
function iteration2layer(iteration::Int)
	return ldexp(1.0, iteration)
end

#--- get functions
function getTrotterparameter(trotterinfo::TrotterInfo)
	return trotterinfo.trotterparameter
end

function getTrotteriteration(trotterinfo::TrotterInfo)
	return trotterinfo.trotteriteration
end

function getTrotterlayers(trotterinfo::TrotterInfo)
	return iteration2layer(getTrotteriteration(trotterinfo))
end

function getBeta(trotterinfo::TrotterInfo)
	return getTrotterlayers(trotterinfo) * getTrotterparameter(trotterinfo)
end

function getTemperature{T}(trotterinfo::TrotterInfo{T})
	return one(T) / getBeta(trotterinfo)
end

function setTrotterparameter!{T}(trotterinfo::TrotterInfo, trotterparameter::T)
	trotterinfo.trotterparameter = trotterparameter
end

function setTrotterIteration!(trotterinfo::TrotterInfo, trotteriteration::Int)
	trotterinfo.trotteriteration = trotteriteration
end

function testTrotterInfo()
	trotterparameter = 0.01
	trotteriteration = 10
	trotter = TrotterInfo(trotterparameter, trotteriteration)
	println(getTrotterlayers(trotter))
	println(getBeta(trotter))
	println(getTemperature(trotter))
end


text:
@testset "PolyVar order" begin
    @polyvar x
    z = x
    @polyvar x
    @test z != x
end


max_stars_repo_name: pgrepds/Codegolf

max_issues_repo_name: pgrepds/Codegolf

max_forks_repo_name: pgrepds/Codegolf


text:
module collision_BallWithBox_Prismatic

using Modia3D
using Modia3D.StaticArrays
import Modia3D.ModiaMath

vmatGraphics = Modia3D.Material(color="LightBlue" , transparency=0.5)    # material of Graphics
vmatSolids = Modia3D.Material(color="Red" , transparency=0.5)         # material of solids

cmat = "Steel"

LxGround = 16.0
LyGround = 8.0
LzGround = 0.1
LyBox = 1.0
LzBox = 1.0

diameter = 1.0

@assembly Billard() begin
  world = Modia3D.Object3D(visualizeFrame=true)
  lengthBox = Modia3D.Solid(Modia3D.SolidBox(LyBox, LyGround, LzBox) , "Steel", vmatSolids; contactMaterial = cmat)
  box4 = Modia3D.Object3D(world, lengthBox, r=[-LxGround/2, 0.0, LzGround], fixed=true)

  sphere = Modia3D.Object3D( Modia3D.Solid(Modia3D.SolidSphere(diameter) , "Steel" , vmatSolids ; contactMaterial = cmat))
  prisX = Modia3D.Prismatic(world, sphere; axis=1, canCollide = true)
end

gravField = Modia3D.UniformGravityField(g=9.81, n=[-1,0,0])
bill = Billard(sceneOptions=Modia3D.SceneOptions(gravityField=gravField,visualizeFrames=true, defaultFrameLength=0.7,nz_max = 100, enableContactDetection=true, visualizeContactPoints=true, visualizeSupportPoints=true))

model = Modia3D.SimulationModel( bill )
result = ModiaMath.simulate!(model; stopTime=1.5, tolerance=1e-8,interval=0.001, log=false)

println("... success of collision_BallWithBox_Prismatic.jl!")
end


text:
function GenerateRandomly(mods::Int; cand::Array{Int,2}=zeros(Int,0,2))::Array{Int,2}
    if (mods<0)
        cand=cand[1:end+mods,:]
    else
        for i=1:mods
            if (size(cand,1)==0) cand = [0 rand(1:numColors)]
            else cand=vcat(cand, [rand(1:size(cand,1)) rand(1:numColors)])
            end
        end
    end
    return cand
end

function ExhaustiveHillClimbing(mods::Int; cand::Array{Int,2}=zeros(Int,0,2))::Array{Int,2}
    if (mods<0)
        cand=cand[1:end+mods,:]
    else
        for i=1:mods
            testCand = vcat(cand, [0 0])
            numLocations = size(cand, 1)
            permutations = repeat(0:numLocations,inner=numColors)
            numLocations+=1
            permutations = hcat(permutations, repeat(1:numColors,outer=numLocations))
            bestScore = typemax(Float64)
            bestIndex = 0
            for j=1:numColors*numLocations
                testCand[numLocations,:]=permutations[j,:]
                score = GetCombinedScore(testCand)
                if (score < bestScore)
                    bestScore = score
                    bestIndex = j
                end
            end
            cand=vcat(cand, permutations[bestIndex:bestIndex,1:2])
        end
    end
    return cand
end

max_stars_repo_name: DesignEngrLab/ColorGraph

max_issues_repo_name: DesignEngrLab/ColorGraph

max_forks_repo_name: DesignEngrLab/ColorGraph


text:
using TimeWarp
using TimeWarp.WarpPlots
using TimeWarp.Datasets
pyplot()

# UCI data repository must be downloaded first, run TimeWarp.download_data()
data = ucr_traindata("Gun_Point");

y1 = Sequence(data[1][:,1])
y2 = Sequence(data[1][:,2])

#dtwplot(y1,y2,clim=[0,1])
dtwplot(y1,y2)
savefig("dtw.png")

if is_linux()
  show()
end


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

@doc raw"""Adapts a ConfigMap into a volume.  The contents of the target ConfigMap's Data field will be presented in a volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. ConfigMap volumes support ownership management and SELinux relabeling.

    IoK8sApiCoreV1ConfigMapVolumeSource(;
        defaultMode=nothing,
        items=nothing,
        name=nothing,
        optional=nothing,
    )

    - defaultMode::Int32 : Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.
    - items::Vector{IoK8sApiCoreV1KeyToPath} : If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.
    - name::String : Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
    - optional::Bool : Specify whether the ConfigMap or its keys must be defined
"""
mutable struct IoK8sApiCoreV1ConfigMapVolumeSource <: SwaggerModel
    defaultMode::Any # spec type: Union{ Nothing, Int32 } # spec name: defaultMode
    items::Any # spec type: Union{ Nothing, Vector{IoK8sApiCoreV1KeyToPath} } # spec name: items
    name::Any # spec type: Union{ Nothing, String } # spec name: name
    optional::Any # spec type: Union{ Nothing, Bool } # spec name: optional

    function IoK8sApiCoreV1ConfigMapVolumeSource(;defaultMode=nothing, items=nothing, name=nothing, optional=nothing)
        o = new()
        validate_property(IoK8sApiCoreV1ConfigMapVolumeSource, Symbol("defaultMode"), defaultMode)
        setfield!(o, Symbol("defaultMode"), defaultMode)
        validate_property(IoK8sApiCoreV1ConfigMapVolumeSource, Symbol("items"), items)
        setfield!(o, Symbol("items"), items)
        validate_property(IoK8sApiCoreV1ConfigMapVolumeSource, Symbol("name"), name)
        setfield!(o, Symbol("name"), name)
        validate_property(IoK8sApiCoreV1ConfigMapVolumeSource, Symbol("optional"), optional)
        setfield!(o, Symbol("optional"), optional)
        o
    end
end # type IoK8sApiCoreV1ConfigMapVolumeSource

const _property_map_IoK8sApiCoreV1ConfigMapVolumeSource = Dict{Symbol,Symbol}(Symbol("defaultMode")=>Symbol("defaultMode"), Symbol("items")=>Symbol("items"), Symbol("name")=>Symbol("name"), Symbol("optional")=>Symbol("optional"))
const _property_types_IoK8sApiCoreV1ConfigMapVolumeSource = Dict{Symbol,String}(Symbol("defaultMode")=>"Int32", Symbol("items")=>"Vector{IoK8sApiCoreV1KeyToPath}", Symbol("name")=>"String", Symbol("optional")=>"Bool")
Base.propertynames(::Type{ IoK8sApiCoreV1ConfigMapVolumeSource }) = collect(keys(_property_map_IoK8sApiCoreV1ConfigMapVolumeSource))
Swagger.property_type(::Type{ IoK8sApiCoreV1ConfigMapVolumeSource }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_IoK8sApiCoreV1ConfigMapVolumeSource[name]))}
Swagger.field_name(::Type{ IoK8sApiCoreV1ConfigMapVolumeSource }, property_name::Symbol) =  _property_map_IoK8sApiCoreV1ConfigMapVolumeSource[property_name]

function check_required(o::IoK8sApiCoreV1ConfigMapVolumeSource)
    true
end

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


text:
###### Weight vector #####

immutable WeightVec{W,Vec<:RealVector}
    values::Vec
    sum::W
end

WeightVec{Vec<:RealVector,W<:Real}(vs::Vec,wsum::W) = WeightVec{W,Vec}(vs, wsum)
WeightVec(vs::RealVector) = WeightVec(vs, sum(vs))

weights(vs::RealVector) = WeightVec(vs)
weights(vs::RealArray) = WeightVec(vec(vs))

eltype(wv::WeightVec) = eltype(wv.values)
length(wv::WeightVec) = length(wv.values)
values(wv::WeightVec) = wv.values
sum(wv::WeightVec) = wv.sum
isempty(wv::WeightVec) = isempty(wv.values)

Base.getindex(wv::WeightVec, i) = getindex(wv.values, i)

##### Weighted sum #####

## weighted sum over vectors

wsum(v::AbstractVector, w::AbstractVector) = dot(v, w)
wsum(v::AbstractArray, w::AbstractVector) = dot(vec(v), w)

# Note: the methods for BitArray and SparseMatrixCSC are to avoid ambiguities
Base.sum(v::BitArray, w::WeightVec) = wsum(v, values(w))
Base.sum(v::SparseMatrixCSC, w::WeightVec) = wsum(v, values(w))
Base.sum(v::AbstractArray, w::WeightVec) = dot(v, values(w))

## wsum along dimension
#
#  Brief explanation of the algorithm:
#  ------------------------------------
#
#  1. _wsum! provides the core implementation, which assumes that
#     the dimensions of all input arguments are consistent, and no
#     dimension checking is performed therein.
#
#     wsum and wsum! perform argument checking and call _wsum!
#     internally.
#
#  2. _wsum! adopt a Cartesian based implementation for general
#     sub types of AbstractArray. Particularly, a faster routine
#     that keeps a local accumulator will be used when dim = 1.
#
#     The internal function that implements this is _wsum_general!
#
#  3. _wsum! is specialized for following cases:
#     (a) A is a vector: we invoke the vector version wsum above.
#         The internal function that implements this is _wsum1!
#
#     (b) A is a dense matrix with eltype <: BlasReal: we call gemv!
#         The internal function that implements this is _wsum2_blas!
#
#     (c) A is a contiguous array with eltype <: BlasReal:
#         dim == 1: treat A like a matrix of size (d1, d2 x ... x dN)
#         dim == N: treat A like a matrix of size (d1 x ... x d(N-1), dN)
#         otherwise: decompose A into multiple pages, and apply _wsum2!
#         for each
#
#     (d) A is a general dense array with eltype <: BlasReal:
#         dim <= 2: delegate to (a) and (b)
#         otherwise, decompose A into multiple pages
#

function _wsum1!(R::AbstractArray, A::AbstractVector, w::AbstractVector, init::Bool)
    r = wsum(A, w)
    if init
        R[1] = r
    else
        R[1] += r
    end
    return R
end

function _wsum2_blas!{T<:BlasReal}(R::StridedVector{T}, A::StridedMatrix{T}, w::StridedVector{T}, dim::Int, init::Bool)
    beta = ifelse(init, zero(T), one(T))
    trans = dim == 1 ? 'T' : 'N'
    BLAS.gemv!(trans, one(T), A, w, beta, R)
    return R
end

function _wsumN!{T<:BlasReal,N}(R::ContiguousArray{T}, A::ContiguousArray{T,N}, w::StridedVector{T}, dim::Int, init::Bool)
    if dim == 1
        m = size(A, 1)
        n = div(length(A), m)
        _wsum2_blas!(view(R,:), reshape_view(A, (m, n)), w, 1, init)
    elseif dim == N
        n = size(A, N)
        m = div(length(A), n)
        _wsum2_blas!(view(R,:), reshape_view(A, (m, n)), w, 2, init)
    else # 1 < dim < N
        m = 1
        for i = 1:dim-1; m *= size(A, i); end
        n = size(A, dim)
        k = 1
        for i = dim+1:N; k *= size(A, i); end
        Av = reshape_view(A, (m, n, k))
        Rv = reshape_view(R, (m, k))
        for i = 1:k
            _wsum2_blas!(view(Rv,:,i), view(Av,:,:,i), w, 2, init)
        end
    end
    return R
end

function _wsumN!{T<:BlasReal,N}(R::ContiguousArray{T}, A::DenseArray{T,N}, w::StridedVector{T}, dim::Int, init::Bool)
    @assert N >= 3
    if dim <= 2
        m = size(A, 1)
        n = size(A, 2)
        npages = 1
        for i = 3:N
            npages *= size(A, i)
        end
        rlen = ifelse(dim == 1, n, m)
        Rv = reshape_view(R, (rlen, npages))
        for i = 1:npages
            _wsum2_blas!(view(Rv,:,i), view(A,:,:,i), w, dim, init)
        end
    else
        _wsum_general!(R, IdFun(), A, w, dim, init)
    end
    return R
end

# General Cartesian-based weighted sum across dimensions
@ngenerate N typeof(R) function _wsum_general!{T,RT,WT,N}(R::AbstractArray{RT}, f::Func{1},
                                                          A::AbstractArray{T,N}, w::AbstractVector{WT}, dim::Int, init::Bool)
    init && fill!(R, zero(RT))
    wi = zero(WT)
    if dim == 1
        @nextract N sizeR d->size(R,d)
        sizA1 = size(A, 1)
        @nloops N i d->(d>1? (1:size(A,d)) : (1:1)) d->(j_d = sizeR_d==1 ? 1 : i_d) begin
            @inbounds r = (@nref N R j)
            for i_1 = 1:sizA1
                @inbounds r += evaluate(f, (@nref N A i)) * w[i_1]
            end
            @inbounds (@nref N R j) = r
        end
    else
        @nloops N i A d->(if d == dim
                               wi = w[i_d]
                               j_d = 1
                           else
                               j_d = i_d
                           end) @inbounds (@nref N R j) += evaluate(f, (@nref N A i)) * wi
    end
    return R
end

@ngenerate N typeof(R) function _wsum_centralize!{T,RT,WT,N}(R::AbstractArray{RT}, f::Func{1},
                                                             A::AbstractArray{T,N}, means, w::AbstractVector{WT},
                                                             dim::Int, init::Bool)
    init && fill!(R, zero(RT))
    wi = zero(WT)
    if dim == 1
        @nextract N sizeR d->size(R,d)
        sizA1 = size(A, 1)
        @nloops N i d->(d>1? (1:size(A,d)) : (1:1)) d->(j_d = sizeR_d==1 ? 1 : i_d) begin
            @inbounds r = (@nref N R j)
            @inbounds m = (@nref N means j)
            for i_1 = 1:sizA1
                @inbounds r += evaluate(f, (@nref N A i) - m) * w[i_1]
            end
            @inbounds (@nref N R j) = r
        end
    else
        @nloops N i A d->(if d == dim
                               wi = w[i_d]
                               j_d = 1
                           else
                               j_d = i_d
                           end) @inbounds (@nref N R j) += evaluate(f, (@nref N A i) - (@nref N means j)) * wi
    end
    return R
end

# N = 1
_wsum!{T<:BlasReal}(R::ContiguousArray{T}, A::DenseArray{T,1}, w::StridedVector{T}, dim::Int, init::Bool) =
    _wsum1!(R, A, w, init)

# N = 2
_wsum!{T<:BlasReal}(R::ContiguousArray{T}, A::DenseArray{T,2}, w::StridedVector{T}, dim::Int, init::Bool) =
    (_wsum2_blas!(view(R,:), A, w, dim, init); R)

# N >= 3
_wsum!{T<:BlasReal,N}(R::ContiguousArray{T}, A::DenseArray{T,N}, w::StridedVector{T}, dim::Int, init::Bool) =
    _wsumN!(R, A, w, dim, init)

_wsum!(R::AbstractArray, A::AbstractArray, w::AbstractVector, dim::Int, init::Bool) = _wsum_general!(R, IdFun(), A, w, dim, init)

## wsum! and wsum

wsumtype{T,W}(::Type{T}, ::Type{W}) = typeof(zero(T) * zero(W) + zero(T) * zero(W))
wsumtype{T<:BlasReal}(::Type{T}, ::Type{T}) = T

function wsum!{T,N}(R::AbstractArray, A::AbstractArray{T,N}, w::AbstractVector, dim::Int; init::Bool=true)
    1 <= dim <= N || error("dim should be within [1, $N]")
    ndims(R) <= N || error("ndims(R) should not exceed $N")
    length(w) == size(A,dim) || throw(DimensionMismatch("Inconsistent array dimension."))
    # TODO: more careful examination of R's size
    _wsum!(R, A, w, dim, init)
end

function wsum{T<:Number,W<:Real}(A::AbstractArray{T}, w::AbstractVector{W}, dim::Int)
    length(w) == size(A,dim) || throw(DimensionMismatch("Inconsistent array dimension."))
    _wsum!(Array(wsumtype(T,W), Base.reduced_dims(size(A), dim)), A, w, dim, true)
end

# extended sum! and wsum

Base.sum!{W<:Real}(R::AbstractArray, A::AbstractArray, w::WeightVec{W}, dim::Int; init::Bool=true) =
    wsum!(R, A, values(w), dim; init=init)

Base.sum{T<:Number,W<:Real}(A::AbstractArray{T}, w::WeightVec{W}, dim::Int) = wsum(A, values(w), dim)

###### Weighted means #####

function wmean{T<:Number}(v::AbstractArray{T}, w::AbstractVector)
    Base.depwarn("wmean is deprecated, use mean(v, weights(w)) instead.", :wmean)
    mean(v, weights(w))
end

Base.mean(v::AbstractArray, w::WeightVec) = sum(v, w) / sum(w)

Base.mean!(R::AbstractArray, A::AbstractArray, w::WeightVec, dim::Int) =
    scale!(Base.sum!(R, A, w, dim), inv(sum(w)))

wmeantype{T,W}(::Type{T}, ::Type{W}) = typeof((zero(T)*zero(W) + zero(T)*zero(W)) / one(W))
wmeantype{T<:BlasReal}(::Type{T}, ::Type{T}) = T

Base.mean{T<:Number,W<:Real}(A::AbstractArray{T}, w::WeightVec{W}, dim::Int) =
    mean!(Array(wmeantype(T, W), Base.reduced_dims(size(A), dim)), A, w, dim)

###### Weighted median #####

function Base.median{W<:Real}(v::RealVector, w::WeightVec{W})
    isempty(v) && error("median of an empty array is undefined")
    if length(v) != length(w)
        error("data and weight vectors must be the same size")
    end
    @inbounds for x in w.values
        isnan(x) && error("weight vector cannot contain NaN entries")
    end
    @inbounds for x in v
        isnan(x) && return x
    end
    mask = w.values .!= 0
    if any(mask)
        if all(w.values .<= 0)
            error("no positive weights found")
        end
        v = v[mask]
        wt = w[mask]
        midpoint = w.sum / 2
        maxval, maxind = findmax(wt)
        if maxval > midpoint
            v[maxind]
        else
            permute = sortperm(v)
            cumulative_weight = zero(eltype(wt))
            i = 0
            for (i, p) in enumerate(permute)
                if cumulative_weight > midpoint
                    cumulative_weight -= wt[p]
                    break
                end
                cumulative_weight += wt[p]
            end
            if cumulative_weight == midpoint
                middle(v[permute[i-2]], v[permute[i-1]])
            else
                middle(v[permute[i-1]])
            end
        end
    else
        error("no nonzero weights found")
    end
end

wmedian(v::RealVector, w::RealVector) = median(v, weights(w))
wmedian{W<:Real}(v::RealVector, w::WeightVec{W}) = median(v, w)


text:
using Test
using LatticeTools

using LinearAlgebra

@testset "embedding" begin
    @testset "two-band" begin
        unitcell = makeunitcell([1.0 0.0; 0.0 1.0]; SiteType=String)
        addsite!(unitcell, "Ox", FractCoord([0,0], [0.5, 0.0]))
        addsite!(unitcell, "Oy", FractCoord([0,0], [0.0, 0.5]))
        @testset "square" begin
            lattice = make_lattice(unitcell, [2 0; 0 2])

            # |       |                 |       |
            # 6       8                 8       6
            # |       |         [1,0]   |       |
            # . - 5 - . - 7 -     =>    . - 7 - . - 5 -
            # |       |                 |       |
            # 2       4                 4       2
            # |       |                 |       |
            # o - 1 - . - 3 -           o - 3 - . - 1 -
            tsym = FiniteTranslationSymmetry(lattice)
            tsymbed = embed(lattice, tsym)
            translation_symmetry_embedding(lattice)

            let n = lowercase(symmetry_name(tsymbed))
                @test occursin("embed", n)
                @test occursin("translation", n)
                @test occursin("2", n) && occursin("0", n)
            end

            @test length(tsymbed) == 4
            @test length(collect(tsymbed)) == 4
            @test length(elements(tsymbed)) == 4
            @test eltype(tsymbed) == SitePermutation
            @test valtype(tsymbed) == SitePermutation
            @test eltype(typeof(tsymbed)) == SitePermutation
            @test valtype(typeof(tsymbed)) == SitePermutation
            @test elements(tsymbed)[1] == SitePermutation([1,2,3,4,5,6,7,8])
            @test elements(tsymbed)[2] == SitePermutation([3,4,1,2,7,8,5,6])
            @test element(tsymbed, 2) == SitePermutation([3,4,1,2,7,8,5,6])
            @test element(tsymbed, [1,2]) == [SitePermutation([1,2,3,4,5,6,7,8]), SitePermutation([3,4,1,2,7,8,5,6])]
            @test generator_indices(tsymbed) == [2, 3]
            @test generator_elements(tsymbed) == [element(tsymbed, 2) , element(tsymbed, 3)]

            # |       |                 |       |
            # 6       8                 3       7
            # |       |         C4      |       |
            # . - 5 - . - 7 -   =>      . - 8 - . - 4 -
            # |       |                 |       |
            # 2       4                 1       5
            # |       |                 |       |
            # o - 1 - . - 3 -           o - 6 - . - 2 -
            psym = project(PointSymmetryDatabase.get(13), [1 0 0; 0 1 0])
            @test psym.hermann_mauguin == "4mm"
            psymbed = embed(lattice, psym)

            let n = lowercase(symmetry_name(psymbed))
                @test occursin("embed", n)
                @test occursin("point", n)
                @test occursin("4mm", n) || occursin("C4v", n)
            end

            @test eltype(psymbed) == SitePermutation
            @test valtype(psymbed) == SitePermutation

            idx_C4 = 3
            @test element_name(psym, idx_C4) == "4+001"
            @test length(psymbed) == 8
            @test length(elements(psymbed)) == 8
            @test length(collect(psymbed)) == 8
            @test element(psymbed, idx_C4) == SitePermutation([2,3,6,7,4,1,8,5])

            @test iscompatible(tsymbed, psymbed)

            @test little_symmetry(tsymbed, psymbed).symmetry.hermann_mauguin == "4mm"
            @test little_symmetry(tsymbed, 1, psymbed).symmetry.hermann_mauguin == "4mm"
            @test little_symmetry(tsymbed, 2, psymbed).symmetry.hermann_mauguin == "mm2"
            @test little_symmetry(tsymbed, 3, psymbed).symmetry.hermann_mauguin == "mm2"
            @test little_symmetry(tsymbed, 4, psymbed).symmetry.hermann_mauguin == "4mm"

            @test little_group_elements(tsymbed, psymbed) == 1:group_order(psymbed)
            @test little_group_elements(tsymbed, 1, psymbed) == 1:group_order(psymbed)
            @test length(little_group_elements(tsymbed, 2, psymbed)) < group_order(psymbed)

            @test iscompatible(tsymbed, 1, psymbed)
            @test !iscompatible(tsymbed, 2, psymbed)
            @test !iscompatible(tsymbed, 3, psymbed)
            @test iscompatible(tsymbed, 4, psymbed)

            @test_throws ArgumentError embed(lattice, PointOperation([1 -1; 1 1])) # lattice not invariant under operation
            embed(make_lattice(unitcell, [1 0; 0 1]), psym) # lattice too small for faithful psym. Only a warning

            let lattice_large = make_lattice(unitcell, [4 0; 0 4])
                tsymbed_large = translation_symmetry_embedding(lattice_large)
                @test !iscompatible(tsymbed_large, psymbed)
                for irrep_index in 1:num_irreps(tsymbed_large)
                    @test !iscompatible(tsymbed_large, irrep_index, psymbed)
                end
                @test_throws ArgumentError little_group_elements(tsymbed_large, psymbed)
                @test_throws ArgumentError little_group_elements(tsymbed_large, 1, psymbed)
                @test_throws ArgumentError little_symmetry(tsymbed_large, psymbed)
                @test_throws ArgumentError little_symmetry(tsymbed_large, 1, psymbed)
            end
        end

        @testset "rectangular" begin
            lattice = make_lattice(unitcell, [3 0; 0 2])
            # tsym = FiniteTranslationSymmetry(lattice)
            # tsymbed = embed(lattice, tsym)
            psym = project(PointSymmetryDatabase.get(13), [1 0 0; 0 1 0])
            @test_throws ArgumentError embed(lattice, psym)
            # @show little_symmetry(tsymbed, psymbed)
        end
    end

    @testset "kagome" begin
        include("Kagome.jl")
        # TODO: add tests
        kagome = make_kagome_lattice([4 0; 0 3])
        let
            kagome2 = make_kagome_lattice([4 0; 0 2])
            @test_throws ArgumentError embed(kagome.lattice, kagome2.translation_symmetry)
        end
        tsym_embed = embed(kagome.lattice, kagome.translation_symmetry)
        @test_throws ArgumentError embed(kagome.lattice, kagome.point_symmetry)
        @test_throws ArgumentError embed(kagome.lattice, SymmorphicSymmetry(kagome.translation_symmetry, kagome.point_symmetry))

        # lattice too small for faithful embedding
        kagome = make_kagome_lattice([1 0; 0 1])
        tsym_embed = embed(kagome.lattice, kagome.translation_symmetry)
        psymbed = embed(kagome.lattice, kagome.point_symmetry)
        ssymbed = embed(kagome.lattice, SymmorphicSymmetry(kagome.translation_symmetry, kagome.point_symmetry))

        kagome = make_kagome_lattice([2 0; 0 2])
        tsym_embed = embed(kagome.lattice, kagome.translation_symmetry)
        psym_embed = embed(kagome.lattice, kagome.point_symmetry)
        ssym_embed = embed(kagome.lattice, SymmorphicSymmetry(kagome.translation_symmetry, kagome.point_symmetry))

        @test group_order(tsym_embed) == group_order(kagome.translation_symmetry)
        @test group_order(psym_embed) == group_order(kagome.point_symmetry)
        @test group_order(ssym_embed) == group_order(kagome.translation_symmetry) * group_order(kagome.point_symmetry)
        # @test group_order(ssym_embed2) == group_order(kagome.translation_symmetry) * group_order(kagome.point_symmetry)

        kagome = make_kagome_lattice([4 -2; 2 2])
        tsym_embed = embed(kagome.lattice, kagome.translation_symmetry)
        psym_embed = embed(kagome.lattice, kagome.point_symmetry)
        ssym_embed = embed(kagome.lattice, SymmorphicSymmetry(kagome.translation_symmetry, kagome.point_symmetry))
    end

    # @testset "kagome-strong" begin
    #     include("Kagome.jl")
    #     kagome = make_kagome_lattice([4 -2; 2 2])
    #     tsymbed = embed(kagome.lattice, kagome.translation_symmetry)
    #     psymbed = little_symmetry_strong(tsymbed, embed(kagome.lattice, kagome.point_symmetry))
    #     @show symmetry_name(tsymbed)
    #     @show symmetry_name(psymbed)
    # end
end


text:
# Try to approximate squared-exponential kernel:
using PyPlot
using Optim

function gaussian_approx3()

ntime = 1000
time = collect(linspace(0,10,ntime))
gaussian=exp(-time.^2/2.)

function compute_chi(x)
model = zeros(ntime)
c1 = 1.0
c2 = 0.0
c3 = 1.0
for k=1:nexp
  model += x[1+(k-1)*3].*exp(-x[2+(k-1)*3].*time).*cos(x[3+(k-1)*3].*time)
  c1 -= x[1+(k-1)*3]
  c2 -= x[1+(k-1)*3]*x[2+(k-1)*3]
  c3 += x[1+(k-1)*3]*(x[2+(k-1)*3]^2-x[3+(k-1)*3]^2)
end
c2 = c2/c1
c3 = sqrt((c3+c1*c2^2)/c1)
#model += c1.*exp(-c2.*time).*cos(x[nexp*3+1].*time)
model += c1.*exp(-c2.*time).*cos(c3.*time)
return sum((gaussian-model).^2)
end

nexp = 2
#nexp = 2
#nexp = 4
npar = 3*nexp
abest=zeros(npar)
#abest[1:12]=[1./6.,0.1,sqrt(3.),1./6.,0.1,sqrt(5.),1./3.,0.1,0.1,1./3.,0.1,0.2]
# Here are best parameters so far:
#New minimum: 855 2.522483789529161 [0.09778291672462784,1.5548632770098678,0.32192744041675075,0.596959899332403,0.3132368383113517,-0.18163977156887445,0.2670528045472698,-1.075894228060323]
#abest=[0.09778291672462784,1.5548632770098678,0.32192744041675075,0.596959899332403,0.3132368383113517,-0.18163977156887445,0.2670528045472698,-1.075894228060323]
#New minimum: 4.2559231434310284e-7 [1.4707280328402002,1.3556988707754538,1.9133776307579318,-0.7331091089111925,3.6344847969483203,1.3207054708438177,-2.5676669507901395,1.4654679150660068,-1.8772555559415482,2.8301497749105042,1.5683246010038931,0.32031045862921226] 2.0325193117951805e-5
#abest=[1.4707280328402002,1.3556988707754538,1.9133776307579318,-0.7331091089111925,3.6344847969483203,1.3207054708438177,-2.5676669507901395,1.4654679150660068,-1.8772555559415482,2.8301497749105042,1.5683246010038931,0.32031045862921226]
#New minimum: 6.819157755054511e-6 [2.7518074963750734,1.5312499407621147,-0.34148888178746056,-0.3546256365636662,4.753504292338284,2.042571639590954,-1.3968344706386124,1.7967431129812566,-1.7641684073510928] 8.113071479846436e-5 0.00034738917279475423
#abest=[2.7518074963750734,1.5312499407621147,-0.34148888178746056,-0.3546256365636662,4.753504292338284,2.042571639590954,-1.3968344706386124,1.7967431129812566,-1.7641684073510928]
#abest=[2.7518074963750734,1.5312499407621147,-0.34148888178746056,-0.3546256365636662,4.753504292338284,2.042571639590954,-1.7641684073510928]
abest=[2.7518074963750734,1.5312499407621147,-0.34148888178746056,-0.3546256365636662,4.753504292338284,2.042571639590954]
#abest=[2.7518074963750734,1.5312499407621147,-0.34148888178746056,-0.3546256365636662,4.753504292338284,2.042571639590954]

atrial = zeros(npar)
for k=1:npar
  atrial[k] = abest[k]
end
model = zeros(ntime)
c1 = 1.0
c2 = 0.0
c3 = 1.0
for k=1:nexp-1
  model += atrial[1+(k-1)*3].*exp(-atrial[2+(k-1)*3].*time).*cos(atrial[3+(k-1)*3].*time)
  c1 -= atrial[1+(k-1)*3]
  c2 -= atrial[1+(k-1)*3]*atrial[2+(k-1)*3]
  c3 += atrial[1+(k-1)*3]*(atrial[2+(k-1)*3]^2-atrial[3+(k-1)*3]^2)
end
c2 = c2/c1
c3 = sqrt((c3+c1*c2^2)/c1)
model += c1.*exp(-c2.*time).*cos(c3.*time)
clf()
plot(time,gaussian)
plot(time,model)
#chibest=sum((gaussian-model).^2)
chibest=compute_chi(atrial)

println("Initial chi-square: ",chibest)
read(STDIN,Char)

result = optimize(compute_chi, atrial, BFGS(), OptimizationOptions(autodiff = true))

println(Optim.minimizer(result),Optim.minimum(result))
abest= Optim.minimizer(result)
clf()
plot(time,gaussian)
plot(time,model)
model = zeros(ntime)
c1 = 1.0
c2 = 0.0
c3 = 1.0
for k=1:nexp
  model += abest[1+(k-1)*3].*exp(-abest[2+(k-1)*3].*time).*cos(abest[3+(k-1)*3].*time)
  c1 -= abest[1+(k-1)*3]
  c2 -= abest[1+(k-1)*3]*abest[2+(k-1)*3]
  c3 += abest[1+(k-1)*3]*(abest[2+(k-1)*3]^2-abest[3+(k-1)*3]^2)
end
c2 = c2/c1
c3 = sqrt((c3+c1*c2^2)/c1)
model += c1.*exp(-c2.*time).*cos(c3.*time)
plot(time,(gaussian-model))
chi=sum((gaussian-model).^2)
println("New minimum: ",chi," ",abest," ",c1," ",c2," ",c3," ",std(gaussian-model)," ",maximum(abs(gaussian-model)))
read(STDIN,Char)

return
end

max_stars_repo_name: dfm/ess

max_issues_repo_name: dfm/ess

max_forks_repo_name: dfm/ess


text:
# --------------------------------------------------
# Ranges

mutable struct MapRange
    xmin::Real
    xmax::Real
    ymin::Real
    ymax::Real
end

mutable struct CubeRange
    xmin::Real
    xmax::Real
    ymin::Real
    ymax::Real
    zmin::Real
    zmax::Real
end

function xy_range(map_::AbstractMap)
    MapRange(map_.xaxis[begin], map_.xaxis[end], map_.yaxis[begin], map_.yaxis[end])
end

function xy_range(cr::CubeRange)
    MapRange(cr.xmin, cr.xmax, cr.ymin, cr.ymax)
end

function xy_range(cube::AbstractSpectralCube)
    cr = xyz_range(cube)
    return MapRange(cr.xmin, cr.xmax, cr.ymin, cr.ymax)
end

function xyz_range(cube::AbstractSpectralCube)
    CubeRange(cube.xaxis[begin], cube.xaxis[end], cube.yaxis[begin], cube.yaxis[end], cube.zaxis[begin], cube.zaxis[end])
end