content
stringlengths 6
1.03M
| input_ids
sequencelengths 4
535k
| ratio_char_token
float64 0.68
8.61
| token_count
int64 4
535k
|
---|---|---|---|
#-----------------------------------------------------------------------------------------------------
# Functions for Operations.
# Operation is the collection of "Operator"s, together with a "Basis".
# Functions on "Operation"s are design to mimic the behavior of matrices.
#-----------------------------------------------------------------------------------------------------
"""
Operator{T1<:Number, T2<:Integer}
Type that contains 2 fields:
1. `mat`: Matrices representation of local operator.
2. `inds`: Indeces of sites the operator acts on.
"""
struct Operator{T1<:Number, T2<:Integer}
mat::Matrix{T1}
inds::Vector{T2}
end
#-----------------------------------------------------------------------------------------------------
# Basic functions on "Operator":
# 1. *: Multiplication by a number.
# 2. /: Division by a number.
#-----------------------------------------------------------------------------------------------------
*(c::Number, o::Operator) = Operator(c * o.mat, o.inds)
/(o::Operator, c::Number) = Operator(o.mat / c, o.inds)
#-----------------------------------------------------------------------------------------------------
# Operator to fill vector/matrix.
# To finally get the multiplication function, here we focus on a single row manipulation:
# 1. Start with a given product state(digits), we cut a segment from it;
# 2. Iterate all possible digits in the segment, and read the matrix element of operator;
# 3. Add to the vector/matrix element.
#-----------------------------------------------------------------------------------------------------
"""
addtovec!(vec::AbstractVector, opt::Operator, basis::Basis, coeff::Number=1)
Elementary multiplication step. Calculate single vector element of an operator * vector.
- `vec`: Vector to fill
- `opt`: Operator
- `basis`: Indicate the specific row
- `coeff`: The vector element of input state
"""
function addtovec!(vec::AbstractVector, opt::Operator, basis::Basis, coeff::Number=1)
basis_view = view(basis, opt.inds) # Create a view on the segment of the digits
index_view = index(basis_view) # Get the initial index of the viewed segment
opt_column = opt.mat[:, index_view] * coeff # Get the elements in row of index_view
row_number = length(opt_column)
for k = 1:row_number
change!(basis_view, k)
i = index(basis)
vec[i] += opt_column[k]
end # Fill the vector
change!(basis_view, index_view) # Reset the segment
end
#-----------------------------------------------------------------------------------------------------
"""
addtovecs!(vecs::AbstractMatrix, opt::Operator, basis::Basis, coeff::AbstractVector)
Elementary multiplication step. Calculate single row of matrix element of an operator * matrix.
- vecs : Vectors to fill
- opt : Operator
- basis: Indicate the specific row
- coeff: The row of matrix elements of input states
"""
function addtovecs!(vecs::AbstractMatrix, opt::Operator, basis::Basis, coeff::AbstractVector{<:Number})
basis_view = view(basis, opt.inds) # Create a view on the segment of the digits
index_view = index(basis_view) # Get the initial index of the viewed segment
opt_column = opt.mat[:, index_view] # Get the elements in row of index_view
row_number = length(opt_column) # Fill the matrix
for k = 1:row_number
change!(basis_view, k)
i = index(basis)
vecs[i, :] += opt_column[k] * coeff
end
change!(basis_view, index_view) # Reset the segment
end
#-----------------------------------------------------------------------------------------------------
# Type: Operation
#-----------------------------------------------------------------------------------------------------
export Operation
"""
Operation{OptType<:AbstractVector{<:Operator}, BasType<:Basis}
Type that contains 2 fields:
1. `opts`: List of operators
2. `basis`: Basis for the system
"""
struct Operation{T1 <: Number, T2 <: Integer, T3}
opts::Vector{Operator{T1, T2}}
basis::Basis{T3}
end
eltype(::Operation{T1, T2, T3}) where T1 where T2 where T3 = T1
function size(opt::Operation)
basis = opt.basis
dim = basis.base ^ basis.len
(dim, dim)
end
#-----------------------------------------------------------------------------------------------------
# Basis Operation initiation
#-----------------------------------------------------------------------------------------------------
export operation
"""
operation(mats, inds, len=0; base=0)
Canonical construction method for `Operation` object.
- `mats`: List of matrix representation of operators.
- `inds`: List of sites the operastors act on.
- `len`: Specify the size of the system. Default `len=0` will induce auto deduction.
- `base`: Quantum number of each sites. Default `base=0` will induce auto deduction.
"""
function operation(
mats::AbstractVector{<:AbstractMatrix},
inds::AbstractVector{<:AbstractVector},
len::Integer=0;
base::Integer=0
)
B = begin
b = base==0 ? round(Int64, size(mats[1], 1)^(1/length(inds[1]))) : Int64(base)
l = len==0 ? maximum(maximum.(inds)) : Int64(len)
basis(b, l)
end
mat_type = promote_type(eltype.(mats)...)
ind_type = promote_type(eltype.(inds)...)
O = [Operator(Array{mat_type}(mats[i]), Array{ind_type}(inds[i])) for i=1:length(mats)]
Operation(O, B)
end
#-----------------------------------------------------------------------------------------------------
# Basic Functions for type Operation
#-----------------------------------------------------------------------------------------------------
*(c::Number, o::Operation) = Operation(c .* o.opts, o.basis)
/(o::Operation, c::Number) = Operation(o.opts ./ c, o.basis)
+(opt1::Operation, opt2::Operation) = Operation(vcat(opt1.opts, opt2.opts), opt1.basis)
-(o1::Operation, o2::Operation) = o1 + ((-1) * o2)
function sum(ol::AbstractVector{<:Operation})
basis = ol[1].basis
opts = vcat([oi.opts for oi in ol]...)
Operation(opts, basis)
end
#-----------------------------------------------------------------------------------------------------
# Operation to fill vector/matrix:
# The method is basically iterate each operator to the given digits-represented basis
#-----------------------------------------------------------------------------------------------------
"""
addtovec!(vec::AbstractVector, opt::Operation, coeff::Number=1)
Elementary multiplication step. Calculate single vector element of an operation * vector.
The row information is stored in the basis of operation.
- `vec`: Vector to fill.
- `opt`: Operation.
- `coeff`: The vector element of input state.
"""
function addtovec!(vec::AbstractVector, opt::Operation, coeff::Number=1)
basis = opt.basis
opts = opt.opts
num_of_opts = length(opts)
for i = 1:num_of_opts
addtovec!(vec, opts[i], basis, coeff)
end # Multiply by each operator and add them all to vector
end
#-----------------------------------------------------------------------------------------------------
"""
addtovecs!(vecs::AbstractMatrix, opt::Operation, coeff::AbstractVector)
Elementary multiplication step. Calculate single row of matrix element of an operation * matrix.
The row information is stored in the basis of operation.
- `vecs`: Vectors to fill
- `opt`: Operation
- `coeff`: The row of matrix elements of input states
"""
function addtovecs!(vecs::AbstractMatrix, opt::Operation, coeff::AbstractVector{<:Number})
basis = opt.basis
opts = opt.opts
num_of_opts = length(opts)
for i = 1:num_of_opts
addtovecs!(vecs, opts[i], basis, coeff)
end # Multiply by each operator and add them all to vectors
end
#-----------------------------------------------------------------------------------------------------
# Multiplication
# The idea is to iterate all product state basis, and get all the vector/matrix elements
#-----------------------------------------------------------------------------------------------------
"""
mul!(vec::AbstractVector, opt::Operation, state::AbstractVector)
Full multiplication for operation and vector.
- `vec`: Vector to fill.
- `opt`: Operation.
- `state`: Input vector.
"""
function mul!(vec::AbstractVector, opt::Operation, state::AbstractVector)
basis = opt.basis
for j = 1:length(state)
change!(basis, j)
addtovec!(vec, opt, state[j])
end
end
#-----------------------------------------------------------------------------------------------------
"""
mul!(mat::AbstractVector, opt::Operation, state::AbstractVector)
Full multiplication for operation and matrix.
- `mat`: Matrix to fill.
- `opt`: Operation.
- `states`: Input states(matrix).
"""
function mul!(mat::AbstractMatrix, opt::Operation, states::AbstractMatrix)
basis = opt.basis
for j = 1:size(states, 1)
change!(basis, j)
addtovecs!(mat, opt, states[j, :])
end
end
#-----------------------------------------------------------------------------------------------------
"""
*(opt::Operation, vec_or_mat::AbstractVecOrMat)
General multiplication for operation and vector/matrix.
- `opt`: Operation.
- `vec_or_mat`: Input vector/matrix.
"""
function *(opt::Operation, vec_or_mat::AbstractVecOrMat)
ctype = promote_type(eltype(opt), eltype(vec_or_mat))
out = zeros(ctype, size(vec_or_mat))
mul!(out, opt, vec_or_mat)
out
end
#-----------------------------------------------------------------------------------------------------
# Fill matrix
#-----------------------------------------------------------------------------------------------------
export fillmat!
"""
fillmat!(mat::AbstractMatrix, opt::Operation)
Fill the zero matrix with matrix element from operation.
- `mat`: Matrix to fill.
- `opt`: Operation.
"""
function fillmat!(mat::AbstractMatrix, opt::Operation)
basis = opt.basis
row_number = size(mat, 1)
for j = 1:row_number
change!(basis, j)
addtovec!(view(mat, :, j), opt)
end
end
#-----------------------------------------------------------------------------------------------------
"""
Array(opt::Operation)
Return the full matrix form of `opt`.
"""
function Array(opt::Operation)
mat = zeros(eltype(opt), size(opt))
fillmat!(mat, opt)
mat
end | [
2,
10097,
3880,
30934,
198,
2,
40480,
329,
16205,
13,
198,
198,
2,
14680,
318,
262,
4947,
286,
366,
18843,
1352,
1,
82,
11,
1978,
351,
257,
366,
15522,
271,
1911,
198,
2,
40480,
319,
366,
32180,
1,
82,
389,
1486,
284,
26332,
262,
4069,
286,
2603,
45977,
13,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
35946,
90,
51,
16,
27,
25,
15057,
11,
309,
17,
27,
25,
46541,
92,
198,
198,
6030,
326,
4909,
362,
7032,
25,
198,
198,
16,
13,
4600,
6759,
63,
25,
6550,
45977,
10552,
286,
1957,
10088,
13,
198,
17,
13,
4600,
521,
82,
63,
25,
1423,
721,
274,
286,
5043,
262,
10088,
6529,
319,
13,
198,
37811,
198,
7249,
35946,
90,
51,
16,
27,
25,
15057,
11,
309,
17,
27,
25,
46541,
92,
198,
220,
220,
220,
2603,
3712,
46912,
90,
51,
16,
92,
198,
220,
220,
220,
773,
82,
3712,
38469,
90,
51,
17,
92,
198,
437,
198,
2,
10097,
3880,
30934,
198,
2,
14392,
5499,
319,
366,
18843,
1352,
1298,
198,
198,
2,
352,
13,
1635,
25,
15237,
489,
3299,
416,
257,
1271,
13,
198,
2,
362,
13,
1220,
25,
7458,
416,
257,
1271,
13,
198,
2,
10097,
3880,
30934,
198,
9,
7,
66,
3712,
15057,
11,
267,
3712,
18843,
1352,
8,
796,
35946,
7,
66,
1635,
267,
13,
6759,
11,
267,
13,
521,
82,
8,
198,
29006,
78,
3712,
18843,
1352,
11,
269,
3712,
15057,
8,
796,
35946,
7,
78,
13,
6759,
1220,
269,
11,
267,
13,
521,
82,
8,
198,
2,
10097,
3880,
30934,
198,
2,
35946,
284,
6070,
15879,
14,
6759,
8609,
13,
198,
198,
2,
1675,
3443,
651,
262,
48473,
2163,
11,
994,
356,
2962,
319,
257,
2060,
5752,
17512,
25,
198,
198,
2,
352,
13,
7253,
351,
257,
1813,
1720,
1181,
7,
12894,
896,
828,
356,
2005,
257,
10618,
422,
340,
26,
198,
2,
362,
13,
40806,
378,
477,
1744,
19561,
287,
262,
10618,
11,
290,
1100,
262,
17593,
5002,
286,
10088,
26,
198,
2,
513,
13,
3060,
284,
262,
15879,
14,
6759,
8609,
5002,
13,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
751,
83,
659,
66,
0,
7,
35138,
3712,
23839,
38469,
11,
2172,
3712,
18843,
1352,
11,
4308,
3712,
15522,
271,
11,
763,
14822,
3712,
15057,
28,
16,
8,
198,
198,
20180,
560,
48473,
2239,
13,
27131,
378,
2060,
15879,
5002,
286,
281,
10088,
1635,
15879,
13,
198,
198,
12,
4600,
35138,
63,
25,
20650,
284,
6070,
198,
12,
4600,
8738,
63,
25,
35946,
198,
12,
4600,
12093,
271,
63,
25,
1423,
5344,
262,
2176,
5752,
198,
12,
4600,
1073,
14822,
63,
25,
383,
15879,
5002,
286,
5128,
1181,
198,
37811,
198,
8818,
751,
83,
659,
66,
0,
7,
35138,
3712,
23839,
38469,
11,
2172,
3712,
18843,
1352,
11,
4308,
3712,
15522,
271,
11,
763,
14822,
3712,
15057,
28,
16,
8,
198,
220,
220,
220,
4308,
62,
1177,
796,
1570,
7,
12093,
271,
11,
2172,
13,
521,
82,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
13610,
257,
1570,
319,
262,
10618,
286,
262,
19561,
198,
220,
220,
220,
6376,
62,
1177,
796,
6376,
7,
12093,
271,
62,
1177,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
3497,
262,
4238,
6376,
286,
262,
9569,
10618,
198,
220,
220,
220,
2172,
62,
28665,
796,
2172,
13,
6759,
58,
45299,
6376,
62,
1177,
60,
1635,
763,
14822,
220,
220,
220,
220,
1303,
3497,
262,
4847,
287,
5752,
286,
6376,
62,
1177,
198,
220,
220,
220,
5752,
62,
17618,
796,
4129,
7,
8738,
62,
28665,
8,
198,
220,
220,
220,
329,
479,
796,
352,
25,
808,
62,
17618,
198,
220,
220,
220,
220,
220,
220,
220,
1487,
0,
7,
12093,
271,
62,
1177,
11,
479,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1312,
796,
6376,
7,
12093,
271,
8,
198,
220,
220,
220,
220,
220,
220,
220,
43030,
58,
72,
60,
15853,
2172,
62,
28665,
58,
74,
60,
198,
220,
220,
220,
886,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
27845,
262,
15879,
198,
220,
220,
220,
1487,
0,
7,
12093,
271,
62,
1177,
11,
6376,
62,
1177,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
30027,
262,
10618,
198,
437,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
751,
83,
659,
6359,
0,
7,
303,
6359,
3712,
23839,
46912,
11,
2172,
3712,
18843,
1352,
11,
4308,
3712,
15522,
271,
11,
763,
14822,
3712,
23839,
38469,
8,
198,
198,
20180,
560,
48473,
2239,
13,
27131,
378,
2060,
5752,
286,
17593,
5002,
286,
281,
10088,
1635,
17593,
13,
198,
198,
12,
1569,
6359,
1058,
569,
478,
669,
284,
6070,
198,
12,
2172,
220,
1058,
35946,
198,
12,
4308,
25,
1423,
5344,
262,
2176,
5752,
198,
12,
763,
14822,
25,
383,
5752,
286,
17593,
4847,
286,
5128,
2585,
198,
37811,
198,
8818,
751,
83,
659,
6359,
0,
7,
303,
6359,
3712,
23839,
46912,
11,
2172,
3712,
18843,
1352,
11,
4308,
3712,
15522,
271,
11,
763,
14822,
3712,
23839,
38469,
90,
27,
25,
15057,
30072,
198,
220,
220,
220,
4308,
62,
1177,
796,
1570,
7,
12093,
271,
11,
2172,
13,
521,
82,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
13610,
257,
1570,
319,
262,
10618,
286,
262,
19561,
198,
220,
220,
220,
6376,
62,
1177,
796,
6376,
7,
12093,
271,
62,
1177,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
3497,
262,
4238,
6376,
286,
262,
9569,
10618,
198,
220,
220,
220,
2172,
62,
28665,
796,
2172,
13,
6759,
58,
45299,
6376,
62,
1177,
60,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
3497,
262,
4847,
287,
5752,
286,
6376,
62,
1177,
198,
220,
220,
220,
5752,
62,
17618,
796,
4129,
7,
8738,
62,
28665,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
27845,
262,
17593,
198,
220,
220,
220,
329,
479,
796,
352,
25,
808,
62,
17618,
198,
220,
220,
220,
220,
220,
220,
220,
1487,
0,
7,
12093,
271,
62,
1177,
11,
479,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1312,
796,
6376,
7,
12093,
271,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1569,
6359,
58,
72,
11,
1058,
60,
15853,
2172,
62,
28665,
58,
74,
60,
1635,
763,
14822,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1487,
0,
7,
12093,
271,
62,
1177,
11,
6376,
62,
1177,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
30027,
262,
10618,
198,
437,
198,
2,
10097,
3880,
30934,
198,
2,
5994,
25,
14680,
198,
2,
10097,
3880,
30934,
198,
39344,
14680,
198,
37811,
198,
220,
220,
220,
14680,
90,
27871,
6030,
27,
25,
23839,
38469,
90,
27,
25,
18843,
1352,
5512,
6455,
6030,
27,
25,
15522,
271,
92,
198,
198,
6030,
326,
4909,
362,
7032,
25,
198,
198,
16,
13,
4600,
404,
912,
63,
25,
7343,
286,
12879,
198,
17,
13,
4600,
12093,
271,
63,
25,
6455,
271,
329,
262,
1080,
198,
37811,
198,
7249,
14680,
90,
51,
16,
1279,
25,
7913,
11,
309,
17,
1279,
25,
34142,
11,
309,
18,
92,
198,
220,
220,
220,
2172,
82,
3712,
38469,
90,
18843,
1352,
90,
51,
16,
11,
309,
17,
11709,
198,
220,
220,
220,
4308,
3712,
15522,
271,
90,
51,
18,
92,
198,
437,
198,
417,
4906,
7,
3712,
32180,
90,
51,
16,
11,
309,
17,
11,
309,
18,
30072,
810,
309,
16,
810,
309,
17,
810,
309,
18,
796,
309,
16,
198,
8818,
2546,
7,
8738,
3712,
32180,
8,
198,
220,
220,
220,
4308,
796,
2172,
13,
12093,
271,
198,
220,
220,
220,
5391,
796,
4308,
13,
8692,
10563,
4308,
13,
11925,
198,
220,
220,
220,
357,
27740,
11,
5391,
8,
198,
437,
198,
2,
10097,
3880,
30934,
198,
2,
6455,
271,
14680,
30122,
198,
2,
10097,
3880,
30934,
198,
39344,
4905,
198,
37811,
198,
220,
220,
220,
4905,
7,
76,
1381,
11,
773,
82,
11,
18896,
28,
15,
26,
2779,
28,
15,
8,
198,
198,
6090,
261,
605,
5103,
2446,
329,
4600,
32180,
63,
2134,
13,
198,
198,
12,
4600,
76,
1381,
63,
25,
7343,
286,
17593,
10552,
286,
12879,
13,
198,
12,
4600,
521,
82,
63,
25,
7343,
286,
5043,
262,
1515,
459,
669,
719,
319,
13,
198,
12,
4600,
11925,
63,
25,
18291,
1958,
262,
2546,
286,
262,
1080,
13,
15161,
4600,
11925,
28,
15,
63,
481,
21155,
8295,
24374,
13,
198,
12,
4600,
8692,
63,
25,
29082,
1271,
286,
1123,
5043,
13,
15161,
4600,
8692,
28,
15,
63,
481,
21155,
8295,
24374,
13,
198,
37811,
198,
8818,
4905,
7,
198,
220,
220,
220,
46054,
3712,
23839,
38469,
90,
27,
25,
23839,
46912,
5512,
220,
198,
220,
220,
220,
773,
82,
3712,
23839,
38469,
90,
27,
25,
23839,
38469,
5512,
220,
198,
220,
220,
220,
18896,
3712,
46541,
28,
15,
26,
220,
198,
220,
220,
220,
2779,
3712,
46541,
28,
15,
198,
8,
198,
220,
220,
220,
347,
796,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
275,
796,
2779,
855,
15,
5633,
2835,
7,
5317,
2414,
11,
2546,
7,
76,
1381,
58,
16,
4357,
352,
8,
61,
7,
16,
14,
13664,
7,
521,
82,
58,
16,
60,
22305,
1058,
2558,
2414,
7,
8692,
8,
198,
220,
220,
220,
220,
220,
220,
220,
300,
796,
18896,
855,
15,
5633,
5415,
7,
47033,
12195,
521,
82,
4008,
1058,
2558,
2414,
7,
11925,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4308,
7,
65,
11,
300,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2603,
62,
4906,
796,
7719,
62,
4906,
7,
417,
4906,
12195,
76,
1381,
8,
23029,
198,
220,
220,
220,
773,
62,
4906,
796,
7719,
62,
4906,
7,
417,
4906,
12195,
521,
82,
8,
23029,
198,
220,
220,
220,
440,
796,
685,
18843,
1352,
7,
19182,
90,
6759,
62,
4906,
92,
7,
76,
1381,
58,
72,
46570,
15690,
90,
521,
62,
4906,
92,
7,
521,
82,
58,
72,
60,
4008,
329,
1312,
28,
16,
25,
13664,
7,
76,
1381,
15437,
198,
220,
220,
220,
14680,
7,
46,
11,
347,
8,
198,
437,
198,
2,
10097,
3880,
30934,
198,
2,
14392,
40480,
329,
2099,
14680,
198,
2,
10097,
3880,
30934,
198,
9,
7,
66,
3712,
15057,
11,
267,
3712,
32180,
8,
796,
14680,
7,
66,
764,
9,
267,
13,
404,
912,
11,
267,
13,
12093,
271,
8,
198,
29006,
78,
3712,
32180,
11,
269,
3712,
15057,
8,
796,
14680,
7,
78,
13,
404,
912,
24457,
269,
11,
267,
13,
12093,
271,
8,
198,
33747,
8738,
16,
3712,
32180,
11,
2172,
17,
3712,
32180,
8,
796,
14680,
7,
85,
9246,
7,
8738,
16,
13,
404,
912,
11,
2172,
17,
13,
404,
912,
828,
2172,
16,
13,
12093,
271,
8,
198,
30420,
78,
16,
3712,
32180,
11,
267,
17,
3712,
32180,
8,
796,
267,
16,
1343,
14808,
12,
16,
8,
1635,
267,
17,
8,
198,
8818,
2160,
7,
349,
3712,
23839,
38469,
90,
27,
25,
32180,
30072,
198,
220,
220,
220,
4308,
796,
25776,
58,
16,
4083,
12093,
271,
198,
220,
220,
220,
2172,
82,
796,
410,
9246,
26933,
23013,
13,
404,
912,
329,
267,
72,
287,
25776,
60,
23029,
198,
220,
220,
220,
14680,
7,
404,
912,
11,
4308,
8,
198,
437,
198,
2,
10097,
3880,
30934,
198,
2,
14680,
284,
6070,
15879,
14,
6759,
8609,
25,
198,
198,
2,
383,
2446,
318,
6209,
11629,
378,
1123,
10088,
284,
262,
1813,
19561,
12,
33469,
4308,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
751,
83,
659,
66,
0,
7,
35138,
3712,
23839,
38469,
11,
2172,
3712,
32180,
11,
763,
14822,
3712,
15057,
28,
16,
8,
198,
198,
20180,
560,
48473,
2239,
13,
27131,
378,
2060,
15879,
5002,
286,
281,
4905,
1635,
15879,
13,
198,
464,
5752,
1321,
318,
8574,
287,
262,
4308,
286,
4905,
13,
198,
198,
12,
4600,
35138,
63,
25,
20650,
284,
6070,
13,
198,
12,
4600,
8738,
63,
25,
14680,
13,
198,
12,
4600,
1073,
14822,
63,
25,
383,
15879,
5002,
286,
5128,
1181,
13,
198,
37811,
198,
8818,
751,
83,
659,
66,
0,
7,
35138,
3712,
23839,
38469,
11,
2172,
3712,
32180,
11,
763,
14822,
3712,
15057,
28,
16,
8,
198,
220,
220,
220,
4308,
796,
2172,
13,
12093,
271,
198,
220,
220,
220,
2172,
82,
796,
2172,
13,
404,
912,
198,
220,
220,
220,
997,
62,
1659,
62,
404,
912,
796,
4129,
7,
404,
912,
8,
198,
220,
220,
220,
329,
1312,
796,
352,
25,
22510,
62,
1659,
62,
404,
912,
198,
220,
220,
220,
220,
220,
220,
220,
751,
83,
659,
66,
0,
7,
35138,
11,
2172,
82,
58,
72,
4357,
4308,
11,
763,
14822,
8,
198,
220,
220,
220,
886,
1303,
7854,
541,
306,
416,
1123,
10088,
290,
751,
606,
477,
284,
15879,
198,
437,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
751,
83,
659,
6359,
0,
7,
303,
6359,
3712,
23839,
46912,
11,
2172,
3712,
32180,
11,
763,
14822,
3712,
23839,
38469,
8,
198,
198,
20180,
560,
48473,
2239,
13,
27131,
378,
2060,
5752,
286,
17593,
5002,
286,
281,
4905,
1635,
17593,
13,
198,
464,
5752,
1321,
318,
8574,
287,
262,
4308,
286,
4905,
13,
198,
198,
12,
4600,
303,
6359,
63,
25,
569,
478,
669,
284,
6070,
198,
12,
4600,
8738,
63,
25,
14680,
198,
12,
4600,
1073,
14822,
63,
25,
383,
5752,
286,
17593,
4847,
286,
5128,
2585,
198,
37811,
198,
8818,
751,
83,
659,
6359,
0,
7,
303,
6359,
3712,
23839,
46912,
11,
2172,
3712,
32180,
11,
763,
14822,
3712,
23839,
38469,
90,
27,
25,
15057,
30072,
198,
220,
220,
220,
4308,
796,
2172,
13,
12093,
271,
198,
220,
220,
220,
2172,
82,
796,
2172,
13,
404,
912,
198,
220,
220,
220,
997,
62,
1659,
62,
404,
912,
796,
4129,
7,
404,
912,
8,
198,
220,
220,
220,
329,
1312,
796,
352,
25,
22510,
62,
1659,
62,
404,
912,
198,
220,
220,
220,
220,
220,
220,
220,
751,
83,
659,
6359,
0,
7,
303,
6359,
11,
2172,
82,
58,
72,
4357,
4308,
11,
763,
14822,
8,
198,
220,
220,
220,
886,
1303,
7854,
541,
306,
416,
1123,
10088,
290,
751,
606,
477,
284,
30104,
198,
437,
198,
2,
10097,
3880,
30934,
198,
2,
15237,
489,
3299,
198,
198,
2,
383,
2126,
318,
284,
11629,
378,
477,
1720,
1181,
4308,
11,
290,
651,
477,
262,
15879,
14,
6759,
8609,
4847,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
35971,
0,
7,
35138,
3712,
23839,
38469,
11,
2172,
3712,
32180,
11,
1181,
3712,
23839,
38469,
8,
198,
198,
13295,
48473,
329,
4905,
290,
15879,
13,
198,
198,
12,
4600,
35138,
63,
25,
20650,
284,
6070,
13,
198,
12,
4600,
8738,
63,
25,
14680,
13,
198,
12,
4600,
5219,
63,
25,
23412,
15879,
13,
198,
37811,
198,
8818,
35971,
0,
7,
35138,
3712,
23839,
38469,
11,
2172,
3712,
32180,
11,
1181,
3712,
23839,
38469,
8,
198,
220,
220,
220,
4308,
796,
2172,
13,
12093,
271,
198,
220,
220,
220,
329,
474,
796,
352,
25,
13664,
7,
5219,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1487,
0,
7,
12093,
271,
11,
474,
8,
198,
220,
220,
220,
220,
220,
220,
220,
751,
83,
659,
66,
0,
7,
35138,
11,
2172,
11,
1181,
58,
73,
12962,
198,
220,
220,
220,
886,
198,
437,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
35971,
0,
7,
6759,
3712,
23839,
38469,
11,
2172,
3712,
32180,
11,
1181,
3712,
23839,
38469,
8,
198,
198,
13295,
48473,
329,
4905,
290,
17593,
13,
198,
198,
12,
4600,
6759,
63,
25,
24936,
284,
6070,
13,
198,
12,
4600,
8738,
63,
25,
14680,
13,
198,
12,
4600,
27219,
63,
25,
23412,
2585,
7,
6759,
8609,
737,
198,
37811,
198,
8818,
35971,
0,
7,
6759,
3712,
23839,
46912,
11,
2172,
3712,
32180,
11,
2585,
3712,
23839,
46912,
8,
198,
220,
220,
220,
4308,
796,
2172,
13,
12093,
271,
198,
220,
220,
220,
329,
474,
796,
352,
25,
7857,
7,
27219,
11,
352,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1487,
0,
7,
12093,
271,
11,
474,
8,
198,
220,
220,
220,
220,
220,
220,
220,
751,
83,
659,
6359,
0,
7,
6759,
11,
2172,
11,
2585,
58,
73,
11,
1058,
12962,
198,
220,
220,
220,
886,
198,
437,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
1635,
7,
8738,
3712,
32180,
11,
43030,
62,
273,
62,
6759,
3712,
23839,
53,
721,
5574,
19044,
8,
198,
198,
12218,
48473,
329,
4905,
290,
15879,
14,
6759,
8609,
13,
198,
198,
12,
4600,
8738,
63,
25,
14680,
13,
198,
12,
4600,
35138,
62,
273,
62,
6759,
63,
25,
23412,
15879,
14,
6759,
8609,
13,
198,
37811,
198,
8818,
1635,
7,
8738,
3712,
32180,
11,
43030,
62,
273,
62,
6759,
3712,
23839,
53,
721,
5574,
19044,
8,
198,
220,
220,
220,
269,
4906,
796,
7719,
62,
4906,
7,
417,
4906,
7,
8738,
828,
1288,
4906,
7,
35138,
62,
273,
62,
6759,
4008,
198,
220,
220,
220,
503,
796,
1976,
27498,
7,
310,
2981,
11,
2546,
7,
35138,
62,
273,
62,
6759,
4008,
198,
220,
220,
220,
35971,
0,
7,
448,
11,
2172,
11,
43030,
62,
273,
62,
6759,
8,
198,
220,
220,
220,
503,
198,
437,
198,
2,
10097,
3880,
30934,
198,
2,
27845,
17593,
198,
2,
10097,
3880,
30934,
198,
39344,
6070,
6759,
0,
198,
37811,
198,
220,
220,
220,
6070,
6759,
0,
7,
6759,
3712,
23839,
46912,
11,
2172,
3712,
32180,
8,
198,
198,
33762,
262,
6632,
17593,
351,
17593,
5002,
422,
4905,
13,
198,
198,
12,
4600,
6759,
63,
25,
24936,
284,
6070,
13,
198,
12,
4600,
8738,
63,
25,
14680,
13,
198,
37811,
198,
8818,
6070,
6759,
0,
7,
6759,
3712,
23839,
46912,
11,
2172,
3712,
32180,
8,
198,
220,
220,
220,
4308,
796,
2172,
13,
12093,
271,
198,
220,
220,
220,
5752,
62,
17618,
796,
2546,
7,
6759,
11,
352,
8,
198,
220,
220,
220,
329,
474,
796,
352,
25,
808,
62,
17618,
198,
220,
220,
220,
220,
220,
220,
220,
1487,
0,
7,
12093,
271,
11,
474,
8,
198,
220,
220,
220,
220,
220,
220,
220,
751,
83,
659,
66,
0,
7,
1177,
7,
6759,
11,
1058,
11,
474,
828,
2172,
8,
198,
220,
220,
220,
886,
198,
437,
198,
2,
10097,
3880,
30934,
198,
37811,
198,
220,
220,
220,
15690,
7,
8738,
3712,
32180,
8,
198,
198,
13615,
262,
1336,
17593,
1296,
286,
4600,
8738,
44646,
198,
37811,
198,
8818,
15690,
7,
8738,
3712,
32180,
8,
198,
220,
220,
220,
2603,
796,
1976,
27498,
7,
417,
4906,
7,
8738,
828,
2546,
7,
8738,
4008,
198,
220,
220,
220,
6070,
6759,
0,
7,
6759,
11,
2172,
8,
198,
220,
220,
220,
2603,
198,
437
] | 3.297033 | 3,168 |
include("Parser.jl")
using DataStructures
struct StaticAnalysisException <: Exception
msg::String
end
default_value_strings = Dict{MPType,String}(
MInt => "-1",
MReal => "-1.0",
MBool => "false",
MString => "",
)
initial_scope_level = 0
unary_result_types = Dict{Tuple{TokenClass,MPType},MPType}(
(kw_not, MBool) => MBool,
(minus, MInt) => MInt,
(minus, MReal) => MReal
)
array_type_to_scalar_type = Dict{MPType,MPType}(
MIntArray => MInt,
MRealArray => MReal,
MBoolArray => MBool,
MStringArray => MString
)
ref_type_to_scalar_type = Dict{MPType,MPType}(
MIntRef => MInt,
MRealRef => MReal,
MBoolRef => MBool,
MStringRef => MString,
MInt => MInt,
MReal => MReal,
MBool => MBool,
MString => MString,
)
binary_result_types = DefaultDict(MError,
(times, MInt, MInt) => MInt,
(times, MReal, MReal) => MReal,
(plus, MInt, MInt) => MInt,
(plus, MReal, MReal) => MReal,
(plus, MString, MString) => MString,
(minus, MInt, MInt) => MInt,
(minus, MReal, MReal) => MReal,
(divide, MInt, MInt) => MInt,
(divide, MReal, MReal) => MReal,
(modulo, MInt, MInt) => MInt,
(kw_or, MBool, MBool) => MBool,
(kw_and, MBool, MBool) => MBool,
(equals, MInt, MInt) => MBool,
(not_equal, MInt, MInt) => MBool,
(less_than, MInt, MInt) => MBool,
(less_than_or_equal, MInt, MInt) => MBool,
(greater_than, MInt, MInt) => MBool,
(greater_than_or_equal, MInt, MInt) => MBool,
(kw_and, MBool, MBool) => MBool,
(equals, MReal, MReal) => MBool,
(not_equal, MReal, MReal) => MBool,
(less_than, MReal, MReal) => MBool,
(less_than_or_equal, MReal, MReal) => MBool,
(greater_than, MReal, MReal) => MBool,
(greater_than_or_equal, MReal, MReal) => MBool,
(equals, MString, MString) => MBool,
(not_equal, MString, MString) => MBool,
(less_than, MString, MString) => MBool,
(less_than_or_equal, MString, MString) => MBool,
(greater_than, MString, MString) => MBool,
(greater_than_or_equal, MString, MString) => MBool,
(equals, MBool, MBool) => MBool,
(not_equal, MBool, MBool) => MBool,
(less_than, MBool, MBool) => MBool,
(less_than_or_equal, MBool, MBool) => MBool,
(greater_than, MBool, MBool) => MBool,
(greater_than_or_equal, MBool, MBool) => MBool,
)
mutable struct Argument
name::String
is_var::Bool
type::MPType
size::Int
end
mutable struct SubroutineEntry
name::String
param_names::Vector{String}
param_types::Vector{MPType}
return_type::MPType
node::Union{Subroutine,Nothing}
end
mutable struct AnalysisContext
scope_stack::Stack{SymTableEntry}
scope::Int
subroutines::Vector{SubroutineEntry}
in_call::Stack{Call}
unique_calls::Vector{Call}
all_var_names_and_types::Vector{Tuple{String,MPType}}
var_id_counter::Int
end
AnalysisContext() = AnalysisContext(
Stack{SymTableEntry}(),
initial_scope_level,
Vector{SubroutineEntry}(),
Stack{Call}(),
Vector{Call}(),
Vector{Tuple{String,MPType}}(),
0
)
function create_var_id(ac::AnalysisContext, var_type::MPType, var_name::String)
counter = ac.var_id_counter
ac.var_id_counter += 1
return "%_$(var_type)_$(var_name)_$(counter)"
end
function hasvariable(s::AnalysisContext, var_name::String, inner_scope_only::Bool=false)
if DEBUG
foreach(println, s.scope_stack)
end
if isempty(s.scope_stack) return false end
if inner_scope_only
scope = s.scope
return any(entry->entry.scope_level == scope && entry.var_name == var_name, s.scope_stack)
end
return any(entry->entry.var_name == var_name, s.scope_stack)
end
function getvariable(s::AnalysisContext, var_name)
return getfirst(entry -> entry.var_name == var_name, s.scope_stack)
end
function popscope!(s::AnalysisContext)
isempty(s.scope_stack) && return
s.scope -= 1
while !isempty(s.scope_stack) && (first(s.scope_stack).scope_level > s.scope)
pop!(s.scope_stack)
end
end
function enterscope!(s::AnalysisContext)
s.scope += 1
end
function pushvar!(ac::AnalysisContext, var_name::String, var_type::MPType, val_identifier::String, is_implicit::Bool=false)
entry = SymTableEntry(var_name, var_type, val_identifier, ac.scope, is_implicit)
push!(ac.scope_stack, entry)
end
function pushsubroutine!(ac::AnalysisContext,
name::String,
param_names::Vector{String},
param_types::Vector{MPType},
return_type::MPType,
node::Union{Subroutine,Nothing})
entry = SubroutineEntry(name, param_names, param_types, return_type, node)
push!(ac.subroutines, entry)
end
function hassubroutine(ac::AnalysisContext, name::String)
return any(entry->entry.name == name, ac.subroutines)
end
function getsubroutine(srs::Vector{SubroutineEntry}, name::String)
index = findfirst(sr->sr.name == name, srs)
return srs[index]
end
function getsubroutine(ac::AnalysisContext, name::String)
getsubroutine(ac.subroutines, name)
end
# The entry point for the static analyzer.
function static_analysis(AST::Program, ac::AnalysisContext)
# Push default values for all var, type combinations used in program
push_defaults!(ac)
# Process definitions
static_analysis(AST.definitions, ac)
# Process main block
static_analysis(AST.main, ac)
end
function push_defaults!(ac::AnalysisContext)
for (name, mptype) in ac.all_var_names_and_types
if mptype ∈ scalar_types
ref_type = scalar_to_ref_type[mptype]
pushvar!(ac, name, ref_type, "@default_$(mptype)")
end
end
enterscope!(ac)
end
static_analysis(AST::Program) = static_analysis(AST, AnalysisContext())
function static_analysis(d::Definitions, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing definitions")
if !allunique([def.name for def in d.defs])
throw(StaticAnalysisException(
"All functions and subroutines must have unique names. Overloading is not allowed."
))
end
for subroutine::Subroutine in d.defs
get_signature(subroutine, ac)
end
end
function get_signature(s::Subroutine, ac::AnalysisContext)
foreach(param::Parameter->static_analysis(param, ac), s.params)
true_types = Vector{MPType}([parameter_to_mptype(param) for param in s.params])
param_names = Vector{String}([param.name for param in s.params])
static_analysis(s.ret_type, ac)
if !isa(s.ret_type.size, ImmediateInt)
throw(StaticAnalysisException(
"Reference types (strings and arrays) are not allowed as function return types (line $(s.line))."
))
end
pushsubroutine!(ac,
s.name,
param_names,
true_types,
s.ret_type.scalar_type,
s
)
end
function parameter_to_mptype(p::Parameter)
if p.is_array && p.is_var_par
throw(StaticAnalysisException(
"Array type cannot be used as var parameter (line $(p.line))."
))
end
if p.is_var_par
return scalar_to_ref_type[p.scalar_type]
end
if p.is_array
return scalar_to_array_type[p.scalar_type]
end
return p.scalar_type
end
function parameter_to_llvmtype(p::Parameter)
mptype_to_llvm_type[parameter_to_mptype(p)]
end
function typecheck(b::BinaryOperation, ac::AnalysisContext)
typecheck(b.left, ac)
typecheck(b.right, ac)
ret_type = binary_result_types[(b.op, b.left.type, b.right.type)]
if ret_type == MError
throw(StaticAnalysisException(
"Type mismatch ($(b.left.type) and $(b.right.type)) for binary operation \"$(b.op)\" on line $(b.line)."
))
end
b.type = ret_type
end
function typecheck(u::UnaryOperation, ac::AnalysisContext)
typecheck(u.operand, ac)
ret_type = unary_result_types[(u.op, u.operand.type)]
if ret_type == MError
throw(StaticAnalysisException(
"Invalid type $(u.operand.type) for unary operation \"$(u.op)\" (line $(u.line))."
))
end
u.type = ret_type
end
function static_analysis(s::Subroutine, ac::AnalysisContext)
static_analysis(s.body, ac)
s.type = MPassed
end
function static_analysis(c::CallStatement, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing CallStatement")
analyze_call(c, ac)
c.type = MPassed
end
function analyze_call(c::Call, ac::AnalysisContext)
DEBUG && println("This is analyze_call, call is to $(c.identifier)")
DEBUG && println("implicit_params are $(c.implicit_params)")
subroutine_entry::SubroutineEntry = getsubroutine(ac, c.identifier)
for (i, (param_type, arg)) in enumerate(zip(subroutine_entry.param_types, c.arguments))
if param_type ∈ ref_types # Parameter is a var parameter
c.arguments[i] = GetRef(c.arguments[i], c.line)
end
end
CallFactor
foreach(arg->typecheck(arg, ac), c.arguments)
compare_with_signature(subroutine_entry, c.arguments, c.line)
c.subroutine = subroutine_entry.node::Subroutine
c.subroutine.is_called = true
all_var_names = Vector{String}(unique([name for (name, type) in ac.all_var_names_and_types]))
c.implicit_params = [getvariable(ac, p) for p in all_var_names]
subroutines_in_call = [call.identifier for call in ac.in_call]
if subroutine_entry.name ∈ subroutines_in_call
return
end
llvm_function_name = get_llvm_function_name(subroutine_entry.name, c.call_id)
c.subroutine.llvm_function_name = llvm_function_name
enterscope!(ac)
c.scope_level = ac.scope
push!(ac.in_call, c)
for var_entry::SymTableEntry in c.implicit_params
param_name = var_entry.var_name
param_type = var_entry.var_type
name_as_implicit = get_implicit_param_id(param_name, param_type)
ref_type = param_type ∈ ref_types ? param_type : scalar_to_ref_type[param_type]
pushvar!(ac, param_name, ref_type, "%$(name_as_implicit)", true)
end
for (param_name, arg) in zip(subroutine_entry.param_names, c.arguments)
type = arg isa GetRef ? arg.type : ref_type_to_scalar_type[arg.type]
pushvar!(ac, param_name, arg.type, "%$(param_name)")
end
static_analysis(c.subroutine, ac)
pop!(ac.in_call)
popscope!(ac)
end
function get_implicit_param_id(name::String, mptype::MPType)
"implicit.$(ref_type_to_scalar_type[mptype]).$(name)"
end
function compare_with_signature(sr::SubroutineEntry, args::Vector{Value}, line::Int)
if length(sr.param_types) != length(args)
throw(StaticAnalysisException(
"Subroutine call has $(length(args)) arguments, expected $(length(sr.param_types)) (line $line)."
))
end
for (param_type, arg) in zip(sr.param_types, args)
if arg.type != param_type
throw(StaticAnalysisException(
"Expected argument of type $param_type, got $(arg.type) (line $line)."
))
end
end
end
function static_analysis(r::Return, ac::AnalysisContext)
current_subroutine::Subroutine = first(ac.in_call).subroutine
typecheck(r.value, ac)
if r.value.type != current_subroutine.ret_type.true_type
throw(StaticAnalysisException(
"Expected return type to be $(current_subroutine.ret_type.true_type), got $(r.value.type) (line $(r.line))."
))
end
r.type = MPassed
end
function static_analysis(p::Parameter, ac::AnalysisContext)
typecheck(p.size, ac)
if p.size.type != MInt
throw(StaticAnalysisException(
"Array size must have integer value, got $(p.size.type) (line $(p.line))."
))
end
p.type = MPassed
end
function static_analysis(b::Block, ac::AnalysisContext, only_collect=false)
if !b.is_subroutine_block enterscope!(ac) end
for stmt in b.statements
if !only_collect
static_analysis(stmt, ac)
elseif stmt isa VariableFactor
if !hasvariable(ac, stmt.identifier, true)
push!(b.subroutine.implicit_params, stmt.identifier)
end
elseif stmt isa Call
push!(b.subroutine.calls_subroutines, stmt.identifier)
end
end
if !b.is_subroutine_block popscope!(ac) end
b.type = MPassed
end
function static_analysis(d::Declaration, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing Declaration")
static_analysis(d.var_type, ac)
var_type = d.var_type.true_type
for name in map(token->token.lexeme, d.names)
if hasvariable(ac, name, true)
entry = getvariable(ac, name)
if !entry.is_implicit
throw(StaticAnalysisException(
"Cannot redeclare variable $(name) (line $(d.line))."
))
end
end
id = create_var_id(ac, var_type, name)
push!(d.unique_ids, id)
pushvar!(ac, name, scalar_to_ref_type[var_type], id)
end
d.type = MPassed
end
function static_analysis(c::TypeOfVarOrValue, ac::AnalysisContext)
typecheck(c.size, ac)
if c.size.type != MInt
throw(StaticAnalysisException(
"Array size must have integer type (line $(c.line))."
))
end
c.type = MPassed
end
function static_analysis(a::Assignment, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing Assignment")
var_name = a.variable_name
if !hasvariable(ac, var_name)
throw(StaticAnalysisException(
"Cannot assign to undeclared variable '$(var_name)' (line $(a.line))."
))
end
index_type = typecheck(a.array_index, ac)
if index_type != MInt
throw(StaticAnalysisException(
"Array index must be an integer, got $(index_type) (line $(a.line))."
))
end
value_type = typecheck(a.value, ac)
entry::SymTableEntry = getvariable(ac, var_name)
var_type = entry.var_type
a.var_type = var_type
if var_type ∈ ref_types
var_type = ref_type_to_scalar_type[var_type]
elseif var_type ∈ scalar_types
entry.val_identifier = create_var_id(ac, var_type, var_name)
end
if value_type != var_type
if !(a.is_array_access && scalar_to_array_type[value_type] == var_type)
throw(StaticAnalysisException(
"Cannot assign a value of type $(value_type) to variable '$(var_name)' of type $(var_type) (line $(a.line))."
))
end
end
a.var_unique_id = entry.val_identifier
a.type = MPassed
end
function static_analysis(i::IfThenElse, ac::AnalysisContext)
cond_type = typecheck(i.condition, ac)
if cond_type != MBool
throw(StaticAnalysisException(
"If statement condition must be boolean, got type $cond_type (line $(i.line))."))
end
static_analysis(i.then_stmt, ac)
static_analysis(i.else_stmt, ac)
i.type = MPassed
end
function static_analysis(i::IfThen, ac::AnalysisContext)
cond_type = typecheck(i.condition, ac)
if cond_type != MBool
throw(StaticAnalysisException(
"If statement condition must be boolean, got type $cond_type (line $(i.line))."))
end
static_analysis(i.then_stmt, ac)
i.type = MPassed
end
function static_analysis(w::While, ac::AnalysisContext)
cond_type = typecheck(w.condition, ac)
if cond_type != MBool
throw(StaticAnalysisException(
"While statement condition must be boolean, got type $cond_type (line $(w.line))."))
end
static_analysis(w.do_stmt, ac)
w.type = MPassed
end
function static_analysis(r::Read, ac::AnalysisContext)
for var::Variable in r.variables
static_analysis(var, ac)
if !hasvariable(ac, var.identifier)
throw(StaticAnalysisException(
"Trying to read to undeclared variable $(var.identifier) (line $(r.line))."
))
end
entry::SymTableEntry = getvariable(ac, var.identifier)
push!(r.var_types, entry.var_type)
if entry.var_type ∉ scalar_types
throw(StaticAnalysisException(
"Only scalar variable types can be read (line $(r.line))."
))
end
end
r.type = MPassed
end
function static_analysis(p::Write, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing Write")
static_analysis(p.arguments, ac)
p.type = MPassed
end
function static_analysis(a::Vector{Value}, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing arguments")
for arg in a
typecheck(arg, ac)
end
end
function typecheck(i::ImmediateInt, ac)
i.type = MInt
end
function typecheck(i::ImmediateReal, ac)
i.type = MReal
end
function typecheck(i::ImmediateString, ac)
i.type = MString
end
function typecheck(i::ImmediateBool, ac)
i.type = MBool
end
function typecheck(g::GetRef, ac)
g.type = scalar_to_ref_type[typecheck(g.operand, ac)]
end
function typecheck(l::LiteralFactor, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing LiteralFactor")
class = l.token.class
if class == int_literal
l.type = MInt
end
if class == real_literal
l.type = MReal
end
if class ∈ [kw_true, kw_false]
l.type = MBool
end
if class == string_literal
l.type = MString
end
return l.type
end
function typecheck(v::VariableFactor, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing VariableFactor")
DEBUG && println("in_call empty? $(isempty(ac.in_call))")
var_name = v.identifier
if !hasvariable(ac, var_name)
throw(StaticAnalysisException(
"Variable $(var_name) is not defined (line $(v.line))."
))
end
var_entry::SymTableEntry = getvariable(ac, var_name)
v.variable_entry = var_entry
var_type = var_entry.var_type
if var_type ∈ ref_types
var_type = ref_type_to_scalar_type[var_type]
end
v.type = var_type
end
function typecheck(a::ArrayAccessFactor, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing ArrayAccessFactor")
index_type = typecheck(a.index, ac)
if index_type != MInt
throw(StaticAnalysisException(
"Array index should be an integer, got type $(index_type) (line $(a.line))."
))
end
var_name = a.identifier
if !hasvariable(ac, var_name)
throw(StaticAnalysisException(
"Variable $(var_name) is not defined (line $(a.line))."
))
end
var_entry::SymTableEntry = getvariable(ac, var_name)
a.variable_entry = var_entry
var_type = var_entry.var_type
if var_type ∉ array_types
throw(StaticAnalysisException(
"Cannot index into non-array type ($var_type) variable '$var_name' (line $(a.line))."
))
end
a.type = array_type_to_scalar_type[var_type]
end
function typecheck(c::CallFactor, ac::AnalysisContext)
DEBUG && println("This is static analysis, analysing CallFactor")
analyze_call(c, ac)
subroutine_entry::SubroutineEntry = getsubroutine(ac, c.identifier)
ret_type = subroutine_entry.return_type
if ret_type == MNothing
name = subroutine_entry.name
throw(StaticAnalysisException(
"A call to subroutine '$name' cannot be used as a value as it has no return type (line $(c.line))."
))
end
c.type = ret_type
end
function typecheck(p::ParenFactor, ac::AnalysisContext)
p.type = typecheck(p.expression, ac)
end
function typecheck(n::NotFactor, ac::AnalysisContext)
arg_type = typecheck(n.argument, ac)
if arg_type != MBool
throw(StaticAnalysisException(
"The \"not\" operation requires a boolean argument, got type $(arg_type) on line $(n.line)."
))
end
n.type = MBool
end
# function typecheck(t::Term, ac::AnalysisContext)
# factor_types = [typecheck(tpl[1], ac) for tpl in t.factors]
# first_type = factor_types[1]
# for tpl in t.factors
# if tpl[1].type != first_type
# throw(StaticAnalysisException(
# "Type mismatch in operation $(tpl[2].class) on line $(tpl[1].line)."
# ))
# end
# end
# t.type = first_type
# return t.type
# end
function typecheck(s::SizeFactor, ac::AnalysisContext)
type = typecheck(s.array, ac)
if type ∉ [MIntArray, MRealArray, MBoolArray, MStringArray]
throw(StaticAnalysisException(
"Array size is not defined for values of type $(type) (on line $(s.line))."))
end
s.type = MInt
end
function get_llvm_function_name(subroutine_name::String, call_id::Int)
return "@$(subroutine_name).$(call_id)"
end
| [
17256,
7203,
46677,
13,
20362,
4943,
198,
198,
3500,
6060,
44909,
942,
198,
198,
7249,
36125,
32750,
16922,
1279,
25,
35528,
198,
220,
31456,
3712,
10100,
198,
437,
198,
198,
12286,
62,
8367,
62,
37336,
796,
360,
713,
90,
7378,
6030,
11,
10100,
92,
7,
198,
220,
337,
5317,
5218,
27444,
16,
1600,
198,
220,
337,
15633,
5218,
27444,
16,
13,
15,
1600,
198,
220,
10771,
970,
5218,
366,
9562,
1600,
198,
220,
337,
10100,
5218,
366,
1600,
198,
8,
198,
198,
36733,
62,
29982,
62,
5715,
796,
657,
198,
198,
403,
560,
62,
20274,
62,
19199,
796,
360,
713,
90,
51,
29291,
90,
30642,
9487,
11,
7378,
6030,
5512,
7378,
6030,
92,
7,
198,
220,
357,
46265,
62,
1662,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
40191,
11,
337,
5317,
8,
5218,
337,
5317,
11,
198,
220,
357,
40191,
11,
337,
15633,
8,
5218,
337,
15633,
198,
8,
198,
198,
18747,
62,
4906,
62,
1462,
62,
1416,
282,
283,
62,
4906,
796,
360,
713,
90,
7378,
6030,
11,
7378,
6030,
92,
7,
198,
220,
337,
5317,
19182,
5218,
337,
5317,
11,
198,
220,
337,
15633,
19182,
5218,
337,
15633,
11,
198,
220,
10771,
970,
19182,
5218,
10771,
970,
11,
198,
220,
337,
10100,
19182,
5218,
337,
10100,
198,
8,
198,
198,
5420,
62,
4906,
62,
1462,
62,
1416,
282,
283,
62,
4906,
796,
360,
713,
90,
7378,
6030,
11,
7378,
6030,
92,
7,
198,
220,
337,
5317,
8134,
5218,
337,
5317,
11,
198,
220,
337,
15633,
8134,
5218,
337,
15633,
11,
198,
220,
10771,
970,
8134,
5218,
10771,
970,
11,
198,
220,
337,
10100,
8134,
5218,
337,
10100,
11,
198,
220,
337,
5317,
5218,
337,
5317,
11,
198,
220,
337,
15633,
5218,
337,
15633,
11,
198,
220,
10771,
970,
5218,
10771,
970,
11,
198,
220,
337,
10100,
5218,
337,
10100,
11,
198,
8,
198,
198,
39491,
62,
20274,
62,
19199,
796,
15161,
35,
713,
7,
44,
12331,
11,
198,
220,
357,
22355,
11,
337,
5317,
11,
337,
5317,
8,
5218,
337,
5317,
11,
198,
220,
357,
22355,
11,
337,
15633,
11,
337,
15633,
8,
5218,
337,
15633,
11,
198,
220,
357,
9541,
11,
337,
5317,
11,
337,
5317,
8,
5218,
337,
5317,
11,
198,
220,
357,
9541,
11,
337,
15633,
11,
337,
15633,
8,
5218,
337,
15633,
11,
198,
220,
357,
9541,
11,
337,
10100,
11,
337,
10100,
8,
5218,
337,
10100,
11,
198,
220,
357,
40191,
11,
337,
5317,
11,
337,
5317,
8,
5218,
337,
5317,
11,
198,
220,
357,
40191,
11,
337,
15633,
11,
337,
15633,
8,
5218,
337,
15633,
11,
198,
220,
357,
7146,
485,
11,
337,
5317,
11,
337,
5317,
8,
5218,
337,
5317,
11,
198,
220,
357,
7146,
485,
11,
337,
15633,
11,
337,
15633,
8,
5218,
337,
15633,
11,
198,
220,
357,
4666,
43348,
11,
337,
5317,
11,
337,
5317,
8,
5218,
337,
5317,
11,
198,
220,
357,
46265,
62,
273,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
46265,
62,
392,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
4853,
874,
11,
337,
5317,
11,
337,
5317,
8,
5218,
10771,
970,
11,
198,
220,
357,
1662,
62,
40496,
11,
337,
5317,
11,
337,
5317,
8,
5218,
10771,
970,
11,
198,
220,
357,
1203,
62,
14813,
11,
337,
5317,
11,
337,
5317,
8,
5218,
10771,
970,
11,
198,
220,
357,
1203,
62,
14813,
62,
273,
62,
40496,
11,
337,
5317,
11,
337,
5317,
8,
5218,
10771,
970,
11,
198,
220,
357,
18223,
263,
62,
14813,
11,
337,
5317,
11,
337,
5317,
8,
5218,
10771,
970,
11,
198,
220,
357,
18223,
263,
62,
14813,
62,
273,
62,
40496,
11,
337,
5317,
11,
337,
5317,
8,
5218,
10771,
970,
11,
198,
220,
357,
46265,
62,
392,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
4853,
874,
11,
337,
15633,
11,
337,
15633,
8,
5218,
10771,
970,
11,
198,
220,
357,
1662,
62,
40496,
11,
337,
15633,
11,
337,
15633,
8,
5218,
10771,
970,
11,
198,
220,
357,
1203,
62,
14813,
11,
337,
15633,
11,
337,
15633,
8,
5218,
10771,
970,
11,
198,
220,
357,
1203,
62,
14813,
62,
273,
62,
40496,
11,
337,
15633,
11,
337,
15633,
8,
5218,
10771,
970,
11,
198,
220,
357,
18223,
263,
62,
14813,
11,
337,
15633,
11,
337,
15633,
8,
5218,
10771,
970,
11,
198,
220,
357,
18223,
263,
62,
14813,
62,
273,
62,
40496,
11,
337,
15633,
11,
337,
15633,
8,
5218,
10771,
970,
11,
198,
220,
357,
4853,
874,
11,
337,
10100,
11,
337,
10100,
8,
5218,
10771,
970,
11,
198,
220,
357,
1662,
62,
40496,
11,
337,
10100,
11,
337,
10100,
8,
5218,
10771,
970,
11,
198,
220,
357,
1203,
62,
14813,
11,
337,
10100,
11,
337,
10100,
8,
5218,
10771,
970,
11,
198,
220,
357,
1203,
62,
14813,
62,
273,
62,
40496,
11,
337,
10100,
11,
337,
10100,
8,
5218,
10771,
970,
11,
198,
220,
357,
18223,
263,
62,
14813,
11,
337,
10100,
11,
337,
10100,
8,
5218,
10771,
970,
11,
198,
220,
357,
18223,
263,
62,
14813,
62,
273,
62,
40496,
11,
337,
10100,
11,
337,
10100,
8,
5218,
10771,
970,
11,
198,
220,
357,
4853,
874,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
1662,
62,
40496,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
1203,
62,
14813,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
1203,
62,
14813,
62,
273,
62,
40496,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
18223,
263,
62,
14813,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
220,
357,
18223,
263,
62,
14813,
62,
273,
62,
40496,
11,
10771,
970,
11,
10771,
970,
8,
5218,
10771,
970,
11,
198,
8,
198,
198,
76,
18187,
2878,
45751,
198,
220,
1438,
3712,
10100,
198,
220,
318,
62,
7785,
3712,
33,
970,
198,
220,
2099,
3712,
7378,
6030,
198,
220,
2546,
3712,
5317,
198,
437,
198,
198,
76,
18187,
2878,
3834,
81,
28399,
30150,
198,
220,
1438,
3712,
10100,
198,
220,
5772,
62,
14933,
3712,
38469,
90,
10100,
92,
198,
220,
5772,
62,
19199,
3712,
38469,
90,
7378,
6030,
92,
198,
220,
1441,
62,
4906,
3712,
7378,
6030,
198,
220,
10139,
3712,
38176,
90,
7004,
81,
28399,
11,
18465,
92,
198,
437,
198,
198,
76,
18187,
2878,
14691,
21947,
198,
220,
8354,
62,
25558,
3712,
25896,
90,
43094,
10962,
30150,
92,
198,
220,
8354,
3712,
5317,
198,
220,
850,
81,
448,
1127,
3712,
38469,
90,
7004,
81,
28399,
30150,
92,
198,
220,
287,
62,
13345,
3712,
25896,
90,
14134,
92,
198,
220,
3748,
62,
66,
5691,
3712,
38469,
90,
14134,
92,
198,
220,
477,
62,
7785,
62,
14933,
62,
392,
62,
19199,
3712,
38469,
90,
51,
29291,
90,
10100,
11,
7378,
6030,
11709,
198,
220,
1401,
62,
312,
62,
24588,
3712,
5317,
198,
437,
198,
32750,
21947,
3419,
796,
14691,
21947,
7,
198,
220,
220,
220,
220,
220,
23881,
90,
43094,
10962,
30150,
92,
22784,
198,
220,
220,
220,
220,
220,
4238,
62,
29982,
62,
5715,
11,
198,
220,
220,
220,
220,
220,
20650,
90,
7004,
81,
28399,
30150,
92,
22784,
198,
220,
220,
220,
220,
220,
23881,
90,
14134,
92,
22784,
198,
220,
220,
220,
220,
220,
20650,
90,
14134,
92,
22784,
198,
220,
220,
220,
220,
220,
20650,
90,
51,
29291,
90,
10100,
11,
7378,
6030,
11709,
22784,
198,
220,
220,
220,
220,
220,
657,
198,
220,
220,
220,
220,
220,
1267,
198,
198,
8818,
2251,
62,
7785,
62,
312,
7,
330,
3712,
32750,
21947,
11,
1401,
62,
4906,
3712,
7378,
6030,
11,
1401,
62,
3672,
3712,
10100,
8,
198,
220,
3753,
796,
936,
13,
7785,
62,
312,
62,
24588,
198,
220,
936,
13,
7785,
62,
312,
62,
24588,
15853,
352,
198,
220,
1441,
36521,
62,
3,
7,
7785,
62,
4906,
8,
62,
3,
7,
7785,
62,
3672,
8,
62,
3,
7,
24588,
16725,
198,
437,
198,
198,
8818,
468,
45286,
7,
82,
3712,
32750,
21947,
11,
1401,
62,
3672,
3712,
10100,
11,
8434,
62,
29982,
62,
8807,
3712,
33,
970,
28,
9562,
8,
198,
220,
611,
16959,
198,
220,
220,
220,
1674,
620,
7,
35235,
11,
264,
13,
29982,
62,
25558,
8,
198,
220,
886,
198,
220,
611,
318,
28920,
7,
82,
13,
29982,
62,
25558,
8,
1441,
3991,
886,
198,
220,
611,
8434,
62,
29982,
62,
8807,
198,
220,
220,
220,
8354,
796,
264,
13,
29982,
198,
220,
220,
220,
1441,
597,
7,
13000,
3784,
13000,
13,
29982,
62,
5715,
6624,
8354,
11405,
5726,
13,
7785,
62,
3672,
6624,
1401,
62,
3672,
11,
264,
13,
29982,
62,
25558,
8,
198,
220,
886,
198,
220,
1441,
597,
7,
13000,
3784,
13000,
13,
7785,
62,
3672,
6624,
1401,
62,
3672,
11,
264,
13,
29982,
62,
25558,
8,
198,
437,
198,
198,
8818,
651,
45286,
7,
82,
3712,
32750,
21947,
11,
1401,
62,
3672,
8,
198,
220,
1441,
651,
11085,
7,
13000,
4613,
5726,
13,
7785,
62,
3672,
6624,
1401,
62,
3672,
11,
264,
13,
29982,
62,
25558,
8,
198,
437,
198,
198,
8818,
1461,
29982,
0,
7,
82,
3712,
32750,
21947,
8,
198,
220,
318,
28920,
7,
82,
13,
29982,
62,
25558,
8,
11405,
1441,
198,
220,
264,
13,
29982,
48185,
352,
198,
220,
981,
5145,
271,
28920,
7,
82,
13,
29982,
62,
25558,
8,
11405,
357,
11085,
7,
82,
13,
29982,
62,
25558,
737,
29982,
62,
5715,
1875,
264,
13,
29982,
8,
198,
220,
220,
220,
1461,
0,
7,
82,
13,
29982,
62,
25558,
8,
198,
220,
886,
198,
437,
198,
198,
8818,
14170,
66,
3008,
0,
7,
82,
3712,
32750,
21947,
8,
198,
220,
264,
13,
29982,
15853,
352,
220,
220,
198,
437,
198,
198,
8818,
4574,
7785,
0,
7,
330,
3712,
32750,
21947,
11,
1401,
62,
3672,
3712,
10100,
11,
1401,
62,
4906,
3712,
7378,
6030,
11,
1188,
62,
738,
7483,
3712,
10100,
11,
318,
62,
23928,
3628,
3712,
33,
970,
28,
9562,
8,
198,
220,
5726,
796,
15845,
10962,
30150,
7,
7785,
62,
3672,
11,
1401,
62,
4906,
11,
1188,
62,
738,
7483,
11,
936,
13,
29982,
11,
318,
62,
23928,
3628,
8,
198,
220,
4574,
0,
7,
330,
13,
29982,
62,
25558,
11,
5726,
8,
198,
437,
198,
198,
8818,
4574,
7266,
81,
28399,
0,
7,
330,
3712,
32750,
21947,
11,
198,
220,
220,
220,
1438,
3712,
10100,
11,
198,
220,
220,
220,
5772,
62,
14933,
3712,
38469,
90,
10100,
5512,
198,
220,
220,
220,
5772,
62,
19199,
3712,
38469,
90,
7378,
6030,
5512,
198,
220,
220,
220,
1441,
62,
4906,
3712,
7378,
6030,
11,
198,
220,
220,
220,
10139,
3712,
38176,
90,
7004,
81,
28399,
11,
18465,
30072,
198,
220,
5726,
796,
3834,
81,
28399,
30150,
7,
3672,
11,
5772,
62,
14933,
11,
5772,
62,
19199,
11,
1441,
62,
4906,
11,
10139,
8,
198,
220,
4574,
0,
7,
330,
13,
7266,
81,
448,
1127,
11,
5726,
8,
198,
437,
198,
198,
8818,
468,
7266,
81,
28399,
7,
330,
3712,
32750,
21947,
11,
1438,
3712,
10100,
8,
198,
220,
1441,
597,
7,
13000,
3784,
13000,
13,
3672,
6624,
1438,
11,
936,
13,
7266,
81,
448,
1127,
8,
198,
437,
198,
198,
8818,
3011,
549,
81,
28399,
7,
82,
3808,
3712,
38469,
90,
7004,
81,
28399,
30150,
5512,
1438,
3712,
10100,
8,
198,
220,
6376,
796,
1064,
11085,
7,
27891,
3784,
27891,
13,
3672,
6624,
1438,
11,
264,
3808,
8,
198,
220,
1441,
264,
3808,
58,
9630,
60,
198,
437,
198,
198,
8818,
3011,
549,
81,
28399,
7,
330,
3712,
32750,
21947,
11,
1438,
3712,
10100,
8,
198,
220,
3011,
549,
81,
28399,
7,
330,
13,
7266,
81,
448,
1127,
11,
1438,
8,
198,
437,
198,
198,
2,
383,
5726,
966,
329,
262,
9037,
4284,
9107,
13,
198,
8818,
9037,
62,
20930,
7,
11262,
3712,
15167,
11,
936,
3712,
32750,
21947,
8,
198,
220,
220,
198,
220,
1303,
23691,
4277,
3815,
329,
477,
1401,
11,
2099,
17790,
973,
287,
1430,
198,
220,
4574,
62,
12286,
82,
0,
7,
330,
8,
628,
220,
1303,
10854,
17336,
198,
220,
9037,
62,
20930,
7,
11262,
13,
4299,
50101,
11,
936,
8,
198,
220,
220,
198,
220,
1303,
10854,
1388,
2512,
198,
220,
9037,
62,
20930,
7,
11262,
13,
12417,
11,
936,
8,
198,
437,
198,
198,
8818,
4574,
62,
12286,
82,
0,
7,
330,
3712,
32750,
21947,
8,
198,
220,
329,
357,
3672,
11,
285,
457,
2981,
8,
287,
936,
13,
439,
62,
7785,
62,
14933,
62,
392,
62,
19199,
198,
220,
220,
220,
611,
285,
457,
2981,
18872,
230,
16578,
283,
62,
19199,
198,
220,
220,
220,
220,
220,
1006,
62,
4906,
796,
16578,
283,
62,
1462,
62,
5420,
62,
4906,
58,
76,
457,
2981,
60,
198,
220,
220,
220,
220,
220,
4574,
7785,
0,
7,
330,
11,
1438,
11,
1006,
62,
4906,
11,
44212,
12286,
62,
3,
7,
76,
457,
2981,
8,
4943,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
14170,
66,
3008,
0,
7,
330,
8,
198,
437,
198,
198,
12708,
62,
20930,
7,
11262,
3712,
15167,
8,
796,
9037,
62,
20930,
7,
11262,
11,
14691,
21947,
28955,
198,
198,
8818,
9037,
62,
20930,
7,
67,
3712,
7469,
50101,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
17336,
4943,
198,
220,
611,
5145,
439,
34642,
26933,
4299,
13,
3672,
329,
825,
287,
288,
13,
4299,
82,
12962,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
3237,
5499,
290,
850,
81,
448,
1127,
1276,
423,
3748,
3891,
13,
3827,
25138,
318,
407,
3142,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
329,
850,
81,
28399,
3712,
7004,
81,
28399,
287,
288,
13,
4299,
82,
198,
220,
220,
220,
651,
62,
12683,
1300,
7,
7266,
81,
28399,
11,
936,
8,
198,
220,
886,
198,
437,
628,
198,
8818,
651,
62,
12683,
1300,
7,
82,
3712,
7004,
81,
28399,
11,
936,
3712,
32750,
21947,
8,
198,
220,
1674,
620,
7,
17143,
3712,
36301,
3784,
12708,
62,
20930,
7,
17143,
11,
936,
828,
264,
13,
37266,
8,
198,
220,
2081,
62,
19199,
796,
20650,
90,
7378,
6030,
92,
26933,
17143,
2357,
62,
1462,
62,
76,
457,
2981,
7,
17143,
8,
329,
5772,
287,
264,
13,
37266,
12962,
198,
220,
5772,
62,
14933,
796,
20650,
90,
10100,
92,
26933,
17143,
13,
3672,
329,
5772,
287,
264,
13,
37266,
12962,
198,
220,
9037,
62,
20930,
7,
82,
13,
1186,
62,
4906,
11,
936,
8,
198,
220,
611,
5145,
9160,
7,
82,
13,
1186,
62,
4906,
13,
7857,
11,
1846,
13857,
5317,
8,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
26687,
3858,
357,
37336,
290,
26515,
8,
389,
407,
3142,
355,
2163,
1441,
3858,
357,
1370,
29568,
82,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
4574,
7266,
81,
28399,
0,
7,
330,
11,
198,
220,
220,
220,
264,
13,
3672,
11,
198,
220,
220,
220,
5772,
62,
14933,
11,
198,
220,
220,
220,
2081,
62,
19199,
11,
198,
220,
220,
220,
264,
13,
1186,
62,
4906,
13,
1416,
282,
283,
62,
4906,
11,
198,
220,
220,
220,
264,
198,
220,
1267,
198,
437,
198,
198,
8818,
11507,
62,
1462,
62,
76,
457,
2981,
7,
79,
3712,
36301,
8,
198,
220,
611,
279,
13,
271,
62,
18747,
11405,
279,
13,
271,
62,
7785,
62,
1845,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
19182,
2099,
2314,
307,
973,
355,
1401,
11507,
357,
1370,
29568,
79,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
611,
279,
13,
271,
62,
7785,
62,
1845,
198,
220,
220,
220,
1441,
16578,
283,
62,
1462,
62,
5420,
62,
4906,
58,
79,
13,
1416,
282,
283,
62,
4906,
60,
198,
220,
886,
198,
220,
611,
279,
13,
271,
62,
18747,
198,
220,
220,
220,
1441,
16578,
283,
62,
1462,
62,
18747,
62,
4906,
58,
79,
13,
1416,
282,
283,
62,
4906,
60,
198,
220,
886,
198,
220,
1441,
279,
13,
1416,
282,
283,
62,
4906,
198,
437,
198,
198,
8818,
11507,
62,
1462,
62,
297,
14761,
4906,
7,
79,
3712,
36301,
8,
198,
220,
285,
457,
2981,
62,
1462,
62,
297,
14761,
62,
4906,
58,
17143,
2357,
62,
1462,
62,
76,
457,
2981,
7,
79,
15437,
198,
437,
198,
198,
8818,
2099,
9122,
7,
65,
3712,
33,
3219,
32180,
11,
936,
3712,
32750,
21947,
8,
198,
220,
2099,
9122,
7,
65,
13,
9464,
11,
936,
8,
198,
220,
2099,
9122,
7,
65,
13,
3506,
11,
936,
8,
198,
220,
1005,
62,
4906,
796,
13934,
62,
20274,
62,
19199,
58,
7,
65,
13,
404,
11,
275,
13,
9464,
13,
4906,
11,
275,
13,
3506,
13,
4906,
15437,
198,
220,
611,
1005,
62,
4906,
6624,
337,
12331,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
6030,
46318,
7198,
7,
65,
13,
9464,
13,
4906,
8,
290,
29568,
65,
13,
3506,
13,
4906,
4008,
329,
13934,
4905,
19990,
3,
7,
65,
13,
404,
8,
7879,
319,
1627,
29568,
65,
13,
1370,
21387,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
275,
13,
4906,
796,
1005,
62,
4906,
198,
437,
198,
198,
8818,
2099,
9122,
7,
84,
3712,
3118,
560,
32180,
11,
936,
3712,
32750,
21947,
8,
198,
220,
2099,
9122,
7,
84,
13,
3575,
392,
11,
936,
8,
198,
220,
1005,
62,
4906,
796,
555,
560,
62,
20274,
62,
19199,
58,
7,
84,
13,
404,
11,
334,
13,
3575,
392,
13,
4906,
15437,
198,
220,
611,
1005,
62,
4906,
6624,
337,
12331,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
44651,
2099,
29568,
84,
13,
3575,
392,
13,
4906,
8,
329,
555,
560,
4905,
19990,
3,
7,
84,
13,
404,
8,
7879,
357,
1370,
29568,
84,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
334,
13,
4906,
796,
1005,
62,
4906,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
82,
3712,
7004,
81,
28399,
11,
936,
3712,
32750,
21947,
8,
198,
220,
9037,
62,
20930,
7,
82,
13,
2618,
11,
936,
8,
198,
220,
264,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
66,
3712,
14134,
48682,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
4889,
48682,
4943,
198,
220,
16602,
62,
13345,
7,
66,
11,
936,
8,
198,
220,
269,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
16602,
62,
13345,
7,
66,
3712,
14134,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
16602,
62,
13345,
11,
869,
318,
284,
29568,
66,
13,
738,
7483,
8,
4943,
198,
220,
16959,
11405,
44872,
7203,
23928,
3628,
62,
37266,
389,
29568,
66,
13,
23928,
3628,
62,
37266,
8,
4943,
628,
220,
850,
81,
28399,
62,
13000,
3712,
7004,
81,
28399,
30150,
796,
3011,
549,
81,
28399,
7,
330,
11,
269,
13,
738,
7483,
8,
198,
220,
329,
357,
72,
11,
357,
17143,
62,
4906,
11,
1822,
4008,
287,
27056,
378,
7,
13344,
7,
7266,
81,
28399,
62,
13000,
13,
17143,
62,
19199,
11,
269,
13,
853,
2886,
4008,
198,
220,
220,
220,
611,
5772,
62,
4906,
18872,
230,
1006,
62,
19199,
220,
1303,
25139,
2357,
318,
257,
1401,
11507,
198,
220,
220,
220,
220,
220,
269,
13,
853,
2886,
58,
72,
60,
796,
3497,
8134,
7,
66,
13,
853,
2886,
58,
72,
4357,
269,
13,
1370,
8,
198,
220,
220,
220,
886,
198,
220,
886,
628,
220,
4889,
41384,
198,
220,
220,
198,
220,
1674,
620,
7,
853,
3784,
4906,
9122,
7,
853,
11,
936,
828,
269,
13,
853,
2886,
8,
198,
220,
8996,
62,
4480,
62,
12683,
1300,
7,
7266,
81,
28399,
62,
13000,
11,
269,
13,
853,
2886,
11,
269,
13,
1370,
8,
198,
220,
220,
198,
220,
269,
13,
7266,
81,
28399,
796,
850,
81,
28399,
62,
13000,
13,
17440,
3712,
7004,
81,
28399,
198,
220,
269,
13,
7266,
81,
28399,
13,
271,
62,
7174,
796,
2081,
628,
220,
477,
62,
7785,
62,
14933,
796,
20650,
90,
10100,
92,
7,
34642,
26933,
3672,
329,
357,
3672,
11,
2099,
8,
287,
936,
13,
439,
62,
7785,
62,
14933,
62,
392,
62,
19199,
60,
4008,
628,
220,
269,
13,
23928,
3628,
62,
37266,
796,
685,
1136,
45286,
7,
330,
11,
279,
8,
329,
279,
287,
477,
62,
7785,
62,
14933,
60,
628,
220,
850,
81,
448,
1127,
62,
259,
62,
13345,
796,
685,
13345,
13,
738,
7483,
329,
869,
287,
936,
13,
259,
62,
13345,
60,
198,
220,
611,
850,
81,
28399,
62,
13000,
13,
3672,
18872,
230,
850,
81,
448,
1127,
62,
259,
62,
13345,
198,
220,
220,
220,
1441,
198,
220,
886,
628,
220,
32660,
14761,
62,
8818,
62,
3672,
796,
651,
62,
297,
14761,
62,
8818,
62,
3672,
7,
7266,
81,
28399,
62,
13000,
13,
3672,
11,
269,
13,
13345,
62,
312,
8,
198,
220,
269,
13,
7266,
81,
28399,
13,
297,
14761,
62,
8818,
62,
3672,
796,
32660,
14761,
62,
8818,
62,
3672,
198,
220,
14170,
66,
3008,
0,
7,
330,
8,
198,
220,
269,
13,
29982,
62,
5715,
796,
936,
13,
29982,
198,
220,
4574,
0,
7,
330,
13,
259,
62,
13345,
11,
269,
8,
198,
220,
329,
1401,
62,
13000,
3712,
43094,
10962,
30150,
287,
269,
13,
23928,
3628,
62,
37266,
198,
220,
220,
220,
5772,
62,
3672,
796,
1401,
62,
13000,
13,
7785,
62,
3672,
198,
220,
220,
220,
5772,
62,
4906,
796,
1401,
62,
13000,
13,
7785,
62,
4906,
198,
220,
220,
220,
1438,
62,
292,
62,
23928,
3628,
796,
651,
62,
23928,
3628,
62,
17143,
62,
312,
7,
17143,
62,
3672,
11,
5772,
62,
4906,
8,
198,
220,
220,
220,
1006,
62,
4906,
796,
5772,
62,
4906,
18872,
230,
1006,
62,
19199,
5633,
5772,
62,
4906,
1058,
16578,
283,
62,
1462,
62,
5420,
62,
4906,
58,
17143,
62,
4906,
60,
198,
220,
220,
220,
4574,
7785,
0,
7,
330,
11,
5772,
62,
3672,
11,
1006,
62,
4906,
11,
36521,
3,
7,
3672,
62,
292,
62,
23928,
3628,
42501,
2081,
8,
198,
220,
886,
198,
220,
329,
357,
17143,
62,
3672,
11,
1822,
8,
287,
19974,
7,
7266,
81,
28399,
62,
13000,
13,
17143,
62,
14933,
11,
269,
13,
853,
2886,
8,
198,
220,
220,
220,
2099,
796,
1822,
318,
64,
3497,
8134,
5633,
1822,
13,
4906,
1058,
1006,
62,
4906,
62,
1462,
62,
1416,
282,
283,
62,
4906,
58,
853,
13,
4906,
60,
198,
220,
220,
220,
4574,
7785,
0,
7,
330,
11,
5772,
62,
3672,
11,
1822,
13,
4906,
11,
36521,
3,
7,
17143,
62,
3672,
8,
4943,
198,
220,
886,
198,
220,
9037,
62,
20930,
7,
66,
13,
7266,
81,
28399,
11,
936,
8,
198,
220,
1461,
0,
7,
330,
13,
259,
62,
13345,
8,
198,
220,
1461,
29982,
0,
7,
330,
8,
198,
437,
198,
198,
8818,
651,
62,
23928,
3628,
62,
17143,
62,
312,
7,
3672,
3712,
10100,
11,
285,
457,
2981,
3712,
7378,
6030,
8,
198,
220,
366,
23928,
3628,
48082,
7,
5420,
62,
4906,
62,
1462,
62,
1416,
282,
283,
62,
4906,
58,
76,
457,
2981,
35944,
3,
7,
3672,
16725,
198,
437,
198,
198,
8818,
8996,
62,
4480,
62,
12683,
1300,
7,
27891,
3712,
7004,
81,
28399,
30150,
11,
26498,
3712,
38469,
90,
11395,
5512,
1627,
3712,
5317,
8,
198,
220,
611,
4129,
7,
27891,
13,
17143,
62,
19199,
8,
14512,
4129,
7,
22046,
8,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
7004,
81,
28399,
869,
468,
29568,
13664,
7,
22046,
4008,
7159,
11,
2938,
29568,
13664,
7,
27891,
13,
17143,
62,
19199,
4008,
357,
1370,
720,
1370,
21387,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
329,
357,
17143,
62,
4906,
11,
1822,
8,
287,
19974,
7,
27891,
13,
17143,
62,
19199,
11,
26498,
8,
198,
220,
220,
220,
611,
1822,
13,
4906,
14512,
5772,
62,
4906,
198,
220,
220,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
220,
220,
366,
3109,
7254,
4578,
286,
2099,
720,
17143,
62,
4906,
11,
1392,
29568,
853,
13,
4906,
8,
357,
1370,
720,
1370,
21387,
198,
220,
220,
220,
15306,
198,
220,
220,
220,
886,
198,
220,
886,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
81,
3712,
13615,
11,
936,
3712,
32750,
21947,
8,
198,
220,
1459,
62,
7266,
81,
28399,
3712,
7004,
81,
28399,
796,
717,
7,
330,
13,
259,
62,
13345,
737,
7266,
81,
28399,
198,
220,
2099,
9122,
7,
81,
13,
8367,
11,
936,
8,
198,
220,
611,
374,
13,
8367,
13,
4906,
14512,
1459,
62,
7266,
81,
28399,
13,
1186,
62,
4906,
13,
7942,
62,
4906,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
3109,
7254,
1441,
2099,
284,
307,
29568,
14421,
62,
7266,
81,
28399,
13,
1186,
62,
4906,
13,
7942,
62,
4906,
828,
1392,
29568,
81,
13,
8367,
13,
4906,
8,
357,
1370,
29568,
81,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
374,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
79,
3712,
36301,
11,
936,
3712,
32750,
21947,
8,
198,
220,
2099,
9122,
7,
79,
13,
7857,
11,
936,
8,
198,
220,
611,
279,
13,
7857,
13,
4906,
14512,
337,
5317,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
19182,
2546,
1276,
423,
18253,
1988,
11,
1392,
29568,
79,
13,
7857,
13,
4906,
8,
357,
1370,
29568,
79,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
279,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
65,
3712,
12235,
11,
936,
3712,
32750,
21947,
11,
691,
62,
33327,
28,
9562,
8,
198,
220,
611,
5145,
65,
13,
271,
62,
7266,
81,
28399,
62,
9967,
14170,
66,
3008,
0,
7,
330,
8,
886,
198,
220,
329,
336,
16762,
287,
275,
13,
14269,
3196,
198,
220,
220,
220,
611,
5145,
8807,
62,
33327,
198,
220,
220,
220,
220,
220,
9037,
62,
20930,
7,
301,
16762,
11,
936,
8,
198,
220,
220,
220,
2073,
361,
336,
16762,
318,
64,
35748,
41384,
198,
220,
220,
220,
220,
220,
611,
5145,
10134,
45286,
7,
330,
11,
336,
16762,
13,
738,
7483,
11,
2081,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
65,
13,
7266,
81,
28399,
13,
23928,
3628,
62,
37266,
11,
336,
16762,
13,
738,
7483,
8,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
2073,
361,
336,
16762,
318,
64,
4889,
198,
220,
220,
220,
220,
220,
4574,
0,
7,
65,
13,
7266,
81,
28399,
13,
66,
5691,
62,
7266,
81,
448,
1127,
11,
336,
16762,
13,
738,
7483,
8,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
611,
5145,
65,
13,
271,
62,
7266,
81,
28399,
62,
9967,
1461,
29982,
0,
7,
330,
8,
886,
198,
220,
275,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
67,
3712,
37835,
10186,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
24720,
4943,
198,
220,
9037,
62,
20930,
7,
67,
13,
7785,
62,
4906,
11,
936,
8,
198,
220,
1401,
62,
4906,
796,
288,
13,
7785,
62,
4906,
13,
7942,
62,
4906,
198,
220,
329,
1438,
287,
3975,
7,
30001,
3784,
30001,
13,
2588,
34755,
11,
288,
13,
14933,
8,
198,
220,
220,
220,
611,
468,
45286,
7,
330,
11,
1438,
11,
2081,
8,
198,
220,
220,
220,
220,
220,
5726,
796,
651,
45286,
7,
330,
11,
1438,
8,
198,
220,
220,
220,
220,
220,
611,
5145,
13000,
13,
271,
62,
23928,
3628,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
34,
34574,
21459,
565,
533,
7885,
29568,
3672,
8,
357,
1370,
29568,
67,
13,
1370,
4008,
526,
198,
220,
220,
220,
220,
220,
220,
220,
15306,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4686,
796,
2251,
62,
7785,
62,
312,
7,
330,
11,
1401,
62,
4906,
11,
1438,
8,
198,
220,
220,
220,
4574,
0,
7,
67,
13,
34642,
62,
2340,
11,
4686,
8,
198,
220,
220,
220,
4574,
7785,
0,
7,
330,
11,
1438,
11,
16578,
283,
62,
1462,
62,
5420,
62,
4906,
58,
7785,
62,
4906,
4357,
4686,
8,
198,
220,
886,
198,
220,
288,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
66,
3712,
6030,
5189,
19852,
5574,
11395,
11,
936,
3712,
32750,
21947,
8,
198,
220,
2099,
9122,
7,
66,
13,
7857,
11,
936,
8,
198,
220,
611,
269,
13,
7857,
13,
4906,
14512,
337,
5317,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
19182,
2546,
1276,
423,
18253,
2099,
357,
1370,
29568,
66,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
269,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
64,
3712,
8021,
16747,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
50144,
4943,
198,
220,
1401,
62,
3672,
796,
257,
13,
45286,
62,
3672,
198,
220,
611,
5145,
10134,
45286,
7,
330,
11,
1401,
62,
3672,
8,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
34,
34574,
8333,
284,
44192,
565,
1144,
7885,
705,
3,
7,
7785,
62,
3672,
33047,
357,
1370,
29568,
64,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
6376,
62,
4906,
796,
2099,
9122,
7,
64,
13,
18747,
62,
9630,
11,
936,
8,
198,
220,
611,
6376,
62,
4906,
14512,
337,
5317,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
19182,
6376,
1276,
307,
281,
18253,
11,
1392,
29568,
9630,
62,
4906,
8,
357,
1370,
29568,
64,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
1988,
62,
4906,
796,
2099,
9122,
7,
64,
13,
8367,
11,
936,
8,
198,
220,
5726,
3712,
43094,
10962,
30150,
796,
651,
45286,
7,
330,
11,
1401,
62,
3672,
8,
198,
220,
1401,
62,
4906,
796,
5726,
13,
7785,
62,
4906,
198,
220,
257,
13,
7785,
62,
4906,
796,
1401,
62,
4906,
198,
220,
611,
1401,
62,
4906,
18872,
230,
1006,
62,
19199,
198,
220,
220,
220,
1401,
62,
4906,
796,
1006,
62,
4906,
62,
1462,
62,
1416,
282,
283,
62,
4906,
58,
7785,
62,
4906,
60,
198,
220,
2073,
361,
1401,
62,
4906,
18872,
230,
16578,
283,
62,
19199,
198,
220,
220,
220,
5726,
13,
2100,
62,
738,
7483,
796,
2251,
62,
7785,
62,
312,
7,
330,
11,
1401,
62,
4906,
11,
1401,
62,
3672,
8,
198,
220,
886,
198,
220,
611,
1988,
62,
4906,
14512,
1401,
62,
4906,
198,
220,
220,
220,
611,
5145,
7,
64,
13,
271,
62,
18747,
62,
15526,
11405,
16578,
283,
62,
1462,
62,
18747,
62,
4906,
58,
8367,
62,
4906,
60,
6624,
1401,
62,
4906,
8,
198,
220,
220,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
220,
220,
366,
34,
34574,
8333,
257,
1988,
286,
2099,
29568,
8367,
62,
4906,
8,
284,
7885,
705,
3,
7,
7785,
62,
3672,
33047,
286,
2099,
29568,
7785,
62,
4906,
8,
357,
1370,
29568,
64,
13,
1370,
4008,
526,
198,
220,
220,
220,
220,
220,
15306,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
257,
13,
7785,
62,
34642,
62,
312,
796,
5726,
13,
2100,
62,
738,
7483,
198,
220,
257,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
72,
3712,
1532,
6423,
40674,
11,
936,
3712,
32750,
21947,
8,
198,
220,
1779,
62,
4906,
796,
2099,
9122,
7,
72,
13,
31448,
11,
936,
8,
198,
220,
611,
1779,
62,
4906,
14512,
10771,
970,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
366,
1532,
2643,
4006,
1276,
307,
25131,
11,
1392,
2099,
720,
17561,
62,
4906,
357,
1370,
29568,
72,
13,
1370,
4008,
526,
4008,
198,
220,
886,
198,
220,
9037,
62,
20930,
7,
72,
13,
8524,
62,
301,
16762,
11,
936,
8,
198,
220,
9037,
62,
20930,
7,
72,
13,
17772,
62,
301,
16762,
11,
936,
8,
198,
220,
1312,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
72,
3712,
1532,
6423,
11,
936,
3712,
32750,
21947,
8,
198,
220,
1779,
62,
4906,
796,
2099,
9122,
7,
72,
13,
31448,
11,
936,
8,
198,
220,
611,
1779,
62,
4906,
14512,
10771,
970,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
366,
1532,
2643,
4006,
1276,
307,
25131,
11,
1392,
2099,
720,
17561,
62,
4906,
357,
1370,
29568,
72,
13,
1370,
4008,
526,
4008,
198,
220,
886,
198,
220,
9037,
62,
20930,
7,
72,
13,
8524,
62,
301,
16762,
11,
936,
8,
198,
220,
1312,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
86,
3712,
3633,
11,
936,
3712,
32750,
21947,
8,
198,
220,
1779,
62,
4906,
796,
2099,
9122,
7,
86,
13,
31448,
11,
936,
8,
198,
220,
611,
1779,
62,
4906,
14512,
10771,
970,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
366,
3633,
2643,
4006,
1276,
307,
25131,
11,
1392,
2099,
720,
17561,
62,
4906,
357,
1370,
29568,
86,
13,
1370,
4008,
526,
4008,
198,
220,
886,
198,
220,
9037,
62,
20930,
7,
86,
13,
4598,
62,
301,
16762,
11,
936,
8,
198,
220,
266,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
81,
3712,
5569,
11,
936,
3712,
32750,
21947,
8,
198,
220,
329,
1401,
3712,
43015,
287,
374,
13,
25641,
2977,
198,
220,
220,
220,
9037,
62,
20930,
7,
7785,
11,
936,
8,
198,
220,
220,
220,
611,
5145,
10134,
45286,
7,
330,
11,
1401,
13,
738,
7483,
8,
198,
220,
220,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
220,
220,
366,
51,
14992,
284,
1100,
284,
44192,
565,
1144,
7885,
29568,
7785,
13,
738,
7483,
8,
357,
1370,
29568,
81,
13,
1370,
4008,
526,
198,
220,
220,
220,
220,
220,
15306,
198,
220,
220,
220,
886,
198,
220,
220,
220,
5726,
3712,
43094,
10962,
30150,
796,
651,
45286,
7,
330,
11,
1401,
13,
738,
7483,
8,
198,
220,
220,
220,
4574,
0,
7,
81,
13,
7785,
62,
19199,
11,
5726,
13,
7785,
62,
4906,
8,
198,
220,
220,
220,
611,
5726,
13,
7785,
62,
4906,
18872,
231,
16578,
283,
62,
19199,
198,
220,
220,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
220,
220,
366,
10049,
16578,
283,
7885,
3858,
460,
307,
1100,
357,
1370,
29568,
81,
13,
1370,
4008,
526,
198,
220,
220,
220,
220,
220,
15306,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
374,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
79,
3712,
16594,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
19430,
4943,
198,
220,
9037,
62,
20930,
7,
79,
13,
853,
2886,
11,
936,
8,
198,
220,
279,
13,
4906,
796,
4904,
21390,
198,
437,
198,
198,
8818,
9037,
62,
20930,
7,
64,
3712,
38469,
90,
11395,
5512,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
7159,
4943,
198,
220,
329,
1822,
287,
257,
198,
220,
220,
220,
2099,
9122,
7,
853,
11,
936,
8,
198,
220,
886,
198,
437,
198,
198,
8818,
2099,
9122,
7,
72,
3712,
3546,
13857,
5317,
11,
936,
8,
198,
220,
1312,
13,
4906,
796,
337,
5317,
198,
437,
198,
198,
8818,
2099,
9122,
7,
72,
3712,
3546,
13857,
15633,
11,
936,
8,
198,
220,
1312,
13,
4906,
796,
337,
15633,
198,
437,
198,
198,
8818,
2099,
9122,
7,
72,
3712,
3546,
13857,
10100,
11,
936,
8,
198,
220,
1312,
13,
4906,
796,
337,
10100,
198,
437,
198,
198,
8818,
2099,
9122,
7,
72,
3712,
3546,
13857,
33,
970,
11,
936,
8,
198,
220,
1312,
13,
4906,
796,
10771,
970,
198,
437,
198,
198,
8818,
2099,
9122,
7,
70,
3712,
3855,
8134,
11,
936,
8,
198,
220,
308,
13,
4906,
796,
16578,
283,
62,
1462,
62,
5420,
62,
4906,
58,
4906,
9122,
7,
70,
13,
3575,
392,
11,
936,
15437,
198,
437,
628,
198,
8818,
2099,
9122,
7,
75,
3712,
43,
270,
1691,
41384,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
25659,
1691,
41384,
4943,
198,
220,
1398,
796,
300,
13,
30001,
13,
4871,
198,
220,
611,
1398,
6624,
493,
62,
18250,
1691,
198,
220,
220,
220,
300,
13,
4906,
796,
337,
5317,
198,
220,
886,
198,
220,
611,
1398,
6624,
1103,
62,
18250,
1691,
198,
220,
220,
220,
300,
13,
4906,
796,
337,
15633,
198,
220,
886,
198,
220,
611,
1398,
18872,
230,
685,
46265,
62,
7942,
11,
479,
86,
62,
9562,
60,
220,
198,
220,
220,
220,
300,
13,
4906,
796,
10771,
970,
198,
220,
886,
198,
220,
611,
1398,
6624,
4731,
62,
18250,
1691,
198,
220,
220,
220,
300,
13,
4906,
796,
337,
10100,
198,
220,
886,
198,
220,
1441,
300,
13,
4906,
198,
437,
198,
198,
8818,
2099,
9122,
7,
85,
3712,
43015,
41384,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
35748,
41384,
4943,
198,
220,
16959,
11405,
44872,
7203,
259,
62,
13345,
6565,
30,
29568,
271,
28920,
7,
330,
13,
259,
62,
13345,
4008,
4943,
198,
220,
1401,
62,
3672,
796,
410,
13,
738,
7483,
198,
220,
611,
5145,
10134,
45286,
7,
330,
11,
1401,
62,
3672,
8,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
43015,
29568,
7785,
62,
3672,
8,
318,
407,
5447,
357,
1370,
29568,
85,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
1401,
62,
13000,
3712,
43094,
10962,
30150,
796,
651,
45286,
7,
330,
11,
1401,
62,
3672,
8,
198,
220,
410,
13,
45286,
62,
13000,
796,
1401,
62,
13000,
198,
220,
1401,
62,
4906,
796,
1401,
62,
13000,
13,
7785,
62,
4906,
198,
220,
611,
1401,
62,
4906,
18872,
230,
1006,
62,
19199,
198,
220,
220,
220,
1401,
62,
4906,
796,
1006,
62,
4906,
62,
1462,
62,
1416,
282,
283,
62,
4906,
58,
7785,
62,
4906,
60,
198,
220,
886,
198,
220,
410,
13,
4906,
796,
1401,
62,
4906,
198,
437,
198,
198,
8818,
2099,
9122,
7,
64,
3712,
19182,
15457,
41384,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
15690,
15457,
41384,
4943,
198,
220,
6376,
62,
4906,
796,
2099,
9122,
7,
64,
13,
9630,
11,
936,
8,
198,
220,
611,
6376,
62,
4906,
14512,
337,
5317,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
19182,
6376,
815,
307,
281,
18253,
11,
1392,
2099,
29568,
9630,
62,
4906,
8,
357,
1370,
29568,
64,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
1401,
62,
3672,
796,
257,
13,
738,
7483,
198,
220,
611,
5145,
10134,
45286,
7,
330,
11,
1401,
62,
3672,
8,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
43015,
29568,
7785,
62,
3672,
8,
318,
407,
5447,
357,
1370,
29568,
64,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
1401,
62,
13000,
3712,
43094,
10962,
30150,
796,
651,
45286,
7,
330,
11,
1401,
62,
3672,
8,
198,
220,
257,
13,
45286,
62,
13000,
796,
1401,
62,
13000,
198,
220,
1401,
62,
4906,
796,
1401,
62,
13000,
13,
7785,
62,
4906,
198,
220,
611,
1401,
62,
4906,
18872,
231,
7177,
62,
19199,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
34,
34574,
6376,
656,
1729,
12,
18747,
2099,
7198,
7785,
62,
4906,
8,
7885,
705,
3,
7785,
62,
3672,
6,
357,
1370,
29568,
64,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
257,
13,
4906,
796,
7177,
62,
4906,
62,
1462,
62,
1416,
282,
283,
62,
4906,
58,
7785,
62,
4906,
60,
198,
437,
198,
198,
8818,
2099,
9122,
7,
66,
3712,
14134,
41384,
11,
936,
3712,
32750,
21947,
8,
198,
220,
16959,
11405,
44872,
7203,
1212,
318,
9037,
3781,
11,
11090,
278,
4889,
41384,
4943,
198,
220,
16602,
62,
13345,
7,
66,
11,
936,
8,
198,
220,
850,
81,
28399,
62,
13000,
3712,
7004,
81,
28399,
30150,
796,
3011,
549,
81,
28399,
7,
330,
11,
269,
13,
738,
7483,
8,
198,
220,
1005,
62,
4906,
796,
850,
81,
28399,
62,
13000,
13,
7783,
62,
4906,
198,
220,
611,
1005,
62,
4906,
6624,
337,
18465,
198,
220,
220,
220,
1438,
796,
850,
81,
28399,
62,
13000,
13,
3672,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
32,
869,
284,
850,
81,
28399,
705,
3,
3672,
6,
2314,
307,
973,
355,
257,
1988,
355,
340,
468,
645,
1441,
2099,
357,
1370,
29568,
66,
13,
1370,
4008,
526,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
269,
13,
4906,
796,
1005,
62,
4906,
198,
437,
198,
198,
8818,
2099,
9122,
7,
79,
3712,
47,
5757,
41384,
11,
936,
3712,
32750,
21947,
8,
198,
220,
279,
13,
4906,
796,
2099,
9122,
7,
79,
13,
38011,
11,
936,
8,
198,
437,
198,
198,
8818,
2099,
9122,
7,
77,
3712,
3673,
41384,
11,
936,
3712,
32750,
21947,
8,
198,
220,
1822,
62,
4906,
796,
2099,
9122,
7,
77,
13,
49140,
11,
936,
8,
198,
220,
611,
1822,
62,
4906,
14512,
10771,
970,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
464,
19990,
1662,
7879,
4905,
4433,
257,
25131,
4578,
11,
1392,
2099,
29568,
853,
62,
4906,
8,
319,
1627,
29568,
77,
13,
1370,
21387,
198,
220,
220,
220,
15306,
198,
220,
886,
198,
220,
299,
13,
4906,
796,
10771,
970,
198,
437,
198,
198,
2,
2163,
2099,
9122,
7,
83,
3712,
40596,
11,
936,
3712,
32750,
21947,
8,
198,
2,
220,
220,
5766,
62,
19199,
796,
685,
4906,
9122,
7,
83,
489,
58,
16,
4357,
936,
8,
329,
256,
489,
287,
256,
13,
22584,
669,
60,
198,
2,
220,
220,
717,
62,
4906,
796,
5766,
62,
19199,
58,
16,
60,
198,
2,
220,
220,
329,
256,
489,
287,
256,
13,
22584,
669,
198,
2,
220,
220,
220,
220,
611,
256,
489,
58,
16,
4083,
4906,
14512,
717,
62,
4906,
198,
2,
220,
220,
220,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
366,
6030,
46318,
287,
4905,
29568,
83,
489,
58,
17,
4083,
4871,
8,
319,
1627,
29568,
83,
489,
58,
16,
4083,
1370,
21387,
198,
2,
220,
220,
220,
220,
220,
220,
15306,
198,
2,
220,
220,
220,
220,
886,
198,
2,
220,
220,
886,
198,
2,
220,
220,
256,
13,
4906,
796,
717,
62,
4906,
198,
2,
220,
220,
1441,
256,
13,
4906,
198,
2,
886,
198,
198,
8818,
2099,
9122,
7,
82,
3712,
10699,
41384,
11,
936,
3712,
32750,
21947,
8,
198,
220,
2099,
796,
2099,
9122,
7,
82,
13,
18747,
11,
936,
8,
198,
220,
611,
2099,
18872,
231,
685,
44,
5317,
19182,
11,
337,
15633,
19182,
11,
10771,
970,
19182,
11,
337,
10100,
19182,
60,
198,
220,
220,
220,
3714,
7,
45442,
32750,
16922,
7,
198,
220,
220,
220,
220,
220,
366,
19182,
2546,
318,
407,
5447,
329,
3815,
286,
2099,
29568,
4906,
8,
357,
261,
1627,
29568,
82,
13,
1370,
4008,
526,
4008,
198,
220,
886,
198,
220,
264,
13,
4906,
796,
337,
5317,
198,
437,
198,
198,
8818,
651,
62,
297,
14761,
62,
8818,
62,
3672,
7,
7266,
81,
28399,
62,
3672,
3712,
10100,
11,
869,
62,
312,
3712,
5317,
8,
198,
220,
1441,
44212,
3,
7,
7266,
81,
28399,
62,
3672,
737,
3,
7,
13345,
62,
312,
16725,
198,
437,
198
] | 2.61983 | 7,423 |
<filename>examples/development/differentiable_cone_program.jl
using LinearAlgebra, ForwardDiff
using Convex, SCS, ECOS
n = 3
m = 3
k = n + m + 1
c = zeros(n)
A = Diagonal(ones(n))
b = zeros(n)
"Convex.jl"
x = Variable(n)
prob = minimize(c' * x)
prob.constraints += norm(b - A * x) <= 0.0
@time solve!(prob, ECOS.Optimizer)
@show prob.status
@show x.value
@show prob.constraints[1].dual
prob.optval
Q = Array([zeros(n, n) A' c;
-A zeros(m, m) b;
-c' -b' 0.0])
Q_vec = vec(Q)
function F(z, Q_vec)
ũ = z[1:k]
u = z[k .+ (1:k)]
v = z[2 * k .+ (1:k)]
[(I + reshape(Q_vec, k, k)) * ũ - (u + v);
u - P_soc(ũ - v);
ũ - u]
end
z = rand(3k)
F(z, Q_vec)
Fz(x) = F(x, Q_vec)
FQ(x) = F(z, x)
Jz = ForwardDiff.jacobian(Fz, z)
JQ = ForwardDiff.jacobian(FQ, Q_vec)
norm((Jz' * Jz) \ (Jz' * JQ), Inf)
| [
27,
34345,
29,
1069,
12629,
14,
31267,
14,
39799,
3379,
62,
49180,
62,
23065,
13,
20362,
198,
3500,
44800,
2348,
29230,
11,
19530,
28813,
198,
3500,
1482,
303,
87,
11,
6374,
50,
11,
13182,
2640,
198,
198,
77,
796,
513,
198,
76,
796,
513,
198,
74,
796,
299,
1343,
285,
1343,
352,
198,
198,
66,
796,
1976,
27498,
7,
77,
8,
198,
32,
796,
6031,
27923,
7,
1952,
7,
77,
4008,
198,
65,
796,
1976,
27498,
7,
77,
8,
198,
198,
1,
3103,
303,
87,
13,
20362,
1,
198,
87,
796,
35748,
7,
77,
8,
198,
1676,
65,
796,
17775,
7,
66,
6,
1635,
2124,
8,
198,
1676,
65,
13,
1102,
2536,
6003,
15853,
2593,
7,
65,
532,
317,
1635,
2124,
8,
19841,
657,
13,
15,
198,
31,
2435,
8494,
0,
7,
1676,
65,
11,
13182,
2640,
13,
27871,
320,
7509,
8,
198,
198,
31,
12860,
1861,
13,
13376,
198,
31,
12860,
2124,
13,
8367,
198,
31,
12860,
1861,
13,
1102,
2536,
6003,
58,
16,
4083,
646,
282,
198,
1676,
65,
13,
8738,
2100,
198,
198,
48,
796,
15690,
26933,
9107,
418,
7,
77,
11,
299,
8,
317,
6,
269,
26,
198,
220,
220,
220,
220,
532,
32,
1976,
27498,
7,
76,
11,
285,
8,
275,
26,
198,
220,
220,
220,
220,
532,
66,
6,
532,
65,
6,
220,
220,
220,
220,
220,
657,
13,
15,
12962,
198,
48,
62,
35138,
796,
43030,
7,
48,
8,
198,
198,
8818,
376,
7,
89,
11,
1195,
62,
35138,
8,
198,
220,
220,
220,
334,
136,
225,
796,
1976,
58,
16,
25,
74,
60,
198,
220,
220,
220,
334,
796,
1976,
58,
74,
764,
10,
357,
16,
25,
74,
15437,
198,
220,
220,
220,
410,
796,
1976,
58,
17,
1635,
479,
764,
10,
357,
16,
25,
74,
15437,
628,
220,
220,
220,
47527,
40,
1343,
27179,
1758,
7,
48,
62,
35138,
11,
479,
11,
479,
4008,
1635,
334,
136,
225,
532,
357,
84,
1343,
410,
1776,
198,
220,
220,
220,
220,
334,
532,
350,
62,
35634,
7,
84,
136,
225,
532,
410,
1776,
198,
220,
220,
220,
220,
334,
136,
225,
532,
334,
60,
198,
437,
198,
198,
89,
796,
43720,
7,
18,
74,
8,
198,
37,
7,
89,
11,
1195,
62,
35138,
8,
198,
37,
89,
7,
87,
8,
796,
376,
7,
87,
11,
1195,
62,
35138,
8,
198,
37,
48,
7,
87,
8,
796,
376,
7,
89,
11,
2124,
8,
198,
41,
89,
796,
19530,
28813,
13,
30482,
672,
666,
7,
37,
89,
11,
1976,
8,
198,
41,
48,
796,
19530,
28813,
13,
30482,
672,
666,
7,
37,
48,
11,
1195,
62,
35138,
8,
198,
198,
27237,
19510,
41,
89,
6,
1635,
449,
89,
8,
3467,
357,
41,
89,
6,
1635,
449,
48,
828,
4806,
8,
198
] | 1.837719 | 456 |
<filename>src/utils.jl
# lightweight type tree printing
AbstractTrees.children(x::Type) = subtypes(x)
"""
`print_struct()`
Prints the definition of a struct.
"""
function print_struct(type)
mutable = ismutable(type) ? "mutable" : ""
println("$mutable struct $type")
for (fn, ft) in zip(fieldnames(type), fieldtypes(type))
println(" $fn::$ft")
end
println("end")
end
function read_json(filename)
return open(filename) do io
JSON3.read(io, Dict)
end
end
abstract type AbstractOS end
abstract type Unix <: AbstractOS end
abstract type BSD <: Unix end
abstract type Windows <: AbstractOS end
abstract type MacOS <: BSD end
abstract type Linux <: BSD end
if Sys.iswindows()
const os = Windows
elseif Sys.isapple()
const os = MacOS
else
const os = Linux
end
"""
Download Data from `branch="master"` name into a "data" folder in given argument path.
Skip the actual download if the folder already exists and force=false.
Defaults to the root of the PowerSystems package.
Returns the downloaded folder name.
"""
function download(
repo::AbstractString,
folder::AbstractString = abspath(joinpath(@__DIR__, "..")),
branch::String = "master",
force::Bool = false,
)
if Sys.iswindows()
DATA_URL = "$repo/archive/$branch.zip"
else
DATA_URL = "$repo/archive/$branch.tar.gz"
end
directory = abspath(normpath(folder))
reponame = splitpath(repo)[end]
data = joinpath(directory, "$reponame-$branch")
if !isdir(data) || force
@info "Downloading $DATA_URL"
tempfilename = Base.download(DATA_URL)
mkpath(directory)
@info "Extracting data to $data"
unzip(os, tempfilename, directory)
# mv(joinpath(directory, "$reponame-$branch"), data, force = true)
end
return data
end
function unzip(::Type{<:BSD}, filename, directory)
@assert success(`tar -xvf $filename -C $directory`) "Unable to extract $filename to $directory"
end
function unzip(::Type{Windows}, filename, directory)
path_7z = if Base.VERSION < v"0.7-"
"$JULIA_HOME/7z"
else
sep = Sys.iswindows() ? ";" : ":"
withenv(
"PATH" => string(
joinpath(Sys.BINDIR, "..", "libexec"),
sep,
Sys.BINDIR,
sep,
ENV["PATH"],
),
) do
Sys.which("7z")
end
end
@assert success(`$path_7z x $filename -y -o$directory`) "Unable to extract $filename to $directory"
end
| [
27,
34345,
29,
10677,
14,
26791,
13,
20362,
198,
198,
2,
18700,
2099,
5509,
13570,
198,
23839,
51,
6037,
13,
17197,
7,
87,
3712,
6030,
8,
796,
850,
19199,
7,
87,
8,
198,
198,
37811,
198,
63,
4798,
62,
7249,
3419,
63,
198,
198,
18557,
82,
262,
6770,
286,
257,
2878,
13,
198,
37811,
198,
8818,
3601,
62,
7249,
7,
4906,
8,
198,
220,
220,
220,
4517,
540,
796,
318,
76,
18187,
7,
4906,
8,
5633,
366,
76,
18187,
1,
1058,
13538,
198,
220,
220,
220,
44872,
7203,
3,
76,
18187,
2878,
720,
4906,
4943,
198,
220,
220,
220,
329,
357,
22184,
11,
10117,
8,
287,
19974,
7,
3245,
14933,
7,
4906,
828,
2214,
19199,
7,
4906,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
220,
220,
220,
720,
22184,
3712,
3,
701,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
44872,
7203,
437,
4943,
198,
437,
198,
198,
8818,
1100,
62,
17752,
7,
34345,
8,
198,
220,
220,
220,
1441,
1280,
7,
34345,
8,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
19449,
18,
13,
961,
7,
952,
11,
360,
713,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
397,
8709,
2099,
27741,
2640,
886,
198,
397,
8709,
2099,
33501,
1279,
25,
27741,
2640,
886,
198,
397,
8709,
2099,
347,
10305,
1279,
25,
33501,
886,
198,
198,
397,
8709,
2099,
3964,
1279,
25,
27741,
2640,
886,
198,
397,
8709,
2099,
4100,
2640,
1279,
25,
347,
10305,
886,
198,
397,
8709,
2099,
7020,
1279,
25,
347,
10305,
886,
198,
198,
361,
311,
893,
13,
271,
28457,
3419,
198,
220,
220,
220,
1500,
28686,
796,
3964,
198,
17772,
361,
311,
893,
13,
271,
18040,
3419,
198,
220,
220,
220,
1500,
28686,
796,
4100,
2640,
198,
17772,
198,
220,
220,
220,
1500,
28686,
796,
7020,
198,
437,
198,
198,
37811,
198,
10002,
6060,
422,
4600,
1671,
3702,
2625,
9866,
1,
63,
1438,
656,
257,
366,
7890,
1,
9483,
287,
1813,
4578,
3108,
13,
198,
50232,
262,
4036,
4321,
611,
262,
9483,
1541,
7160,
290,
2700,
28,
9562,
13,
198,
7469,
13185,
284,
262,
6808,
286,
262,
4333,
11964,
82,
5301,
13,
198,
198,
35561,
262,
15680,
9483,
1438,
13,
198,
37811,
198,
8818,
4321,
7,
198,
220,
220,
220,
29924,
3712,
23839,
10100,
11,
198,
220,
220,
220,
9483,
3712,
23839,
10100,
796,
2352,
6978,
7,
22179,
6978,
7,
31,
834,
34720,
834,
11,
366,
492,
4943,
828,
198,
220,
220,
220,
8478,
3712,
10100,
796,
366,
9866,
1600,
198,
220,
220,
220,
2700,
3712,
33,
970,
796,
3991,
11,
198,
8,
198,
220,
220,
220,
611,
311,
893,
13,
271,
28457,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
42865,
62,
21886,
796,
17971,
260,
7501,
14,
17474,
32624,
1671,
3702,
13,
13344,
1,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
42865,
62,
21886,
796,
17971,
260,
7501,
14,
17474,
32624,
1671,
3702,
13,
18870,
13,
34586,
1,
198,
220,
220,
220,
886,
198,
220,
220,
220,
8619,
796,
2352,
6978,
7,
27237,
6978,
7,
43551,
4008,
198,
220,
220,
220,
1128,
261,
480,
796,
6626,
6978,
7,
260,
7501,
38381,
437,
60,
198,
220,
220,
220,
1366,
796,
4654,
6978,
7,
34945,
11,
17971,
7856,
261,
480,
22799,
1671,
3702,
4943,
198,
220,
220,
220,
611,
5145,
9409,
343,
7,
7890,
8,
8614,
2700,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
10951,
366,
10002,
278,
720,
26947,
62,
21886,
1,
198,
220,
220,
220,
220,
220,
220,
220,
20218,
34345,
796,
7308,
13,
15002,
7,
26947,
62,
21886,
8,
198,
220,
220,
220,
220,
220,
220,
220,
33480,
6978,
7,
34945,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
10951,
366,
11627,
974,
278,
1366,
284,
720,
7890,
1,
198,
220,
220,
220,
220,
220,
220,
220,
555,
13344,
7,
418,
11,
20218,
34345,
11,
8619,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
285,
85,
7,
22179,
6978,
7,
34945,
11,
17971,
7856,
261,
480,
22799,
1671,
3702,
12340,
1366,
11,
2700,
796,
2081,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
1366,
198,
437,
198,
198,
8818,
555,
13344,
7,
3712,
6030,
90,
27,
25,
21800,
5512,
29472,
11,
8619,
8,
198,
220,
220,
220,
2488,
30493,
1943,
7,
63,
18870,
532,
87,
85,
69,
720,
34345,
532,
34,
720,
34945,
63,
8,
366,
3118,
540,
284,
7925,
720,
34345,
284,
720,
34945,
1,
198,
437,
198,
198,
8818,
555,
13344,
7,
3712,
6030,
90,
11209,
5512,
29472,
11,
8619,
8,
198,
220,
220,
220,
3108,
62,
22,
89,
796,
611,
7308,
13,
43717,
1279,
410,
1,
15,
13,
22,
21215,
198,
220,
220,
220,
220,
220,
220,
220,
17971,
41,
6239,
3539,
62,
39069,
14,
22,
89,
1,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
41767,
796,
311,
893,
13,
271,
28457,
3419,
5633,
366,
26033,
1058,
366,
11097,
198,
220,
220,
220,
220,
220,
220,
220,
20868,
831,
85,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
34219,
1,
5218,
4731,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4654,
6978,
7,
44387,
13,
33,
12115,
4663,
11,
366,
492,
1600,
366,
8019,
18558,
12340,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
41767,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
311,
893,
13,
33,
12115,
4663,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
41767,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
12964,
53,
14692,
34219,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
311,
893,
13,
4758,
7203,
22,
89,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2488,
30493,
1943,
7,
63,
3,
6978,
62,
22,
89,
2124,
720,
34345,
532,
88,
532,
78,
3,
34945,
63,
8,
366,
3118,
540,
284,
7925,
720,
34345,
284,
720,
34945,
1,
198,
437,
198
] | 2.39868 | 1,061 |
export default_if_empty
import Base: show
"""
default_if_empty(value::T)
Creates a `default_if_empty` operator, which emits a given value if the source Observable completes
without emitting any next value, otherwise mirrors the source Observable.
```jldoctest
using Rocket
source = completed(Int) |> default_if_empty(0)
subscribe!(source, logger())
;
# output
[LogActor] Data: 0
[LogActor] Completed
```
See also: [`AbstractOperator`](@ref), [`InferableOperator`](@ref), [`logger`](@ref), [`map`](@ref)
"""
default_if_empty(value::T) where T = DefaultIfEmptyOperator{T}(value)
struct DefaultIfEmptyOperator{T} <: InferableOperator
value :: T
end
operator_right(operator::DefaultIfEmptyOperator{T}, ::Type{L}) where { L, T } = Union{L, T}
function on_call!(::Type{L}, ::Type{Union{L, T}}, operator::DefaultIfEmptyOperator{T}, source) where { L, T }
return proxy(Union{L, T}, source, DefaultIfEmptyProxy{Union{L, T}}(convert(Union{L, T}, operator.value)))
end
struct DefaultIfEmptyProxy{L} <: ActorProxy
default :: L
end
actor_proxy!(::Type, proxy::DefaultIfEmptyProxy{L}, actor::A) where { L, A } = DefaultIfEmptyActor{L, A}(actor, false, proxy.default)
mutable struct DefaultIfEmptyActor{L, A} <: Actor{L}
actor :: A
is_emitted :: Bool
default :: L
end
function on_next!(actor::DefaultIfEmptyActor{L}, data::L) where L
actor.is_emitted = true
next!(actor.actor, data)
end
function on_error!(actor::DefaultIfEmptyActor, err)
actor.is_emitted = true
error!(actor.actor, err)
end
function on_complete!(actor::DefaultIfEmptyActor)
if !actor.is_emitted
next!(actor.actor, actor.default)
end
complete!(actor.actor)
end
Base.show(io::IO, ::DefaultIfEmptyOperator{T}) where T = print(io, "DefaultIfEmptyOperator($T)")
Base.show(io::IO, ::DefaultIfEmptyProxy{L}) where L = print(io, "DefaultIfEmptyProxy($L)")
Base.show(io::IO, ::DefaultIfEmptyActor{L}) where L = print(io, "DefaultIfEmptyActor($L)")
| [
39344,
4277,
62,
361,
62,
28920,
198,
198,
11748,
7308,
25,
905,
198,
198,
37811,
198,
220,
220,
220,
4277,
62,
361,
62,
28920,
7,
8367,
3712,
51,
8,
198,
198,
16719,
274,
257,
4600,
12286,
62,
361,
62,
28920,
63,
10088,
11,
543,
48300,
257,
1813,
1988,
611,
262,
2723,
19243,
540,
32543,
198,
19419,
48143,
597,
1306,
1988,
11,
4306,
22353,
262,
2723,
19243,
540,
13,
198,
198,
15506,
63,
73,
335,
38441,
395,
198,
3500,
16920,
198,
198,
10459,
796,
5668,
7,
5317,
8,
930,
29,
4277,
62,
361,
62,
28920,
7,
15,
8,
198,
198,
7266,
12522,
0,
7,
10459,
11,
49706,
28955,
198,
26,
198,
198,
2,
5072,
198,
58,
11187,
40277,
60,
6060,
25,
657,
198,
58,
11187,
40277,
60,
32983,
198,
15506,
63,
198,
6214,
635,
25,
685,
63,
23839,
18843,
1352,
63,
16151,
31,
5420,
828,
685,
63,
818,
2232,
540,
18843,
1352,
63,
16151,
31,
5420,
828,
685,
63,
6404,
1362,
63,
16151,
31,
5420,
828,
685,
63,
8899,
63,
16151,
31,
5420,
8,
198,
37811,
198,
12286,
62,
361,
62,
28920,
7,
8367,
3712,
51,
8,
810,
309,
796,
15161,
1532,
40613,
18843,
1352,
90,
51,
92,
7,
8367,
8,
198,
198,
7249,
15161,
1532,
40613,
18843,
1352,
90,
51,
92,
1279,
25,
554,
2232,
540,
18843,
1352,
198,
220,
220,
220,
1988,
7904,
309,
198,
437,
198,
198,
46616,
62,
3506,
7,
46616,
3712,
19463,
1532,
40613,
18843,
1352,
90,
51,
5512,
7904,
6030,
90,
43,
30072,
810,
1391,
406,
11,
309,
1782,
796,
4479,
90,
43,
11,
309,
92,
198,
198,
8818,
319,
62,
13345,
0,
7,
3712,
6030,
90,
43,
5512,
7904,
6030,
90,
38176,
90,
43,
11,
309,
92,
5512,
10088,
3712,
19463,
1532,
40613,
18843,
1352,
90,
51,
5512,
2723,
8,
810,
1391,
406,
11,
309,
1782,
198,
220,
220,
220,
1441,
15741,
7,
38176,
90,
43,
11,
309,
5512,
2723,
11,
15161,
1532,
40613,
44148,
90,
38176,
90,
43,
11,
309,
11709,
7,
1102,
1851,
7,
38176,
90,
43,
11,
309,
5512,
10088,
13,
8367,
22305,
198,
437,
198,
198,
7249,
15161,
1532,
40613,
44148,
90,
43,
92,
1279,
25,
27274,
44148,
198,
220,
220,
220,
4277,
7904,
406,
198,
437,
198,
198,
11218,
62,
36436,
0,
7,
3712,
6030,
11,
15741,
3712,
19463,
1532,
40613,
44148,
90,
43,
5512,
8674,
3712,
32,
8,
810,
1391,
406,
11,
317,
1782,
796,
15161,
1532,
40613,
40277,
90,
43,
11,
317,
92,
7,
11218,
11,
3991,
11,
15741,
13,
12286,
8,
198,
198,
76,
18187,
2878,
15161,
1532,
40613,
40277,
90,
43,
11,
317,
92,
1279,
25,
27274,
90,
43,
92,
198,
220,
220,
220,
8674,
220,
220,
220,
220,
220,
7904,
317,
198,
220,
220,
220,
318,
62,
368,
2175,
7904,
347,
970,
198,
220,
220,
220,
4277,
220,
220,
220,
7904,
406,
198,
437,
198,
198,
8818,
319,
62,
19545,
0,
7,
11218,
3712,
19463,
1532,
40613,
40277,
90,
43,
5512,
1366,
3712,
43,
8,
810,
406,
198,
220,
220,
220,
8674,
13,
271,
62,
368,
2175,
796,
2081,
198,
220,
220,
220,
1306,
0,
7,
11218,
13,
11218,
11,
1366,
8,
198,
437,
198,
198,
8818,
319,
62,
18224,
0,
7,
11218,
3712,
19463,
1532,
40613,
40277,
11,
11454,
8,
198,
220,
220,
220,
8674,
13,
271,
62,
368,
2175,
796,
2081,
198,
220,
220,
220,
4049,
0,
7,
11218,
13,
11218,
11,
11454,
8,
198,
437,
198,
198,
8818,
319,
62,
20751,
0,
7,
11218,
3712,
19463,
1532,
40613,
40277,
8,
198,
220,
220,
220,
611,
5145,
11218,
13,
271,
62,
368,
2175,
198,
220,
220,
220,
220,
220,
220,
220,
1306,
0,
7,
11218,
13,
11218,
11,
8674,
13,
12286,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1844,
0,
7,
11218,
13,
11218,
8,
198,
437,
198,
198,
14881,
13,
12860,
7,
952,
3712,
9399,
11,
7904,
19463,
1532,
40613,
18843,
1352,
90,
51,
30072,
810,
309,
796,
3601,
7,
952,
11,
366,
19463,
1532,
40613,
18843,
1352,
16763,
51,
8,
4943,
198,
14881,
13,
12860,
7,
952,
3712,
9399,
11,
7904,
19463,
1532,
40613,
44148,
90,
43,
30072,
220,
220,
220,
810,
406,
796,
3601,
7,
952,
11,
366,
19463,
1532,
40613,
44148,
16763,
43,
8,
4943,
198,
14881,
13,
12860,
7,
952,
3712,
9399,
11,
7904,
19463,
1532,
40613,
40277,
90,
43,
30072,
220,
220,
220,
810,
406,
796,
3601,
7,
952,
11,
366,
19463,
1532,
40613,
40277,
16763,
43,
8,
4943,
198
] | 2.696065 | 737 |
"""
Struct for Standard American Option
amOption=AmericanOption(T::num1,K::num2,isCall::Bool=true) where {num1 <: Number,num2 <: Number}
Where:\n
T = Time to maturity of the Option.
K = Strike Price of the Option.
isCall = true for CALL, false for PUT.
"""
mutable struct AmericanOption{num1 <: Number, num2 <: Number, numtype <: Number} <: AmericanPayoff{numtype}
T::num1
K::num2
isCall::Bool
function AmericanOption(T::num1, K::num2, isCall::Bool = true) where {num1 <: Number, num2 <: Number}
if T <= 0.0
error("Time to Maturity must be positive")
elseif K <= 0.0
error("Strike Price must be positive")
else
zero_typed = zero(num1) + zero(num2)
return new{num1, num2, typeof(zero_typed)}(T, K, isCall)
end
end
end
export AmericanOption;
function payout(Sti::numtype_, amPayoff::AmericanOption) where {numtype_ <: Number}
iscall = amPayoff.isCall ? 1 : -1
return ((Sti - amPayoff.K) * iscall > 0.0) ? (Sti - amPayoff.K) * iscall : zero(numtype_)
end
| [
37811,
198,
44909,
329,
8997,
1605,
16018,
628,
197,
197,
321,
19722,
28,
7437,
19722,
7,
51,
3712,
22510,
16,
11,
42,
3712,
22510,
17,
11,
271,
14134,
3712,
33,
970,
28,
7942,
8,
810,
1391,
22510,
16,
1279,
25,
7913,
11,
22510,
17,
1279,
25,
7913,
92,
198,
197,
198,
8496,
7479,
77,
198,
197,
197,
51,
197,
28,
197,
7575,
284,
24841,
286,
262,
16018,
13,
198,
197,
197,
42,
197,
28,
197,
31584,
7886,
286,
262,
16018,
13,
198,
197,
197,
271,
14134,
220,
796,
2081,
329,
42815,
11,
3991,
329,
350,
3843,
13,
198,
37811,
198,
76,
18187,
2878,
1605,
19722,
90,
22510,
16,
1279,
25,
7913,
11,
997,
17,
1279,
25,
7913,
11,
997,
4906,
1279,
25,
7913,
92,
1279,
25,
1605,
19197,
2364,
90,
22510,
4906,
92,
198,
220,
220,
220,
309,
3712,
22510,
16,
198,
220,
220,
220,
509,
3712,
22510,
17,
198,
220,
220,
220,
318,
14134,
3712,
33,
970,
198,
220,
220,
220,
2163,
1605,
19722,
7,
51,
3712,
22510,
16,
11,
509,
3712,
22510,
17,
11,
318,
14134,
3712,
33,
970,
796,
2081,
8,
810,
1391,
22510,
16,
1279,
25,
7913,
11,
997,
17,
1279,
25,
7913,
92,
198,
220,
220,
220,
220,
220,
220,
220,
611,
309,
19841,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
7575,
284,
6550,
1684,
1276,
307,
3967,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
509,
19841,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
31584,
7886,
1276,
307,
3967,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6632,
62,
774,
9124,
796,
6632,
7,
22510,
16,
8,
1343,
6632,
7,
22510,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
649,
90,
22510,
16,
11,
997,
17,
11,
2099,
1659,
7,
22570,
62,
774,
9124,
38165,
7,
51,
11,
509,
11,
318,
14134,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
39344,
1605,
19722,
26,
198,
198,
8818,
40055,
7,
1273,
72,
3712,
22510,
4906,
62,
11,
716,
19197,
2364,
3712,
7437,
19722,
8,
810,
1391,
22510,
4906,
62,
1279,
25,
7913,
92,
198,
220,
220,
220,
318,
13345,
796,
716,
19197,
2364,
13,
271,
14134,
5633,
352,
1058,
532,
16,
198,
220,
220,
220,
1441,
14808,
1273,
72,
532,
716,
19197,
2364,
13,
42,
8,
1635,
318,
13345,
1875,
657,
13,
15,
8,
5633,
357,
1273,
72,
532,
716,
19197,
2364,
13,
42,
8,
1635,
318,
13345,
1058,
6632,
7,
22510,
4906,
62,
8,
198,
437,
198
] | 2.344978 | 458 |
"""
InitialValueProblem{S <: AbstractSystem, XT} <: AbstractSystem
Parametric composite type for initial value problems. It is parameterized in the
system's type and the initial state's type
### Fields
- `s` -- system
- `x0` -- initial state
### Examples
The linear system ``x' = -x`` with initial condition ``x₀ = [-1/2, 1/2]``:
```jldoctest
julia> s = LinearContinuousSystem([-1.0 0.0; 0.0 -1.0]);
julia> x₀ = [-1/2, 1/2];
julia> p = InitialValueProblem(s, x₀);
julia> initial_state(p) # same as p.x0
2-element Array{Float64,1}:
-0.5
0.5
julia> statedim(p)
2
julia> inputdim(p)
0
```
"""
struct InitialValueProblem{S <: AbstractSystem, XT} <: AbstractSystem
s::S
x0::XT
end
statedim(ivp::InitialValueProblem) = statedim(ivp.s)
stateset(ivp::InitialValueProblem) = stateset(ivp.s)
inputdim(ivp::InitialValueProblem) = inputdim(ivp.s)
inputset(ivp::InitialValueProblem) = inputset(ivp.s)
islinear(ivp::InitialValueProblem) = islinear(ivp.s)
isaffine(ivp::InitialValueProblem) = isaffine(ivp.s)
ispolynomial(ivp::InitialValueProblem) = ispolynomial(ivp.s)
state_matrix(ivp::InitialValueProblem) = state_matrix(ivp.s)
input_matrix(ivp::InitialValueProblem) = input_matrix(ivp.s)
noise_matrix(ivp::InitialValueProblem) = noise_matrix(ivp.s)
affine_term(ivp::InitialValueProblem) = affine_term(ivp.s)
"""
initial_state(ivp::InitialValueProblem)
Return the initial state of an initial-value problem.
### Input
- `ivp` -- initial-value problem
### Output
The initial state of an initial-value problem.
"""
initial_state(ivp::InitialValueProblem) = ivp.x0
"""
system(ivp::InitialValueProblem)
Return the system wrapped by an initial-value problem.
### Input
- `ivp` -- initial-value problem
### Output
The system of the given initial-value problem.
"""
system(ivp::InitialValueProblem) = ivp.s
"""
IVP
`IVP` is an alias for `InitialValueProblem`.
"""
const IVP = InitialValueProblem
| [
37811,
198,
220,
220,
220,
20768,
11395,
40781,
90,
50,
1279,
25,
27741,
11964,
11,
44235,
92,
1279,
25,
27741,
11964,
198,
198,
22973,
19482,
24185,
2099,
329,
4238,
1988,
2761,
13,
632,
318,
11507,
1143,
287,
262,
198,
10057,
338,
2099,
290,
262,
4238,
1181,
338,
2099,
198,
198,
21017,
23948,
198,
198,
12,
4600,
82,
63,
220,
1377,
1080,
198,
12,
4600,
87,
15,
63,
1377,
4238,
1181,
198,
198,
21017,
21066,
198,
198,
464,
14174,
1080,
7559,
87,
6,
796,
532,
87,
15506,
351,
4238,
4006,
7559,
87,
158,
224,
222,
796,
25915,
16,
14,
17,
11,
352,
14,
17,
60,
15506,
25,
198,
198,
15506,
63,
73,
335,
38441,
395,
198,
73,
43640,
29,
264,
796,
44800,
17875,
5623,
11964,
26933,
12,
16,
13,
15,
657,
13,
15,
26,
657,
13,
15,
532,
16,
13,
15,
36563,
198,
198,
73,
43640,
29,
2124,
158,
224,
222,
796,
25915,
16,
14,
17,
11,
352,
14,
17,
11208,
198,
198,
73,
43640,
29,
279,
796,
20768,
11395,
40781,
7,
82,
11,
2124,
158,
224,
222,
1776,
198,
198,
73,
43640,
29,
4238,
62,
5219,
7,
79,
8,
1303,
976,
355,
279,
13,
87,
15,
198,
17,
12,
30854,
15690,
90,
43879,
2414,
11,
16,
38362,
198,
532,
15,
13,
20,
198,
220,
657,
13,
20,
198,
198,
73,
43640,
29,
5081,
320,
7,
79,
8,
198,
17,
198,
198,
73,
43640,
29,
5128,
27740,
7,
79,
8,
198,
15,
198,
15506,
63,
198,
37811,
198,
7249,
20768,
11395,
40781,
90,
50,
1279,
25,
27741,
11964,
11,
44235,
92,
1279,
25,
27741,
11964,
198,
220,
220,
220,
264,
3712,
50,
198,
220,
220,
220,
2124,
15,
3712,
25010,
198,
437,
198,
198,
21989,
320,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
5081,
320,
7,
452,
79,
13,
82,
8,
198,
27219,
316,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
2585,
316,
7,
452,
79,
13,
82,
8,
198,
15414,
27740,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
5128,
27740,
7,
452,
79,
13,
82,
8,
198,
15414,
2617,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
5128,
2617,
7,
452,
79,
13,
82,
8,
198,
271,
29127,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
318,
29127,
7,
452,
79,
13,
82,
8,
198,
271,
2001,
500,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
318,
2001,
500,
7,
452,
79,
13,
82,
8,
198,
8802,
3366,
26601,
498,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
318,
35428,
26601,
498,
7,
452,
79,
13,
82,
8,
198,
5219,
62,
6759,
8609,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
1181,
62,
6759,
8609,
7,
452,
79,
13,
82,
8,
198,
15414,
62,
6759,
8609,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
5128,
62,
6759,
8609,
7,
452,
79,
13,
82,
8,
198,
3919,
786,
62,
6759,
8609,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
7838,
62,
6759,
8609,
7,
452,
79,
13,
82,
8,
198,
2001,
500,
62,
4354,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
1527,
500,
62,
4354,
7,
452,
79,
13,
82,
8,
198,
198,
37811,
198,
220,
220,
220,
4238,
62,
5219,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
198,
198,
13615,
262,
4238,
1181,
286,
281,
4238,
12,
8367,
1917,
13,
198,
198,
21017,
23412,
198,
198,
12,
4600,
452,
79,
63,
1377,
4238,
12,
8367,
1917,
198,
198,
21017,
25235,
198,
198,
464,
4238,
1181,
286,
281,
4238,
12,
8367,
1917,
13,
198,
37811,
198,
36733,
62,
5219,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
21628,
79,
13,
87,
15,
198,
198,
37811,
198,
220,
220,
220,
1080,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
198,
198,
13615,
262,
1080,
12908,
416,
281,
4238,
12,
8367,
1917,
13,
198,
198,
21017,
23412,
198,
198,
12,
4600,
452,
79,
63,
1377,
4238,
12,
8367,
1917,
198,
198,
21017,
25235,
198,
198,
464,
1080,
286,
262,
1813,
4238,
12,
8367,
1917,
13,
198,
37811,
198,
10057,
7,
452,
79,
3712,
24243,
11395,
40781,
8,
796,
21628,
79,
13,
82,
198,
198,
37811,
198,
220,
220,
220,
8363,
47,
198,
198,
63,
3824,
47,
63,
318,
281,
16144,
329,
4600,
24243,
11395,
40781,
44646,
198,
37811,
198,
9979,
8363,
47,
796,
20768,
11395,
40781,
198
] | 2.676838 | 721 |
using Electron
using URIParser
using Test
@testset "Electron" begin
@testset "local URI" begin
dir = pwd(URI)
@test unescape(dir.path) == join(push!(split(pwd(), Base.Filesystem.path_separator_re), ""), "/")
@test dir.query == dir.fragment == dir.host == ""
@test string(dir) == "file://$(dir.path)"
__dirname = @__DIR__
dir = Electron.URI_file(__dirname, "")
@test_skip URI(dir, path = dir.path * "test.html", query = "a", fragment = "b") ==
Electron.@LOCAL("test.html?a#b") ==
Electron.@LOCAL(begin; "test.html?a#b"; end) ==
Electron.URI_file(__dirname, "test.html?a#b")
end
@testset "Core" begin
w = Window(URI("file://test.html"))
a = applications()[1]
@test isa(w, Window)
@test length(applications()) == 1
@test length(windows(a)) == 1
res = run(w, "Math.log(Math.exp(1))")
@test res == 1
res = run(a, "Math.log(Math.exp(1))")
@test res ==1
close(w)
@test length(applications()) == 1
@test isempty(windows(a)) == 1
w2 = Window(URI("file://test.html"))
toggle_devtools(w2)
close(a)
@test length(applications()) == 1
@test length(windows(a)) == 0
sleep(1)
@test isempty(applications())
@test isempty(windows(a))
w3 = Window(Dict("url" => string(URI("file://test.html"))))
w4 = Window(URI("file://test.html"), options=Dict("title" => "Window title"))
w5 = Window("<body></body>", options=Dict("title" => "Window title"))
a2 = applications()[1]
w6 = Window(a2, "<body></body>", options=Dict("title" => "Window title"))
w7 = Window(a2)
run(w7, "sendMessageToJulia('foo')")
@test take!(msgchannel(w7)) == "foo"
load(w7, "<body>bar</body>")
run(w7, "sendMessageToJulia(window.document.documentElement.innerHTML)")
@test occursin("bar", take!(msgchannel(w7)))
@testset "ElectronAPI" begin
win = Window()
@test (ElectronAPI.setBackgroundColor(win, "#000"); true)
@test ElectronAPI.isFocused(win) isa Bool
bounds = ElectronAPI.getBounds(win)
boundskeys = ["width", "height", "x", "y"]
@test Set(boundskeys) <= Set(keys(bounds))
@test all(isa.(get.(Ref(bounds), boundskeys, nothing), Real))
close(win)
end
close(w7)
close(w3)
close(w4)
close(w5)
close(w6)
close(a2)
end # testset "Electron"
end | [
3500,
5903,
1313,
198,
3500,
471,
32618,
28198,
198,
3500,
6208,
198,
198,
31,
9288,
2617,
366,
19453,
1313,
1,
2221,
198,
198,
31,
9288,
2617,
366,
12001,
43975,
1,
2221,
198,
220,
220,
220,
26672,
796,
279,
16993,
7,
47269,
8,
198,
220,
220,
220,
2488,
9288,
555,
41915,
7,
15908,
13,
6978,
8,
6624,
4654,
7,
14689,
0,
7,
35312,
7,
79,
16993,
22784,
7308,
13,
25876,
6781,
13,
6978,
62,
25512,
1352,
62,
260,
828,
366,
12340,
12813,
4943,
198,
220,
220,
220,
2488,
9288,
26672,
13,
22766,
6624,
26672,
13,
8310,
363,
434,
6624,
26672,
13,
4774,
6624,
13538,
198,
220,
220,
220,
2488,
9288,
4731,
7,
15908,
8,
6624,
366,
7753,
1378,
3,
7,
15908,
13,
6978,
16725,
628,
220,
220,
220,
11593,
15908,
3672,
796,
2488,
834,
34720,
834,
198,
220,
220,
220,
26672,
796,
5903,
1313,
13,
47269,
62,
7753,
7,
834,
15908,
3672,
11,
366,
4943,
198,
220,
220,
220,
2488,
9288,
62,
48267,
43975,
7,
15908,
11,
3108,
796,
26672,
13,
6978,
1635,
366,
9288,
13,
6494,
1600,
12405,
796,
366,
64,
1600,
24225,
796,
366,
65,
4943,
6624,
198,
220,
220,
220,
220,
220,
220,
220,
5903,
1313,
13,
31,
29701,
1847,
7203,
9288,
13,
6494,
30,
64,
2,
65,
4943,
6624,
198,
220,
220,
220,
220,
220,
220,
220,
5903,
1313,
13,
31,
29701,
1847,
7,
27471,
26,
366,
9288,
13,
6494,
30,
64,
2,
65,
8172,
886,
8,
6624,
198,
220,
220,
220,
220,
220,
220,
220,
5903,
1313,
13,
47269,
62,
7753,
7,
834,
15908,
3672,
11,
366,
9288,
13,
6494,
30,
64,
2,
65,
4943,
198,
437,
628,
198,
31,
9288,
2617,
366,
14055,
1,
2221,
198,
198,
86,
796,
26580,
7,
47269,
7203,
7753,
1378,
9288,
13,
6494,
48774,
198,
198,
64,
796,
5479,
3419,
58,
16,
60,
198,
198,
31,
9288,
318,
64,
7,
86,
11,
26580,
8,
198,
198,
31,
9288,
4129,
7,
1324,
677,
602,
28955,
6624,
352,
198,
31,
9288,
4129,
7,
28457,
7,
64,
4008,
6624,
352,
198,
198,
411,
796,
1057,
7,
86,
11,
366,
37372,
13,
6404,
7,
37372,
13,
11201,
7,
16,
4008,
4943,
198,
198,
31,
9288,
581,
6624,
352,
198,
198,
411,
796,
1057,
7,
64,
11,
366,
37372,
13,
6404,
7,
37372,
13,
11201,
7,
16,
4008,
4943,
198,
198,
31,
9288,
581,
6624,
16,
198,
198,
19836,
7,
86,
8,
198,
31,
9288,
4129,
7,
1324,
677,
602,
28955,
6624,
352,
198,
31,
9288,
318,
28920,
7,
28457,
7,
64,
4008,
6624,
352,
198,
198,
86,
17,
796,
26580,
7,
47269,
7203,
7753,
1378,
9288,
13,
6494,
48774,
198,
198,
44256,
62,
7959,
31391,
7,
86,
17,
8,
198,
198,
19836,
7,
64,
8,
198,
31,
9288,
4129,
7,
1324,
677,
602,
28955,
6624,
352,
198,
31,
9288,
4129,
7,
28457,
7,
64,
4008,
6624,
657,
198,
198,
42832,
7,
16,
8,
198,
31,
9288,
318,
28920,
7,
1324,
677,
602,
28955,
198,
31,
9288,
318,
28920,
7,
28457,
7,
64,
4008,
198,
198,
86,
18,
796,
26580,
7,
35,
713,
7203,
6371,
1,
5218,
4731,
7,
47269,
7203,
7753,
1378,
9288,
13,
6494,
1,
35514,
198,
198,
86,
19,
796,
26580,
7,
47269,
7203,
7753,
1378,
9288,
13,
6494,
12340,
3689,
28,
35,
713,
7203,
7839,
1,
5218,
366,
27703,
3670,
48774,
198,
198,
86,
20,
796,
26580,
7203,
27,
2618,
12240,
2618,
29,
1600,
3689,
28,
35,
713,
7203,
7839,
1,
5218,
366,
27703,
3670,
48774,
198,
198,
64,
17,
796,
5479,
3419,
58,
16,
60,
198,
198,
86,
21,
796,
26580,
7,
64,
17,
11,
33490,
2618,
12240,
2618,
29,
1600,
3689,
28,
35,
713,
7203,
7839,
1,
5218,
366,
27703,
3670,
48774,
198,
198,
86,
22,
796,
26580,
7,
64,
17,
8,
198,
198,
5143,
7,
86,
22,
11,
366,
21280,
12837,
2514,
16980,
544,
10786,
21943,
11537,
4943,
198,
198,
31,
9288,
1011,
0,
7,
19662,
17620,
7,
86,
22,
4008,
6624,
366,
21943,
1,
198,
198,
2220,
7,
86,
22,
11,
33490,
2618,
29,
5657,
3556,
2618,
29,
4943,
198,
198,
5143,
7,
86,
22,
11,
366,
21280,
12837,
2514,
16980,
544,
7,
17497,
13,
22897,
13,
22897,
20180,
13,
5083,
28656,
8,
4943,
198,
198,
31,
9288,
8833,
259,
7203,
5657,
1600,
1011,
0,
7,
19662,
17620,
7,
86,
22,
22305,
198,
198,
31,
9288,
2617,
366,
19453,
1313,
17614,
1,
2221,
198,
220,
220,
220,
1592,
796,
26580,
3419,
628,
220,
220,
220,
2488,
9288,
357,
19453,
1313,
17614,
13,
2617,
21756,
10258,
7,
5404,
11,
25113,
830,
15341,
2081,
8,
198,
220,
220,
220,
2488,
9288,
5903,
1313,
17614,
13,
271,
37,
13073,
7,
5404,
8,
318,
64,
347,
970,
628,
220,
220,
220,
22303,
796,
5903,
1313,
17614,
13,
1136,
33,
3733,
7,
5404,
8,
198,
220,
220,
220,
22303,
13083,
796,
14631,
10394,
1600,
366,
17015,
1600,
366,
87,
1600,
366,
88,
8973,
198,
220,
220,
220,
2488,
9288,
5345,
7,
65,
3733,
13083,
8,
19841,
5345,
7,
13083,
7,
65,
3733,
4008,
198,
220,
220,
220,
2488,
9288,
477,
7,
9160,
12195,
1136,
12195,
8134,
7,
65,
3733,
828,
22303,
13083,
11,
2147,
828,
6416,
4008,
628,
220,
220,
220,
1969,
7,
5404,
8,
198,
437,
198,
198,
19836,
7,
86,
22,
8,
198,
198,
19836,
7,
86,
18,
8,
198,
19836,
7,
86,
19,
8,
198,
19836,
7,
86,
20,
8,
198,
19836,
7,
86,
21,
8,
198,
19836,
7,
64,
17,
8,
198,
198,
437,
1303,
1332,
2617,
366,
19453,
1313,
1,
198,
198,
437
] | 2.412664 | 916 |
using PMDPs
using PMDPs.LP
using DrWatson
using POMDPs
using BSON, CSV
using DrWatson
using RandomNumbers.Xorshifts
using Random
using DataFrames
using StaticArrays, Distributions # load
using MCTS, DiscreteValueIteration
using POMDPSimulators # load histories
using POMDPPolicies
using LightGraphs
using GraphPlot
using Cairo, Compose
using Debugger
using TableView
include(srcdir("MDPPricing.jl"))
function prepare_traces(pp::PMDPs.PMDPProblem, pp_params::Dict, vi::Bool, name::String, N::Int64; trace_folder = "test_traces", seed = 1, verbose=false)
mg = PMDPs.PMDPg(pp)
rnd = Xorshift128Plus(seed)
fname = savename("$(name)_N=$(N)", pp_params, "bson")
fpath = datadir(trace_folder, fname)
if isfile(fpath)
data = PMDPs.load_traces(fpath)
verbose ? println("Loading $fpath") : nothing
else
traces = [PMDPs.simulate_trace(mg, rnd) for i in 1:N]
data = @dict(name, pp, pp_params, traces, vi)
@tagsave(fpath, data)
verbose ? println("Saving $fpath") : nothing
end
return data
end
"""
Get input data
"""
problems = get_fast_benchmarks()
inputs = [prepare_traces(pp, params, vi, name, 100; verbose=true) for (pp, params, vi, name) in problems[1:end] ]
"""
Evaluate
"""
N_sim = 20
dpw_solver_params = (;depth=50,
exploration_constant=40.0, max_time=1.,
enable_state_pw = false,
keep_tree=true, show_progress=false, rng=Xorshift128Plus())
mcts_solver_params = (;depth=50,
exploration_constant=40.0, max_time=1.,
rng=Xorshift128Plus())
# pp_params = Dict(pairs((nᵣ=3, c=3, T=10, expected_res=3., res_budget_μ=5., objective=objective)))
# name = "linear_problem"
out_folder="test"
for (i, data) in enumerate(inputs)
print("\t Data $i - Evaluating $(data[:name]) with $(data[:pp_params]): ")
print("flatrate..."); PMDPs.process_data(data, PMDPs.flatrate; folder=out_folder, N=N_sim)
print("hindsight..."); PMDPs.process_data(data, PMDPs.hindsight; folder=out_folder, N=N_sim)
print("vi..."); data[:vi] && PMDPs.process_data(data, PMDPs.vi; folder=out_folder, N=N_sim)
# print("vi..."); data[:vi] && PMDPs.process_data(data, PMDPs.fhvi; folder=out_folder, N=N_sim)
print("dpw..."); PMDPs.process_data(data, PMDPs.mcts; folder=out_folder, N=N_sim,
method_info="dpw_$(savename(dpw_solver_params))", solver=DPWSolver(;dpw_solver_params...))
println("mcts..."); PMDPs.process_data(data, PMDPs.mcts; folder=out_folder, N=N_sim,
method_info="vanilla_$(savename(mcts_solver_params))", solver=MCTSSolver(;mcts_solver_params...))
end
println("LP Done.")
"""
Collect results
"""
results = folder_report(datadir("results", "test", "linear_problem"); raw_result_array=false);
agg_res = format_result_table(results.results; N=N_sim)
# using WebIO
vscodedisplay(agg_res)
| [
3500,
3122,
6322,
82,
198,
3500,
3122,
6322,
82,
13,
19930,
198,
3500,
1583,
54,
13506,
198,
198,
3500,
350,
2662,
6322,
82,
198,
3500,
347,
11782,
11,
44189,
198,
3500,
1583,
54,
13506,
198,
3500,
14534,
49601,
13,
55,
669,
71,
19265,
198,
3500,
14534,
198,
3500,
6060,
35439,
198,
3500,
36125,
3163,
20477,
11,
46567,
507,
1303,
3440,
198,
198,
3500,
337,
4177,
50,
11,
8444,
8374,
11395,
29993,
341,
198,
3500,
350,
2662,
35,
3705,
320,
24325,
1303,
3440,
25985,
198,
3500,
350,
2662,
6322,
47,
4160,
444,
198,
198,
3500,
4401,
37065,
82,
198,
3500,
29681,
43328,
198,
3500,
23732,
11,
3082,
577,
198,
198,
3500,
31687,
1362,
198,
198,
3500,
8655,
7680,
198,
198,
17256,
7,
10677,
15908,
7203,
44,
6322,
47,
1173,
278,
13,
20362,
48774,
198,
198,
8818,
8335,
62,
2213,
2114,
7,
381,
3712,
5868,
6322,
82,
13,
5868,
6322,
40781,
11,
9788,
62,
37266,
3712,
35,
713,
11,
25357,
3712,
33,
970,
11,
1438,
3712,
10100,
11,
399,
3712,
5317,
2414,
26,
12854,
62,
43551,
796,
366,
9288,
62,
2213,
2114,
1600,
9403,
796,
352,
11,
15942,
577,
28,
9562,
8,
198,
220,
220,
220,
10527,
796,
3122,
6322,
82,
13,
5868,
6322,
70,
7,
381,
8,
198,
220,
220,
220,
374,
358,
796,
1395,
669,
29323,
12762,
17860,
7,
28826,
8,
198,
220,
220,
220,
277,
3672,
796,
473,
574,
480,
7203,
3,
7,
3672,
8,
62,
45,
43641,
7,
45,
42501,
9788,
62,
37266,
11,
220,
366,
1443,
261,
4943,
198,
220,
220,
220,
277,
6978,
796,
4818,
324,
343,
7,
40546,
62,
43551,
11,
277,
3672,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
611,
318,
7753,
7,
69,
6978,
8,
220,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
3122,
6322,
82,
13,
2220,
62,
2213,
2114,
7,
69,
6978,
8,
198,
220,
220,
220,
220,
220,
220,
220,
15942,
577,
5633,
44872,
7203,
19031,
720,
69,
6978,
4943,
1058,
2147,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
20675,
796,
685,
5868,
6322,
82,
13,
14323,
5039,
62,
40546,
7,
11296,
11,
374,
358,
8,
329,
1312,
287,
352,
25,
45,
60,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
220,
2488,
11600,
7,
3672,
11,
9788,
11,
9788,
62,
37266,
11,
20675,
11,
25357,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
31499,
1015,
7,
69,
6978,
11,
1366,
8,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
15942,
577,
5633,
44872,
7203,
50,
2703,
720,
69,
6978,
4943,
1058,
2147,
220,
220,
220,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
1366,
198,
437,
198,
198,
37811,
198,
3855,
5128,
1366,
198,
37811,
198,
198,
1676,
22143,
796,
651,
62,
7217,
62,
26968,
14306,
3419,
198,
15414,
82,
796,
685,
46012,
533,
62,
2213,
2114,
7,
381,
11,
42287,
11,
25357,
11,
1438,
11,
1802,
26,
15942,
577,
28,
7942,
8,
329,
357,
381,
11,
42287,
11,
25357,
11,
1438,
8,
287,
2761,
58,
16,
25,
437,
60,
2361,
628,
198,
37811,
198,
36,
2100,
4985,
198,
37811,
198,
45,
62,
14323,
796,
1160,
198,
198,
26059,
86,
62,
82,
14375,
62,
37266,
796,
357,
26,
18053,
28,
1120,
11,
220,
198,
220,
220,
220,
13936,
62,
9979,
415,
28,
1821,
13,
15,
11,
3509,
62,
2435,
28,
16,
1539,
198,
220,
220,
220,
7139,
62,
5219,
62,
79,
86,
796,
3991,
11,
220,
198,
220,
220,
220,
1394,
62,
21048,
28,
7942,
11,
905,
62,
33723,
28,
9562,
11,
374,
782,
28,
55,
669,
29323,
12762,
17860,
28955,
198,
198,
76,
310,
82,
62,
82,
14375,
62,
37266,
796,
357,
26,
18053,
28,
1120,
11,
220,
198,
220,
220,
220,
13936,
62,
9979,
415,
28,
1821,
13,
15,
11,
3509,
62,
2435,
28,
16,
1539,
198,
220,
220,
220,
374,
782,
28,
55,
669,
29323,
12762,
17860,
28955,
198,
198,
2,
9788,
62,
37266,
796,
360,
713,
7,
79,
3468,
19510,
77,
39611,
96,
28,
18,
11,
269,
28,
18,
11,
309,
28,
940,
11,
2938,
62,
411,
28,
18,
1539,
581,
62,
37315,
62,
34703,
28,
20,
1539,
9432,
28,
15252,
425,
22305,
198,
2,
1438,
796,
366,
29127,
62,
45573,
1,
198,
448,
62,
43551,
2625,
9288,
1,
198,
198,
1640,
357,
72,
11,
1366,
8,
287,
27056,
378,
7,
15414,
82,
8,
198,
220,
220,
220,
3601,
7203,
59,
83,
6060,
720,
72,
532,
26439,
11927,
29568,
7890,
58,
25,
3672,
12962,
351,
29568,
7890,
58,
25,
381,
62,
37266,
60,
2599,
366,
8,
198,
220,
220,
220,
3601,
7203,
38568,
4873,
9313,
1776,
3122,
6322,
82,
13,
14681,
62,
7890,
7,
7890,
11,
3122,
6322,
82,
13,
38568,
4873,
26,
9483,
28,
448,
62,
43551,
11,
399,
28,
45,
62,
14323,
8,
198,
220,
220,
220,
3601,
7203,
71,
521,
18627,
9313,
1776,
3122,
6322,
82,
13,
14681,
62,
7890,
7,
7890,
11,
3122,
6322,
82,
13,
71,
521,
18627,
26,
9483,
28,
448,
62,
43551,
11,
399,
28,
45,
62,
14323,
8,
198,
220,
220,
220,
3601,
7203,
8903,
9313,
1776,
1366,
58,
25,
8903,
60,
11405,
3122,
6322,
82,
13,
14681,
62,
7890,
7,
7890,
11,
3122,
6322,
82,
13,
8903,
26,
9483,
28,
448,
62,
43551,
11,
399,
28,
45,
62,
14323,
8,
198,
220,
220,
220,
1303,
3601,
7203,
8903,
9313,
1776,
1366,
58,
25,
8903,
60,
11405,
3122,
6322,
82,
13,
14681,
62,
7890,
7,
7890,
11,
3122,
6322,
82,
13,
69,
71,
8903,
26,
9483,
28,
448,
62,
43551,
11,
399,
28,
45,
62,
14323,
8,
628,
220,
220,
220,
3601,
7203,
26059,
86,
9313,
1776,
3122,
6322,
82,
13,
14681,
62,
7890,
7,
7890,
11,
3122,
6322,
82,
13,
76,
310,
82,
26,
9483,
28,
448,
62,
43551,
11,
399,
28,
45,
62,
14323,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2446,
62,
10951,
2625,
26059,
86,
62,
3,
7,
82,
4005,
480,
7,
26059,
86,
62,
82,
14375,
62,
37266,
4008,
1600,
1540,
332,
28,
6322,
19416,
14375,
7,
26,
26059,
86,
62,
82,
14375,
62,
37266,
986,
4008,
198,
220,
220,
220,
44872,
7203,
76,
310,
82,
9313,
1776,
3122,
6322,
82,
13,
14681,
62,
7890,
7,
7890,
11,
3122,
6322,
82,
13,
76,
310,
82,
26,
9483,
28,
448,
62,
43551,
11,
399,
28,
45,
62,
14323,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2446,
62,
10951,
2625,
10438,
5049,
62,
3,
7,
82,
4005,
480,
7,
76,
310,
82,
62,
82,
14375,
62,
37266,
4008,
1600,
1540,
332,
28,
44,
4177,
5432,
14375,
7,
26,
76,
310,
82,
62,
82,
14375,
62,
37266,
986,
4008,
198,
437,
198,
35235,
7203,
19930,
24429,
19570,
198,
198,
37811,
198,
31337,
2482,
198,
37811,
198,
198,
43420,
796,
9483,
62,
13116,
7,
19608,
324,
343,
7203,
43420,
1600,
366,
9288,
1600,
366,
29127,
62,
45573,
15341,
8246,
62,
20274,
62,
18747,
28,
9562,
1776,
198,
9460,
62,
411,
796,
5794,
62,
20274,
62,
11487,
7,
43420,
13,
43420,
26,
399,
28,
45,
62,
14323,
8,
198,
198,
2,
1262,
5313,
9399,
198,
85,
1416,
9043,
271,
1759,
7,
9460,
62,
411,
8,
628
] | 2.358804 | 1,204 |
"""
NUTS(n_iters::Int, n_adapts::Int, delta::Float64)
No-U-Turn Sampler (NUTS) sampler.
Usage:
```julia
NUTS(1000, 200, 0.6j_max)
```
Arguments:
- `n_iters::Int` : The number of samples to pull.
- `n_adapts::Int` : The number of samples to use with adapatation.
- `delta::Float64` : Target acceptance rate.
Example:
```julia
# Define a simple Normal model with unknown mean and variance.
@model gdemo(x) = begin
s ~ InverseGamma(2,3)
m ~ Normal(0, sqrt(s))
x[1] ~ Normal(m, sqrt(s))
x[2] ~ Normal(m, sqrt(s))
return s, m
end
sample(gdemo([1.j_max, 2]), NUTS(1000, 200, 0.6j_max))
```
"""
mutable struct NUTS{AD, T} <: AdaptiveHamiltonian{AD}
n_iters :: Int # number of samples
n_adapts :: Int # number of samples with adaption for epsilon
delta :: Float64 # target accept rate
space :: Set{T} # sampling space, emtpy means all
gid :: Int # group ID
end
NUTS(args...; kwargs...) = NUTS{ADBackend()}(args...; kwargs...)
function NUTS{AD}(n_adapts::Int, delta::Float64, space...) where AD
_space = isa(space, Symbol) ? Set([space]) : Set(space)
NUTS{AD, eltype(_space)}(1, n_adapts, delta, _space, 0)
end
function NUTS{AD}(n_iters::Int, n_adapts::Int, delta::Float64, space...) where AD
_space = isa(space, Symbol) ? Set([space]) : Set(space)
NUTS{AD, eltype(_space)}(n_iters, n_adapts, delta, _space, 0)
end
function NUTS{AD}(n_iters::Int, delta::Float64) where AD
n_adapts_default = Int(round(n_iters / 2))
NUTS{AD, Any}(n_iters, n_adapts_default > 1000 ? 1000 : n_adapts_default, delta, Set(), 0)
end
function NUTS{AD1}(alg::NUTS{AD2, T}, new_gid::Int) where {AD1, AD2, T}
NUTS{AD1, T}(alg.n_iters, alg.n_adapts, alg.delta, alg.space, new_gid)
end
function NUTS{AD, T}(alg::NUTS, new_gid::Int) where {AD, T}
NUTS{AD, T}(alg.n_iters, alg.n_adapts, alg.delta, alg.space, new_gid)
end
function hmc_step(θ, lj, lj_func, grad_func, H_func, ϵ, alg::NUTS, momentum_sampler::Function;
rev_func=nothing, log_func=nothing)
θ_new, α = _nuts_step(θ, ϵ, lj, lj_func, grad_func, H_func, momentum_sampler)
lj_new = lj_func(θ_new)
is_accept = true
return θ_new, lj_new, is_accept, α
end
"""
function _build_tree(θ::T, r::AbstractVector, logu::AbstractFloat, v::Int, j::Int, ϵ::AbstractFloat,
H0::AbstractFloat,lj_func::Function, grad_func::Function, H_func::Function;
Δ_max::AbstractFloat=1000) where {T<:Union{Vector,SubArray}}
Recursively build balanced tree.
Ref: Algorithm 6 on http://www.stat.columbia.edu/~gelman/research/published/nuts.pdf
Arguments:
- `θ` : model parameter
- `r` : momentum variable
- `logu` : slice variable (in log scale)
- `v` : direction ∈ {-1, 1}
- `j` : depth of tree
- `ϵ` : leapfrog step size
- `H0` : initial H
- `lj_func` : function for log-joint
- `grad_func` : function for the gradient of log-joint
- `H_func` : function for Hamiltonian energy
- `Δ_max` : threshold for exploeration error tolerance
"""
function _build_tree(θ::T, r::AbstractVector, logu::AbstractFloat, v::Int, j::Int, ϵ::AbstractFloat,
H0::AbstractFloat, lj_func::Function, grad_func::Function, H_func::Function;
Δ_max::AbstractFloat=1000.0) where {T<:Union{AbstractVector,SubArray}}
if j == 0
# Base case - take one leapfrog step in the direction v.
θ′, r′, τ_valid = _leapfrog(θ, r, 1, v * ϵ, grad_func)
# Use old H to save computation
H′ = τ_valid == 0 ? Inf : H_func(θ′, r′, lj_func(θ′))
n′ = (logu <= -H′) ? 1 : 0
s′ = (logu < Δ_max + -H′) ? 1 : 0
α′ = exp(min(0, -H′ - (-H0)))
return θ′, r′, θ′, r′, θ′, n′, s′, α′, 1
else
# Recursion - build the left and right subtrees.
θm, rm, θp, rp, θ′, n′, s′, α′, n′α = _build_tree(θ, r, logu, v, j - 1, ϵ, H0, lj_func, grad_func, H_func)
if s′ == 1
if v == -1
θm, rm, _, _, θ′′, n′′, s′′, α′′, n′′α = _build_tree(θm, rm, logu, v, j - 1, ϵ, H0, lj_func, grad_func, H_func)
else
_, _, θp, rp, θ′′, n′′, s′′, α′′, n′′α = _build_tree(θp, rp, logu, v, j - 1, ϵ, H0, lj_func, grad_func, H_func)
end
if rand() < n′′ / (n′ + n′′)
θ′ = θ′′
end
α′ = α′ + α′′
n′α = n′α + n′′α
s′ = s′′ * (dot(θp - θm, rm) >= 0 ? 1 : 0) * (dot(θp - θm, rp) >= 0 ? 1 : 0)
n′ = n′ + n′′
end
θm, rm, θp, rp, θ′, n′, s′, α′, n′α
end
end
"""
function _nuts_step(θ::T, r0, ϵ::AbstractFloat, lj_func::Function, grad_func::Function, H_func::Function;
j_max::Int=j_max) where {T<:Union{AbstractVector,SubArray}}
Perform one NUTS step.
Ref: Algorithm 6 on http://www.stat.columbia.edu/~gelman/research/published/nuts.pdf
Arguments:
- `θ` : model parameter
- `ϵ` : leapfrog step size
- `lj` : initial log-joint prob
- `lj_func` : function for log-joint
- `grad_func` : function for the gradient of log-joint
- `H_func` : function for Hamiltonian energy
- `j_max` : maximum expanding of doubling tree
"""
function _nuts_step(θ::T, ϵ::AbstractFloat, lj::Real,
lj_func::Function, grad_func::Function, H_func::Function, momentum_sampler::Function;
j_max::Int=5) where {T<:Union{AbstractVector,SubArray}}
@debug "sampling momentums..."
θ_dim = length(θ)
r0 = momentum_sampler()
H0 = H_func(θ, r0, lj)
logu = log(rand()) + -H0
θm = θ; θp = θ; rm = r0; rp = r0; j = 0; θ_new = θ; n = 1; s = 1
local da_stat
while s == 1 && j <= j_max
v = rand([-1, 1])
if v == -1
θm, rm, _, _, θ′, n′, s′, α, nα = _build_tree(θm, rm, logu, v, j, ϵ, H0, lj_func, grad_func, H_func)
else
_, _, θp, rp, θ′, n′, s′, α, nα = _build_tree(θp, rp, logu, v, j, ϵ, H0, lj_func, grad_func, H_func)
end
if s′ == 1
if rand() < min(1, n′ / n)
θ_new = θ′
end
end
n = n + n′
s = s′ * (dot(θp - θm, rm) >= 0 ? 1 : 0) * (dot(θp - θm, rp) >= 0 ? 1 : 0)
j = j + 1
da_stat = α / nα
end
return θ_new, da_stat
end
| [
37811,
198,
220,
220,
220,
399,
3843,
50,
7,
77,
62,
270,
364,
3712,
5317,
11,
299,
62,
42552,
82,
3712,
5317,
11,
25979,
3712,
43879,
2414,
8,
198,
198,
2949,
12,
52,
12,
17278,
3409,
20053,
357,
45,
3843,
50,
8,
6072,
20053,
13,
198,
198,
28350,
25,
198,
198,
15506,
63,
73,
43640,
198,
45,
3843,
50,
7,
12825,
11,
939,
11,
657,
13,
21,
73,
62,
9806,
8,
198,
15506,
63,
198,
198,
28100,
2886,
25,
198,
198,
12,
4600,
77,
62,
270,
364,
3712,
5317,
63,
1058,
383,
1271,
286,
8405,
284,
2834,
13,
198,
12,
4600,
77,
62,
42552,
82,
3712,
5317,
63,
1058,
383,
1271,
286,
8405,
284,
779,
351,
512,
499,
265,
341,
13,
198,
12,
4600,
67,
12514,
3712,
43879,
2414,
63,
1058,
12744,
13427,
2494,
13,
198,
198,
16281,
25,
198,
198,
15506,
63,
73,
43640,
198,
2,
2896,
500,
257,
2829,
14435,
2746,
351,
6439,
1612,
290,
24198,
13,
198,
31,
19849,
308,
9536,
78,
7,
87,
8,
796,
2221,
198,
220,
264,
5299,
554,
4399,
34777,
2611,
7,
17,
11,
18,
8,
198,
220,
285,
5299,
14435,
7,
15,
11,
19862,
17034,
7,
82,
4008,
198,
220,
2124,
58,
16,
60,
5299,
14435,
7,
76,
11,
19862,
17034,
7,
82,
4008,
198,
220,
2124,
58,
17,
60,
5299,
14435,
7,
76,
11,
19862,
17034,
7,
82,
4008,
198,
220,
1441,
264,
11,
285,
198,
437,
198,
198,
39873,
7,
70,
9536,
78,
26933,
16,
13,
73,
62,
9806,
11,
362,
46570,
399,
3843,
50,
7,
12825,
11,
939,
11,
657,
13,
21,
73,
62,
9806,
4008,
198,
15506,
63,
198,
37811,
198,
76,
18187,
2878,
399,
3843,
50,
90,
2885,
11,
309,
92,
1279,
25,
30019,
425,
45405,
666,
90,
2885,
92,
198,
220,
220,
220,
299,
62,
270,
364,
220,
220,
7904,
220,
2558,
220,
220,
220,
220,
220,
220,
1303,
1271,
286,
8405,
198,
220,
220,
220,
299,
62,
42552,
82,
220,
7904,
220,
2558,
220,
220,
220,
220,
220,
220,
1303,
1271,
286,
8405,
351,
512,
64,
1159,
329,
304,
862,
33576,
198,
220,
220,
220,
25979,
220,
220,
220,
220,
7904,
220,
48436,
2414,
220,
220,
1303,
2496,
2453,
2494,
198,
220,
220,
220,
2272,
220,
220,
220,
220,
7904,
220,
5345,
90,
51,
92,
220,
220,
220,
1303,
19232,
2272,
11,
795,
83,
9078,
1724,
477,
198,
220,
220,
220,
308,
312,
220,
220,
220,
220,
220,
220,
7904,
220,
2558,
220,
220,
220,
220,
220,
220,
1303,
1448,
4522,
198,
437,
198,
45,
3843,
50,
7,
22046,
986,
26,
479,
86,
22046,
23029,
796,
399,
3843,
50,
90,
2885,
7282,
437,
3419,
92,
7,
22046,
986,
26,
479,
86,
22046,
23029,
198,
8818,
399,
3843,
50,
90,
2885,
92,
7,
77,
62,
42552,
82,
3712,
5317,
11,
25979,
3712,
43879,
2414,
11,
2272,
23029,
810,
5984,
198,
220,
220,
220,
4808,
13200,
796,
318,
64,
7,
13200,
11,
38357,
8,
5633,
5345,
26933,
13200,
12962,
1058,
5345,
7,
13200,
8,
198,
220,
220,
220,
399,
3843,
50,
90,
2885,
11,
1288,
4906,
28264,
13200,
38165,
7,
16,
11,
299,
62,
42552,
82,
11,
25979,
11,
4808,
13200,
11,
657,
8,
198,
437,
198,
8818,
399,
3843,
50,
90,
2885,
92,
7,
77,
62,
270,
364,
3712,
5317,
11,
299,
62,
42552,
82,
3712,
5317,
11,
25979,
3712,
43879,
2414,
11,
2272,
23029,
810,
5984,
198,
220,
220,
220,
4808,
13200,
796,
318,
64,
7,
13200,
11,
38357,
8,
5633,
5345,
26933,
13200,
12962,
1058,
5345,
7,
13200,
8,
198,
220,
220,
220,
399,
3843,
50,
90,
2885,
11,
1288,
4906,
28264,
13200,
38165,
7,
77,
62,
270,
364,
11,
299,
62,
42552,
82,
11,
25979,
11,
4808,
13200,
11,
657,
8,
198,
437,
198,
8818,
399,
3843,
50,
90,
2885,
92,
7,
77,
62,
270,
364,
3712,
5317,
11,
25979,
3712,
43879,
2414,
8,
810,
5984,
198,
220,
220,
220,
299,
62,
42552,
82,
62,
12286,
796,
2558,
7,
744,
7,
77,
62,
270,
364,
1220,
362,
4008,
198,
220,
220,
220,
399,
3843,
50,
90,
2885,
11,
4377,
92,
7,
77,
62,
270,
364,
11,
299,
62,
42552,
82,
62,
12286,
1875,
8576,
5633,
8576,
1058,
299,
62,
42552,
82,
62,
12286,
11,
25979,
11,
5345,
22784,
657,
8,
198,
437,
198,
8818,
399,
3843,
50,
90,
2885,
16,
92,
7,
14016,
3712,
45,
3843,
50,
90,
2885,
17,
11,
309,
5512,
649,
62,
70,
312,
3712,
5317,
8,
810,
1391,
2885,
16,
11,
5984,
17,
11,
309,
92,
198,
220,
220,
220,
399,
3843,
50,
90,
2885,
16,
11,
309,
92,
7,
14016,
13,
77,
62,
270,
364,
11,
435,
70,
13,
77,
62,
42552,
82,
11,
435,
70,
13,
67,
12514,
11,
435,
70,
13,
13200,
11,
649,
62,
70,
312,
8,
198,
437,
198,
8818,
399,
3843,
50,
90,
2885,
11,
309,
92,
7,
14016,
3712,
45,
3843,
50,
11,
649,
62,
70,
312,
3712,
5317,
8,
810,
1391,
2885,
11,
309,
92,
198,
220,
220,
220,
399,
3843,
50,
90,
2885,
11,
309,
92,
7,
14016,
13,
77,
62,
270,
364,
11,
435,
70,
13,
77,
62,
42552,
82,
11,
435,
70,
13,
67,
12514,
11,
435,
70,
13,
13200,
11,
649,
62,
70,
312,
8,
198,
437,
198,
198,
8818,
289,
23209,
62,
9662,
7,
138,
116,
11,
300,
73,
11,
300,
73,
62,
20786,
11,
3915,
62,
20786,
11,
367,
62,
20786,
11,
18074,
113,
11,
435,
70,
3712,
45,
3843,
50,
11,
12858,
62,
37687,
20053,
3712,
22203,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2710,
62,
20786,
28,
22366,
11,
2604,
62,
20786,
28,
22366,
8,
198,
220,
220,
220,
7377,
116,
62,
3605,
11,
26367,
796,
4808,
31381,
62,
9662,
7,
138,
116,
11,
18074,
113,
11,
300,
73,
11,
300,
73,
62,
20786,
11,
3915,
62,
20786,
11,
367,
62,
20786,
11,
12858,
62,
37687,
20053,
8,
198,
220,
220,
220,
300,
73,
62,
3605,
796,
300,
73,
62,
20786,
7,
138,
116,
62,
3605,
8,
198,
220,
220,
220,
318,
62,
13635,
796,
2081,
198,
220,
220,
220,
1441,
7377,
116,
62,
3605,
11,
300,
73,
62,
3605,
11,
318,
62,
13635,
11,
26367,
198,
437,
198,
198,
37811,
198,
220,
2163,
4808,
11249,
62,
21048,
7,
138,
116,
3712,
51,
11,
374,
3712,
23839,
38469,
11,
2604,
84,
3712,
23839,
43879,
11,
410,
3712,
5317,
11,
474,
3712,
5317,
11,
18074,
113,
3712,
23839,
43879,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
367,
15,
3712,
23839,
43879,
11,
75,
73,
62,
20786,
3712,
22203,
11,
3915,
62,
20786,
3712,
22203,
11,
367,
62,
20786,
3712,
22203,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37455,
62,
9806,
3712,
23839,
43879,
28,
12825,
8,
810,
1391,
51,
27,
25,
38176,
90,
38469,
11,
7004,
19182,
11709,
198,
198,
6690,
1834,
2280,
1382,
12974,
5509,
13,
198,
198,
8134,
25,
978,
42289,
718,
319,
2638,
1378,
2503,
13,
14269,
13,
4033,
2178,
544,
13,
15532,
14,
93,
25280,
805,
14,
34033,
14,
30271,
14,
31381,
13,
12315,
198,
198,
28100,
2886,
25,
198,
198,
12,
4600,
138,
116,
63,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
2746,
11507,
198,
12,
4600,
81,
63,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
12858,
7885,
198,
12,
4600,
6404,
84,
63,
220,
220,
220,
220,
220,
1058,
16416,
7885,
357,
259,
2604,
5046,
8,
198,
12,
4600,
85,
63,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
4571,
18872,
230,
1391,
12,
16,
11,
352,
92,
198,
12,
4600,
73,
63,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
6795,
286,
5509,
198,
12,
4600,
139,
113,
63,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
16470,
49956,
2239,
2546,
198,
12,
4600,
39,
15,
63,
220,
220,
220,
220,
220,
220,
220,
1058,
4238,
367,
198,
12,
4600,
75,
73,
62,
20786,
63,
220,
220,
1058,
2163,
329,
2604,
12,
73,
1563,
198,
12,
4600,
9744,
62,
20786,
63,
1058,
2163,
329,
262,
31312,
286,
2604,
12,
73,
1563,
198,
12,
4600,
39,
62,
20786,
63,
220,
220,
220,
1058,
2163,
329,
11582,
666,
2568,
198,
12,
4600,
138,
242,
62,
9806,
63,
220,
220,
220,
220,
1058,
11387,
329,
6694,
263,
341,
4049,
15621,
198,
37811,
198,
8818,
4808,
11249,
62,
21048,
7,
138,
116,
3712,
51,
11,
374,
3712,
23839,
38469,
11,
2604,
84,
3712,
23839,
43879,
11,
410,
3712,
5317,
11,
474,
3712,
5317,
11,
18074,
113,
3712,
23839,
43879,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
367,
15,
3712,
23839,
43879,
11,
300,
73,
62,
20786,
3712,
22203,
11,
3915,
62,
20786,
3712,
22203,
11,
367,
62,
20786,
3712,
22203,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37455,
62,
9806,
3712,
23839,
43879,
28,
12825,
13,
15,
8,
810,
1391,
51,
27,
25,
38176,
90,
23839,
38469,
11,
7004,
19182,
11709,
198,
220,
220,
220,
611,
474,
6624,
657,
198,
220,
220,
220,
220,
220,
1303,
7308,
1339,
532,
1011,
530,
16470,
49956,
2239,
287,
262,
4571,
410,
13,
198,
220,
220,
220,
220,
220,
7377,
116,
17478,
11,
374,
17478,
11,
46651,
62,
12102,
796,
4808,
293,
499,
49956,
7,
138,
116,
11,
374,
11,
352,
11,
410,
1635,
18074,
113,
11,
3915,
62,
20786,
8,
198,
220,
220,
220,
220,
220,
1303,
5765,
1468,
367,
284,
3613,
29964,
198,
220,
220,
220,
220,
220,
367,
17478,
796,
46651,
62,
12102,
6624,
657,
5633,
4806,
1058,
367,
62,
20786,
7,
138,
116,
17478,
11,
374,
17478,
11,
300,
73,
62,
20786,
7,
138,
116,
17478,
4008,
198,
220,
220,
220,
220,
220,
299,
17478,
796,
357,
6404,
84,
19841,
532,
39,
17478,
8,
5633,
352,
1058,
657,
198,
220,
220,
220,
220,
220,
264,
17478,
796,
357,
6404,
84,
1279,
37455,
62,
9806,
1343,
532,
39,
17478,
8,
5633,
352,
1058,
657,
198,
220,
220,
220,
220,
220,
26367,
17478,
796,
1033,
7,
1084,
7,
15,
11,
532,
39,
17478,
532,
13841,
39,
15,
22305,
628,
220,
220,
220,
220,
220,
1441,
7377,
116,
17478,
11,
374,
17478,
11,
7377,
116,
17478,
11,
374,
17478,
11,
7377,
116,
17478,
11,
299,
17478,
11,
264,
17478,
11,
26367,
17478,
11,
352,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
1303,
3311,
24197,
532,
1382,
262,
1364,
290,
826,
13284,
6037,
13,
198,
220,
220,
220,
220,
220,
7377,
116,
76,
11,
42721,
11,
7377,
116,
79,
11,
374,
79,
11,
7377,
116,
17478,
11,
299,
17478,
11,
264,
17478,
11,
26367,
17478,
11,
299,
17478,
17394,
796,
4808,
11249,
62,
21048,
7,
138,
116,
11,
374,
11,
2604,
84,
11,
410,
11,
474,
532,
352,
11,
18074,
113,
11,
367,
15,
11,
300,
73,
62,
20786,
11,
3915,
62,
20786,
11,
367,
62,
20786,
8,
628,
220,
220,
220,
220,
220,
611,
264,
17478,
6624,
352,
198,
220,
220,
220,
220,
220,
220,
220,
611,
410,
6624,
532,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7377,
116,
76,
11,
42721,
11,
4808,
11,
4808,
11,
7377,
116,
17478,
17478,
11,
299,
17478,
17478,
11,
264,
17478,
17478,
11,
26367,
17478,
17478,
11,
299,
17478,
17478,
17394,
796,
4808,
11249,
62,
21048,
7,
138,
116,
76,
11,
42721,
11,
2604,
84,
11,
410,
11,
474,
532,
352,
11,
18074,
113,
11,
367,
15,
11,
300,
73,
62,
20786,
11,
3915,
62,
20786,
11,
367,
62,
20786,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4808,
11,
4808,
11,
7377,
116,
79,
11,
374,
79,
11,
7377,
116,
17478,
17478,
11,
299,
17478,
17478,
11,
264,
17478,
17478,
11,
26367,
17478,
17478,
11,
299,
17478,
17478,
17394,
796,
4808,
11249,
62,
21048,
7,
138,
116,
79,
11,
374,
79,
11,
2604,
84,
11,
410,
11,
474,
532,
352,
11,
18074,
113,
11,
367,
15,
11,
300,
73,
62,
20786,
11,
3915,
62,
20786,
11,
367,
62,
20786,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
611,
43720,
3419,
1279,
299,
17478,
17478,
1220,
357,
77,
17478,
1343,
299,
17478,
17478,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7377,
116,
17478,
796,
7377,
116,
17478,
17478,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
26367,
17478,
796,
26367,
17478,
1343,
26367,
17478,
17478,
198,
220,
220,
220,
220,
220,
220,
220,
299,
17478,
17394,
796,
299,
17478,
17394,
1343,
299,
17478,
17478,
17394,
198,
220,
220,
220,
220,
220,
220,
220,
264,
17478,
796,
264,
17478,
17478,
1635,
357,
26518,
7,
138,
116,
79,
532,
7377,
116,
76,
11,
42721,
8,
18189,
657,
5633,
352,
1058,
657,
8,
1635,
357,
26518,
7,
138,
116,
79,
532,
7377,
116,
76,
11,
374,
79,
8,
18189,
657,
5633,
352,
1058,
657,
8,
198,
220,
220,
220,
220,
220,
220,
220,
299,
17478,
796,
299,
17478,
1343,
299,
17478,
17478,
198,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
7377,
116,
76,
11,
42721,
11,
7377,
116,
79,
11,
374,
79,
11,
7377,
116,
17478,
11,
299,
17478,
11,
264,
17478,
11,
26367,
17478,
11,
299,
17478,
17394,
198,
220,
220,
220,
886,
198,
220,
886,
628,
198,
37811,
198,
220,
2163,
4808,
31381,
62,
9662,
7,
138,
116,
3712,
51,
11,
374,
15,
11,
18074,
113,
3712,
23839,
43879,
11,
300,
73,
62,
20786,
3712,
22203,
11,
3915,
62,
20786,
3712,
22203,
11,
367,
62,
20786,
3712,
22203,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
474,
62,
9806,
3712,
5317,
28,
73,
62,
9806,
8,
810,
1391,
51,
27,
25,
38176,
90,
23839,
38469,
11,
7004,
19182,
11709,
198,
198,
5990,
687,
530,
399,
3843,
50,
2239,
13,
198,
198,
8134,
25,
978,
42289,
718,
319,
2638,
1378,
2503,
13,
14269,
13,
4033,
2178,
544,
13,
15532,
14,
93,
25280,
805,
14,
34033,
14,
30271,
14,
31381,
13,
12315,
198,
198,
28100,
2886,
25,
198,
198,
12,
4600,
138,
116,
63,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
2746,
11507,
198,
12,
4600,
139,
113,
63,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
16470,
49956,
2239,
2546,
198,
12,
4600,
75,
73,
63,
220,
220,
220,
220,
220,
220,
220,
1058,
4238,
2604,
12,
73,
1563,
1861,
198,
12,
4600,
75,
73,
62,
20786,
63,
220,
220,
1058,
2163,
329,
2604,
12,
73,
1563,
198,
12,
4600,
9744,
62,
20786,
63,
1058,
2163,
329,
262,
31312,
286,
2604,
12,
73,
1563,
198,
12,
4600,
39,
62,
20786,
63,
220,
220,
220,
1058,
2163,
329,
11582,
666,
2568,
198,
12,
4600,
73,
62,
9806,
63,
220,
220,
220,
220,
1058,
5415,
11581,
286,
26862,
5509,
198,
37811,
198,
8818,
4808,
31381,
62,
9662,
7,
138,
116,
3712,
51,
11,
18074,
113,
3712,
23839,
43879,
11,
300,
73,
3712,
15633,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
300,
73,
62,
20786,
3712,
22203,
11,
3915,
62,
20786,
3712,
22203,
11,
367,
62,
20786,
3712,
22203,
11,
12858,
62,
37687,
20053,
3712,
22203,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
474,
62,
9806,
3712,
5317,
28,
20,
8,
810,
1391,
51,
27,
25,
38176,
90,
23839,
38469,
11,
7004,
19182,
11709,
628,
220,
2488,
24442,
366,
37687,
11347,
2589,
5700,
9313,
198,
220,
7377,
116,
62,
27740,
796,
4129,
7,
138,
116,
8,
198,
220,
374,
15,
796,
12858,
62,
37687,
20053,
3419,
628,
220,
367,
15,
796,
367,
62,
20786,
7,
138,
116,
11,
374,
15,
11,
300,
73,
8,
198,
220,
2604,
84,
796,
2604,
7,
25192,
28955,
1343,
532,
39,
15,
628,
220,
7377,
116,
76,
796,
7377,
116,
26,
7377,
116,
79,
796,
7377,
116,
26,
42721,
796,
374,
15,
26,
374,
79,
796,
374,
15,
26,
474,
796,
657,
26,
7377,
116,
62,
3605,
796,
7377,
116,
26,
299,
796,
352,
26,
264,
796,
352,
198,
220,
1957,
12379,
62,
14269,
628,
220,
981,
264,
6624,
352,
11405,
474,
19841,
474,
62,
9806,
628,
220,
220,
220,
410,
796,
43720,
26933,
12,
16,
11,
352,
12962,
198,
220,
220,
220,
611,
410,
6624,
532,
16,
198,
220,
220,
220,
220,
220,
220,
220,
7377,
116,
76,
11,
42721,
11,
4808,
11,
4808,
11,
7377,
116,
17478,
11,
299,
17478,
11,
264,
17478,
11,
26367,
11,
299,
17394,
796,
4808,
11249,
62,
21048,
7,
138,
116,
76,
11,
42721,
11,
2604,
84,
11,
410,
11,
474,
11,
18074,
113,
11,
367,
15,
11,
300,
73,
62,
20786,
11,
3915,
62,
20786,
11,
367,
62,
20786,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
11,
4808,
11,
7377,
116,
79,
11,
374,
79,
11,
7377,
116,
17478,
11,
299,
17478,
11,
264,
17478,
11,
26367,
11,
299,
17394,
796,
4808,
11249,
62,
21048,
7,
138,
116,
79,
11,
374,
79,
11,
2604,
84,
11,
410,
11,
474,
11,
18074,
113,
11,
367,
15,
11,
300,
73,
62,
20786,
11,
3915,
62,
20786,
11,
367,
62,
20786,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
264,
17478,
6624,
352,
198,
220,
220,
220,
220,
220,
220,
220,
611,
43720,
3419,
1279,
949,
7,
16,
11,
299,
17478,
1220,
299,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7377,
116,
62,
3605,
796,
7377,
116,
17478,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
299,
796,
299,
1343,
299,
17478,
198,
220,
220,
220,
264,
796,
264,
17478,
1635,
357,
26518,
7,
138,
116,
79,
532,
7377,
116,
76,
11,
42721,
8,
18189,
657,
5633,
352,
1058,
657,
8,
1635,
357,
26518,
7,
138,
116,
79,
532,
7377,
116,
76,
11,
374,
79,
8,
18189,
657,
5633,
352,
1058,
657,
8,
198,
220,
220,
220,
474,
796,
474,
1343,
352,
628,
220,
220,
220,
12379,
62,
14269,
796,
26367,
1220,
299,
17394,
628,
220,
886,
628,
220,
1441,
7377,
116,
62,
3605,
11,
12379,
62,
14269,
198,
198,
437,
198
] | 1.987476 | 3,114 |
<filename>test/test-utils.jl
##### Beginning of file
Test.@testset "git tests" begin
git = MirrorUpdater.Utils._get_git_binary_path()
@info(string("git: "), git,)
git_version_cmd = `$(git) --version`
@info(string("Attempting to run command: "), git_version_cmd,)
Test.@test(
MirrorUpdater.Utils.command_ran_successfully!!(
git_version_cmd
)
)
Test.@test(
MirrorUpdater.Utils.command_ran_successfully!!(
`$(git) --version`
)
)
Test.@test_throws(
ErrorException,
MirrorUpdater.Utils.command_ran_successfully!!(
`$(git) --versionBLAHBLAHBLAH`;
max_attempts = 5,
seconds_to_wait_between_attempts = 5,
error_on_failure = true,
last_resort_run = true,
),
)
Test.@test_throws(
ErrorException,
MirrorUpdater.Utils.command_ran_successfully!!(
`$(git) --versionBLAHBLAHBLAH`;
max_attempts = 5,
seconds_to_wait_between_attempts = 5,
error_on_failure = true,
last_resort_run = false,
),
)
Test.@test_throws(
ErrorException,
MirrorUpdater.Utils.command_ran_successfully!!(
`$(git) --versionBLAHBLAHBLAH`;
max_attempts = 5,
seconds_to_wait_between_attempts = 5,
error_on_failure = false,
last_resort_run = true,
),
)
Test.@test(
!(
MirrorUpdater.Utils.command_ran_successfully!!(
`$(git) --versionBLAHBLAHBLAH`;
max_attempts = 5,
seconds_to_wait_between_attempts = 5,
error_on_failure = false,
last_resort_run = false,
)
)
)
function f_1()
return "Hello There"
end
Test.@test(
"Hello There" ==
MirrorUpdater.Utils.retry_function_until_success(
() -> f_1()
)
)
f_2_counter = Ref{Int}()
f_2_counter[] = 0
function f_2(counter)
counter[] += 1
@debug(
string(
"Incremented counter from ",
"$(counter[] - 1) to $(counter[])",
)
)
if counter[] < 7
error("f2_counter < 7")
else
return "General Kenobi"
end
end
Test.@test(
"General Kenobi" ==
MirrorUpdater.Utils.retry_function_until_success(
() -> f_2(f_2_counter);
max_attempts = 10,
seconds_to_wait_between_attempts = 5,
)
)
function f_3()
error("f_3() will always fail")
end
Test.@test_throws(
ErrorException,
MirrorUpdater.Utils.retry_function_until_success(
()->f_3();
max_attempts = 5,
seconds_to_wait_between_attempts = 5,
),
)
previous_directory::String = pwd()
temp_directory_1::String = joinpath(mktempdir(), "TEMPGITREPOLOCAL")
mkpath(temp_directory_1)
temp_directory_2::String = joinpath(mktempdir(), "TEMPGITREPOREMOTE")
mkpath(temp_directory_2)
cd(temp_directory_2)
run(`$(git) init --bare`)
cd(temp_directory_1)
run(`$(git) init`)
MirrorUpdater.Utils.git_add_all!()
MirrorUpdater.Utils.git_commit!(
;
message="test commit 1",
allow_empty=true,
committer_name="test name",
committer_email="test email",
)
run(`git branch branch1`)
run(`git branch branch2`)
run(`git branch branch3`)
run(`git checkout master`)
Test.@test(
typeof(MirrorUpdater.Utils.git_version()) <: VersionNumber
)
Test.@test(
typeof(MirrorUpdater.Utils.get_all_branches_local()) <:
Vector{String}
)
Test.@test(
typeof(MirrorUpdater.Utils.get_all_branches_local_and_remote()) <:
Vector{String}
)
Test.@test(
typeof(MirrorUpdater.Utils.get_current_branch()) <: String )
Test.@test(
MirrorUpdater.Utils.branch_exists("branch1") )
Test.@test(
!MirrorUpdater.Utils.branch_exists("non-existent-branch") )
Test.@test(
!MirrorUpdater.Utils.branch_exists("non-existent-but-create-me") )
Test.@test(
typeof(MirrorUpdater.Utils.checkout_branch!("branch1")) <: Nothing )
Test.@test_throws(
ErrorException,
MirrorUpdater.Utils.checkout_branch!("non-existent-branch"),
)
Test.@test_warn(
"",
MirrorUpdater.Utils.checkout_branch!(
"non-existent-branch";
error_on_failure=false,
),
)
Test.@test(
typeof(
MirrorUpdater.Utils.checkout_branch!(
"non-existent-but-create-me";
create=true,
)
) <: Nothing
)
MirrorUpdater.Utils.git_add_all!()
MirrorUpdater.Utils.git_commit!(
;
message="test commit 2",
allow_empty=true,
committer_name="<NAME>",
committer_email="test email",
)
run(`git checkout master`)
Test.@test(
MirrorUpdater.Utils.branch_exists("branch1")
)
Test.@test(
!MirrorUpdater.Utils.branch_exists("non-existent-branch")
)
Test.@test(
MirrorUpdater.Utils.branch_exists("non-existent-but-create-me")
)
run(`$(git) remote add origin $(temp_directory_2)`)
Test.@test(
typeof(MirrorUpdater.Utils.git_push_upstream_all!()) <: Nothing
)
run(`git checkout master`)
include_patterns::Vector{Regex} = Regex[
r"^bRANCh1$"i,
r"^bRanCh3$"i,
]
exclude_patterns::Vector{Regex} = Regex[
r"^brANcH3$"i,
]
branches_to_snapshot::Vector{String} =
MirrorUpdater.Utils.make_list_of_branches_to_snapshot(
;
default_branch = "maSTeR",
include = include_patterns,
exclude = exclude_patterns,
)
Test.@test( length(branches_to_snapshot) == 2 )
Test.@test( length(unique(branches_to_snapshot)) == 2 )
Test.@test(
length(branches_to_snapshot) == length(unique(branches_to_snapshot))
)
Test.@test( branches_to_snapshot[1] == "branch1" )
Test.@test( branches_to_snapshot[2] == "master" )
cd(previous_directory)
MirrorUpdater.Utils.delete_everything_except_dot_git!(temp_directory_1)
MirrorUpdater.Utils.delete_only_dot_git!(temp_directory_2)
rm(temp_directory_1; recursive=true, force=true)
rm(temp_directory_2; recursive=true, force=true)
end # end testset "git tests"
##### End of file
| [
27,
34345,
29,
9288,
14,
9288,
12,
26791,
13,
20362,
198,
4242,
2,
25976,
286,
2393,
198,
198,
14402,
13,
31,
9288,
2617,
366,
18300,
5254,
1,
2221,
628,
220,
220,
220,
17606,
796,
17918,
4933,
67,
729,
13,
18274,
4487,
13557,
1136,
62,
18300,
62,
39491,
62,
6978,
3419,
198,
220,
220,
220,
2488,
10951,
7,
8841,
7203,
18300,
25,
366,
828,
17606,
35751,
628,
220,
220,
220,
17606,
62,
9641,
62,
28758,
796,
4600,
3,
7,
18300,
8,
1377,
9641,
63,
198,
220,
220,
220,
2488,
10951,
7,
8841,
7203,
37177,
278,
284,
1057,
3141,
25,
366,
828,
17606,
62,
9641,
62,
28758,
35751,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
21812,
62,
2596,
62,
37351,
3228,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17606,
62,
9641,
62,
28758,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
21812,
62,
2596,
62,
37351,
3228,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4600,
3,
7,
18300,
8,
1377,
9641,
63,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
6208,
13,
31,
9288,
62,
400,
8516,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13047,
16922,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
21812,
62,
2596,
62,
37351,
3228,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4600,
3,
7,
18300,
8,
1377,
9641,
9148,
18429,
9148,
18429,
9148,
18429,
63,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4201,
62,
1462,
62,
17077,
62,
23395,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
62,
261,
62,
32165,
495,
796,
2081,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
938,
62,
411,
419,
62,
5143,
796,
2081,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
6208,
13,
31,
9288,
62,
400,
8516,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13047,
16922,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
21812,
62,
2596,
62,
37351,
3228,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4600,
3,
7,
18300,
8,
1377,
9641,
9148,
18429,
9148,
18429,
9148,
18429,
63,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4201,
62,
1462,
62,
17077,
62,
23395,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
62,
261,
62,
32165,
495,
796,
2081,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
938,
62,
411,
419,
62,
5143,
796,
3991,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
6208,
13,
31,
9288,
62,
400,
8516,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13047,
16922,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
21812,
62,
2596,
62,
37351,
3228,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4600,
3,
7,
18300,
8,
1377,
9641,
9148,
18429,
9148,
18429,
9148,
18429,
63,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4201,
62,
1462,
62,
17077,
62,
23395,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
62,
261,
62,
32165,
495,
796,
3991,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
938,
62,
411,
419,
62,
5143,
796,
2081,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5145,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
21812,
62,
2596,
62,
37351,
3228,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4600,
3,
7,
18300,
8,
1377,
9641,
9148,
18429,
9148,
18429,
9148,
18429,
63,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4201,
62,
1462,
62,
17077,
62,
23395,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
62,
261,
62,
32165,
495,
796,
3991,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
938,
62,
411,
419,
62,
5143,
796,
3991,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
2163,
277,
62,
16,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
366,
15496,
1318,
1,
198,
220,
220,
220,
886,
628,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15496,
1318,
1,
6624,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
1186,
563,
62,
8818,
62,
28446,
62,
13138,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7499,
4613,
277,
62,
16,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
277,
62,
17,
62,
24588,
796,
6524,
90,
5317,
92,
3419,
198,
220,
220,
220,
277,
62,
17,
62,
24588,
21737,
796,
657,
198,
220,
220,
220,
2163,
277,
62,
17,
7,
24588,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3753,
21737,
15853,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
24442,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4731,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15562,
12061,
3753,
422,
33172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17971,
7,
24588,
21737,
532,
352,
8,
284,
29568,
24588,
58,
12962,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
3753,
21737,
1279,
767,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
69,
17,
62,
24588,
1279,
767,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
366,
12218,
46217,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
12218,
46217,
1,
6624,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
1186,
563,
62,
8818,
62,
28446,
62,
13138,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7499,
4613,
277,
62,
17,
7,
69,
62,
17,
62,
24588,
1776,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
1078,
1791,
82,
796,
838,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4201,
62,
1462,
62,
17077,
62,
23395,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
2163,
277,
62,
18,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
69,
62,
18,
3419,
481,
1464,
2038,
4943,
198,
220,
220,
220,
886,
628,
220,
220,
220,
6208,
13,
31,
9288,
62,
400,
8516,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13047,
16922,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
1186,
563,
62,
8818,
62,
28446,
62,
13138,
7,
198,
220,
220,
220,
220,
220,
220,
220,
7499,
3784,
69,
62,
18,
9783,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
4201,
62,
1462,
62,
17077,
62,
23395,
62,
1078,
1791,
82,
796,
642,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
2180,
62,
34945,
3712,
10100,
796,
279,
16993,
3419,
198,
220,
220,
220,
20218,
62,
34945,
62,
16,
3712,
10100,
796,
4654,
6978,
7,
28015,
29510,
15908,
22784,
366,
51,
3620,
6968,
2043,
35316,
3535,
4503,
1847,
4943,
198,
220,
220,
220,
33480,
6978,
7,
29510,
62,
34945,
62,
16,
8,
198,
220,
220,
220,
20218,
62,
34945,
62,
17,
3712,
10100,
796,
4654,
6978,
7,
28015,
29510,
15908,
22784,
366,
51,
3620,
6968,
2043,
35316,
1581,
36862,
4943,
198,
220,
220,
220,
33480,
6978,
7,
29510,
62,
34945,
62,
17,
8,
198,
220,
220,
220,
22927,
7,
29510,
62,
34945,
62,
17,
8,
198,
220,
220,
220,
1057,
7,
63,
3,
7,
18300,
8,
2315,
1377,
49382,
63,
8,
198,
220,
220,
220,
22927,
7,
29510,
62,
34945,
62,
16,
8,
198,
220,
220,
220,
1057,
7,
63,
3,
7,
18300,
8,
2315,
63,
8,
198,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
18300,
62,
2860,
62,
439,
0,
3419,
198,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
18300,
62,
41509,
0,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2162,
198,
220,
220,
220,
220,
220,
220,
220,
3275,
2625,
9288,
4589,
352,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
1249,
62,
28920,
28,
7942,
11,
198,
220,
220,
220,
220,
220,
220,
220,
725,
1967,
62,
3672,
2625,
9288,
1438,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
725,
1967,
62,
12888,
2625,
9288,
3053,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
1057,
7,
63,
18300,
8478,
8478,
16,
63,
8,
198,
220,
220,
220,
1057,
7,
63,
18300,
8478,
8478,
17,
63,
8,
198,
220,
220,
220,
1057,
7,
63,
18300,
8478,
8478,
18,
63,
8,
198,
220,
220,
220,
1057,
7,
63,
18300,
28006,
4958,
63,
8,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2099,
1659,
7,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
18300,
62,
9641,
28955,
1279,
25,
10628,
15057,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2099,
1659,
7,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
1136,
62,
439,
62,
1671,
12140,
62,
12001,
28955,
1279,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
20650,
90,
10100,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2099,
1659,
7,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
1136,
62,
439,
62,
1671,
12140,
62,
12001,
62,
392,
62,
47960,
28955,
1279,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
20650,
90,
10100,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2099,
1659,
7,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
1136,
62,
14421,
62,
1671,
3702,
28955,
1279,
25,
10903,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
1671,
3702,
62,
1069,
1023,
7203,
1671,
3702,
16,
4943,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
5145,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
1671,
3702,
62,
1069,
1023,
7203,
13159,
12,
32786,
12,
1671,
3702,
4943,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
5145,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
1671,
3702,
62,
1069,
1023,
7203,
13159,
12,
32786,
12,
4360,
12,
17953,
12,
1326,
4943,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2099,
1659,
7,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
9122,
448,
62,
1671,
3702,
0,
7203,
1671,
3702,
16,
48774,
1279,
25,
10528,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
62,
400,
8516,
7,
198,
220,
220,
220,
220,
220,
220,
220,
13047,
16922,
11,
198,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
9122,
448,
62,
1671,
3702,
0,
7203,
13159,
12,
32786,
12,
1671,
3702,
12340,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
62,
40539,
7,
198,
220,
220,
220,
220,
220,
220,
220,
366,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
9122,
448,
62,
1671,
3702,
0,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
13159,
12,
32786,
12,
1671,
3702,
8172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
62,
261,
62,
32165,
495,
28,
9562,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2099,
1659,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
9122,
448,
62,
1671,
3702,
0,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
13159,
12,
32786,
12,
4360,
12,
17953,
12,
1326,
8172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2251,
28,
7942,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
1279,
25,
10528,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
18300,
62,
2860,
62,
439,
0,
3419,
198,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
18300,
62,
41509,
0,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2162,
198,
220,
220,
220,
220,
220,
220,
220,
3275,
2625,
9288,
4589,
362,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
1249,
62,
28920,
28,
7942,
11,
198,
220,
220,
220,
220,
220,
220,
220,
725,
1967,
62,
3672,
2625,
27,
20608,
29,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
725,
1967,
62,
12888,
2625,
9288,
3053,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
1057,
7,
63,
18300,
28006,
4958,
63,
8,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
1671,
3702,
62,
1069,
1023,
7203,
1671,
3702,
16,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
5145,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
1671,
3702,
62,
1069,
1023,
7203,
13159,
12,
32786,
12,
1671,
3702,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
1671,
3702,
62,
1069,
1023,
7203,
13159,
12,
32786,
12,
4360,
12,
17953,
12,
1326,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
1057,
7,
63,
3,
7,
18300,
8,
6569,
751,
8159,
29568,
29510,
62,
34945,
62,
17,
8,
63,
8,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
2099,
1659,
7,
27453,
1472,
4933,
67,
729,
13,
18274,
4487,
13,
18300,
62,
14689,
62,
929,
5532,
62,
439,
0,
28955,
1279,
25,
10528,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
1057,
7,
63,
18300,
28006,
4958,
63,
8,
198,
220,
220,
220,
2291,
62,
33279,
82,
3712,
38469,
90,
3041,
25636,
92,
796,
797,
25636,
58,
198,
220,
220,
220,
220,
220,
220,
220,
374,
1,
61,
65,
49,
1565,
1925,
16,
3,
1,
72,
11,
198,
220,
220,
220,
220,
220,
220,
220,
374,
1,
61,
65,
49,
272,
1925,
18,
3,
1,
72,
11,
198,
220,
220,
220,
220,
220,
220,
220,
2361,
198,
220,
220,
220,
19607,
62,
33279,
82,
3712,
38469,
90,
3041,
25636,
92,
796,
797,
25636,
58,
198,
220,
220,
220,
220,
220,
220,
220,
374,
1,
61,
1671,
1565,
66,
39,
18,
3,
1,
72,
11,
198,
220,
220,
220,
220,
220,
220,
220,
2361,
198,
220,
220,
220,
13737,
62,
1462,
62,
45380,
9442,
3712,
38469,
90,
10100,
92,
796,
198,
220,
220,
220,
220,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
15883,
62,
4868,
62,
1659,
62,
1671,
12140,
62,
1462,
62,
45380,
9442,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2162,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4277,
62,
1671,
3702,
796,
366,
2611,
2257,
68,
49,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2291,
796,
2291,
62,
33279,
82,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19607,
796,
19607,
62,
33279,
82,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
4129,
7,
1671,
12140,
62,
1462,
62,
45380,
9442,
8,
6624,
362,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
4129,
7,
34642,
7,
1671,
12140,
62,
1462,
62,
45380,
9442,
4008,
6624,
362,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
198,
220,
220,
220,
220,
220,
220,
220,
4129,
7,
1671,
12140,
62,
1462,
62,
45380,
9442,
8,
6624,
4129,
7,
34642,
7,
1671,
12140,
62,
1462,
62,
45380,
9442,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
13737,
62,
1462,
62,
45380,
9442,
58,
16,
60,
6624,
366,
1671,
3702,
16,
1,
1267,
198,
220,
220,
220,
6208,
13,
31,
9288,
7,
13737,
62,
1462,
62,
45380,
9442,
58,
17,
60,
6624,
366,
9866,
1,
1267,
198,
220,
220,
220,
22927,
7,
3866,
1442,
62,
34945,
8,
198,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
33678,
62,
37814,
62,
16341,
62,
26518,
62,
18300,
0,
7,
29510,
62,
34945,
62,
16,
8,
198,
220,
220,
220,
17918,
4933,
67,
729,
13,
18274,
4487,
13,
33678,
62,
8807,
62,
26518,
62,
18300,
0,
7,
29510,
62,
34945,
62,
17,
8,
198,
220,
220,
220,
42721,
7,
29510,
62,
34945,
62,
16,
26,
45115,
28,
7942,
11,
2700,
28,
7942,
8,
198,
220,
220,
220,
42721,
7,
29510,
62,
34945,
62,
17,
26,
45115,
28,
7942,
11,
2700,
28,
7942,
8,
198,
198,
437,
1303,
886,
1332,
2617,
366,
18300,
5254,
1,
198,
198,
4242,
2,
5268,
286,
2393,
198
] | 1.785958 | 4,102 |
<reponame>JuliaDynamics/NonlinearDynamicsTextbook
# %% CCM illustration
using DrWatson
@quickactivate "NonlinearDynamicsTextbook"
include(srcdir("style.jl"))
using DynamicalSystems, PyPlot, Random
ds = Systems.lorenz()
tr = trajectory(ds, 100; Ttr = 100)
x, y, z = columns(tr)
τx = estimate_delay(x, "mi_min")
τy = estimate_delay(y, "mi_min")
τz = estimate_delay(z, "mi_min")
X = embed(x, 3, τx)
Y = embed(y, 3, τy)
Z = embed(z, 3, τz)
using3D()
fig = figure()
axts = fig.add_subplot(1, 3, 1)
axx = fig.add_subplot(1,3,2; projection="3d")
axy = fig.add_subplot(1,3,3; projection="3d")
axts.plot(x .- 10)
axts.plot(y .+ 20; color = "C2")
axts.set_xlim(0, 1000)
axts.set_xticklabels([])
axts.set_yticklabels([])
axx.plot3D(columns(X)...; lw = 1)
axy.plot3D(columns(Y)...; lw = 1, color = "C2")
for s in (:x, :y, :z)
f = Symbol(:set_, s, :ticklabels)
@eval axx.$(f)([])
@eval axy.$(f)([])
g = Symbol(:set_, s, :lim)
@eval axx.$(g)(-15, 15)
@eval axy.$(g)(-20, 20)
end
# Axis pretty-fication
axx.dist = 8
axy.dist = 8
axx.elev = 20
axy.elev = 20
axx.text3D(-10, -10, 15, "\$M_x\$", size = 40)
axy.text3D(-10, -10, 20, "\$M_y\$", size = 40)
axts.set_ylabel("timeseries")
axx.text(15, 12, 21, "b"; bbox = bbox, zorder = 99, va = "top")
axy.text(17, 17, 27.5, "c"; bbox = bbox, zorder = 99, va = "top")
# axy.text(45, 40, 54, "c"; bbox = bbox, zorder = 99, va = "top")
add_identifiers!(fig)
fig.tight_layout(pad=0.35)
fig.subplots_adjust(wspace = 0.2)
wsave(plotsdir("7", "ccm"), fig) | [
27,
7856,
261,
480,
29,
16980,
544,
35,
4989,
873,
14,
15419,
29127,
35,
4989,
873,
8206,
2070,
198,
2,
43313,
12624,
44,
20936,
198,
3500,
1583,
54,
13506,
198,
31,
24209,
39022,
366,
15419,
29127,
35,
4989,
873,
8206,
2070,
1,
198,
17256,
7,
10677,
15908,
7203,
7635,
13,
20362,
48774,
198,
3500,
14970,
605,
11964,
82,
11,
9485,
43328,
11,
14534,
198,
198,
9310,
796,
11998,
13,
31131,
27305,
3419,
198,
2213,
796,
22942,
7,
9310,
11,
1802,
26,
309,
2213,
796,
1802,
8,
198,
87,
11,
331,
11,
1976,
796,
15180,
7,
2213,
8,
198,
198,
32830,
87,
796,
8636,
62,
40850,
7,
87,
11,
366,
11632,
62,
1084,
4943,
198,
32830,
88,
796,
8636,
62,
40850,
7,
88,
11,
366,
11632,
62,
1084,
4943,
198,
32830,
89,
796,
8636,
62,
40850,
7,
89,
11,
366,
11632,
62,
1084,
4943,
198,
198,
55,
796,
11525,
7,
87,
11,
513,
11,
46651,
87,
8,
198,
56,
796,
11525,
7,
88,
11,
513,
11,
46651,
88,
8,
198,
57,
796,
11525,
7,
89,
11,
513,
11,
46651,
89,
8,
198,
198,
3500,
18,
35,
3419,
198,
5647,
796,
3785,
3419,
198,
64,
742,
82,
796,
2336,
13,
2860,
62,
7266,
29487,
7,
16,
11,
513,
11,
352,
8,
198,
897,
87,
796,
2336,
13,
2860,
62,
7266,
29487,
7,
16,
11,
18,
11,
17,
26,
20128,
2625,
18,
67,
4943,
198,
6969,
796,
2336,
13,
2860,
62,
7266,
29487,
7,
16,
11,
18,
11,
18,
26,
20128,
2625,
18,
67,
4943,
198,
198,
64,
742,
82,
13,
29487,
7,
87,
764,
12,
838,
8,
198,
64,
742,
82,
13,
29487,
7,
88,
764,
10,
1160,
26,
3124,
796,
366,
34,
17,
4943,
198,
64,
742,
82,
13,
2617,
62,
87,
2475,
7,
15,
11,
8576,
8,
198,
64,
742,
82,
13,
2617,
62,
742,
624,
23912,
1424,
26933,
12962,
198,
64,
742,
82,
13,
2617,
62,
20760,
624,
23912,
1424,
26933,
12962,
198,
198,
897,
87,
13,
29487,
18,
35,
7,
28665,
82,
7,
55,
26513,
26,
300,
86,
796,
352,
8,
198,
6969,
13,
29487,
18,
35,
7,
28665,
82,
7,
56,
26513,
26,
300,
86,
796,
352,
11,
3124,
796,
366,
34,
17,
4943,
198,
1640,
264,
287,
357,
25,
87,
11,
1058,
88,
11,
1058,
89,
8,
198,
220,
220,
220,
277,
796,
38357,
7,
25,
2617,
62,
11,
264,
11,
1058,
42298,
23912,
1424,
8,
198,
220,
220,
220,
2488,
18206,
257,
5324,
48082,
7,
69,
5769,
58,
12962,
198,
220,
220,
220,
2488,
18206,
257,
5431,
48082,
7,
69,
5769,
58,
12962,
198,
220,
220,
220,
308,
796,
38357,
7,
25,
2617,
62,
11,
264,
11,
1058,
2475,
8,
198,
220,
220,
220,
2488,
18206,
257,
5324,
48082,
7,
70,
5769,
12,
1314,
11,
1315,
8,
198,
220,
220,
220,
2488,
18206,
257,
5431,
48082,
7,
70,
5769,
12,
1238,
11,
1160,
8,
198,
437,
198,
198,
2,
38349,
2495,
12,
69,
3299,
198,
897,
87,
13,
17080,
796,
807,
198,
6969,
13,
17080,
796,
807,
198,
897,
87,
13,
68,
2768,
796,
1160,
198,
6969,
13,
68,
2768,
796,
1160,
198,
897,
87,
13,
5239,
18,
35,
32590,
940,
11,
532,
940,
11,
1315,
11,
37082,
3,
44,
62,
87,
59,
3,
1600,
2546,
796,
2319,
8,
198,
6969,
13,
5239,
18,
35,
32590,
940,
11,
532,
940,
11,
1160,
11,
37082,
3,
44,
62,
88,
59,
3,
1600,
2546,
796,
2319,
8,
198,
64,
742,
82,
13,
2617,
62,
2645,
9608,
7203,
22355,
10640,
4943,
198,
198,
897,
87,
13,
5239,
7,
1314,
11,
1105,
11,
2310,
11,
366,
65,
8172,
275,
3524,
796,
275,
3524,
11,
1976,
2875,
796,
7388,
11,
46935,
796,
366,
4852,
4943,
198,
6969,
13,
5239,
7,
1558,
11,
1596,
11,
2681,
13,
20,
11,
366,
66,
8172,
275,
3524,
796,
275,
3524,
11,
1976,
2875,
796,
7388,
11,
46935,
796,
366,
4852,
4943,
198,
2,
257,
5431,
13,
5239,
7,
2231,
11,
2319,
11,
7175,
11,
366,
66,
8172,
275,
3524,
796,
275,
3524,
11,
1976,
2875,
796,
7388,
11,
46935,
796,
366,
4852,
4943,
198,
198,
2860,
62,
738,
13350,
0,
7,
5647,
8,
198,
5647,
13,
33464,
62,
39786,
7,
15636,
28,
15,
13,
2327,
8,
198,
5647,
13,
7266,
489,
1747,
62,
23032,
7,
86,
13200,
796,
657,
13,
17,
8,
198,
18504,
1015,
7,
489,
1747,
15908,
7203,
22,
1600,
366,
535,
76,
12340,
2336,
8
] | 2.057221 | 734 |
<filename>src/ConstantQ.jl
__precompile__()
module ConstantQ
using Compat
export
GeometricFrequency, # geometrically spaced frequency
KernelProperty, # kernel property
SpectralKernelMatrix, # frequency-domain kernel matrix
TemporalKernelMatrix, # time-domain kernel matrix
property,
nbins_per_octave, # number of frequency bins per octave
nfreqs, # number of frequency bins
freqs, # generate array of frequencies
q, # Q-factor
speckernel, # construct frequency-domain kernel
tempkernel, # construct time-domain kernel
cqt # A fast constant-Q transform
include("cqt.jl")
end # module
| [
27,
34345,
29,
10677,
14,
3103,
18797,
48,
13,
20362,
198,
834,
3866,
5589,
576,
834,
3419,
198,
21412,
20217,
48,
198,
198,
3500,
3082,
265,
198,
198,
39344,
198,
220,
220,
220,
2269,
16996,
37,
28707,
11,
220,
220,
1303,
4903,
908,
81,
1146,
38980,
8373,
198,
220,
220,
220,
32169,
21746,
11,
220,
220,
220,
220,
220,
220,
1303,
9720,
3119,
198,
220,
220,
220,
13058,
1373,
42,
7948,
46912,
11,
1303,
8373,
12,
27830,
9720,
17593,
198,
220,
220,
220,
5825,
35738,
42,
7948,
46912,
11,
1303,
640,
12,
27830,
9720,
17593,
198,
220,
220,
220,
3119,
11,
198,
220,
220,
220,
299,
65,
1040,
62,
525,
62,
38441,
1015,
11,
220,
220,
220,
220,
1303,
1271,
286,
8373,
41701,
583,
19318,
1015,
198,
220,
220,
220,
299,
19503,
48382,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1271,
286,
8373,
41701,
198,
220,
220,
220,
2030,
48382,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
7716,
7177,
286,
19998,
198,
220,
220,
220,
10662,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1195,
12,
31412,
198,
220,
220,
220,
693,
694,
7948,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
5678,
8373,
12,
27830,
9720,
198,
220,
220,
220,
20218,
33885,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
5678,
640,
12,
27830,
9720,
198,
220,
220,
220,
269,
39568,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
317,
3049,
6937,
12,
48,
6121,
198,
198,
17256,
7203,
66,
39568,
13,
20362,
4943,
198,
198,
437,
1303,
8265,
198
] | 2.427152 | 302 |
<reponame>UnofficialJuliaMirrorSnapshots/TimeSeriesResampler.jl-209c9289-0e93-5bc3-a9c6-3b517a31ee3c
module TimeSeriesResampler
export resample, ohlc, mean, sum
export TimeFrame, Begin, End
include("resample.jl")
end # module
| [
27,
7856,
261,
480,
29,
3118,
16841,
16980,
544,
27453,
1472,
43826,
20910,
14,
7575,
27996,
4965,
321,
20053,
13,
20362,
12,
22567,
66,
24,
27693,
12,
15,
68,
6052,
12,
20,
15630,
18,
12,
64,
24,
66,
21,
12,
18,
65,
48170,
64,
3132,
1453,
18,
66,
198,
21412,
3862,
27996,
4965,
321,
20053,
198,
198,
39344,
581,
1403,
11,
11752,
44601,
11,
1612,
11,
2160,
198,
39344,
3862,
19778,
11,
16623,
11,
5268,
198,
198,
17256,
7203,
411,
1403,
13,
20362,
4943,
198,
198,
437,
1303,
8265,
198
] | 2.544444 | 90 |
<gh_stars>0
"""
# InteractiveCodeSearch.jl --- Interactively search Julia code
Julia has `@edit`, `@less`, etc. which are very handy for reading the
implementation of functions. However, you need to specify a "good
enough" set of (type) parameters for them to find the location of the
code.
Instead, `InteractiveCodeSearch` provides a few macros to
interactively choose the code you want to read.
## Features
* Interactively choose a method signature before opening the code
location in your editor.
* Various ways to search methods, such as: by function name `@search show`,
function call expression `@search show(stdout, "hello")`,
function call signature `@search show(::IO, ::String)`,
module name `@search Base`, argument value `@searchmethods 1`,
argument type `@searchmethods ::Int`, and return type `@searchreturn Int`.
* Interactively search history. It works in IJulia as well.
## Examples
```julia
using InteractiveCodeSearch
@search show # search method definitions
@searchmethods 1 # search methods defined for integer
@searchhistory # search history (Julia ≥ 0.7)
@searchreturn String Pkg # search methods returning a given type (Julia ≥ 0.7)
```
## Requirements
* Interactive matching command. For example:
* [peco](https://github.com/peco/peco) (default in terminal)
* [percol](https://github.com/mooz/percol)
* [rofi](https://github.com/DaveDavenport/rofi) (GUI; default in IJulia)
"""
module InteractiveCodeSearch
export @search, @searchmethods
import Pkg
using Base
using Base: IOError
using InteractiveUtils: edit, gen_call_with_extracted_types, methodswith
abstract type SearchPolicy end
struct Shallow <: SearchPolicy end
struct Recursive <: SearchPolicy end
mutable struct SearchConfig # CONFIG
open
interactive_matcher::Function
auto_open::Bool
end
function setmatcher!(cmd::Function, obj::SearchConfig)
obj.interactive_matcher = cmd
return
end
function setmatcher!(cmd::Cmd, obj::SearchConfig)
setmatcher!(convertCmd(cmd), obj)
end
function convertCmd(cmd)
maybe_warn_matcher(cmd)
return function (f)
maybe_warn_matcher(cmd)
f(cmd)
end
end
maybe_identifier(s) = !startswith(string(s), "#")
is_locatable(::Any) = false
is_locatable(::Function) = true
is_locatable(t::Type) = !(t <: Vararg)
# https://github.com/JuliaLang/julia/issues/29645
is_defined_in(child, parent) =
child !== parent && parentmodule(child) === parent
function list_locatables(p::SearchPolicy, m::Module)
locs = []
for s in names(m; all=true)
if maybe_identifier(s)
x = try
getfield(m, s)
catch err
err isa UndefVarError && continue
rethrow()
end
if is_locatable(x)
push!(locs, x)
elseif p isa Recursive && x isa Module && is_defined_in(x, m)
append!(locs, list_locatables(p, x))
end
end
end
return locs
end
module_methods(p::SearchPolicy, m::Module) :: Vector{Method} =
vcat(collect.(methods.(list_locatables(p, m)))...)
# Note: the conversion `:: Vector{Method}` seems to be required only
# for Julia 0.6.
struct _Dummy end
function uninteresting_locs()
locs = []
for m in methods(_Dummy)
path = string(m.file)
if path != @__FILE__
push!(locs, (path, m.line))
end
end
return locs
end
"""
find_source_file(file)
Find source `file` and return its full path. It just calls
`Base.find_source_file` and return its result for normal Julia
installation. For nightly Julia build, it tries to guess the right
path when `Base.find_source_file` failed.
"""
function find_source_file(file)
path = Base.find_source_file(file)
if path isa AbstractString && ! isfile(path)
for m in methods(Pkg.add)
exfile = try
String(m.file)
catch err
continue
end
idx = findlast(joinpath(Base.Filesystem.path_separator,
"share", "julia"), exfile)
if idx isa Nothing
continue
end
prefix = exfile[1:idx[1]]
if startswith(file, prefix)
# e.g., relpath = "share/julia/stdlib/v0.7/..."
relpath = file[length(prefix)+1:end]
return joinpath(Base.Sys.BINDIR, "..", relpath)
end
end
end
return path
end
function _readandwrite(matcher)
proc = matcher() do cmd
open(`$cmd`, "r+")
end
return (proc.out, proc.in, proc)
end
"""
read_stdout(input::AbstractString, cmd)
read_stdout(input_provider, cmd)
Julia implementation of "echo {input} | {cmd}".
"""
function read_stdout(input::AbstractString, cmd)
read_stdout(cmd) do stdin
write(stdin, input)
end
end
function read_stdout(input_provider, cmd)
stdout, stdin, process = _readandwrite(cmd)
reader = @async read(stdout)
try
input_provider(stdin)
catch err
if ! (err isa IOError)
rethrow()
end
finally
close(stdin)
end
return fetch(reader)
end
function parse_loc(line)
rest, lineno = rsplit(line, ":", limit=2)
_, path = rsplit(rest, " at ", limit=2)
return String(path), parse(Int, lineno)
end
function run_matcher(input)
return String(read_stdout(input, CONFIG.interactive_matcher))
end
choose_method(methods::T) where T =
_choose_method(Base.IteratorSize(T), methods)
function _choose_method(::Base.HasLength, methods)
if isempty(methods)
@info "No (interesting) method found"
return
end
if CONFIG.auto_open && length(methods) == 1
m = first(methods)
loc = (string(m.file), m.line)
if loc in uninteresting_locs()
path, lineno = loc
@info "Not opening uninteresting location: $path:$lineno"
return
end
return loc
end
return _choose_method(Base.SizeUnknown(), methods)
end
function _choose_method(::Base.IteratorSize, methods)
out = run_matcher() do stdin
for m in methods
show(stdin, m)
println(stdin)
end
end
if isempty(out)
return
end
return parse_loc(out)
end
function run_open(path, lineno)
@info "Opening $path:$lineno"
CONFIG.open(find_source_file(path), lineno)
end
maybe_open(::Nothing) = nothing
maybe_open(x::Tuple{String, Integer}) = run_open(x...)
search_methods(methods) = maybe_open(choose_method(methods))
code_search_typed(f, t) = search_methods(methods(f, t))
code_search(::SearchPolicy, f::Base.Callable) = search_methods(methods(f))
code_search(p::SearchPolicy, m::Module) = search_methods(module_methods(p, m))
function code_search(p::SearchPolicy, ::T) where T
@warn """Cannot search for given value of type $T
Searching for its type instead..."""
code_search(p, T)
end
"""
Configuration interface for `InteractiveCodeSearch`.
# Examples
```julia
using InteractiveCodeSearch
InteractiveCodeSearch.CONFIG.interactive_matcher = `peco` # default in terminal
InteractiveCodeSearch.CONFIG.interactive_matcher = `percol`
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "🔎"` # use GUI matcher (default in non-terminal
# environment like IJulia)
InteractiveCodeSearch.CONFIG.interactive_matcher =
`rofi -dmenu -i -p "🔎" -fullscreen` # bigger screen
InteractiveCodeSearch.CONFIG.open = edit # default
InteractiveCodeSearch.CONFIG.open = less # use Base.less to read code
InteractiveCodeSearch.CONFIG.auto_open = true # default
InteractiveCodeSearch.CONFIG.auto_open = false # open matcher even when there
# is only one candidate
```
## Using InteractiveCodeSearch.jl by default
Put the following code in your `~/.julia/config/startup.jl`:
```julia
using InteractiveCodeSearch
# InteractiveCodeSearch.CONFIG.interactive_matcher = ...
```
"""
const CONFIG = SearchConfig(
edit, # open
x->error("uninitialized"), # interactive_matcher
true, # auto_open
)
should_eval(::Any) = false
should_eval(::Symbol) = true
should_eval(ex::Expr) = ex.head in (:., :ref)
# Given (say) `a.b[c].d[e]` It probably is better to only eval
# `a.b[c].d` and then search for `getindex(a.b[c].d, e)`. But it's
# (1) a bit harder to implement and (2) evaluating the whole
# expression is still useful. So let's keep the current
# implementation for a while.
isliteral(::Symbol) = false
isliteral(::Expr) = false
isliteral(::Any) = true
isline(::Any) = false
isline(ex::Expr) = ex.head == :line
isline(::LineNumberNode) = true
single_macrocall(::Any) = nothing
function single_macrocall(x::Expr)
if x.head == :macrocall && all(isline.(x.args[2:end]))
return x.args[1]
elseif x.head == :block
statements = findall(a -> !isline(a), x.args)
if length(statements) == 1
return single_macrocall(x.args[statements[1]])
end
end
return nothing
end
explicitly_typed(::Any) = nothing
function explicitly_typed(ex::Expr)
if ex.head == :call &&
all(x isa Expr && x.head == :(::) for x in ex.args[2:end])
return ex.args[1], [x.args[end] for x in ex.args[2:end]]
end
return nothing
end
# Julia >= 0.7:
parse_search_policy(flag::QuoteNode) = parse_search_policy(flag.value)
# Julia 0.6:
function parse_search_policy(flag::Expr)
@assert flag.head == :quote
@assert length(flag.args) == 1
return parse_search_policy(flag.args[1])
end
function parse_search_policy(flag::Symbol)
if flag in (:shallow, :s)
return Shallow()
elseif flag in (:recursive, :r)
return Recursive()
end
error("Invalid flag $flag")
end
"""
@search x [:shallow | :s | :recursive | :r]
List file locations at which `x` are defined in an interactive matcher
and then open the chosen location in the editor.
When `x` is a module, only the top-level definitions are searched. To
search all definitions in the submodule, pass `:recursive` or `:r`
flag.
@search
If no expression is provided, search for the method returned by the
previous execution; i.e., `x` defaults to `ans`.
# Examples
```julia
@search show # all method definitions
@search @time # all macro definitions
@search Base.Enums # methods and macros in a module
@search REPL :r # search the module recursively
@search *(::Integer, ::Integer) # methods with specified types
@search dot(π, ℯ) # methods with inferred types
```
Note that `@search` evaluates complex expression with `.` and `[]`
such as follows and search the returned value or the type of it:
```julia
@search Base.Multimedia.displays[2].repl
```
"""
macro search(x = :ans, flag = :(:shallow))
p = parse_search_policy(flag)
if should_eval(x)
# Examples:
# @search show
# @search Base.Enums
# @search Base.Multimedia.displays[2].repl
return :(code_search($p, $(esc(x))))
end
macrocall = single_macrocall(x)
if macrocall !== nothing
# Examples:
# @search @time
# @search begin @time end
return :(code_search($p, $(esc(macrocall))))
end
func_type = explicitly_typed(x)
if func_type !== nothing
f, ts = func_type
# Examples:
# @search *(::Integer, ::Integer)
# @search dot(::AbstractVector, ::SparseVector)
return :(code_search_typed($(esc(f)), tuple($(esc.(ts)...))))
end
# Since `gen_call_with_extracted_types` does not handle literals,
# let's handle this case here (although there are not much can be
# done).
if isliteral(x)
# Examples:
# @search ""
# @search 1
return :(code_search($p, $(esc(x))))
end
# Examples:
# @search 1 * 2
# @search dot([], [])
gen_call_with_extracted_types(__module__, code_search_typed, x)
end
code_search_methods(T) = search_methods(methodswith(T; supertypes=true))
"""
@searchmethods x
@searchmethods ::X
Interactively search through `methodswith(typeof(x))` or
`methodswith(X)`.
# Examples
```julia
@searchmethods 1 # search methods defined for integer
@searchmethods ::Int # search methods defined for a specified type
```
"""
macro searchmethods(x)
if x isa Expr && x.head == :(::)
if length(x.args) > 1
@info "Ignoring: $(x.args[1:end-1]...) in $x"
end
:(code_search_methods($(esc(x.args[end]))))
else
:(code_search_methods(typeof($(esc(x)))))
end
end
################################################################################
# matcher binaries #
################################################################################
@static if VERSION<v"1.3-"
const preferred_terminal = Cmd[
`peco`,
`percol`,
]
else
using peco_jll
const preferred_terminal = Union{Function,Cmd}[
`peco`,
peco,
`percol`,
]
end
const preferred_gui = Cmd[
`rofi -dmenu -i -p "🔎"`,
# what else?
]
function need_gui(stdstreams = [stdout, stdin])
return !all(isa.(stdstreams, Ref(Base.TTY)))
end
function choose_preferred_command(commands::Vector{<:Union{Function,Cmd}}, default=nothing)
for cmd in commands
if !(cmd isa Cmd) || Sys.which(cmd.exec[1]) !== nothing
return cmd
end
end
return default
end
function choose_interactive_matcher()
need_gui() && return choose_preferred_command(preferred_gui, preferred_gui[1])
return choose_preferred_command(vcat(preferred_terminal, preferred_gui), preferred_terminal[1])
end
function matcher_installation_tips(program::AbstractString)
if program == "peco"
return """
See https://github.com/peco/peco for how to install peco.
"""
elseif program == "rofi"
msg = """
See https://github.com/DaveDavenport/rofi for how to install rofi.
"""
else
msg = ""
end
return """
$msg
For terminal usage, `peco` is recommended.
See https://github.com/peco/peco for how to install peco.
"""
end
function maybe_warn_matcher(cmd::Cmd)
if Sys.which(cmd.exec[1]) === nothing
@warn """
Matcher $(cmd.exec[1]) not installed.
$(matcher_installation_tips(cmd.exec[1]))
"""
end
end
function __init__()
setmatcher!(choose_interactive_matcher(), CONFIG)
end
include("taskmanager.jl")
include("history.jl")
include("return.jl")
end # module
| [
27,
456,
62,
30783,
29,
15,
198,
37811,
198,
2,
21365,
10669,
18243,
13,
20362,
11420,
4225,
33329,
2989,
22300,
2438,
198,
198,
16980,
544,
468,
4600,
31,
19312,
47671,
4600,
31,
1203,
47671,
3503,
13,
543,
389,
845,
15728,
329,
3555,
262,
198,
320,
32851,
286,
5499,
13,
220,
2102,
11,
345,
761,
284,
11986,
257,
366,
11274,
198,
48229,
1,
900,
286,
357,
4906,
8,
10007,
329,
606,
284,
1064,
262,
4067,
286,
262,
198,
8189,
13,
198,
198,
13193,
11,
4600,
9492,
5275,
10669,
18243,
63,
3769,
257,
1178,
34749,
284,
198,
3849,
33329,
3853,
262,
2438,
345,
765,
284,
1100,
13,
198,
198,
2235,
17571,
198,
198,
9,
4225,
33329,
3853,
257,
2446,
9877,
878,
4756,
262,
2438,
198,
220,
4067,
287,
534,
5464,
13,
198,
198,
9,
26386,
2842,
284,
2989,
5050,
11,
884,
355,
25,
416,
2163,
1438,
4600,
31,
12947,
905,
47671,
198,
220,
2163,
869,
5408,
4600,
31,
12947,
905,
7,
19282,
448,
11,
366,
31373,
4943,
47671,
198,
220,
2163,
869,
9877,
4600,
31,
12947,
905,
7,
3712,
9399,
11,
7904,
10100,
8,
47671,
198,
220,
8265,
1438,
4600,
31,
12947,
7308,
47671,
4578,
1988,
4600,
31,
12947,
24396,
82,
352,
47671,
198,
220,
4578,
2099,
4600,
31,
12947,
24396,
82,
7904,
5317,
47671,
290,
1441,
2099,
4600,
31,
12947,
7783,
2558,
44646,
198,
198,
9,
4225,
33329,
2989,
2106,
13,
220,
632,
2499,
287,
314,
16980,
544,
355,
880,
13,
198,
198,
2235,
21066,
198,
198,
15506,
63,
73,
43640,
198,
3500,
21365,
10669,
18243,
198,
31,
12947,
905,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2989,
2446,
17336,
198,
31,
12947,
24396,
82,
352,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2989,
5050,
5447,
329,
18253,
198,
31,
12947,
23569,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2989,
2106,
357,
16980,
544,
26870,
657,
13,
22,
8,
198,
31,
12947,
7783,
10903,
350,
10025,
1303,
2989,
5050,
8024,
257,
1813,
2099,
357,
16980,
544,
26870,
657,
13,
22,
8,
198,
15506,
63,
198,
198,
2235,
24422,
198,
198,
9,
21365,
12336,
3141,
13,
220,
1114,
1672,
25,
198,
220,
1635,
685,
431,
1073,
16151,
5450,
1378,
12567,
13,
785,
14,
431,
1073,
14,
431,
1073,
8,
357,
12286,
287,
12094,
8,
198,
220,
1635,
685,
525,
4033,
16151,
5450,
1378,
12567,
13,
785,
14,
76,
2238,
89,
14,
525,
4033,
8,
198,
220,
1635,
685,
305,
12463,
16151,
5450,
1378,
12567,
13,
785,
14,
27984,
35,
4005,
634,
14,
305,
12463,
8,
357,
40156,
26,
4277,
287,
314,
16980,
544,
8,
198,
37811,
198,
21412,
21365,
10669,
18243,
198,
39344,
2488,
12947,
11,
2488,
12947,
24396,
82,
198,
198,
11748,
350,
10025,
198,
3500,
7308,
198,
3500,
7308,
25,
24418,
12331,
198,
3500,
21365,
18274,
4487,
25,
4370,
11,
2429,
62,
13345,
62,
4480,
62,
2302,
20216,
62,
19199,
11,
2446,
2032,
342,
198,
198,
397,
8709,
2099,
11140,
36727,
886,
198,
7249,
911,
12154,
1279,
25,
11140,
36727,
886,
198,
7249,
3311,
30753,
1279,
25,
11140,
36727,
886,
628,
198,
76,
18187,
2878,
11140,
16934,
220,
1303,
25626,
198,
220,
220,
220,
1280,
198,
220,
220,
220,
14333,
62,
6759,
2044,
3712,
22203,
198,
220,
220,
220,
8295,
62,
9654,
3712,
33,
970,
198,
437,
198,
198,
8818,
900,
6759,
2044,
0,
7,
28758,
3712,
22203,
11,
26181,
3712,
18243,
16934,
8,
198,
220,
220,
220,
26181,
13,
3849,
5275,
62,
6759,
2044,
796,
23991,
198,
220,
220,
220,
1441,
198,
437,
198,
198,
8818,
900,
6759,
2044,
0,
7,
28758,
3712,
40109,
11,
26181,
3712,
18243,
16934,
8,
198,
220,
220,
220,
900,
6759,
2044,
0,
7,
1102,
1851,
40109,
7,
28758,
828,
26181,
8,
198,
437,
198,
198,
8818,
10385,
40109,
7,
28758,
8,
198,
220,
220,
220,
3863,
62,
40539,
62,
6759,
2044,
7,
28758,
8,
198,
220,
220,
220,
1441,
2163,
357,
69,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3863,
62,
40539,
62,
6759,
2044,
7,
28758,
8,
198,
220,
220,
220,
220,
220,
220,
220,
277,
7,
28758,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
25991,
62,
738,
7483,
7,
82,
8,
796,
5145,
9688,
2032,
342,
7,
8841,
7,
82,
828,
25113,
4943,
198,
198,
271,
62,
17946,
21156,
7,
3712,
7149,
8,
796,
3991,
198,
271,
62,
17946,
21156,
7,
3712,
22203,
8,
796,
2081,
198,
271,
62,
17946,
21156,
7,
83,
3712,
6030,
8,
796,
5145,
7,
83,
1279,
25,
12372,
853,
8,
198,
2,
3740,
1378,
12567,
13,
785,
14,
16980,
544,
43,
648,
14,
73,
43640,
14,
37165,
14,
27137,
2231,
198,
198,
271,
62,
23211,
62,
259,
7,
9410,
11,
2560,
8,
796,
198,
220,
220,
220,
1200,
5145,
855,
2560,
11405,
2560,
21412,
7,
9410,
8,
24844,
2560,
198,
198,
8818,
1351,
62,
17946,
265,
2977,
7,
79,
3712,
18243,
36727,
11,
285,
3712,
26796,
8,
198,
220,
220,
220,
1179,
82,
796,
17635,
198,
220,
220,
220,
329,
264,
287,
3891,
7,
76,
26,
477,
28,
7942,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
3863,
62,
738,
7483,
7,
82,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
796,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
651,
3245,
7,
76,
11,
264,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4929,
11454,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11454,
318,
64,
13794,
891,
19852,
12331,
11405,
2555,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
302,
16939,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
318,
62,
17946,
21156,
7,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
17946,
82,
11,
2124,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
279,
318,
64,
3311,
30753,
11405,
2124,
318,
64,
19937,
11405,
318,
62,
23211,
62,
259,
7,
87,
11,
285,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
24443,
0,
7,
17946,
82,
11,
1351,
62,
17946,
265,
2977,
7,
79,
11,
2124,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
1179,
82,
198,
437,
198,
198,
21412,
62,
24396,
82,
7,
79,
3712,
18243,
36727,
11,
285,
3712,
26796,
8,
7904,
20650,
90,
17410,
92,
796,
198,
220,
220,
220,
410,
9246,
7,
33327,
12195,
24396,
82,
12195,
4868,
62,
17946,
265,
2977,
7,
79,
11,
285,
22305,
23029,
198,
2,
5740,
25,
262,
11315,
4600,
3712,
20650,
90,
17410,
92,
63,
2331,
284,
307,
2672,
691,
198,
2,
329,
22300,
657,
13,
21,
13,
628,
198,
7249,
4808,
35,
13513,
886,
198,
198,
8818,
555,
47914,
62,
17946,
82,
3419,
198,
220,
220,
220,
1179,
82,
796,
17635,
198,
220,
220,
220,
329,
285,
287,
5050,
28264,
35,
13513,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3108,
796,
4731,
7,
76,
13,
7753,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
3108,
14512,
2488,
834,
25664,
834,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
17946,
82,
11,
357,
6978,
11,
285,
13,
1370,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
1179,
82,
198,
437,
628,
198,
37811,
198,
220,
220,
220,
1064,
62,
10459,
62,
7753,
7,
7753,
8,
198,
198,
16742,
2723,
4600,
7753,
63,
290,
1441,
663,
1336,
3108,
13,
220,
632,
655,
3848,
198,
63,
14881,
13,
19796,
62,
10459,
62,
7753,
63,
290,
1441,
663,
1255,
329,
3487,
22300,
198,
17350,
341,
13,
220,
1114,
37862,
22300,
1382,
11,
340,
8404,
284,
4724,
262,
826,
198,
6978,
618,
4600,
14881,
13,
19796,
62,
10459,
62,
7753,
63,
4054,
13,
198,
37811,
198,
8818,
1064,
62,
10459,
62,
7753,
7,
7753,
8,
198,
220,
220,
220,
3108,
796,
7308,
13,
19796,
62,
10459,
62,
7753,
7,
7753,
8,
198,
220,
220,
220,
611,
3108,
318,
64,
27741,
10100,
11405,
5145,
318,
7753,
7,
6978,
8,
198,
220,
220,
220,
220,
220,
220,
220,
329,
285,
287,
5050,
7,
47,
10025,
13,
2860,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
409,
7753,
796,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10903,
7,
76,
13,
7753,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4929,
11454,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2555,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4686,
87,
796,
1064,
12957,
7,
22179,
6978,
7,
14881,
13,
25876,
6781,
13,
6978,
62,
25512,
1352,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
20077,
1600,
366,
73,
43640,
12340,
409,
7753,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
4686,
87,
318,
64,
10528,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2555,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
21231,
796,
409,
7753,
58,
16,
25,
312,
87,
58,
16,
11907,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
923,
2032,
342,
7,
7753,
11,
21231,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
304,
13,
70,
1539,
823,
6978,
796,
366,
20077,
14,
73,
43640,
14,
19282,
8019,
14,
85,
15,
13,
22,
14,
9313,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
823,
6978,
796,
2393,
58,
13664,
7,
40290,
47762,
16,
25,
437,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
4654,
6978,
7,
14881,
13,
44387,
13,
33,
12115,
4663,
11,
366,
492,
1600,
823,
6978,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
3108,
198,
437,
198,
198,
8818,
4808,
961,
392,
13564,
7,
6759,
2044,
8,
198,
220,
220,
220,
13834,
796,
2603,
2044,
3419,
466,
23991,
198,
220,
220,
220,
220,
220,
220,
220,
1280,
7,
63,
3,
28758,
47671,
366,
81,
10,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
357,
36942,
13,
448,
11,
13834,
13,
259,
11,
13834,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
1100,
62,
19282,
448,
7,
15414,
3712,
23839,
10100,
11,
23991,
8,
198,
220,
220,
220,
1100,
62,
19282,
448,
7,
15414,
62,
15234,
1304,
11,
23991,
8,
198,
198,
16980,
544,
7822,
286,
366,
30328,
1391,
15414,
92,
930,
1391,
28758,
92,
1911,
198,
37811,
198,
8818,
1100,
62,
19282,
448,
7,
15414,
3712,
23839,
10100,
11,
23991,
8,
198,
220,
220,
220,
1100,
62,
19282,
448,
7,
28758,
8,
466,
14367,
259,
198,
220,
220,
220,
220,
220,
220,
220,
3551,
7,
19282,
259,
11,
5128,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
1100,
62,
19282,
448,
7,
15414,
62,
15234,
1304,
11,
23991,
8,
198,
220,
220,
220,
14367,
448,
11,
14367,
259,
11,
1429,
796,
4808,
961,
392,
13564,
7,
28758,
8,
198,
220,
220,
220,
9173,
796,
2488,
292,
13361,
1100,
7,
19282,
448,
8,
198,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
5128,
62,
15234,
1304,
7,
19282,
259,
8,
198,
220,
220,
220,
4929,
11454,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5145,
357,
8056,
318,
64,
24418,
12331,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
302,
16939,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
3443,
198,
220,
220,
220,
220,
220,
220,
220,
1969,
7,
19282,
259,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
21207,
7,
46862,
8,
198,
437,
198,
198,
8818,
21136,
62,
17946,
7,
1370,
8,
198,
220,
220,
220,
1334,
11,
9493,
23397,
796,
374,
35312,
7,
1370,
11,
366,
25,
1600,
4179,
28,
17,
8,
198,
220,
220,
220,
4808,
11,
3108,
796,
374,
35312,
7,
2118,
11,
366,
379,
33172,
4179,
28,
17,
8,
198,
220,
220,
220,
1441,
10903,
7,
6978,
828,
21136,
7,
5317,
11,
9493,
23397,
8,
198,
437,
198,
198,
8818,
1057,
62,
6759,
2044,
7,
15414,
8,
198,
220,
220,
220,
1441,
10903,
7,
961,
62,
19282,
448,
7,
15414,
11,
25626,
13,
3849,
5275,
62,
6759,
2044,
4008,
198,
437,
198,
198,
6679,
577,
62,
24396,
7,
24396,
82,
3712,
51,
8,
810,
309,
796,
198,
220,
220,
220,
4808,
6679,
577,
62,
24396,
7,
14881,
13,
37787,
10699,
7,
51,
828,
5050,
8,
198,
198,
8818,
4808,
6679,
577,
62,
24396,
7,
3712,
14881,
13,
19242,
24539,
11,
5050,
8,
198,
220,
220,
220,
611,
318,
28920,
7,
24396,
82,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
10951,
366,
2949,
357,
47914,
8,
2446,
1043,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
25626,
13,
23736,
62,
9654,
11405,
4129,
7,
24396,
82,
8,
6624,
352,
198,
220,
220,
220,
220,
220,
220,
220,
285,
796,
717,
7,
24396,
82,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1179,
796,
357,
8841,
7,
76,
13,
7753,
828,
285,
13,
1370,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1179,
287,
555,
47914,
62,
17946,
82,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3108,
11,
9493,
23397,
796,
1179,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
10951,
366,
3673,
4756,
555,
47914,
4067,
25,
720,
6978,
25,
3,
2815,
23397,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1179,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
4808,
6679,
577,
62,
24396,
7,
14881,
13,
10699,
20035,
22784,
5050,
8,
198,
437,
198,
198,
8818,
4808,
6679,
577,
62,
24396,
7,
3712,
14881,
13,
37787,
10699,
11,
5050,
8,
198,
220,
220,
220,
503,
796,
1057,
62,
6759,
2044,
3419,
466,
14367,
259,
198,
220,
220,
220,
220,
220,
220,
220,
329,
285,
287,
5050,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
905,
7,
19282,
259,
11,
285,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
7,
19282,
259,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
318,
28920,
7,
448,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
21136,
62,
17946,
7,
448,
8,
198,
437,
198,
198,
8818,
1057,
62,
9654,
7,
6978,
11,
9493,
23397,
8,
198,
220,
220,
220,
2488,
10951,
366,
43093,
720,
6978,
25,
3,
2815,
23397,
1,
198,
220,
220,
220,
25626,
13,
9654,
7,
19796,
62,
10459,
62,
7753,
7,
6978,
828,
9493,
23397,
8,
198,
437,
198,
198,
25991,
62,
9654,
7,
3712,
18465,
8,
796,
2147,
198,
25991,
62,
9654,
7,
87,
3712,
51,
29291,
90,
10100,
11,
34142,
30072,
796,
1057,
62,
9654,
7,
87,
23029,
198,
198,
12947,
62,
24396,
82,
7,
24396,
82,
8,
796,
3863,
62,
9654,
7,
6679,
577,
62,
24396,
7,
24396,
82,
4008,
628,
198,
8189,
62,
12947,
62,
774,
9124,
7,
69,
11,
256,
8,
796,
2989,
62,
24396,
82,
7,
24396,
82,
7,
69,
11,
256,
4008,
198,
198,
8189,
62,
12947,
7,
3712,
18243,
36727,
11,
277,
3712,
14881,
13,
14134,
540,
8,
796,
2989,
62,
24396,
82,
7,
24396,
82,
7,
69,
4008,
198,
8189,
62,
12947,
7,
79,
3712,
18243,
36727,
11,
285,
3712,
26796,
8,
796,
2989,
62,
24396,
82,
7,
21412,
62,
24396,
82,
7,
79,
11,
285,
4008,
198,
198,
8818,
2438,
62,
12947,
7,
79,
3712,
18243,
36727,
11,
7904,
51,
8,
810,
309,
198,
220,
220,
220,
2488,
40539,
37227,
34,
34574,
2989,
329,
1813,
1988,
286,
2099,
720,
51,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11140,
278,
329,
663,
2099,
2427,
9313,
15931,
198,
220,
220,
220,
2438,
62,
12947,
7,
79,
11,
309,
8,
198,
437,
198,
198,
37811,
198,
38149,
7071,
329,
4600,
9492,
5275,
10669,
18243,
44646,
198,
198,
2,
21066,
198,
198,
15506,
63,
73,
43640,
198,
3500,
21365,
10669,
18243,
198,
9492,
5275,
10669,
18243,
13,
10943,
16254,
13,
3849,
5275,
62,
6759,
2044,
796,
4600,
431,
1073,
63,
220,
1303,
4277,
287,
12094,
198,
9492,
5275,
10669,
18243,
13,
10943,
16254,
13,
3849,
5275,
62,
6759,
2044,
796,
4600,
525,
4033,
63,
198,
9492,
5275,
10669,
18243,
13,
10943,
16254,
13,
3849,
5275,
62,
6759,
2044,
796,
198,
220,
220,
220,
4600,
305,
12463,
532,
67,
26272,
532,
72,
532,
79,
366,
8582,
242,
236,
1,
63,
220,
1303,
779,
25757,
2603,
2044,
357,
12286,
287,
1729,
12,
23705,
282,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2858,
588,
314,
16980,
544,
8,
198,
9492,
5275,
10669,
18243,
13,
10943,
16254,
13,
3849,
5275,
62,
6759,
2044,
796,
198,
220,
220,
220,
4600,
305,
12463,
532,
67,
26272,
532,
72,
532,
79,
366,
8582,
242,
236,
1,
532,
12853,
9612,
63,
220,
1303,
5749,
3159,
198,
9492,
5275,
10669,
18243,
13,
10943,
16254,
13,
9654,
796,
4370,
220,
1303,
4277,
198,
9492,
5275,
10669,
18243,
13,
10943,
16254,
13,
9654,
796,
1342,
220,
1303,
779,
7308,
13,
1203,
284,
1100,
2438,
198,
9492,
5275,
10669,
18243,
13,
10943,
16254,
13,
23736,
62,
9654,
796,
2081,
220,
220,
1303,
4277,
198,
9492,
5275,
10669,
18243,
13,
10943,
16254,
13,
23736,
62,
9654,
796,
3991,
220,
1303,
1280,
2603,
2044,
772,
618,
612,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
318,
691,
530,
4540,
198,
15506,
63,
198,
198,
2235,
8554,
21365,
10669,
18243,
13,
20362,
416,
4277,
198,
198,
11588,
262,
1708,
2438,
287,
534,
4600,
93,
11757,
73,
43640,
14,
11250,
14,
9688,
929,
13,
20362,
63,
25,
198,
198,
15506,
63,
73,
43640,
198,
3500,
21365,
10669,
18243,
198,
2,
21365,
10669,
18243,
13,
10943,
16254,
13,
3849,
5275,
62,
6759,
2044,
796,
2644,
198,
15506,
63,
198,
37811,
198,
9979,
25626,
796,
11140,
16934,
7,
198,
220,
220,
220,
4370,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1280,
198,
220,
220,
220,
2124,
3784,
18224,
7203,
403,
17532,
12340,
220,
1303,
14333,
62,
6759,
2044,
198,
220,
220,
220,
2081,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
8295,
62,
9654,
198,
8,
198,
198,
21754,
62,
18206,
7,
3712,
7149,
8,
796,
3991,
198,
21754,
62,
18206,
7,
3712,
13940,
23650,
8,
796,
2081,
198,
21754,
62,
18206,
7,
1069,
3712,
3109,
1050,
8,
796,
409,
13,
2256,
287,
357,
25,
1539,
1058,
5420,
8,
198,
2,
11259,
357,
16706,
8,
4600,
64,
13,
65,
58,
66,
4083,
67,
58,
68,
60,
63,
632,
2192,
318,
1365,
284,
691,
5418,
198,
2,
4600,
64,
13,
65,
58,
66,
4083,
67,
63,
290,
788,
2989,
329,
4600,
1136,
9630,
7,
64,
13,
65,
58,
66,
4083,
67,
11,
304,
8,
44646,
220,
887,
340,
338,
198,
2,
357,
16,
8,
257,
1643,
7069,
284,
3494,
290,
357,
17,
8,
22232,
262,
2187,
198,
2,
5408,
318,
991,
4465,
13,
220,
1406,
1309,
338,
1394,
262,
1459,
198,
2,
7822,
329,
257,
981,
13,
198,
198,
3044,
270,
1691,
7,
3712,
13940,
23650,
8,
796,
3991,
198,
3044,
270,
1691,
7,
3712,
3109,
1050,
8,
796,
3991,
198,
3044,
270,
1691,
7,
3712,
7149,
8,
796,
2081,
198,
198,
271,
1370,
7,
3712,
7149,
8,
796,
3991,
198,
271,
1370,
7,
1069,
3712,
3109,
1050,
8,
796,
409,
13,
2256,
6624,
1058,
1370,
198,
271,
1370,
7,
3712,
13949,
15057,
19667,
8,
796,
2081,
198,
198,
29762,
62,
20285,
12204,
439,
7,
3712,
7149,
8,
796,
2147,
198,
8818,
2060,
62,
20285,
12204,
439,
7,
87,
3712,
3109,
1050,
8,
198,
220,
220,
220,
611,
2124,
13,
2256,
6624,
1058,
20285,
12204,
439,
11405,
477,
7,
271,
1370,
12195,
87,
13,
22046,
58,
17,
25,
437,
60,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2124,
13,
22046,
58,
16,
60,
198,
220,
220,
220,
2073,
361,
2124,
13,
2256,
6624,
1058,
9967,
198,
220,
220,
220,
220,
220,
220,
220,
6299,
796,
1064,
439,
7,
64,
4613,
5145,
271,
1370,
7,
64,
828,
2124,
13,
22046,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4129,
7,
14269,
3196,
8,
6624,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
2060,
62,
20285,
12204,
439,
7,
87,
13,
22046,
58,
14269,
3196,
58,
16,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
20676,
3628,
306,
62,
774,
9124,
7,
3712,
7149,
8,
796,
2147,
198,
8818,
11777,
62,
774,
9124,
7,
1069,
3712,
3109,
1050,
8,
198,
220,
220,
220,
611,
409,
13,
2256,
6624,
1058,
13345,
11405,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
477,
7,
87,
318,
64,
1475,
1050,
11405,
2124,
13,
2256,
6624,
36147,
3712,
8,
329,
2124,
287,
409,
13,
22046,
58,
17,
25,
437,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
409,
13,
22046,
58,
16,
4357,
685,
87,
13,
22046,
58,
437,
60,
329,
2124,
287,
409,
13,
22046,
58,
17,
25,
437,
11907,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
2,
22300,
18189,
657,
13,
22,
25,
198,
29572,
62,
12947,
62,
30586,
7,
32109,
3712,
25178,
19667,
8,
796,
21136,
62,
12947,
62,
30586,
7,
32109,
13,
8367,
8,
198,
2,
22300,
657,
13,
21,
25,
198,
8818,
21136,
62,
12947,
62,
30586,
7,
32109,
3712,
3109,
1050,
8,
198,
220,
220,
220,
2488,
30493,
6056,
13,
2256,
6624,
1058,
22708,
198,
220,
220,
220,
2488,
30493,
4129,
7,
32109,
13,
22046,
8,
6624,
352,
198,
220,
220,
220,
1441,
21136,
62,
12947,
62,
30586,
7,
32109,
13,
22046,
58,
16,
12962,
198,
437,
198,
198,
8818,
21136,
62,
12947,
62,
30586,
7,
32109,
3712,
13940,
23650,
8,
198,
220,
220,
220,
611,
6056,
287,
357,
25,
1477,
12154,
11,
1058,
82,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
911,
12154,
3419,
198,
220,
220,
220,
2073,
361,
6056,
287,
357,
25,
8344,
30753,
11,
1058,
81,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
3311,
30753,
3419,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4049,
7203,
44651,
6056,
720,
32109,
4943,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
2488,
12947,
2124,
685,
25,
1477,
12154,
930,
1058,
82,
930,
1058,
8344,
30753,
930,
1058,
81,
60,
198,
198,
8053,
2393,
7064,
379,
543,
4600,
87,
63,
389,
5447,
287,
281,
14333,
2603,
2044,
198,
392,
788,
1280,
262,
7147,
4067,
287,
262,
5464,
13,
198,
198,
2215,
4600,
87,
63,
318,
257,
8265,
11,
691,
262,
1353,
12,
5715,
17336,
389,
16499,
13,
220,
1675,
198,
12947,
477,
17336,
287,
262,
850,
21412,
11,
1208,
4600,
25,
8344,
30753,
63,
393,
4600,
25,
81,
63,
198,
32109,
13,
628,
220,
220,
220,
2488,
12947,
198,
198,
1532,
645,
5408,
318,
2810,
11,
2989,
329,
262,
2446,
4504,
416,
262,
198,
3866,
1442,
9706,
26,
1312,
13,
68,
1539,
4600,
87,
63,
26235,
284,
4600,
504,
44646,
198,
198,
2,
21066,
198,
15506,
63,
73,
43640,
198,
31,
12947,
905,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
477,
2446,
17336,
198,
31,
12947,
2488,
2435,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
477,
15021,
17336,
198,
31,
12947,
7308,
13,
4834,
5700,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
5050,
290,
34749,
287,
257,
8265,
198,
31,
12947,
45285,
1058,
81,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2989,
262,
8265,
664,
1834,
2280,
198,
31,
12947,
1635,
7,
3712,
46541,
11,
7904,
46541,
8,
220,
220,
1303,
5050,
351,
7368,
3858,
198,
31,
12947,
16605,
7,
46582,
11,
2343,
226,
107,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
5050,
351,
41240,
3858,
198,
15506,
63,
198,
198,
6425,
326,
4600,
31,
12947,
63,
47850,
3716,
5408,
351,
4600,
13,
63,
290,
4600,
21737,
63,
198,
10508,
355,
5679,
290,
2989,
262,
4504,
1988,
393,
262,
2099,
286,
340,
25,
198,
15506,
63,
73,
43640,
198,
31,
12947,
7308,
13,
15205,
20626,
13,
6381,
26024,
58,
17,
4083,
35666,
198,
15506,
63,
198,
37811,
198,
20285,
305,
2989,
7,
87,
796,
1058,
504,
11,
6056,
796,
36147,
25,
1477,
12154,
4008,
198,
220,
220,
220,
279,
796,
21136,
62,
12947,
62,
30586,
7,
32109,
8,
628,
220,
220,
220,
611,
815,
62,
18206,
7,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
21066,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
905,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
7308,
13,
4834,
5700,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
7308,
13,
15205,
20626,
13,
6381,
26024,
58,
17,
4083,
35666,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
36147,
8189,
62,
12947,
16763,
79,
11,
29568,
3798,
7,
87,
35514,
198,
220,
220,
220,
886,
628,
220,
220,
220,
8352,
12204,
439,
796,
2060,
62,
20285,
12204,
439,
7,
87,
8,
198,
220,
220,
220,
611,
8352,
12204,
439,
5145,
855,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
21066,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
2488,
2435,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
2221,
2488,
2435,
886,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
36147,
8189,
62,
12947,
16763,
79,
11,
29568,
3798,
7,
20285,
12204,
439,
35514,
198,
220,
220,
220,
886,
628,
220,
220,
220,
25439,
62,
4906,
796,
11777,
62,
774,
9124,
7,
87,
8,
198,
220,
220,
220,
611,
25439,
62,
4906,
5145,
855,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
277,
11,
40379,
796,
25439,
62,
4906,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
21066,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
1635,
7,
3712,
46541,
11,
7904,
46541,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
16605,
7,
3712,
23839,
38469,
11,
7904,
50,
29572,
38469,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
36147,
8189,
62,
12947,
62,
774,
9124,
16763,
7,
3798,
7,
69,
36911,
46545,
16763,
7,
3798,
12195,
912,
26513,
35514,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1303,
4619,
4600,
5235,
62,
13345,
62,
4480,
62,
2302,
20216,
62,
19199,
63,
857,
407,
5412,
4187,
874,
11,
198,
220,
220,
220,
1303,
1309,
338,
5412,
428,
1339,
994,
357,
16670,
612,
389,
407,
881,
460,
307,
198,
220,
220,
220,
1303,
1760,
737,
198,
220,
220,
220,
611,
318,
18250,
1691,
7,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
21066,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
2488,
12947,
352,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
36147,
8189,
62,
12947,
16763,
79,
11,
29568,
3798,
7,
87,
35514,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1303,
21066,
25,
198,
220,
220,
220,
1303,
220,
220,
2488,
12947,
352,
1635,
362,
198,
220,
220,
220,
1303,
220,
220,
2488,
12947,
16605,
26933,
4357,
685,
12962,
198,
220,
220,
220,
2429,
62,
13345,
62,
4480,
62,
2302,
20216,
62,
19199,
7,
834,
21412,
834,
11,
2438,
62,
12947,
62,
774,
9124,
11,
2124,
8,
198,
437,
198,
198,
8189,
62,
12947,
62,
24396,
82,
7,
51,
8,
796,
2989,
62,
24396,
82,
7,
24396,
2032,
342,
7,
51,
26,
2208,
19199,
28,
7942,
4008,
198,
198,
37811,
198,
220,
220,
220,
2488,
12947,
24396,
82,
2124,
198,
220,
220,
220,
2488,
12947,
24396,
82,
7904,
55,
198,
198,
9492,
33329,
2989,
832,
4600,
24396,
2032,
342,
7,
4906,
1659,
7,
87,
4008,
63,
393,
198,
63,
24396,
2032,
342,
7,
55,
8,
44646,
198,
198,
2,
21066,
198,
15506,
63,
73,
43640,
198,
31,
12947,
24396,
82,
352,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2989,
5050,
5447,
329,
18253,
198,
31,
12947,
24396,
82,
7904,
5317,
220,
220,
220,
220,
1303,
2989,
5050,
5447,
329,
257,
7368,
2099,
198,
15506,
63,
198,
37811,
198,
20285,
305,
2989,
24396,
82,
7,
87,
8,
198,
220,
220,
220,
611,
2124,
318,
64,
1475,
1050,
11405,
2124,
13,
2256,
6624,
36147,
3712,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4129,
7,
87,
13,
22046,
8,
1875,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
10951,
366,
32916,
3255,
25,
29568,
87,
13,
22046,
58,
16,
25,
437,
12,
16,
60,
23029,
287,
720,
87,
1,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
36147,
8189,
62,
12947,
62,
24396,
82,
16763,
7,
3798,
7,
87,
13,
22046,
58,
437,
60,
35514,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
36147,
8189,
62,
12947,
62,
24396,
82,
7,
4906,
1659,
16763,
7,
3798,
7,
87,
4008,
22305,
198,
220,
220,
220,
886,
198,
437,
198,
198,
29113,
29113,
14468,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2603,
2044,
38640,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
198,
29113,
29113,
14468,
198,
198,
31,
12708,
611,
44156,
2849,
27,
85,
1,
16,
13,
18,
21215,
198,
220,
220,
220,
1500,
9871,
62,
23705,
282,
796,
327,
9132,
58,
198,
220,
220,
220,
220,
220,
220,
220,
4600,
431,
1073,
47671,
198,
220,
220,
220,
220,
220,
220,
220,
4600,
525,
4033,
47671,
198,
220,
220,
220,
2361,
198,
17772,
198,
220,
220,
220,
1262,
613,
1073,
62,
73,
297,
198,
220,
220,
220,
1500,
9871,
62,
23705,
282,
796,
4479,
90,
22203,
11,
40109,
92,
58,
198,
220,
220,
220,
220,
220,
220,
220,
4600,
431,
1073,
47671,
198,
220,
220,
220,
220,
220,
220,
220,
613,
1073,
11,
198,
220,
220,
220,
220,
220,
220,
220,
4600,
525,
4033,
47671,
198,
220,
220,
220,
2361,
198,
437,
198,
198,
9979,
9871,
62,
48317,
796,
327,
9132,
58,
198,
220,
220,
220,
4600,
305,
12463,
532,
67,
26272,
532,
72,
532,
79,
366,
8582,
242,
236,
1,
47671,
198,
220,
220,
220,
1303,
644,
2073,
30,
198,
60,
198,
198,
8818,
761,
62,
48317,
7,
19282,
5532,
82,
796,
685,
19282,
448,
11,
14367,
259,
12962,
198,
220,
220,
220,
1441,
5145,
439,
7,
9160,
12195,
19282,
5532,
82,
11,
6524,
7,
14881,
13,
51,
9936,
22305,
198,
437,
198,
198,
8818,
3853,
62,
3866,
18186,
62,
21812,
7,
9503,
1746,
3712,
38469,
90,
27,
25,
38176,
90,
22203,
11,
40109,
92,
5512,
4277,
28,
22366,
8,
198,
220,
220,
220,
329,
23991,
287,
9729,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5145,
7,
28758,
318,
64,
327,
9132,
8,
8614,
311,
893,
13,
4758,
7,
28758,
13,
18558,
58,
16,
12962,
5145,
855,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
23991,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
4277,
198,
437,
198,
198,
8818,
3853,
62,
3849,
5275,
62,
6759,
2044,
3419,
198,
220,
220,
220,
761,
62,
48317,
3419,
11405,
1441,
3853,
62,
3866,
18186,
62,
21812,
7,
3866,
18186,
62,
48317,
11,
9871,
62,
48317,
58,
16,
12962,
198,
220,
220,
220,
1441,
3853,
62,
3866,
18186,
62,
21812,
7,
85,
9246,
7,
3866,
18186,
62,
23705,
282,
11,
9871,
62,
48317,
828,
9871,
62,
23705,
282,
58,
16,
12962,
198,
437,
198,
198,
8818,
2603,
2044,
62,
17350,
341,
62,
41315,
7,
23065,
3712,
23839,
10100,
8,
198,
220,
220,
220,
611,
1430,
6624,
366,
431,
1073,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
4091,
3740,
1378,
12567,
13,
785,
14,
431,
1073,
14,
431,
1073,
329,
703,
284,
2721,
613,
1073,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
2073,
361,
1430,
6624,
366,
305,
12463,
1,
198,
220,
220,
220,
220,
220,
220,
220,
31456,
796,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
4091,
3740,
1378,
12567,
13,
785,
14,
27984,
35,
4005,
634,
14,
305,
12463,
329,
703,
284,
2721,
686,
12463,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
31456,
796,
13538,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
37227,
198,
220,
220,
220,
720,
19662,
198,
220,
220,
220,
1114,
12094,
8748,
11,
4600,
431,
1073,
63,
318,
7151,
13,
198,
220,
220,
220,
4091,
3740,
1378,
12567,
13,
785,
14,
431,
1073,
14,
431,
1073,
329,
703,
284,
2721,
613,
1073,
13,
198,
220,
220,
220,
37227,
198,
437,
198,
198,
8818,
3863,
62,
40539,
62,
6759,
2044,
7,
28758,
3712,
40109,
8,
198,
220,
220,
220,
611,
311,
893,
13,
4758,
7,
28758,
13,
18558,
58,
16,
12962,
24844,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
40539,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
6550,
2044,
29568,
28758,
13,
18558,
58,
16,
12962,
407,
6589,
13,
198,
220,
220,
220,
220,
220,
220,
220,
29568,
6759,
2044,
62,
17350,
341,
62,
41315,
7,
28758,
13,
18558,
58,
16,
60,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
11593,
15003,
834,
3419,
198,
220,
220,
220,
900,
6759,
2044,
0,
7,
6679,
577,
62,
3849,
5275,
62,
6759,
2044,
22784,
25626,
8,
198,
437,
198,
198,
17256,
7203,
35943,
37153,
13,
20362,
4943,
198,
17256,
7203,
23569,
13,
20362,
4943,
198,
17256,
7203,
7783,
13,
20362,
4943,
198,
198,
437,
1303,
8265,
198
] | 2.426211 | 6,112 |
<reponame>JuliaNeuroscience/NeuroGraphs.jl
# core methods
###
### neighbors
###
@propagate_inbounds function outneighbors(g::AdjacencyMap, v::Integer)
cptr = getcolptr(g)
rvals = rowvals(g)
out = unsafe_inneighbors(nvertices(g), cptr, rvals, v)
@inbounds for i in cptr[v]:cptr[v + 1] - 1
pushfirst!(out, i)
end
return out
end
inneighbors(g::AdjMap, v::Integer) = outneighbors(g, v)
function inneighbors(g::AdjDiMap, v::Integer)
unsafe_inneighbors(nvertices(g), getcolptr(g), rowvals(g), v)
end
function unsafe_inneighbors(N, cptr, rval, v)
nzinds = Int[]
ptrI = 1
@inbounds for j in OneTo(N)
rowI = v
ptrA = Int(cptr[j])
stopA = Int(cptr[j+1]-1)
if ptrA <= stopA
if rval[ptrA] <= rowI
ptrA = searchsortedfirst(rval, rowI, ptrA, stopA, Base.Order.Forward)
if ptrA <= stopA && rval[ptrA] == rowI
push!(nzinds, j)
end
end
ptrI += 1
end
end
return nzinds
end
neighbors(g::AdjMap, v::Integer) = outneighbors(g, v)
## all_neighbors
all_neighbors(g::AdjMap, v::Integer) = outneighbors(g, v)
all_neighbors(g::AdjDiMap, v::Integer) = union(outneighbors(g, v), inneighbors(g, v))
## common_neighbors
function common_neighbors(g::AdjacencyMap, u::Integer, v::Integer)
intersect(neighbors(g, u), neighbors(g, v))
end
###
### density
###
function density(g::AdjDiMap)
N = nvertices(g)
return nedges(g) / (N * (N - 1))
end
function density(g::AdjMap)
N = nvertices(g)
return (2 * nedges(g)) / (N * (N - 1))
end
## num_self_loops
function num_self_loops(g::AdjacencyMap)
if nvertices(g) == 0
return 0
else
return sum(v -> has_edge(g, v, v), vertices(g))
end
end
## degree_histogram
function degree_histogram(g::AdjacencyMap, degfn=degree)
hist = Dict{eltype(g),Int}()
for v in vertices(g) # minimize allocations by
for d in degfn(g, v) # iterating over vertices
hist[d] = get(hist, d, 0) + 1
end
end
return hist
end
###
### induced_subgraph
###
#=
function induced_subgraph(g::AdjacencyMap, elist::AbstractVector{U}) where {U <: AbstractEdge}
h = zero(g)
T = eltype(T)
newvid = Dict{T,T}()
vmap = Vector{T}()
for e in elist
u, v = Tuple(e)
for i in (u, v)
if !haskey(newvid, i)
add_vertex!(h)
newvid[i] = nvertices(h)
push!(vmap, i)
end
end
add_edge!(h, newvid[u], newvid[v])
end
return h, vmap
end
=#
| [
27,
7856,
261,
480,
29,
16980,
544,
8199,
1434,
16801,
14,
8199,
1434,
37065,
82,
13,
20362,
198,
2,
4755,
5050,
198,
198,
21017,
198,
21017,
12020,
198,
21017,
198,
31,
22930,
37861,
62,
259,
65,
3733,
2163,
503,
710,
394,
32289,
7,
70,
3712,
2782,
30482,
1387,
13912,
11,
410,
3712,
46541,
8,
198,
220,
220,
220,
269,
20692,
796,
651,
4033,
20692,
7,
70,
8,
198,
220,
220,
220,
374,
12786,
796,
5752,
12786,
7,
70,
8,
198,
220,
220,
220,
503,
796,
21596,
62,
259,
710,
394,
32289,
7,
77,
1851,
1063,
7,
70,
828,
269,
20692,
11,
374,
12786,
11,
410,
8,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
1312,
287,
269,
20692,
58,
85,
5974,
66,
20692,
58,
85,
1343,
352,
60,
532,
352,
198,
220,
220,
220,
220,
220,
220,
220,
4574,
11085,
0,
7,
448,
11,
1312,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
503,
198,
437,
198,
198,
259,
710,
394,
32289,
7,
70,
3712,
2782,
73,
13912,
11,
410,
3712,
46541,
8,
796,
503,
710,
394,
32289,
7,
70,
11,
410,
8,
198,
8818,
287,
710,
394,
32289,
7,
70,
3712,
2782,
73,
18683,
13912,
11,
410,
3712,
46541,
8,
198,
220,
220,
220,
21596,
62,
259,
710,
394,
32289,
7,
77,
1851,
1063,
7,
70,
828,
651,
4033,
20692,
7,
70,
828,
5752,
12786,
7,
70,
828,
410,
8,
198,
437,
198,
8818,
21596,
62,
259,
710,
394,
32289,
7,
45,
11,
269,
20692,
11,
374,
2100,
11,
410,
8,
198,
220,
220,
220,
299,
89,
521,
82,
796,
2558,
21737,
198,
220,
220,
220,
50116,
40,
796,
352,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
474,
287,
1881,
2514,
7,
45,
8,
198,
220,
220,
220,
220,
220,
220,
220,
5752,
40,
796,
410,
198,
220,
220,
220,
220,
220,
220,
220,
50116,
32,
796,
2558,
7,
66,
20692,
58,
73,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
2245,
32,
796,
2558,
7,
66,
20692,
58,
73,
10,
16,
45297,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
50116,
32,
19841,
2245,
32,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
374,
2100,
58,
20692,
32,
60,
19841,
5752,
40,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
50116,
32,
796,
2989,
82,
9741,
11085,
7,
81,
2100,
11,
5752,
40,
11,
50116,
32,
11,
2245,
32,
11,
7308,
13,
18743,
13,
39746,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
50116,
32,
19841,
2245,
32,
11405,
374,
2100,
58,
20692,
32,
60,
6624,
5752,
40,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
27305,
521,
82,
11,
474,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
50116,
40,
15853,
352,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
299,
89,
521,
82,
198,
437,
198,
198,
710,
394,
32289,
7,
70,
3712,
2782,
73,
13912,
11,
410,
3712,
46541,
8,
796,
503,
710,
394,
32289,
7,
70,
11,
410,
8,
198,
198,
2235,
477,
62,
710,
394,
32289,
198,
439,
62,
710,
394,
32289,
7,
70,
3712,
2782,
73,
13912,
11,
410,
3712,
46541,
8,
796,
503,
710,
394,
32289,
7,
70,
11,
410,
8,
198,
439,
62,
710,
394,
32289,
7,
70,
3712,
2782,
73,
18683,
13912,
11,
410,
3712,
46541,
8,
796,
6441,
7,
448,
710,
394,
32289,
7,
70,
11,
410,
828,
287,
710,
394,
32289,
7,
70,
11,
410,
4008,
198,
198,
2235,
2219,
62,
710,
394,
32289,
198,
8818,
2219,
62,
710,
394,
32289,
7,
70,
3712,
2782,
30482,
1387,
13912,
11,
334,
3712,
46541,
11,
410,
3712,
46541,
8,
198,
220,
220,
220,
36177,
7,
710,
394,
32289,
7,
70,
11,
334,
828,
12020,
7,
70,
11,
410,
4008,
198,
437,
198,
198,
21017,
198,
21017,
12109,
198,
21017,
198,
8818,
12109,
7,
70,
3712,
2782,
73,
18683,
13912,
8,
198,
220,
220,
220,
399,
796,
299,
1851,
1063,
7,
70,
8,
198,
220,
220,
220,
1441,
299,
276,
3212,
7,
70,
8,
1220,
357,
45,
1635,
357,
45,
532,
352,
4008,
198,
437,
198,
8818,
12109,
7,
70,
3712,
2782,
73,
13912,
8,
198,
220,
220,
220,
399,
796,
299,
1851,
1063,
7,
70,
8,
198,
220,
220,
220,
1441,
357,
17,
1635,
299,
276,
3212,
7,
70,
4008,
1220,
357,
45,
1635,
357,
45,
532,
352,
4008,
198,
437,
198,
198,
2235,
997,
62,
944,
62,
5439,
2840,
198,
8818,
997,
62,
944,
62,
5439,
2840,
7,
70,
3712,
2782,
30482,
1387,
13912,
8,
198,
220,
220,
220,
611,
299,
1851,
1063,
7,
70,
8,
6624,
657,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
657,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2160,
7,
85,
4613,
468,
62,
14907,
7,
70,
11,
410,
11,
410,
828,
9421,
1063,
7,
70,
4008,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2235,
4922,
62,
10034,
21857,
198,
8818,
4922,
62,
10034,
21857,
7,
70,
3712,
2782,
30482,
1387,
13912,
11,
3396,
22184,
28,
16863,
8,
198,
220,
220,
220,
1554,
796,
360,
713,
90,
417,
4906,
7,
70,
828,
5317,
92,
3419,
198,
220,
220,
220,
329,
410,
287,
9421,
1063,
7,
70,
8,
220,
220,
220,
220,
220,
220,
220,
1303,
17775,
49157,
416,
198,
220,
220,
220,
220,
220,
220,
220,
329,
288,
287,
3396,
22184,
7,
70,
11,
410,
8,
220,
220,
220,
1303,
11629,
803,
625,
9421,
1063,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1554,
58,
67,
60,
796,
651,
7,
10034,
11,
288,
11,
657,
8,
1343,
352,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
1554,
198,
437,
198,
198,
21017,
198,
21017,
18268,
62,
7266,
34960,
198,
21017,
198,
2,
28,
198,
8818,
18268,
62,
7266,
34960,
7,
70,
3712,
2782,
30482,
1387,
13912,
11,
1288,
396,
3712,
23839,
38469,
90,
52,
30072,
810,
1391,
52,
1279,
25,
27741,
37021,
92,
198,
220,
220,
220,
289,
796,
6632,
7,
70,
8,
198,
220,
220,
220,
309,
796,
1288,
4906,
7,
51,
8,
198,
220,
220,
220,
649,
16921,
796,
360,
713,
90,
51,
11,
51,
92,
3419,
198,
220,
220,
220,
410,
8899,
796,
20650,
90,
51,
92,
3419,
628,
220,
220,
220,
329,
304,
287,
1288,
396,
198,
220,
220,
220,
220,
220,
220,
220,
334,
11,
410,
796,
309,
29291,
7,
68,
8,
198,
220,
220,
220,
220,
220,
220,
220,
329,
1312,
287,
357,
84,
11,
410,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
5145,
10134,
2539,
7,
3605,
16921,
11,
1312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
751,
62,
332,
16886,
0,
7,
71,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
649,
16921,
58,
72,
60,
796,
299,
1851,
1063,
7,
71,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
85,
8899,
11,
1312,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
751,
62,
14907,
0,
7,
71,
11,
649,
16921,
58,
84,
4357,
649,
16921,
58,
85,
12962,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
289,
11,
410,
8899,
198,
437,
198,
46249,
628
] | 1.973013 | 1,334 |
using BinaryBuilder, Pkg
name = "MicrosoftMPI"
version = v"10.1.2"
sources = [
FileSource("https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisetup.exe",
"c305ce3f05d142d519f8dd800d83a4b894fc31bcad30512cefb557feaccbe8b4"),
FileSource("https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisdk.msi",
"f9174c54feda794586ebd83eea065be4ad38b36f32af6e7dd9158d8fd1c08433"),
ArchiveSource("https://github.com/eschnett/MPIconstants/archive/refs/tags/v1.4.0.tar.gz",
"610d816c22cd05e16e17371c6384e0b6f9d3a2bdcb311824d0d40790812882fc"),
]
script = raw"""
apk add p7zip
cd ${WORKSPACE}/srcdir/
7z x -t# msmpisetup.exe -otmp
if [[ ${target} == i686-w64-* ]]; then
# 32-bit files
7z x tmp/2.msi -o$prefix
else
# 64-bit files
7z x tmp/4.msi -o$prefix
mv -f $prefix/msmpi64.dll $prefix/msmpi.dll
mv -f $prefix/msmpires64.dll $prefix/msmpires.dll
fi
7z x msmpisdk.msi -o$prefix
cd ${WORKSPACE}/destdir/
chmod +x *.exe
mkdir -p bin
mv *.exe *.dll bin
mkdir -p lib
mv *.lib lib
mkdir -p include
# Move to includedir only the mpifptr.h for current architecture
mv "mpifptr${nbits}.h" "include/mpifptr.h"
rm mpifptr*.h
mv *.h *.man include
mkdir -p src
mv *.f90 src
mkdir -p share/licenses/MicrosoftMPI
mv *.txt *.rtf share/licenses/MicrosoftMPI
################################################################################
# Install MPIconstants
################################################################################
cd ${WORKSPACE}/srcdir/MPIconstants*
mkdir build
cd build
if [[ "$target" == x86_64-w64-mingw32 ]]; then
cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DCMAKE_FIND_ROOT_PATH=${prefix} \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-DBUILD_SHARED_LIBS=ON \
-DMPI_HOME=$prefix \
-DMPI_GUESS_LIBRARY_NAME=MSMPI \
-DMPI_C_LIBRARIES=msmpi64 \
-DMPI_CXX_LIBRARIES=msmpi64 \
-DMPI_Fortran_LIBRARIES='msmpifec64;msmpi64;cfg_stub' \
..
elif [[ "$target" == *-mingw* ]]; then
cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DCMAKE_FIND_ROOT_PATH=${prefix} \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-DBUILD_SHARED_LIBS=ON \
-DMPI_HOME=$prefix \
-DMPI_GUESS_LIBRARY_NAME=MSMPI \
..
else
exit 1
fi
cmake --build . --config RelWithDebInfo --parallel $nproc
cmake --build . --config RelWithDebInfo --parallel $nproc --target install
install_license $WORKSPACE/destdir/share/licenses/MicrosoftMPI/* $WORKSPACE/srcdir/MPIconstants*/LICENSE.md
"""
platforms = filter!(Sys.iswindows, supported_platforms())
products = [
# MicrosoftMPI
LibraryProduct("msmpi", :libmpi),
ExecutableProduct("mpiexec", :mpiexec),
# MPIconstants
LibraryProduct("libload_time_mpi_constants", :libload_time_mpi_constants),
ExecutableProduct("generate_compile_time_mpi_constants", :generate_compile_time_mpi_constants),
]
dependencies = Dependency[
]
# Build the tarballs.
# We manually bump the version up to `v10.1.3` here to avoid compat-changing issues
# X-ref: https://github.com/JuliaRegistries/General/pull/28956
version = v"10.1.3"
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies)
| [
3500,
45755,
32875,
11,
350,
10025,
198,
198,
3672,
796,
366,
15905,
7378,
40,
1,
198,
9641,
796,
410,
1,
940,
13,
16,
13,
17,
1,
198,
82,
2203,
796,
685,
198,
220,
220,
220,
9220,
7416,
7203,
5450,
1378,
15002,
13,
40485,
13,
785,
14,
15002,
14,
64,
14,
20,
14,
17,
14,
64,
20,
22745,
6888,
20,
12,
1065,
3070,
12,
41289,
64,
12,
23,
21855,
23,
12,
24,
3312,
16344,
3104,
3609,
46872,
14,
907,
3149,
271,
316,
929,
13,
13499,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
66,
22515,
344,
18,
69,
2713,
67,
23726,
67,
47785,
69,
23,
1860,
7410,
67,
5999,
64,
19,
65,
4531,
19,
16072,
3132,
15630,
324,
22515,
1065,
344,
21855,
41948,
5036,
4134,
1350,
23,
65,
19,
12340,
198,
220,
220,
220,
9220,
7416,
7203,
5450,
1378,
15002,
13,
40485,
13,
785,
14,
15002,
14,
64,
14,
20,
14,
17,
14,
64,
20,
22745,
6888,
20,
12,
1065,
3070,
12,
41289,
64,
12,
23,
21855,
23,
12,
24,
3312,
16344,
3104,
3609,
46872,
14,
907,
3149,
9409,
74,
13,
907,
72,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
69,
24,
22985,
66,
4051,
69,
18082,
3720,
2231,
4521,
1765,
67,
5999,
1453,
64,
15,
2996,
1350,
19,
324,
2548,
65,
2623,
69,
2624,
1878,
21,
68,
22,
1860,
24,
21273,
67,
23,
16344,
16,
66,
2919,
42117,
12340,
198,
220,
220,
220,
20816,
7416,
7203,
5450,
1378,
12567,
13,
785,
14,
274,
1349,
3087,
14,
7378,
40,
9979,
1187,
14,
17474,
14,
5420,
82,
14,
31499,
14,
85,
16,
13,
19,
13,
15,
13,
18870,
13,
34586,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
39132,
67,
23,
1433,
66,
1828,
10210,
2713,
68,
1433,
68,
1558,
38056,
66,
21,
22842,
68,
15,
65,
21,
69,
24,
67,
18,
64,
17,
17457,
21101,
18,
16817,
1731,
67,
15,
67,
1821,
3720,
2919,
1065,
42980,
16072,
12340,
198,
60,
198,
198,
12048,
796,
8246,
37811,
198,
499,
74,
751,
279,
22,
13344,
198,
198,
10210,
25597,
33249,
4303,
11598,
92,
14,
10677,
15908,
14,
198,
22,
89,
2124,
532,
83,
2,
13845,
3149,
271,
316,
929,
13,
13499,
532,
313,
3149,
198,
361,
16410,
25597,
16793,
92,
6624,
1312,
33808,
12,
86,
2414,
12,
9,
2361,
11208,
788,
198,
220,
220,
220,
1303,
3933,
12,
2545,
3696,
198,
220,
220,
220,
767,
89,
2124,
45218,
14,
17,
13,
907,
72,
532,
78,
3,
40290,
198,
17772,
198,
220,
220,
220,
1303,
5598,
12,
2545,
3696,
198,
220,
220,
220,
767,
89,
2124,
45218,
14,
19,
13,
907,
72,
532,
78,
3,
40290,
198,
220,
220,
220,
285,
85,
532,
69,
720,
40290,
14,
907,
3149,
72,
2414,
13,
12736,
720,
40290,
14,
907,
3149,
72,
13,
12736,
198,
220,
220,
220,
285,
85,
532,
69,
720,
40290,
14,
907,
3149,
2387,
2414,
13,
12736,
720,
40290,
14,
907,
3149,
2387,
13,
12736,
198,
12463,
198,
22,
89,
2124,
13845,
3149,
9409,
74,
13,
907,
72,
532,
78,
3,
40290,
198,
198,
10210,
25597,
33249,
4303,
11598,
92,
14,
16520,
15908,
14,
198,
198,
354,
4666,
1343,
87,
46866,
13499,
198,
28015,
15908,
532,
79,
9874,
198,
76,
85,
46866,
13499,
46866,
12736,
9874,
198,
28015,
15908,
532,
79,
9195,
198,
76,
85,
46866,
8019,
9195,
198,
28015,
15908,
532,
79,
2291,
198,
2,
10028,
284,
3017,
343,
691,
262,
29034,
361,
20692,
13,
71,
329,
1459,
10959,
198,
76,
85,
366,
3149,
361,
20692,
38892,
77,
9895,
27422,
71,
1,
366,
17256,
14,
3149,
361,
20692,
13,
71,
1,
198,
26224,
29034,
361,
20692,
24620,
71,
198,
76,
85,
46866,
71,
46866,
805,
2291,
198,
28015,
15908,
532,
79,
12351,
198,
76,
85,
46866,
69,
3829,
12351,
198,
28015,
15908,
532,
79,
2648,
14,
677,
4541,
14,
15905,
7378,
40,
198,
76,
85,
46866,
14116,
46866,
17034,
69,
2648,
14,
677,
4541,
14,
15905,
7378,
40,
198,
198,
29113,
29113,
14468,
198,
2,
15545,
4904,
40,
9979,
1187,
198,
29113,
29113,
14468,
198,
198,
10210,
25597,
33249,
4303,
11598,
92,
14,
10677,
15908,
14,
7378,
40,
9979,
1187,
9,
198,
28015,
15908,
1382,
198,
10210,
1382,
198,
198,
361,
16410,
17971,
16793,
1,
6624,
2124,
4521,
62,
2414,
12,
86,
2414,
12,
2229,
86,
2624,
2361,
11208,
788,
198,
220,
220,
220,
12067,
539,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
9697,
5673,
7336,
62,
10468,
3535,
3398,
29833,
62,
25664,
28,
38892,
34,
5673,
7336,
62,
51,
46095,
62,
10468,
3535,
3398,
29833,
92,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
9697,
5673,
7336,
62,
37,
12115,
62,
13252,
2394,
62,
34219,
28,
38892,
40290,
92,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
9697,
5673,
7336,
62,
38604,
7036,
62,
47,
31688,
10426,
28,
38892,
40290,
92,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
11012,
52,
26761,
62,
9693,
1503,
1961,
62,
31271,
4462,
28,
1340,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
35,
7378,
40,
62,
39069,
43641,
40290,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
35,
7378,
40,
62,
38022,
7597,
62,
40347,
49,
13153,
62,
20608,
28,
5653,
7378,
40,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
35,
7378,
40,
62,
34,
62,
40347,
49,
1503,
11015,
28,
907,
3149,
72,
2414,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
35,
7378,
40,
62,
34,
8051,
62,
40347,
49,
1503,
11015,
28,
907,
3149,
72,
2414,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
35,
7378,
40,
62,
21926,
2596,
62,
40347,
49,
1503,
11015,
11639,
907,
3149,
361,
721,
2414,
26,
907,
3149,
72,
2414,
26,
37581,
62,
301,
549,
6,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
11485,
198,
417,
361,
16410,
17971,
16793,
1,
6624,
1635,
12,
2229,
86,
9,
2361,
11208,
788,
198,
220,
220,
220,
12067,
539,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
9697,
5673,
7336,
62,
10468,
3535,
3398,
29833,
62,
25664,
28,
38892,
34,
5673,
7336,
62,
51,
46095,
62,
10468,
3535,
3398,
29833,
92,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
9697,
5673,
7336,
62,
37,
12115,
62,
13252,
2394,
62,
34219,
28,
38892,
40290,
92,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
9697,
5673,
7336,
62,
38604,
7036,
62,
47,
31688,
10426,
28,
38892,
40290,
92,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
11012,
52,
26761,
62,
9693,
1503,
1961,
62,
31271,
4462,
28,
1340,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
35,
7378,
40,
62,
39069,
43641,
40290,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
532,
35,
7378,
40,
62,
38022,
7597,
62,
40347,
49,
13153,
62,
20608,
28,
5653,
7378,
40,
3467,
198,
220,
220,
220,
220,
220,
220,
220,
11485,
198,
17772,
198,
220,
220,
220,
8420,
352,
198,
12463,
198,
198,
11215,
539,
1377,
11249,
764,
1377,
11250,
4718,
3152,
16587,
12360,
1377,
1845,
29363,
720,
77,
36942,
198,
11215,
539,
1377,
11249,
764,
1377,
11250,
4718,
3152,
16587,
12360,
1377,
1845,
29363,
720,
77,
36942,
1377,
16793,
2721,
198,
198,
17350,
62,
43085,
720,
33249,
4303,
11598,
14,
16520,
15908,
14,
20077,
14,
677,
4541,
14,
15905,
7378,
40,
15211,
720,
33249,
4303,
11598,
14,
10677,
15908,
14,
7378,
40,
9979,
1187,
16208,
43,
2149,
24290,
13,
9132,
198,
37811,
198,
198,
24254,
82,
796,
8106,
0,
7,
44387,
13,
271,
28457,
11,
4855,
62,
24254,
82,
28955,
198,
198,
29498,
796,
685,
198,
220,
220,
220,
1303,
5413,
7378,
40,
198,
220,
220,
220,
10074,
15667,
7203,
907,
3149,
72,
1600,
1058,
8019,
3149,
72,
828,
198,
220,
220,
220,
8393,
18187,
15667,
7203,
3149,
494,
87,
721,
1600,
1058,
3149,
494,
87,
721,
828,
198,
220,
220,
220,
1303,
4904,
40,
9979,
1187,
198,
220,
220,
220,
10074,
15667,
7203,
8019,
2220,
62,
2435,
62,
3149,
72,
62,
9979,
1187,
1600,
1058,
8019,
2220,
62,
2435,
62,
3149,
72,
62,
9979,
1187,
828,
198,
220,
220,
220,
8393,
18187,
15667,
7203,
8612,
378,
62,
5589,
576,
62,
2435,
62,
3149,
72,
62,
9979,
1187,
1600,
1058,
8612,
378,
62,
5589,
576,
62,
2435,
62,
3149,
72,
62,
9979,
1187,
828,
198,
60,
198,
198,
45841,
3976,
796,
37947,
1387,
58,
198,
60,
198,
198,
2,
10934,
262,
13422,
21591,
13,
198,
2,
775,
14500,
13852,
262,
2196,
510,
284,
4600,
85,
940,
13,
16,
13,
18,
63,
994,
284,
3368,
8330,
12,
22954,
2428,
198,
2,
1395,
12,
5420,
25,
3740,
1378,
12567,
13,
785,
14,
16980,
544,
8081,
32995,
14,
12218,
14,
31216,
14,
2078,
50148,
198,
9641,
796,
410,
1,
940,
13,
16,
13,
18,
1,
198,
11249,
62,
18870,
21591,
7,
1503,
14313,
11,
1438,
11,
2196,
11,
4237,
11,
4226,
11,
9554,
11,
3186,
11,
20086,
8,
198
] | 2.214003 | 1,514 |
using FaultTolerantControl
using Transducers
using Plots
function main()
N = 4
d = 2
θ = [[0, 0], [0.3, 0.1], [0.5, 0.2], [0.7, 0.3], [1, 1]]
θ_x = θ |> Map(_θ -> _θ[1]) |> collect
θ_y = θ |> Map(_θ -> _θ[2]) |> collect
t0 = 0.0
tf = 1.0
curve = Bezier(θ, t0, tf)
curve_params = t0:0.01:tf
points = curve_params |> Map(curve) |> collect
points_x = points |> Map(point -> point[1]) |> collect
points_y = points |> Map(point -> point[2]) |> collect
fig = plot(points_x, points_y; label="Bezier curve")
plot!(fig, θ_x, θ_y; st=:scatter, label="control points")
end
| [
3500,
40050,
51,
13625,
415,
15988,
198,
3500,
3602,
41213,
198,
3500,
1345,
1747,
628,
198,
8818,
1388,
3419,
198,
220,
220,
220,
399,
796,
604,
198,
220,
220,
220,
288,
796,
362,
198,
220,
220,
220,
7377,
116,
796,
16410,
15,
11,
657,
4357,
685,
15,
13,
18,
11,
657,
13,
16,
4357,
685,
15,
13,
20,
11,
657,
13,
17,
4357,
685,
15,
13,
22,
11,
657,
13,
18,
4357,
685,
16,
11,
352,
11907,
198,
220,
220,
220,
7377,
116,
62,
87,
796,
7377,
116,
930,
29,
9347,
28264,
138,
116,
4613,
4808,
138,
116,
58,
16,
12962,
930,
29,
2824,
198,
220,
220,
220,
7377,
116,
62,
88,
796,
7377,
116,
930,
29,
9347,
28264,
138,
116,
4613,
4808,
138,
116,
58,
17,
12962,
930,
29,
2824,
198,
220,
220,
220,
256,
15,
796,
657,
13,
15,
198,
220,
220,
220,
48700,
796,
352,
13,
15,
198,
220,
220,
220,
12133,
796,
1355,
89,
959,
7,
138,
116,
11,
256,
15,
11,
48700,
8,
198,
220,
220,
220,
12133,
62,
37266,
796,
256,
15,
25,
15,
13,
486,
25,
27110,
198,
220,
220,
220,
2173,
796,
12133,
62,
37266,
930,
29,
9347,
7,
22019,
303,
8,
930,
29,
2824,
198,
220,
220,
220,
2173,
62,
87,
796,
2173,
930,
29,
9347,
7,
4122,
4613,
966,
58,
16,
12962,
930,
29,
2824,
198,
220,
220,
220,
2173,
62,
88,
796,
2173,
930,
29,
9347,
7,
4122,
4613,
966,
58,
17,
12962,
930,
29,
2824,
198,
220,
220,
220,
2336,
796,
7110,
7,
13033,
62,
87,
11,
2173,
62,
88,
26,
6167,
2625,
3856,
89,
959,
12133,
4943,
198,
220,
220,
220,
7110,
0,
7,
5647,
11,
7377,
116,
62,
87,
11,
7377,
116,
62,
88,
26,
336,
28,
25,
1416,
1436,
11,
6167,
2625,
13716,
2173,
4943,
198,
437,
198
] | 2.046205 | 303 |
# Attempt to compute a reasonable default mu: at the starting
# position, the gradient of the input function should dominate the
# gradient of the barrier.
function initial_mu(gfunc::AbstractArray{T}, gbarrier::AbstractArray{T}, mu0factor::T = 0.001, mu0::T = convert(T, NaN)) where T
if isnan(mu0)
gbarriernorm = sum(abs, gbarrier)
if gbarriernorm > 0
mu = mu0factor*sum(abs, gfunc)/gbarriernorm
else
# Presumably, there is no barrier function
mu = zero(T)
end
else
mu = mu0
end
return mu
end
function barrier_box(g, x::AbstractArray{T}, l::AbstractArray{T}, u::AbstractArray{T}) where T
calc_g = g !== nothing
v = zero(T)
@inbounds for i in eachindex(x)
thisl = l[i]
if isfinite(thisl)
dx = x[i] - thisl
if dx <= zero(T)
return convert(T, Inf)
end
v -= log(dx)
if calc_g
g[i] = -one(T)/dx
end
else
if calc_g
g[i] = zero(T)
end
end
thisu = u[i]
if isfinite(thisu)
dx = thisu - x[i]
if dx <= zero(T)
return convert(T, Inf)
end
v -= log(dx)
if calc_g
g[i] += one(T)/dx
end
end
end
return v
end
function function_barrier(gfunc, gbarrier, x::AbstractArray, f, fbarrier)
vbarrier = fbarrier(gbarrier, x)
return (isfinite(vbarrier) ? f(gfunc, x) : vbarrier), vbarrier
end
function barrier_combined(gfunc, gbarrier, g, x::AbstractArray,
fb, mu::Ref{<:Real})
valfunc, valbarrier = fb(gbarrier, x, gfunc)
if g !== nothing
g .= gfunc .+ mu[].*gbarrier
end
return convert(eltype(x), valfunc + mu[]*valbarrier) # FIXME make this unnecessary
end
function limits_box(x::AbstractArray{T}, d::AbstractArray{T},
l::AbstractArray{T}, u::AbstractArray{T}) where T
alphamax = convert(T, Inf)
@inbounds for i in eachindex(x)
if d[i] < 0
alphamax = min(alphamax, ((l[i]-x[i])+eps(l[i]))/d[i])
elseif d[i] > 0
alphamax = min(alphamax, ((u[i]-x[i])-eps(u[i]))/d[i])
end
end
epsilon = eps(max(alphamax, one(T)))
if !isinf(alphamax) && alphamax > epsilon
alphamax -= epsilon
end
return alphamax
end
# Default preconditioner for box-constrained optimization
# This creates the inverse Hessian of the barrier penalty
function precondprepbox!(P, x, l, u, mu)
@. P.diag = 1/(mu[]*(1/(x-l)^2 + 1/(u-x)^2) + 1)
end
struct Fminbox{O<:AbstractOptimizer, T, P} <: AbstractConstrainedOptimizer
method::O
mu0::T
mufactor::T
precondprep::P
end
"""
# Fminbox
## Constructor
```julia
Fminbox(method;
mu0=NaN,
mufactor=0.0001,
precondprep(P, x, l, u, mu) -> precondprepbox!(P, x, l, u, mu))
```
"""
function Fminbox(method::AbstractOptimizer = LBFGS();
mu0::Real = NaN, mufactor::Real = 0.001,
precondprep = (P, x, l, u, mu) -> precondprepbox!(P, x, l, u, mu))
if method isa Newton || method isa NewtonTrustRegion
throw(ArgumentError("Newton is not supported as the Fminbox optimizer."))
end
Fminbox(method, promote(mu0, mufactor)..., precondprep) # default optimizer
end
Base.summary(F::Fminbox) = "Fminbox with $(summary(F.method))"
# barrier_method() constructs an optimizer to solve the barrier problem using m = Fminbox.method as the reference.
# Essentially it only updates the P and precondprep fields of `m`.
# fallback
barrier_method(m::AbstractOptimizer, P, precondprep) =
error("You need to specify a valid inner optimizer for Fminbox, $m is not supported. Please consult the documentation.")
barrier_method(m::ConjugateGradient, P, precondprep) =
ConjugateGradient(eta = m.eta, alphaguess = m.alphaguess!,
linesearch = m.linesearch!, P = P,
precondprep = precondprep)
barrier_method(m::LBFGS, P, precondprep) =
LBFGS(alphaguess = m.alphaguess!, linesearch = m.linesearch!, P = P,
precondprep = precondprep)
barrier_method(m::GradientDescent, P, precondprep) =
GradientDescent(alphaguess = m.alphaguess!, linesearch = m.linesearch!, P = P,
precondprep = precondprep)
barrier_method(m::Union{NelderMead, SimulatedAnnealing, ParticleSwarm, BFGS, AbstractNGMRES},
P, precondprep) = m # use `m` as is
function optimize(f,
g,
l::AbstractArray{T},
u::AbstractArray{T},
initial_x::AbstractArray{T},
F::Fminbox = Fminbox(),
options = Options(); inplace = true, autodiff = :finite) where T<:AbstractFloat
g! = inplace ? g : (G, x) -> copyto!(G, g(x))
od = OnceDifferentiable(f, g!, initial_x, zero(T))
optimize(od, l, u, initial_x, F, options)
end
function optimize(f,
l::AbstractArray{T},
u::AbstractArray{T},
initial_x::AbstractArray{T},
F::Fminbox = Fminbox(),
options = Options(); inplace = true, autodiff = :finite) where T<:AbstractFloat
od = OnceDifferentiable(f, initial_x, zero(T); autodiff = autodiff)
optimize(od, l, u, initial_x, F, options)
end
function optimize(
df::OnceDifferentiable,
l::AbstractArray{T},
u::AbstractArray{T},
initial_x::AbstractArray{T},
F::Fminbox = Fminbox(),
options = Options()) where T<:AbstractFloat
outer_iterations = options.outer_iterations
allow_outer_f_increases = options.allow_outer_f_increases
show_trace, store_trace, extended_trace = options.show_trace, options.store_trace, options.extended_trace
x = copy(initial_x)
fbarrier = (gbarrier, x) -> barrier_box(gbarrier, x, l, u)
fb = (gbarrier, x, gfunc) -> function_barrier(gfunc, gbarrier, x, df.fdf, fbarrier)
gfunc = similar(x)
gbarrier = similar(x)
P = InverseDiagonal(similar(initial_x))
# to be careful about one special case that might occur commonly
# in practice: the initial guess x is exactly in the center of the
# box. In that case, gbarrier is zero. But since the
# initialization only makes use of the magnitude, we can fix this
# by using the sum of the absolute values of the contributions
# from each edge.
boundaryidx = Vector{Int}()
for i in eachindex(gbarrier)
thisx = x[i]
thisl = l[i]
thisu = u[i]
if thisx == thisl
thisx = 0.99*thisl+0.01*thisu
x[i] = thisx
push!(boundaryidx,i)
elseif thisx == thisu
thisx = 0.01*thisl+0.99*thisu
x[i] = thisx
push!(boundaryidx,i)
elseif thisx < thisl || thisx > thisu
throw(ArgumentError("Initial x[$(Tuple(CartesianIndices(x)[i]))]=$thisx is outside of [$thisl, $thisu]"))
end
gbarrier[i] = (isfinite(thisl) ? one(T)/(thisx-thisl) : zero(T)) + (isfinite(thisu) ? one(T)/(thisu-thisx) : zero(T))
end
if length(boundaryidx) > 0
@warn("Initial position cannot be on the boundary of the box. Moving elements to the interior.\nElement indices affected: $boundaryidx")
end
gradient!(df, x)
gfunc .= gradient(df)
mu = Ref(initial_mu(gfunc, gbarrier, T(F.mufactor), T(F.mu0)))
# Use the barrier-aware preconditioner to define
# barrier-aware optimization method instance (precondition relevance)
_optimizer = barrier_method(F.method, P, (P, x) -> F.precondprep(P, x, l, u, mu))
if show_trace > 0
println("Fminbox")
println("-------")
print("Initial mu = ")
show(IOContext(stdout, :compact=>true), "text/plain", mu[])
println("\n")
end
g = similar(x)
fval_all = Vector{Vector{T}}()
# Count the total number of outer iterations
iteration = 0
# define the function (dfbox) to optimize by the inner optimizer
funcc = (g, x) -> barrier_combined(gfunc, gbarrier, g, x, fb, mu)
dfbox = OnceDifferentiable(x -> funcc(nothing, x),
(g, x) -> (funcc(g, x); g),
funcc, initial_x, zero(T))
xold = similar(x)
converged = false
local results
first = true
fval0 = zero(T)
while !converged && iteration < outer_iterations
# Increment the number of steps we've had to perform
iteration += 1
copyto!(xold, x)
# Optimize with current setting of mu
fval0 = funcc(nothing, x)
if show_trace > 0
header_string = "Fminbox iteration $iteration"
println(header_string)
println("-"^length(header_string))
print("Calling inner optimizer with mu = ")
show(IOContext(stdout, :compact=>true), "text/plain", mu[])
println("\n")
println("(numbers below include barrier contribution)")
end
resultsnew = optimize(dfbox, x, _optimizer, options)
if first
results = resultsnew
first = false
else
append!(results, resultsnew)
end
copyto!(x, minimizer(results))
if show_trace > 0
println()
println("Exiting inner optimizer with x = ", x)
print("Current distance to box: ")
show(IOContext(stdout, :compact=>true), "text/plain", min(minimum(x-l), minimum(u-x)))
println()
println("Decreasing barrier term μ.\n")
end
# Decrease mu
mu[] *= F.mufactor
# Test for convergence
g .= gfunc .+ mu[].*gbarrier
results.x_converged, results.f_converged,
results.g_converged, converged, f_increased = assess_convergence(x, xold, minimum(results), fval0, g,
options.outer_x_tol, options.outer_f_tol, options.outer_g_tol)
if f_increased && !allow_outer_f_increases
@warn("f(x) increased: stopping optimization")
break
end
end
return MultivariateOptimizationResults(F, initial_x, minimizer(results), df.f(minimizer(results)),
iteration, results.iteration_converged,
results.x_converged, results.x_tol, norm(x - xold),
results.f_converged, results.f_tol, f_abschange(minimum(results), fval0),
results.g_converged, results.g_tol, norm(g, Inf),
results.f_increased, results.trace, results.f_calls,
results.g_calls, results.h_calls)
end
| [
2,
25770,
284,
24061,
257,
6397,
4277,
38779,
25,
379,
262,
3599,
198,
2,
2292,
11,
262,
31312,
286,
262,
5128,
2163,
815,
17863,
262,
198,
2,
31312,
286,
262,
13054,
13,
198,
8818,
4238,
62,
30300,
7,
70,
20786,
3712,
23839,
19182,
90,
51,
5512,
308,
5657,
5277,
3712,
23839,
19182,
90,
51,
5512,
38779,
15,
31412,
3712,
51,
796,
657,
13,
8298,
11,
38779,
15,
3712,
51,
796,
10385,
7,
51,
11,
11013,
45,
4008,
810,
309,
198,
220,
220,
220,
611,
2125,
272,
7,
30300,
15,
8,
198,
220,
220,
220,
220,
220,
220,
220,
308,
5657,
380,
1142,
579,
796,
2160,
7,
8937,
11,
308,
5657,
5277,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
308,
5657,
380,
1142,
579,
1875,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
38779,
796,
38779,
15,
31412,
9,
16345,
7,
8937,
11,
308,
20786,
20679,
70,
5657,
380,
1142,
579,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
48800,
11,
612,
318,
645,
13054,
2163,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
38779,
796,
6632,
7,
51,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
38779,
796,
38779,
15,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
38779,
198,
437,
198,
198,
8818,
13054,
62,
3524,
7,
70,
11,
2124,
3712,
23839,
19182,
90,
51,
5512,
300,
3712,
23839,
19182,
90,
51,
5512,
334,
3712,
23839,
19182,
90,
51,
30072,
810,
309,
198,
220,
220,
220,
42302,
62,
70,
796,
308,
5145,
855,
2147,
628,
220,
220,
220,
410,
796,
6632,
7,
51,
8,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
1312,
287,
1123,
9630,
7,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
428,
75,
796,
300,
58,
72,
60,
198,
220,
220,
220,
220,
220,
220,
220,
611,
318,
69,
9504,
7,
400,
3044,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44332,
796,
2124,
58,
72,
60,
532,
428,
75,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
44332,
19841,
6632,
7,
51,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10385,
7,
51,
11,
4806,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
410,
48185,
2604,
7,
34350,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
42302,
62,
70,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
308,
58,
72,
60,
796,
532,
505,
7,
51,
20679,
34350,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
42302,
62,
70,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
308,
58,
72,
60,
796,
6632,
7,
51,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
428,
84,
796,
334,
58,
72,
60,
198,
220,
220,
220,
220,
220,
220,
220,
611,
318,
69,
9504,
7,
5661,
84,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44332,
796,
428,
84,
532,
2124,
58,
72,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
44332,
19841,
6632,
7,
51,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10385,
7,
51,
11,
4806,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
410,
48185,
2604,
7,
34350,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
42302,
62,
70,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
308,
58,
72,
60,
15853,
530,
7,
51,
20679,
34350,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
410,
198,
437,
198,
198,
8818,
2163,
62,
5657,
5277,
7,
70,
20786,
11,
308,
5657,
5277,
11,
2124,
3712,
23839,
19182,
11,
277,
11,
277,
5657,
5277,
8,
198,
220,
220,
220,
410,
5657,
5277,
796,
277,
5657,
5277,
7,
70,
5657,
5277,
11,
2124,
8,
198,
220,
220,
220,
1441,
357,
4468,
9504,
7,
85,
5657,
5277,
8,
5633,
277,
7,
70,
20786,
11,
2124,
8,
1058,
410,
5657,
5277,
828,
410,
5657,
5277,
198,
437,
198,
198,
8818,
13054,
62,
24011,
1389,
7,
70,
20786,
11,
308,
5657,
5277,
11,
308,
11,
2124,
3712,
23839,
19182,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
277,
65,
11,
38779,
3712,
8134,
90,
27,
25,
15633,
30072,
198,
220,
220,
220,
1188,
20786,
11,
1188,
5657,
5277,
796,
277,
65,
7,
70,
5657,
5277,
11,
2124,
11,
308,
20786,
8,
198,
220,
220,
220,
611,
308,
5145,
855,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
308,
764,
28,
308,
20786,
764,
10,
38779,
58,
4083,
9,
70,
5657,
5277,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
10385,
7,
417,
4906,
7,
87,
828,
1188,
20786,
1343,
38779,
21737,
9,
2100,
5657,
5277,
8,
1303,
44855,
11682,
787,
428,
13114,
198,
437,
198,
198,
8818,
7095,
62,
3524,
7,
87,
3712,
23839,
19182,
90,
51,
5512,
288,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
300,
3712,
23839,
19182,
90,
51,
5512,
334,
3712,
23839,
19182,
90,
51,
30072,
810,
309,
198,
220,
220,
220,
435,
746,
321,
897,
796,
10385,
7,
51,
11,
4806,
8,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
1312,
287,
1123,
9630,
7,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
288,
58,
72,
60,
1279,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
435,
746,
321,
897,
796,
949,
7,
17307,
321,
897,
11,
14808,
75,
58,
72,
45297,
87,
58,
72,
12962,
10,
25386,
7,
75,
58,
72,
60,
4008,
14,
67,
58,
72,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
288,
58,
72,
60,
1875,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
435,
746,
321,
897,
796,
949,
7,
17307,
321,
897,
11,
14808,
84,
58,
72,
45297,
87,
58,
72,
12962,
12,
25386,
7,
84,
58,
72,
60,
4008,
14,
67,
58,
72,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
304,
862,
33576,
796,
304,
862,
7,
9806,
7,
17307,
321,
897,
11,
530,
7,
51,
22305,
198,
220,
220,
220,
611,
5145,
271,
10745,
7,
17307,
321,
897,
8,
11405,
435,
746,
321,
897,
1875,
304,
862,
33576,
198,
220,
220,
220,
220,
220,
220,
220,
435,
746,
321,
897,
48185,
304,
862,
33576,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
435,
746,
321,
897,
198,
437,
198,
198,
2,
15161,
3718,
623,
653,
263,
329,
3091,
12,
1102,
2536,
1328,
23989,
198,
2,
770,
8075,
262,
34062,
46305,
666,
286,
262,
13054,
7389,
198,
8818,
3718,
623,
46012,
3524,
0,
7,
47,
11,
2124,
11,
300,
11,
334,
11,
38779,
8,
198,
220,
220,
220,
2488,
13,
350,
13,
10989,
363,
796,
352,
29006,
30300,
21737,
9,
7,
16,
29006,
87,
12,
75,
8,
61,
17,
1343,
352,
29006,
84,
12,
87,
8,
61,
17,
8,
1343,
352,
8,
198,
437,
198,
198,
7249,
376,
1084,
3524,
90,
46,
27,
25,
23839,
27871,
320,
7509,
11,
309,
11,
350,
92,
1279,
25,
27741,
3103,
2536,
1328,
27871,
320,
7509,
198,
220,
220,
220,
2446,
3712,
46,
198,
220,
220,
220,
38779,
15,
3712,
51,
198,
220,
220,
220,
285,
3603,
273,
3712,
51,
198,
220,
220,
220,
3718,
623,
46012,
3712,
47,
198,
437,
198,
198,
37811,
198,
2,
376,
1084,
3524,
198,
2235,
28407,
273,
198,
15506,
63,
73,
43640,
198,
37,
1084,
3524,
7,
24396,
26,
198,
220,
220,
220,
220,
220,
220,
220,
38779,
15,
28,
26705,
45,
11,
198,
220,
220,
220,
220,
220,
220,
220,
285,
3603,
273,
28,
15,
13,
18005,
11,
198,
220,
220,
220,
220,
220,
220,
220,
3718,
623,
46012,
7,
47,
11,
2124,
11,
300,
11,
334,
11,
38779,
8,
4613,
3718,
623,
46012,
3524,
0,
7,
47,
11,
2124,
11,
300,
11,
334,
11,
38779,
4008,
198,
15506,
63,
198,
37811,
198,
8818,
376,
1084,
3524,
7,
24396,
3712,
23839,
27871,
320,
7509,
796,
22199,
37,
14313,
9783,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
38779,
15,
3712,
15633,
796,
11013,
45,
11,
285,
3603,
273,
3712,
15633,
796,
657,
13,
8298,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3718,
623,
46012,
796,
357,
47,
11,
2124,
11,
300,
11,
334,
11,
38779,
8,
4613,
3718,
623,
46012,
3524,
0,
7,
47,
11,
2124,
11,
300,
11,
334,
11,
38779,
4008,
198,
220,
220,
220,
611,
2446,
318,
64,
17321,
8614,
2446,
318,
64,
17321,
33814,
47371,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
3791,
1122,
318,
407,
4855,
355,
262,
376,
1084,
3524,
6436,
7509,
526,
4008,
198,
220,
220,
220,
886,
198,
220,
220,
220,
376,
1084,
3524,
7,
24396,
11,
7719,
7,
30300,
15,
11,
285,
3603,
273,
26513,
11,
3718,
623,
46012,
8,
1303,
4277,
6436,
7509,
198,
437,
198,
198,
14881,
13,
49736,
7,
37,
3712,
37,
1084,
3524,
8,
796,
366,
37,
1084,
3524,
351,
29568,
49736,
7,
37,
13,
24396,
4008,
1,
198,
198,
2,
13054,
62,
24396,
3419,
34175,
281,
6436,
7509,
284,
8494,
262,
13054,
1917,
1262,
285,
796,
376,
1084,
3524,
13,
24396,
355,
262,
4941,
13,
198,
2,
34039,
340,
691,
5992,
262,
350,
290,
3718,
623,
46012,
7032,
286,
4600,
76,
44646,
198,
198,
2,
2121,
1891,
198,
5657,
5277,
62,
24396,
7,
76,
3712,
23839,
27871,
320,
7509,
11,
350,
11,
3718,
623,
46012,
8,
796,
198,
220,
220,
220,
4049,
7203,
1639,
761,
284,
11986,
257,
4938,
8434,
6436,
7509,
329,
376,
1084,
3524,
11,
720,
76,
318,
407,
4855,
13,
4222,
5725,
262,
10314,
19570,
198,
198,
5657,
5277,
62,
24396,
7,
76,
3712,
3103,
31761,
378,
42731,
1153,
11,
350,
11,
3718,
623,
46012,
8,
796,
198,
220,
220,
220,
1482,
31761,
378,
42731,
1153,
7,
17167,
796,
285,
13,
17167,
11,
435,
746,
11433,
408,
796,
285,
13,
17307,
11433,
408,
28265,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3951,
3679,
796,
285,
13,
6615,
3679,
28265,
350,
796,
350,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3718,
623,
46012,
796,
3718,
623,
46012,
8,
198,
198,
5657,
5277,
62,
24396,
7,
76,
3712,
43,
29499,
14313,
11,
350,
11,
3718,
623,
46012,
8,
796,
198,
220,
220,
220,
22199,
37,
14313,
7,
17307,
11433,
408,
796,
285,
13,
17307,
11433,
408,
28265,
3951,
3679,
796,
285,
13,
6615,
3679,
28265,
350,
796,
350,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3718,
623,
46012,
796,
3718,
623,
46012,
8,
198,
198,
5657,
5277,
62,
24396,
7,
76,
3712,
42731,
1153,
5960,
1087,
11,
350,
11,
3718,
623,
46012,
8,
796,
198,
220,
220,
220,
17701,
1153,
5960,
1087,
7,
17307,
11433,
408,
796,
285,
13,
17307,
11433,
408,
28265,
3951,
3679,
796,
285,
13,
6615,
3679,
28265,
350,
796,
350,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3718,
623,
46012,
796,
3718,
623,
46012,
8,
198,
198,
5657,
5277,
62,
24396,
7,
76,
3712,
38176,
90,
8199,
6499,
44,
1329,
11,
3184,
4817,
43227,
4272,
11,
2142,
1548,
10462,
1670,
11,
41646,
14313,
11,
27741,
10503,
13599,
1546,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
350,
11,
3718,
623,
46012,
8,
796,
285,
1303,
779,
4600,
76,
63,
355,
318,
198,
198,
8818,
27183,
7,
69,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
308,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
300,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
334,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4238,
62,
87,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
376,
3712,
37,
1084,
3524,
796,
376,
1084,
3524,
22784,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3689,
796,
18634,
9783,
287,
5372,
796,
2081,
11,
1960,
375,
733,
796,
1058,
69,
9504,
8,
810,
309,
27,
25,
23839,
43879,
628,
220,
220,
220,
308,
0,
796,
287,
5372,
5633,
308,
1058,
357,
38,
11,
2124,
8,
4613,
4866,
1462,
0,
7,
38,
11,
308,
7,
87,
4008,
198,
220,
220,
220,
16298,
796,
4874,
40341,
3379,
7,
69,
11,
308,
28265,
4238,
62,
87,
11,
6632,
7,
51,
4008,
628,
220,
220,
220,
27183,
7,
375,
11,
300,
11,
334,
11,
4238,
62,
87,
11,
376,
11,
3689,
8,
198,
437,
198,
198,
8818,
27183,
7,
69,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
300,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
334,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4238,
62,
87,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
376,
3712,
37,
1084,
3524,
796,
376,
1084,
3524,
22784,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3689,
796,
18634,
9783,
287,
5372,
796,
2081,
11,
1960,
375,
733,
796,
1058,
69,
9504,
8,
810,
309,
27,
25,
23839,
43879,
628,
220,
220,
220,
16298,
796,
4874,
40341,
3379,
7,
69,
11,
4238,
62,
87,
11,
6632,
7,
51,
1776,
1960,
375,
733,
796,
1960,
375,
733,
8,
198,
220,
220,
220,
27183,
7,
375,
11,
300,
11,
334,
11,
4238,
62,
87,
11,
376,
11,
3689,
8,
198,
437,
198,
198,
8818,
27183,
7,
198,
220,
220,
220,
220,
220,
220,
220,
47764,
3712,
7454,
40341,
3379,
11,
198,
220,
220,
220,
220,
220,
220,
220,
300,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
334,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
4238,
62,
87,
3712,
23839,
19182,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
376,
3712,
37,
1084,
3524,
796,
376,
1084,
3524,
22784,
198,
220,
220,
220,
220,
220,
220,
220,
3689,
796,
18634,
28955,
810,
309,
27,
25,
23839,
43879,
628,
220,
220,
220,
12076,
62,
2676,
602,
796,
3689,
13,
39605,
62,
2676,
602,
198,
220,
220,
220,
1249,
62,
39605,
62,
69,
62,
24988,
1386,
796,
3689,
13,
12154,
62,
39605,
62,
69,
62,
24988,
1386,
198,
220,
220,
220,
905,
62,
40546,
11,
3650,
62,
40546,
11,
7083,
62,
40546,
796,
3689,
13,
12860,
62,
40546,
11,
3689,
13,
8095,
62,
40546,
11,
3689,
13,
2302,
1631,
62,
40546,
628,
220,
220,
220,
2124,
796,
4866,
7,
36733,
62,
87,
8,
198,
220,
220,
220,
277,
5657,
5277,
796,
357,
70,
5657,
5277,
11,
2124,
8,
4613,
13054,
62,
3524,
7,
70,
5657,
5277,
11,
2124,
11,
300,
11,
334,
8,
198,
220,
220,
220,
277,
65,
796,
357,
70,
5657,
5277,
11,
2124,
11,
308,
20786,
8,
4613,
2163,
62,
5657,
5277,
7,
70,
20786,
11,
308,
5657,
5277,
11,
2124,
11,
47764,
13,
69,
7568,
11,
277,
5657,
5277,
8,
198,
220,
220,
220,
308,
20786,
796,
2092,
7,
87,
8,
198,
220,
220,
220,
308,
5657,
5277,
796,
2092,
7,
87,
8,
198,
220,
220,
220,
350,
796,
554,
4399,
18683,
27923,
7,
38610,
7,
36733,
62,
87,
4008,
198,
220,
220,
220,
1303,
284,
307,
8161,
546,
530,
2041,
1339,
326,
1244,
3051,
8811,
198,
220,
220,
220,
1303,
287,
3357,
25,
262,
4238,
4724,
2124,
318,
3446,
287,
262,
3641,
286,
262,
198,
220,
220,
220,
1303,
3091,
13,
554,
326,
1339,
11,
308,
5657,
5277,
318,
6632,
13,
887,
1201,
262,
198,
220,
220,
220,
1303,
37588,
691,
1838,
779,
286,
262,
14735,
11,
356,
460,
4259,
428,
198,
220,
220,
220,
1303,
416,
1262,
262,
2160,
286,
262,
4112,
3815,
286,
262,
9284,
198,
220,
220,
220,
1303,
422,
1123,
5743,
13,
198,
220,
220,
220,
18645,
312,
87,
796,
20650,
90,
5317,
92,
3419,
198,
220,
220,
220,
329,
1312,
287,
1123,
9630,
7,
70,
5657,
5277,
8,
198,
220,
220,
220,
220,
220,
220,
220,
428,
87,
796,
2124,
58,
72,
60,
198,
220,
220,
220,
220,
220,
220,
220,
428,
75,
796,
300,
58,
72,
60,
198,
220,
220,
220,
220,
220,
220,
220,
428,
84,
796,
334,
58,
72,
60,
628,
220,
220,
220,
220,
220,
220,
220,
611,
428,
87,
6624,
428,
75,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
428,
87,
796,
657,
13,
2079,
9,
400,
3044,
10,
15,
13,
486,
9,
5661,
84,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
58,
72,
60,
796,
428,
87,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
7784,
560,
312,
87,
11,
72,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
428,
87,
6624,
428,
84,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
428,
87,
796,
657,
13,
486,
9,
400,
3044,
10,
15,
13,
2079,
9,
5661,
84,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
58,
72,
60,
796,
428,
87,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
7784,
560,
312,
87,
11,
72,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
428,
87,
1279,
428,
75,
8614,
428,
87,
1875,
428,
84,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
24243,
2124,
58,
3,
7,
51,
29291,
7,
43476,
35610,
5497,
1063,
7,
87,
38381,
72,
60,
4008,
22241,
3,
5661,
87,
318,
2354,
286,
685,
3,
400,
3044,
11,
720,
5661,
84,
30866,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
308,
5657,
5277,
58,
72,
60,
796,
357,
4468,
9504,
7,
400,
3044,
8,
5633,
530,
7,
51,
20679,
7,
5661,
87,
12,
400,
3044,
8,
1058,
6632,
7,
51,
4008,
1343,
357,
4468,
9504,
7,
5661,
84,
8,
5633,
530,
7,
51,
20679,
7,
5661,
84,
12,
5661,
87,
8,
1058,
6632,
7,
51,
4008,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
4129,
7,
7784,
560,
312,
87,
8,
1875,
657,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
40539,
7203,
24243,
2292,
2314,
307,
319,
262,
18645,
286,
262,
3091,
13,
26768,
4847,
284,
262,
11087,
13,
59,
77,
20180,
36525,
5676,
25,
720,
7784,
560,
312,
87,
4943,
198,
220,
220,
220,
886,
628,
220,
220,
220,
31312,
0,
7,
7568,
11,
2124,
8,
198,
220,
220,
220,
308,
20786,
764,
28,
31312,
7,
7568,
8,
628,
220,
220,
220,
38779,
796,
6524,
7,
36733,
62,
30300,
7,
70,
20786,
11,
308,
5657,
5277,
11,
309,
7,
37,
13,
76,
3603,
273,
828,
309,
7,
37,
13,
30300,
15,
22305,
628,
220,
220,
220,
1303,
5765,
262,
13054,
12,
9685,
3718,
623,
653,
263,
284,
8160,
198,
220,
220,
220,
1303,
13054,
12,
9685,
23989,
2446,
4554,
357,
3866,
31448,
23082,
8,
198,
220,
220,
220,
4808,
40085,
7509,
796,
13054,
62,
24396,
7,
37,
13,
24396,
11,
350,
11,
357,
47,
11,
2124,
8,
4613,
376,
13,
3866,
17561,
46012,
7,
47,
11,
2124,
11,
300,
11,
334,
11,
38779,
4008,
628,
220,
220,
220,
611,
905,
62,
40546,
1875,
657,
198,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
37,
1084,
3524,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
26866,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
24243,
38779,
796,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
905,
7,
9399,
21947,
7,
19282,
448,
11,
1058,
5589,
529,
14804,
7942,
828,
366,
5239,
14,
25638,
1600,
38779,
58,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
59,
77,
4943,
198,
220,
220,
220,
886,
628,
220,
220,
220,
308,
796,
2092,
7,
87,
8,
198,
220,
220,
220,
277,
2100,
62,
439,
796,
20650,
90,
38469,
90,
51,
11709,
3419,
628,
220,
220,
220,
1303,
2764,
262,
2472,
1271,
286,
12076,
34820,
198,
220,
220,
220,
24415,
796,
657,
628,
220,
220,
220,
1303,
8160,
262,
2163,
357,
7568,
3524,
8,
284,
27183,
416,
262,
8434,
6436,
7509,
198,
220,
220,
220,
1257,
535,
796,
357,
70,
11,
2124,
8,
4613,
13054,
62,
24011,
1389,
7,
70,
20786,
11,
308,
5657,
5277,
11,
308,
11,
2124,
11,
277,
65,
11,
38779,
8,
198,
220,
220,
220,
47764,
3524,
796,
4874,
40341,
3379,
7,
87,
4613,
1257,
535,
7,
22366,
11,
2124,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
70,
11,
2124,
8,
4613,
357,
12543,
535,
7,
70,
11,
2124,
1776,
308,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1257,
535,
11,
4238,
62,
87,
11,
6632,
7,
51,
4008,
628,
220,
220,
220,
2124,
727,
796,
2092,
7,
87,
8,
198,
220,
220,
220,
6718,
2004,
796,
3991,
198,
220,
220,
220,
1957,
2482,
198,
220,
220,
220,
717,
796,
2081,
198,
220,
220,
220,
277,
2100,
15,
796,
6632,
7,
51,
8,
628,
220,
220,
220,
981,
5145,
1102,
332,
2004,
11405,
24415,
1279,
12076,
62,
2676,
602,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
10791,
434,
262,
1271,
286,
4831,
356,
1053,
550,
284,
1620,
198,
220,
220,
220,
220,
220,
220,
220,
24415,
15853,
352,
628,
220,
220,
220,
220,
220,
220,
220,
4866,
1462,
0,
7,
87,
727,
11,
2124,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
30011,
1096,
351,
1459,
4634,
286,
38779,
198,
220,
220,
220,
220,
220,
220,
220,
277,
2100,
15,
796,
1257,
535,
7,
22366,
11,
2124,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
905,
62,
40546,
1875,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13639,
62,
8841,
796,
366,
37,
1084,
3524,
24415,
720,
2676,
341,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
7,
25677,
62,
8841,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
21215,
61,
13664,
7,
25677,
62,
8841,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
48593,
8434,
6436,
7509,
351,
38779,
796,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
905,
7,
9399,
21947,
7,
19282,
448,
11,
1058,
5589,
529,
14804,
7942,
828,
366,
5239,
14,
25638,
1600,
38779,
58,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
7,
77,
17024,
2174,
2291,
13054,
10156,
8,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
2482,
3605,
796,
27183,
7,
7568,
3524,
11,
2124,
11,
4808,
40085,
7509,
11,
3689,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
717,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2482,
796,
2482,
3605,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
717,
796,
3991,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
24443,
0,
7,
43420,
11,
2482,
3605,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
4866,
1462,
0,
7,
87,
11,
10356,
7509,
7,
43420,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
611,
905,
62,
40546,
1875,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
3109,
1780,
8434,
6436,
7509,
351,
2124,
796,
33172,
2124,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
11297,
5253,
284,
3091,
25,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
905,
7,
9399,
21947,
7,
19282,
448,
11,
1058,
5589,
529,
14804,
7942,
828,
366,
5239,
14,
25638,
1600,
949,
7,
39504,
7,
87,
12,
75,
828,
5288,
7,
84,
12,
87,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
43198,
2313,
13054,
3381,
18919,
13,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
36400,
589,
38779,
198,
220,
220,
220,
220,
220,
220,
220,
38779,
21737,
1635,
28,
376,
13,
76,
3603,
273,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
6208,
329,
40826,
198,
220,
220,
220,
220,
220,
220,
220,
308,
764,
28,
308,
20786,
764,
10,
38779,
58,
4083,
9,
70,
5657,
5277,
628,
220,
220,
220,
220,
220,
220,
220,
2482,
13,
87,
62,
1102,
332,
2004,
11,
2482,
13,
69,
62,
1102,
332,
2004,
11,
198,
220,
220,
220,
220,
220,
220,
220,
2482,
13,
70,
62,
1102,
332,
2004,
11,
6718,
2004,
11,
277,
62,
24988,
839,
796,
4659,
62,
1102,
332,
12745,
7,
87,
11,
2124,
727,
11,
5288,
7,
43420,
828,
277,
2100,
15,
11,
308,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3689,
13,
39605,
62,
87,
62,
83,
349,
11,
3689,
13,
39605,
62,
69,
62,
83,
349,
11,
3689,
13,
39605,
62,
70,
62,
83,
349,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
277,
62,
24988,
839,
11405,
5145,
12154,
62,
39605,
62,
69,
62,
24988,
1386,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
40539,
7203,
69,
7,
87,
8,
3220,
25,
12225,
23989,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
7854,
42524,
27871,
320,
1634,
25468,
7,
37,
11,
4238,
62,
87,
11,
10356,
7509,
7,
43420,
828,
47764,
13,
69,
7,
1084,
320,
7509,
7,
43420,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
24415,
11,
2482,
13,
2676,
341,
62,
1102,
332,
2004,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2482,
13,
87,
62,
1102,
332,
2004,
11,
2482,
13,
87,
62,
83,
349,
11,
2593,
7,
87,
532,
2124,
727,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2482,
13,
69,
62,
1102,
332,
2004,
11,
2482,
13,
69,
62,
83,
349,
11,
277,
62,
8937,
3803,
7,
39504,
7,
43420,
828,
277,
2100,
15,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2482,
13,
70,
62,
1102,
332,
2004,
11,
2482,
13,
70,
62,
83,
349,
11,
2593,
7,
70,
11,
4806,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2482,
13,
69,
62,
24988,
839,
11,
2482,
13,
40546,
11,
2482,
13,
69,
62,
66,
5691,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2482,
13,
70,
62,
66,
5691,
11,
2482,
13,
71,
62,
66,
5691,
8,
198,
437,
198
] | 2.131997 | 5,038 |
<filename>src/tst/make-ref.jl
import NSG: make_ref, make_bed
function tst_make_ref()
lmp = ["dat/2021-05/data/maps/HD.map",
"dat/2021-05/data/maps/18k_v1.map",
"dat/2021-05/data/maps/18k_v2.map",
"dat/2021-05/data/maps/18k_v3.map",
"dat/2021-05/data/maps/18k_v4.map",
"dat/2021-05/data/maps/8k_rudi.map"]
frd = ["dat/2021-05/data/genotypes/600k", # final report directory
"dat/2021-05/data/genotypes/b17k",
"dat/2021-05/data/genotypes/a17k",
"dat/2021-05/data/genotypes/g17k",
"dat/2021-05/data/genotypes/S18k_v4",
"dat/2021-05/data/genotypes/7327"]
tgt = ["dat/2021-05/result/hd",
"dat/2021-05/result/v1",
"dat/2021-05/result/v2",
"dat/2021-05/result/v3",
"dat/2021-05/result/v4",
"dat/2021-05/result/8k"]
for i in 1:6
# Note, here I used the simplified version of `make_bed`
# You can later change it to:
# make_bed(dir, lmap, sid, nf, target)
make_bed(frd[i], lmp[i], tgt[i])
end
make_ref("dat/2021-05/result/v2ref", lmp[3], tgt[1:5]...)
make_ref("dat/2021-05/result/v4ref", lmp[5], tgt[1:5]...)
end
| [
27,
34345,
29,
10677,
14,
83,
301,
14,
15883,
12,
5420,
13,
20362,
198,
11748,
10896,
38,
25,
787,
62,
5420,
11,
787,
62,
3077,
198,
8818,
256,
301,
62,
15883,
62,
5420,
3419,
198,
220,
220,
220,
300,
3149,
796,
14631,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
31803,
14,
10227,
13,
8899,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
31803,
14,
1507,
74,
62,
85,
16,
13,
8899,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
31803,
14,
1507,
74,
62,
85,
17,
13,
8899,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
31803,
14,
1507,
74,
62,
85,
18,
13,
8899,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
31803,
14,
1507,
74,
62,
85,
19,
13,
8899,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
31803,
14,
23,
74,
62,
81,
47928,
13,
8899,
8973,
628,
220,
220,
220,
1216,
67,
796,
14631,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
5235,
13567,
14,
8054,
74,
1600,
1303,
2457,
989,
8619,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
5235,
13567,
14,
65,
1558,
74,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
5235,
13567,
14,
64,
1558,
74,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
5235,
13567,
14,
70,
1558,
74,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
5235,
13567,
14,
50,
1507,
74,
62,
85,
19,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
7890,
14,
5235,
13567,
14,
4790,
1983,
8973,
628,
220,
220,
220,
256,
13655,
796,
14631,
19608,
14,
1238,
2481,
12,
2713,
14,
20274,
14,
31298,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
20274,
14,
85,
16,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
20274,
14,
85,
17,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
20274,
14,
85,
18,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
20274,
14,
85,
19,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19608,
14,
1238,
2481,
12,
2713,
14,
20274,
14,
23,
74,
8973,
628,
220,
220,
220,
329,
1312,
287,
352,
25,
21,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
5740,
11,
994,
314,
973,
262,
27009,
2196,
286,
4600,
15883,
62,
3077,
63,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
921,
460,
1568,
1487,
340,
284,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
787,
62,
3077,
7,
15908,
11,
300,
8899,
11,
9785,
11,
299,
69,
11,
2496,
8,
198,
220,
220,
220,
220,
220,
220,
220,
787,
62,
3077,
7,
69,
4372,
58,
72,
4357,
300,
3149,
58,
72,
4357,
256,
13655,
58,
72,
12962,
198,
220,
220,
220,
886,
628,
220,
220,
220,
787,
62,
5420,
7203,
19608,
14,
1238,
2481,
12,
2713,
14,
20274,
14,
85,
17,
5420,
1600,
300,
3149,
58,
18,
4357,
256,
13655,
58,
16,
25,
20,
60,
23029,
198,
220,
220,
220,
787,
62,
5420,
7203,
19608,
14,
1238,
2481,
12,
2713,
14,
20274,
14,
85,
19,
5420,
1600,
300,
3149,
58,
20,
4357,
256,
13655,
58,
16,
25,
20,
60,
23029,
198,
437,
198
] | 1.767575 | 697 |
<reponame>JasmineHao/DCDC.jl<filename>dev/test.jl
using LinearAlgebra, DataFrames,Optim, ForwardDiff, BenchmarkTools,Distributions,
Expectations, QuantEcon, Statistics, GLM
using Distributions: invsqrt2π, log2π, sqrt2, invsqrt2
using DCDC
using Test
using Distributed, Suppressor
using Plots
begin "Dynamic Decision Process"
σ₀ = 1;
β = 0.8;
nM = 50;
nT = 5;
ddc = DynamicDecisionProcess(σ₀,0.8);
plot(ddc.ValueFn.xdata,ddc.ValueFn.y);
plot!(ddc.PolicyFn.xdata,ddc.PolicyFn.y);
data = simulate_ddc(nM,nT,ddc);
end
begin "GLM"
x = randn(300,3);
y = x * [1,3,4] + randn(300);
testdata = DataFrame(x);
testdata.y = y;
ols = lm(@formula(y ~ x1+x2+x3), testdata);
@show stderror(ols);
# @show ols.model.pp.beta0;
end
using ForwardDiff
begin "ForwardDiff"
h(x) = sin(x[1]) + x[1] * x[2] + sinh(x[1] * x[2]) # multivariate.
x = [1.4 2.2]
@show ForwardDiff.gradient(h,x) # use AD, seeds from x
#Or, can use complicated functions of many variables
f(x) = sum(sin, x) + prod(tan, x) * sum(sqrt, x)
g = (x) -> ForwardDiff.gradient(f, x); # g() is now the gradient
@show g(rand(20)); # gradient at a random point
function squareroot(x) #pretending we don't know sqrt()
z = copy(x) # Initial starting point for Newton’s method
while abs(z*z - x) > 1e-13
z = z - (z*z-x)/(2z)
end
return z
end
sqrt(2.0)
dsqrt(x) = ForwardDiff.derivative(squareroot, x)
dsqrt(2.0)
end
begin "Multi-variate function: Can we forwarddiff?"
func = (x,y) -> x^3 + y^2;
kk = y->(x->func(x,y));
a,b = randn(2);
ans1 = kk(b)(a);
ans2 = func(a,b);
@show ans1 == ans2;
dfunx = (x,y) -> ForwardDiff.derivative(z->kk(y)(z),x);
dfunx2 = (x,y) -> ForwardDiff.derivative(z->func(z,y),x);
deriv1 =dfunx(a,b);
deriv2 = dfunx2(a,b);
@show deriv1 == deriv2;
end
begin "Test transition derivative"
dtrans_x = (x,y) -> ForwardDiff.derivative( z-> ddc.trans(z,y),x) #Derivative w.r.t first component
dtrans_c = (x,y) -> ForwardDiff.derivative( z-> ddc.trans(y,z),x) #Derivative w.r.t second component
dtrans_x(1,3) == 1.05
end
using Flux
using Flux.Tracker
using Flux.Tracker: update!
begin "Test flux: graident and jacobian"
f(x) = 3x^2 + 2x + 1
# df/dx = 6x + 2
df(x) = Tracker.gradient(f, x)[1]
df(2);
A = rand(2,2);
f(x) = A * x
x0 = [0.1, 2.0]
f(x0)
Flux.jacobian(f, x0)
end
using TimerOutputs
begin
# Create the timer object
to = TimerOutput()
# Time something with an assigned label
@timeit to "sleep" sleep(0.3)
# Data is accumulated for multiple calls
for i in 1:100
@timeit to "loop" 1+1
end
# Nested sections are possible
@timeit to "nest 1" begin
@timeit to "nest 2" begin
@timeit to "nest 3.1" rand(10^3)
@timeit to "nest 3.2" rand(10^4)
@timeit to "nest 3.3" rand(10^5)
end
rand(10^6)
end
end
# Expectations
begin "Test Expectatoin"
dist = Normal();
E = expectation(dist, Gaussian; n = 301)
f = x -> x^2
expectation(f, dist)
end
using Optim
using Optim: converged, maximum, maximizer, minimizer, iterations #some extra functions
begin "Test Optim"
result = optimize(x-> x^2, -2.0, 1.0)
@show converged(result) || error("Failed to converge in $(iterations(result)) iterations")
@show xmin = result.minimizer
@show result.minimum
end
| [
27,
7856,
261,
480,
29,
41,
292,
3810,
39,
5488,
14,
35,
47667,
13,
20362,
27,
34345,
29,
7959,
14,
9288,
13,
20362,
198,
3500,
44800,
2348,
29230,
11,
6060,
35439,
11,
27871,
320,
11,
19530,
28813,
11,
25187,
4102,
33637,
11,
20344,
2455,
507,
11,
198,
220,
220,
220,
23600,
602,
11,
16972,
36,
1102,
11,
14370,
11,
10188,
44,
198,
3500,
46567,
507,
25,
800,
31166,
17034,
17,
46582,
11,
2604,
17,
46582,
11,
19862,
17034,
17,
11,
800,
31166,
17034,
17,
198,
3500,
6257,
9697,
198,
3500,
6208,
198,
3500,
4307,
6169,
11,
8105,
44292,
198,
3500,
1345,
1747,
198,
198,
27471,
366,
44090,
26423,
10854,
1,
198,
220,
220,
220,
18074,
225,
158,
224,
222,
796,
352,
26,
198,
220,
220,
220,
27169,
796,
657,
13,
23,
26,
198,
220,
220,
220,
299,
44,
796,
2026,
26,
198,
220,
220,
220,
299,
51,
796,
642,
26,
198,
220,
220,
220,
288,
17896,
796,
26977,
10707,
1166,
18709,
7,
38392,
158,
224,
222,
11,
15,
13,
23,
1776,
198,
220,
220,
220,
7110,
7,
1860,
66,
13,
11395,
37,
77,
13,
87,
7890,
11,
1860,
66,
13,
11395,
37,
77,
13,
88,
1776,
198,
220,
220,
220,
7110,
0,
7,
1860,
66,
13,
36727,
37,
77,
13,
87,
7890,
11,
1860,
66,
13,
36727,
37,
77,
13,
88,
1776,
198,
220,
220,
220,
1366,
796,
29308,
62,
1860,
66,
7,
77,
44,
11,
77,
51,
11,
1860,
66,
1776,
198,
437,
198,
198,
27471,
366,
8763,
44,
1,
198,
220,
220,
220,
2124,
796,
43720,
77,
7,
6200,
11,
18,
1776,
198,
220,
220,
220,
331,
796,
2124,
1635,
685,
16,
11,
18,
11,
19,
60,
1343,
43720,
77,
7,
6200,
1776,
198,
220,
220,
220,
1332,
7890,
796,
6060,
19778,
7,
87,
1776,
198,
220,
220,
220,
1332,
7890,
13,
88,
796,
331,
26,
198,
220,
220,
220,
267,
7278,
796,
300,
76,
7,
31,
687,
4712,
7,
88,
5299,
2124,
16,
10,
87,
17,
10,
87,
18,
828,
1332,
7890,
1776,
198,
220,
220,
220,
2488,
12860,
336,
1082,
1472,
7,
10220,
1776,
198,
220,
220,
220,
1303,
2488,
12860,
267,
7278,
13,
19849,
13,
381,
13,
31361,
15,
26,
198,
437,
198,
198,
3500,
19530,
28813,
198,
27471,
366,
39746,
28813,
1,
198,
220,
220,
220,
289,
7,
87,
8,
796,
7813,
7,
87,
58,
16,
12962,
1343,
2124,
58,
16,
60,
1635,
2124,
58,
17,
60,
1343,
7813,
71,
7,
87,
58,
16,
60,
1635,
2124,
58,
17,
12962,
1303,
1963,
42524,
13,
198,
220,
220,
220,
2124,
796,
685,
16,
13,
19,
362,
13,
17,
60,
198,
220,
220,
220,
2488,
12860,
19530,
28813,
13,
49607,
7,
71,
11,
87,
8,
1303,
779,
5984,
11,
11904,
422,
2124,
198,
220,
220,
220,
1303,
5574,
11,
460,
779,
8253,
5499,
286,
867,
9633,
198,
220,
220,
220,
277,
7,
87,
8,
796,
2160,
7,
31369,
11,
2124,
8,
1343,
40426,
7,
38006,
11,
2124,
8,
1635,
2160,
7,
31166,
17034,
11,
2124,
8,
198,
220,
220,
220,
308,
796,
357,
87,
8,
4613,
19530,
28813,
13,
49607,
7,
69,
11,
2124,
1776,
1303,
308,
3419,
318,
783,
262,
31312,
198,
220,
220,
220,
2488,
12860,
308,
7,
25192,
7,
1238,
18125,
1303,
31312,
379,
257,
4738,
966,
628,
220,
220,
220,
2163,
6616,
15763,
7,
87,
8,
1303,
5310,
1571,
356,
836,
470,
760,
19862,
17034,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1976,
796,
4866,
7,
87,
8,
1303,
20768,
3599,
966,
329,
17321,
447,
247,
82,
2446,
198,
220,
220,
220,
220,
220,
220,
220,
981,
2352,
7,
89,
9,
89,
532,
2124,
8,
1875,
352,
68,
12,
1485,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1976,
796,
1976,
532,
357,
89,
9,
89,
12,
87,
20679,
7,
17,
89,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1976,
198,
220,
220,
220,
886,
198,
220,
220,
220,
19862,
17034,
7,
17,
13,
15,
8,
198,
220,
220,
220,
288,
31166,
17034,
7,
87,
8,
796,
19530,
28813,
13,
1082,
452,
876,
7,
23415,
15763,
11,
2124,
8,
198,
220,
220,
220,
288,
31166,
17034,
7,
17,
13,
15,
8,
198,
437,
628,
198,
27471,
366,
29800,
12,
25641,
378,
2163,
25,
1680,
356,
2651,
26069,
1701,
198,
220,
220,
220,
25439,
796,
357,
87,
11,
88,
8,
4613,
2124,
61,
18,
1343,
331,
61,
17,
26,
198,
220,
220,
220,
479,
74,
220,
796,
331,
3784,
7,
87,
3784,
20786,
7,
87,
11,
88,
18125,
198,
220,
220,
220,
257,
11,
65,
796,
43720,
77,
7,
17,
1776,
198,
220,
220,
220,
9093,
16,
796,
479,
74,
7,
65,
5769,
64,
1776,
198,
220,
220,
220,
9093,
17,
796,
25439,
7,
64,
11,
65,
1776,
198,
220,
220,
220,
2488,
12860,
9093,
16,
6624,
9093,
17,
26,
198,
220,
220,
220,
288,
12543,
87,
796,
357,
87,
11,
88,
8,
4613,
19530,
28813,
13,
1082,
452,
876,
7,
89,
3784,
28747,
7,
88,
5769,
89,
828,
87,
1776,
198,
220,
220,
220,
288,
12543,
87,
17,
796,
357,
87,
11,
88,
8,
4613,
19530,
28813,
13,
1082,
452,
876,
7,
89,
3784,
20786,
7,
89,
11,
88,
828,
87,
1776,
198,
220,
220,
220,
16124,
16,
796,
7568,
403,
87,
7,
64,
11,
65,
1776,
198,
220,
220,
220,
16124,
17,
796,
288,
12543,
87,
17,
7,
64,
11,
65,
1776,
198,
220,
220,
220,
2488,
12860,
16124,
16,
6624,
16124,
17,
26,
198,
437,
198,
198,
27471,
366,
14402,
6801,
27255,
1,
198,
220,
220,
220,
288,
7645,
62,
87,
796,
357,
87,
11,
88,
8,
4613,
19530,
28813,
13,
1082,
452,
876,
7,
1976,
3784,
288,
17896,
13,
7645,
7,
89,
11,
88,
828,
87,
8,
1303,
28532,
452,
876,
266,
13,
81,
13,
83,
717,
7515,
198,
220,
220,
220,
288,
7645,
62,
66,
796,
357,
87,
11,
88,
8,
4613,
19530,
28813,
13,
1082,
452,
876,
7,
1976,
3784,
288,
17896,
13,
7645,
7,
88,
11,
89,
828,
87,
8,
1303,
28532,
452,
876,
266,
13,
81,
13,
83,
1218,
7515,
198,
220,
220,
220,
288,
7645,
62,
87,
7,
16,
11,
18,
8,
6624,
352,
13,
2713,
198,
437,
198,
198,
3500,
1610,
2821,
198,
3500,
1610,
2821,
13,
35694,
198,
3500,
1610,
2821,
13,
35694,
25,
4296,
0,
198,
27471,
366,
14402,
28462,
25,
7933,
738,
290,
474,
330,
672,
666,
1,
198,
220,
220,
220,
277,
7,
87,
8,
796,
513,
87,
61,
17,
1343,
362,
87,
1343,
352,
198,
220,
220,
220,
1303,
47764,
14,
34350,
796,
718,
87,
1343,
362,
198,
220,
220,
220,
47764,
7,
87,
8,
796,
26885,
13,
49607,
7,
69,
11,
2124,
38381,
16,
60,
198,
220,
220,
220,
47764,
7,
17,
1776,
198,
220,
220,
220,
317,
796,
43720,
7,
17,
11,
17,
1776,
198,
220,
220,
220,
277,
7,
87,
8,
796,
317,
1635,
2124,
198,
220,
220,
220,
2124,
15,
796,
685,
15,
13,
16,
11,
362,
13,
15,
60,
198,
220,
220,
220,
277,
7,
87,
15,
8,
198,
220,
220,
220,
1610,
2821,
13,
30482,
672,
666,
7,
69,
11,
2124,
15,
8,
198,
437,
198,
198,
3500,
5045,
263,
26410,
82,
198,
27471,
198,
220,
220,
220,
1303,
13610,
262,
19781,
2134,
198,
220,
220,
220,
284,
796,
5045,
263,
26410,
3419,
198,
220,
220,
220,
1303,
3862,
1223,
351,
281,
8686,
6167,
198,
220,
220,
220,
2488,
2435,
270,
284,
366,
42832,
1,
3993,
7,
15,
13,
18,
8,
198,
220,
220,
220,
1303,
6060,
318,
22425,
329,
3294,
3848,
198,
220,
220,
220,
329,
1312,
287,
352,
25,
3064,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
2435,
270,
284,
366,
26268,
1,
352,
10,
16,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1303,
399,
7287,
9004,
389,
1744,
198,
220,
220,
220,
2488,
2435,
270,
284,
366,
77,
395,
352,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
2435,
270,
284,
366,
77,
395,
362,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
2435,
270,
284,
366,
77,
395,
513,
13,
16,
1,
43720,
7,
940,
61,
18,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
2435,
270,
284,
366,
77,
395,
513,
13,
17,
1,
43720,
7,
940,
61,
19,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
2435,
270,
284,
366,
77,
395,
513,
13,
18,
1,
43720,
7,
940,
61,
20,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
43720,
7,
940,
61,
21,
8,
198,
220,
220,
220,
886,
198,
437,
628,
198,
2,
23600,
602,
198,
27471,
366,
14402,
23600,
5549,
259,
1,
198,
220,
220,
220,
1233,
796,
14435,
9783,
198,
220,
220,
220,
412,
796,
17507,
7,
17080,
11,
12822,
31562,
26,
299,
796,
25643,
8,
198,
220,
220,
220,
277,
796,
2124,
4613,
2124,
61,
17,
198,
220,
220,
220,
17507,
7,
69,
11,
1233,
8,
198,
437,
198,
198,
3500,
30011,
198,
3500,
30011,
25,
6718,
2004,
11,
5415,
11,
12991,
7509,
11,
10356,
7509,
11,
34820,
1303,
11246,
3131,
5499,
198,
27471,
366,
14402,
30011,
1,
198,
220,
220,
220,
220,
220,
1255,
796,
27183,
7,
87,
3784,
2124,
61,
17,
11,
532,
17,
13,
15,
11,
352,
13,
15,
8,
198,
220,
220,
220,
220,
220,
2488,
12860,
6718,
2004,
7,
20274,
8,
8614,
4049,
7203,
37,
6255,
284,
47873,
287,
29568,
2676,
602,
7,
20274,
4008,
34820,
4943,
198,
220,
220,
220,
220,
220,
2488,
12860,
2124,
1084,
796,
1255,
13,
1084,
320,
7509,
198,
220,
220,
220,
220,
220,
2488,
12860,
1255,
13,
39504,
198,
437,
198
] | 2.141284 | 1,635 |
<filename>src/Sloth.jl<gh_stars>1-10
module Sloth
using Knet
using MAT
using Images, FileIO
import Knet.Ops20: BNMoments
import Knet: atype
const SlothArray = Union{Array{T}, KnetArray{T}} where T <: AbstractFloat
const SlothParam = Param{T} where T <: SlothArray
const SlothWeight = Union{SlothArray, SlothParam}
const SlothBias = Union{SlothArray, SlothParam, AbstractFloat}
const IntHyperparam = Union{Int, Tuple{Vararg{Int}}}
F(x::T) where T <: AbstractFloat = eltype(atype())(x)
dir() = abspath(@__DIR__)
dir(args...) = abspath(joinpath(dir(), args...))
include("layers.jl")
include("rnn.jl")
include("beautify.jl")
include("data.jl")
include("vgg.jl")
end # module | [
27,
34345,
29,
10677,
14,
11122,
849,
13,
20362,
27,
456,
62,
30783,
29,
16,
12,
940,
198,
21412,
3454,
849,
198,
198,
3500,
509,
3262,
198,
3500,
36775,
198,
3500,
5382,
11,
9220,
9399,
198,
11748,
509,
3262,
13,
41472,
1238,
25,
347,
45,
29252,
658,
198,
11748,
509,
3262,
25,
379,
2981,
628,
198,
9979,
3454,
849,
19182,
796,
4479,
90,
19182,
90,
51,
5512,
509,
3262,
19182,
90,
51,
11709,
810,
309,
1279,
25,
27741,
43879,
198,
9979,
3454,
849,
22973,
796,
25139,
90,
51,
92,
810,
309,
1279,
25,
3454,
849,
19182,
198,
9979,
3454,
849,
25844,
796,
4479,
90,
11122,
849,
19182,
11,
3454,
849,
22973,
92,
198,
9979,
3454,
849,
33,
4448,
796,
4479,
90,
11122,
849,
19182,
11,
3454,
849,
22973,
11,
27741,
43879,
92,
198,
9979,
2558,
38197,
17143,
796,
4479,
90,
5317,
11,
309,
29291,
90,
19852,
853,
90,
5317,
42535,
198,
37,
7,
87,
3712,
51,
8,
810,
309,
1279,
25,
27741,
43879,
796,
1288,
4906,
7,
265,
2981,
3419,
5769,
87,
8,
198,
15908,
3419,
796,
2352,
6978,
7,
31,
834,
34720,
834,
8,
198,
15908,
7,
22046,
23029,
796,
2352,
6978,
7,
22179,
6978,
7,
15908,
22784,
26498,
986,
4008,
198,
198,
17256,
7203,
75,
6962,
13,
20362,
4943,
198,
17256,
7203,
81,
20471,
13,
20362,
4943,
198,
17256,
7203,
40544,
1958,
13,
20362,
4943,
198,
17256,
7203,
7890,
13,
20362,
4943,
198,
17256,
7203,
85,
1130,
13,
20362,
4943,
198,
198,
437,
1303,
8265
] | 2.732794 | 247 |
using Invariants
import Test
using ReTest
Invariants.runtests()
Test.@testset "Invariants.jl" begin
end
| [
3500,
10001,
2743,
1187,
198,
11748,
6208,
198,
3500,
797,
14402,
198,
198,
19904,
2743,
1187,
13,
81,
2797,
3558,
3419,
198,
14402,
13,
31,
9288,
2617,
366,
19904,
2743,
1187,
13,
20362,
1,
2221,
198,
437,
198
] | 2.763158 | 38 |
# Spatial calculations
export
vector1D,
vector,
wrapcoords,
wrapcoordsvec
"""
vector1D(c1, c2, side_length)
Displacement between two 1D coordinate values from c1 to c2, accounting for
the bounding box.
The minimum image convention is used, so the displacement is to the closest
version of the coordinate accounting for the periodic boundaries.
"""
function vector1D(c1, c2, side_length)
if c1 < c2
return (c2 - c1) < (c1 - c2 + side_length) ? (c2 - c1) : (c2 - c1 - side_length)
else
return (c1 - c2) < (c2 - c1 + side_length) ? (c2 - c1) : (c2 - c1 + side_length)
end
end
"""
vector(c1, c2, box_size)
Displacement between two coordinate values, accounting for the bounding box.
The minimum image convention is used, so the displacement is to the closest
version of the coordinates accounting for the periodic boundaries.
"""
vector(c1, c2, box_size) = vector1D.(c1, c2, box_size)
@generated function vector(c1::SVector{N}, c2::SVector{N}, box_size) where N
quote
Base.Cartesian.@ncall $N SVector{$N} i->vector1D(c1[i], c2[i], box_size[i])
end
end
sqdistance(i, j, coords, box_size) = sum(abs2, vector(coords[i], coords[j], box_size))
"""
wrapcoords(c, side_length)
Ensure a 1D coordinate is within the simulation box and return the coordinate.
"""
wrapcoords(c, side_length) = c - floor(c / side_length) * side_length
"""
wrapcoordsvec(c, box_size)
Ensure a coordinate is within the simulation box and return the coordinate.
"""
wrapcoordsvec(v, box_size) = wrapcoords.(v, box_size)
| [
2,
1338,
34961,
16765,
198,
198,
39344,
198,
220,
220,
220,
15879,
16,
35,
11,
198,
220,
220,
220,
15879,
11,
198,
220,
220,
220,
14441,
1073,
3669,
11,
198,
220,
220,
220,
14441,
1073,
3669,
35138,
198,
198,
37811,
198,
220,
220,
220,
15879,
16,
35,
7,
66,
16,
11,
269,
17,
11,
1735,
62,
13664,
8,
198,
198,
7279,
489,
5592,
1022,
734,
352,
35,
20435,
3815,
422,
269,
16,
284,
269,
17,
11,
14317,
329,
198,
1169,
5421,
278,
3091,
13,
198,
464,
5288,
2939,
9831,
318,
973,
11,
523,
262,
29358,
318,
284,
262,
11706,
198,
9641,
286,
262,
20435,
14317,
329,
262,
27458,
13215,
13,
198,
37811,
198,
8818,
15879,
16,
35,
7,
66,
16,
11,
269,
17,
11,
1735,
62,
13664,
8,
198,
220,
220,
220,
611,
269,
16,
1279,
269,
17,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
66,
17,
532,
269,
16,
8,
1279,
357,
66,
16,
532,
269,
17,
1343,
1735,
62,
13664,
8,
5633,
357,
66,
17,
532,
269,
16,
8,
1058,
357,
66,
17,
532,
269,
16,
532,
1735,
62,
13664,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
66,
16,
532,
269,
17,
8,
1279,
357,
66,
17,
532,
269,
16,
1343,
1735,
62,
13664,
8,
5633,
357,
66,
17,
532,
269,
16,
8,
1058,
357,
66,
17,
532,
269,
16,
1343,
1735,
62,
13664,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
15879,
7,
66,
16,
11,
269,
17,
11,
3091,
62,
7857,
8,
198,
198,
7279,
489,
5592,
1022,
734,
20435,
3815,
11,
14317,
329,
262,
5421,
278,
3091,
13,
198,
464,
5288,
2939,
9831,
318,
973,
11,
523,
262,
29358,
318,
284,
262,
11706,
198,
9641,
286,
262,
22715,
14317,
329,
262,
27458,
13215,
13,
198,
37811,
198,
31364,
7,
66,
16,
11,
269,
17,
11,
3091,
62,
7857,
8,
796,
15879,
16,
35,
12195,
66,
16,
11,
269,
17,
11,
3091,
62,
7857,
8,
198,
198,
31,
27568,
2163,
15879,
7,
66,
16,
3712,
50,
38469,
90,
45,
5512,
269,
17,
3712,
50,
38469,
90,
45,
5512,
3091,
62,
7857,
8,
810,
399,
198,
220,
220,
220,
9577,
198,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
43476,
35610,
13,
31,
10782,
439,
720,
45,
20546,
9250,
90,
3,
45,
92,
1312,
3784,
31364,
16,
35,
7,
66,
16,
58,
72,
4357,
269,
17,
58,
72,
4357,
3091,
62,
7857,
58,
72,
12962,
198,
220,
220,
220,
886,
198,
437,
198,
198,
31166,
30246,
7,
72,
11,
474,
11,
763,
3669,
11,
3091,
62,
7857,
8,
796,
2160,
7,
8937,
17,
11,
15879,
7,
1073,
3669,
58,
72,
4357,
763,
3669,
58,
73,
4357,
3091,
62,
7857,
4008,
198,
198,
37811,
198,
220,
220,
220,
14441,
1073,
3669,
7,
66,
11,
1735,
62,
13664,
8,
198,
198,
4834,
19532,
257,
352,
35,
20435,
318,
1626,
262,
18640,
3091,
290,
1441,
262,
20435,
13,
198,
37811,
198,
37150,
1073,
3669,
7,
66,
11,
1735,
62,
13664,
8,
796,
269,
532,
4314,
7,
66,
1220,
1735,
62,
13664,
8,
1635,
1735,
62,
13664,
198,
198,
37811,
198,
220,
220,
220,
14441,
1073,
3669,
35138,
7,
66,
11,
3091,
62,
7857,
8,
198,
198,
4834,
19532,
257,
20435,
318,
1626,
262,
18640,
3091,
290,
1441,
262,
20435,
13,
198,
37811,
198,
37150,
1073,
3669,
35138,
7,
85,
11,
3091,
62,
7857,
8,
796,
14441,
1073,
3669,
12195,
85,
11,
3091,
62,
7857,
8,
198
] | 2.680887 | 586 |
# ---
# title: Symmetric monogenic filters
# id: demo_phasesymmono
# cover: assets/phasesymmono.gif
# author: <NAME>
# date: 2018-10-26
# ---
# Phase symmetry responds well to line like features and circular objects. The number of
# filter scales will affect the scale of features that are marked. Phase symmetry marks
# features independently of contrast (a bright circle is not more symmetric than a grey
# circle) and is a dimensionless quantity between 0 and 1. However this may not be what one
# desires in which case the symmetry energy may be of greater interest.
using TestImages
using Images
using ImagePhaseCongruency
img = Gray.(testimage("blobs"))
## Detect regions of bright symmetry (polarity = 1)
phase_bright, = phasesymmono(img; nscale=5, polarity=1)
## Detect regions of dark symmetry (polarity = -1)
phase_dark, = phasesymmono(img; nscale=5, polarity=-1)
mosaic(img, phase_bright, phase_dark; nrow=1)
# save cover image #src
isdir("assets") || mkdir("assets") #src
save(joinpath("assets", "phasesymmono.gif"), Images.gif([phase_bright, phase_dark]); fps=1) #src
| [
2,
11420,
198,
2,
3670,
25,
1632,
3020,
19482,
937,
15147,
16628,
198,
2,
4686,
25,
13605,
62,
746,
1386,
4948,
2144,
78,
198,
2,
3002,
25,
6798,
14,
746,
1386,
4948,
2144,
78,
13,
27908,
198,
2,
1772,
25,
1279,
20608,
29,
198,
2,
3128,
25,
2864,
12,
940,
12,
2075,
198,
2,
11420,
198,
198,
2,
18983,
40686,
20067,
880,
284,
1627,
588,
3033,
290,
18620,
5563,
13,
220,
383,
1271,
286,
198,
2,
8106,
16252,
481,
2689,
262,
5046,
286,
3033,
326,
389,
7498,
13,
18983,
40686,
8849,
198,
2,
3033,
14799,
286,
6273,
357,
64,
6016,
9197,
318,
407,
517,
23606,
19482,
621,
257,
13791,
198,
2,
9197,
8,
290,
318,
257,
15793,
1203,
12040,
1022,
657,
290,
352,
13,
220,
2102,
428,
743,
407,
307,
644,
530,
198,
2,
15997,
287,
543,
1339,
262,
40686,
2568,
743,
307,
286,
3744,
1393,
13,
198,
198,
3500,
6208,
29398,
198,
3500,
5382,
198,
3500,
7412,
35645,
18649,
622,
1387,
198,
198,
9600,
796,
12723,
12195,
9288,
9060,
7203,
2436,
8158,
48774,
198,
2235,
35874,
7652,
286,
6016,
40686,
357,
79,
6192,
414,
796,
352,
8,
198,
40715,
62,
29199,
11,
796,
21164,
4948,
2144,
78,
7,
9600,
26,
299,
9888,
28,
20,
11,
755,
6806,
28,
16,
8,
198,
198,
2235,
35874,
7652,
286,
3223,
40686,
357,
79,
6192,
414,
796,
532,
16,
8,
198,
40715,
62,
21953,
11,
796,
21164,
4948,
2144,
78,
7,
9600,
26,
299,
9888,
28,
20,
11,
755,
6806,
10779,
16,
8,
198,
198,
76,
8546,
291,
7,
9600,
11,
7108,
62,
29199,
11,
7108,
62,
21953,
26,
299,
808,
28,
16,
8,
198,
198,
2,
3613,
3002,
2939,
1303,
10677,
198,
9409,
343,
7203,
19668,
4943,
8614,
33480,
15908,
7203,
19668,
4943,
1303,
10677,
198,
21928,
7,
22179,
6978,
7203,
19668,
1600,
366,
746,
1386,
4948,
2144,
78,
13,
27908,
12340,
5382,
13,
27908,
26933,
40715,
62,
29199,
11,
7108,
62,
21953,
36563,
32977,
28,
16,
8,
1303,
10677,
198
] | 3.31003 | 329 |
using RunTests
using Base.Test
@testmodule TestModuleWithOneXFailingTest begin
@xfail function test_xfailing()
@test false
end
end | [
3500,
5660,
51,
3558,
198,
3500,
7308,
13,
14402,
198,
198,
31,
9288,
21412,
6208,
26796,
3152,
3198,
55,
37,
11608,
14402,
2221,
198,
198,
31,
26152,
603,
2163,
1332,
62,
26152,
11608,
3419,
198,
220,
2488,
9288,
3991,
198,
437,
198,
198,
437
] | 3.068182 | 44 |
<gh_stars>1-10
################################################################################
#
# Module Potentials.jl
#
# This module will implement a variety of interatomic potentials and defines abstract types
# that allow these potentials to be used in other packages (PotentialLearning.jl, PotentialUQ.jl,
# Atomistic.jl, etc...).
# 'implementation' means:
# 1. Having a defined structure for each potential
# 1.1 The structure holds all of the necessary parameters for evaluating energies, forces, ...
# 1.2 The potential structure should expose the trainable and nontrainable parameters (necessary for learning).
# 2. Having a method to get the potential energy of given configuration, as
# defined by that potential.
# 3. Having a method to produce the force of a given configuration, as defined
# by that potential.
# 4. Having a method to produce the stresses of a given configuration, as defined
# by that potential.
# 5. (For inference) Having a method to produce the gradient of each of the above methods with
# respect to the potential parameters.
#
################################################################################
module InteratomicPotentials
using StaticArrays
using LAMMPS
using LinearAlgebra
using AtomsBase
using Unitful
using UnitfulAtomic
include("Utilities/utils.jl")
include("PotentialTypes/types.jl")
export NeighborList, neighborlist
export potential_energy, force, virial, virial_stress
export grad_potential_energy, grad_force, grad_virial, grad_virial_stress
export SNAPParams, compute_snap, get_num_coeffs
export EmpiricalPotential, LennardJones
# export BornMayer, Coulomb, GaN, MixedPotential
end
| [
27,
456,
62,
30783,
29,
16,
12,
940,
198,
29113,
29113,
14468,
198,
2,
198,
2,
220,
220,
220,
19937,
6902,
14817,
13,
20362,
198,
2,
198,
2,
220,
220,
220,
770,
8265,
481,
3494,
257,
4996,
286,
987,
47116,
2785,
82,
290,
15738,
12531,
3858,
198,
2,
220,
220,
220,
326,
1249,
777,
2785,
82,
284,
307,
973,
287,
584,
10392,
357,
25396,
1843,
41730,
13,
20362,
11,
32480,
52,
48,
13,
20362,
11,
220,
198,
2,
220,
220,
220,
33102,
2569,
13,
20362,
11,
3503,
986,
737,
220,
198,
2,
220,
220,
220,
220,
220,
220,
705,
320,
32851,
6,
1724,
25,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
352,
13,
11136,
257,
5447,
4645,
329,
1123,
2785,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
352,
13,
16,
383,
4645,
6622,
477,
286,
262,
3306,
10007,
329,
22232,
27598,
11,
3386,
11,
2644,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
352,
13,
17,
383,
2785,
4645,
815,
15651,
262,
4512,
540,
290,
45930,
3201,
540,
10007,
357,
49986,
329,
4673,
737,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
362,
13,
11136,
257,
2446,
284,
651,
262,
2785,
2568,
286,
1813,
8398,
11,
355,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5447,
416,
326,
2785,
13,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
513,
13,
11136,
257,
2446,
284,
4439,
262,
2700,
286,
257,
1813,
8398,
11,
355,
5447,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
416,
326,
2785,
13,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
604,
13,
11136,
257,
2446,
284,
4439,
262,
29787,
286,
257,
1813,
8398,
11,
355,
5447,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
416,
326,
2785,
13,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
642,
13,
357,
1890,
32278,
8,
11136,
257,
2446,
284,
4439,
262,
31312,
286,
1123,
286,
262,
2029,
5050,
351,
220,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2461,
284,
262,
2785,
10007,
13,
198,
2,
198,
198,
29113,
29113,
14468,
198,
21412,
4225,
47116,
25396,
14817,
198,
198,
3500,
36125,
3163,
20477,
198,
3500,
406,
2390,
44,
3705,
198,
3500,
44800,
2348,
29230,
198,
3500,
1629,
3150,
14881,
198,
3500,
11801,
913,
198,
3500,
11801,
913,
2953,
10179,
198,
17256,
7203,
18274,
2410,
14,
26791,
13,
20362,
4943,
198,
17256,
7203,
25396,
1843,
31431,
14,
19199,
13,
20362,
4943,
198,
39344,
28708,
8053,
11,
4780,
4868,
198,
39344,
2785,
62,
22554,
11,
2700,
11,
5709,
498,
11,
5709,
498,
62,
41494,
198,
39344,
3915,
62,
13059,
1843,
62,
22554,
11,
3915,
62,
3174,
11,
3915,
62,
37040,
498,
11,
3915,
62,
37040,
498,
62,
41494,
198,
39344,
48592,
10044,
4105,
11,
24061,
62,
45380,
11,
651,
62,
22510,
62,
1073,
14822,
82,
198,
39344,
2295,
4063,
605,
25396,
1843,
11,
28423,
446,
25784,
198,
2,
10784,
18889,
44,
2794,
11,
27854,
2381,
11,
12822,
45,
11,
35250,
25396,
1843,
198,
198,
437,
198
] | 3.25045 | 555 |
@testset "ridge-reg" begin
rng = StableRNG(622161)
n, p = 100, 5
X = randn(rng, n, p)
y = randn(rng, n)
X1 = R.augment_X(X, true)
λ = 0.3
Xt = MLJBase.table(X)
rr = RidgeRegressor(lambda=λ, penalize_intercept=true,
scale_penalty_with_samples = false)
fr, = MLJBase.fit(rr, 1, Xt, y)
ŷ = MLJBase.predict(rr, fr, Xt)
θ = (X1'X1 + λ*I)\(X1'y)
coefs = θ[1:end-1]
intercept = θ[end]
fp = MLJBase.fitted_params(rr, fr)
@test last.(fp.coefs) ≈ coefs
@test fp.intercept ≈ intercept
end
@testset "logistic" begin
((X, y, θ), (X1, y1, θ1)) = generate_binary(100, 5)
λ = 0.7
γ = 0.1
Xt = MLJBase.table(X)
yc = MLJBase.categorical(y1)
lr = LogisticClassifier(lambda=λ, gamma=γ, scale_penalty_with_samples = false)
fr, = MLJBase.fit(lr, 1, Xt, yc)
ŷ = MLJBase.predict(lr, fr, Xt)
ŷ = MLJBase.mode.(ŷ)
mcr = MLJBase.misclassification_rate(ŷ, yc)
@test mcr ≤ 0.2
end
@testset "multinomial" begin
((X, y, θ), (X1, y1, θ1)) = generate_multiclass(100, 5, 3)
λ = 0.5
γ = 0.2
Xt = MLJBase.table(X)
yc = MLJBase.categorical(y1)
mc = MultinomialClassifier(lambda=λ, gamma=γ, fit_intercept=false,
scale_penalty_with_samples = false)
fr, = MLJBase.fit(mc, 1, Xt, yc)
mach = MLJBase.machine(mc, Xt, yc)
MLJBase.fit!(mach)
fp = MLJBase.fitted_params(mach)
@test length(fp.coefs) == 5
ŷ = MLJBase.predict(mc, fr, Xt)
ŷ = MLJBase.mode.(ŷ)
mcr = MLJBase.misclassification_rate(ŷ, yc)
@test mcr ≤ 0.3
end
# see issue https://github.com/alan-turing-institute/MLJ.jl/issues/387
@testset "String-Symbol" begin
model = LogisticClassifier(penalty="l1")
@test model.penalty == "l1"
gr = MLJLinearModels.glr(model, 2)
@test gr isa GLR
@test gr.penalty isa ScaledPenalty{L1Penalty}
end
# see issue #71
@testset "Logistic-m" begin
X, y = MLJBase.make_blobs(centers=3)
model = LogisticClassifier()
mach = MLJBase.machine(model, X, y)
MLJBase.fit!(mach)
fp = MLJBase.fitted_params(mach)
@test unique(fp.classes) == [1,2,3]
end
| [
31,
9288,
2617,
366,
12818,
12,
2301,
1,
2221,
198,
220,
220,
220,
374,
782,
796,
520,
540,
49,
10503,
7,
21,
1828,
25948,
8,
198,
220,
220,
220,
299,
11,
279,
796,
1802,
11,
642,
198,
220,
220,
220,
1395,
796,
43720,
77,
7,
81,
782,
11,
299,
11,
279,
8,
198,
220,
220,
220,
331,
796,
43720,
77,
7,
81,
782,
11,
299,
8,
198,
220,
220,
220,
1395,
16,
796,
371,
13,
559,
5154,
62,
55,
7,
55,
11,
2081,
8,
628,
220,
220,
220,
7377,
119,
796,
657,
13,
18,
628,
220,
220,
220,
1395,
83,
796,
10373,
41,
14881,
13,
11487,
7,
55,
8,
198,
220,
220,
220,
374,
81,
796,
20614,
8081,
44292,
7,
50033,
28,
39377,
11,
23634,
1096,
62,
3849,
984,
28,
7942,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5046,
62,
3617,
6017,
62,
4480,
62,
82,
12629,
796,
3991,
8,
198,
220,
220,
220,
1216,
11,
796,
10373,
41,
14881,
13,
11147,
7,
21062,
11,
352,
11,
1395,
83,
11,
331,
8,
198,
220,
220,
220,
331,
136,
224,
796,
10373,
41,
14881,
13,
79,
17407,
7,
21062,
11,
1216,
11,
1395,
83,
8,
628,
220,
220,
220,
7377,
116,
796,
357,
55,
16,
6,
55,
16,
1343,
7377,
119,
9,
40,
19415,
7,
55,
16,
6,
88,
8,
198,
220,
220,
220,
763,
891,
82,
796,
7377,
116,
58,
16,
25,
437,
12,
16,
60,
198,
220,
220,
220,
15788,
796,
7377,
116,
58,
437,
60,
628,
220,
220,
220,
277,
79,
796,
10373,
41,
14881,
13,
38631,
62,
37266,
7,
21062,
11,
1216,
8,
198,
220,
220,
220,
2488,
9288,
938,
12195,
46428,
13,
1073,
891,
82,
8,
15139,
230,
763,
891,
82,
198,
220,
220,
220,
2488,
9288,
277,
79,
13,
3849,
984,
15139,
230,
15788,
198,
437,
198,
198,
31,
9288,
2617,
366,
6404,
2569,
1,
2221,
198,
220,
220,
220,
14808,
55,
11,
331,
11,
7377,
116,
828,
357,
55,
16,
11,
331,
16,
11,
7377,
116,
16,
4008,
796,
7716,
62,
39491,
7,
3064,
11,
642,
8,
628,
220,
220,
220,
7377,
119,
796,
657,
13,
22,
198,
220,
220,
220,
7377,
111,
796,
657,
13,
16,
628,
220,
220,
220,
1395,
83,
796,
10373,
41,
14881,
13,
11487,
7,
55,
8,
198,
220,
220,
220,
331,
66,
796,
10373,
41,
14881,
13,
66,
2397,
12409,
7,
88,
16,
8,
628,
220,
220,
220,
300,
81,
796,
5972,
2569,
9487,
7483,
7,
50033,
28,
39377,
11,
34236,
28,
42063,
11,
5046,
62,
3617,
6017,
62,
4480,
62,
82,
12629,
796,
3991,
8,
198,
220,
220,
220,
1216,
11,
796,
10373,
41,
14881,
13,
11147,
7,
14050,
11,
352,
11,
1395,
83,
11,
331,
66,
8,
628,
220,
220,
220,
331,
136,
224,
796,
10373,
41,
14881,
13,
79,
17407,
7,
14050,
11,
1216,
11,
1395,
83,
8,
198,
220,
220,
220,
331,
136,
224,
796,
10373,
41,
14881,
13,
14171,
12195,
88,
136,
224,
8,
628,
220,
220,
220,
285,
6098,
796,
10373,
41,
14881,
13,
25413,
4871,
2649,
62,
4873,
7,
88,
136,
224,
11,
331,
66,
8,
198,
220,
220,
220,
2488,
9288,
285,
6098,
41305,
657,
13,
17,
198,
437,
198,
198,
31,
9288,
2617,
366,
16680,
259,
49070,
1,
2221,
198,
220,
220,
220,
14808,
55,
11,
331,
11,
7377,
116,
828,
357,
55,
16,
11,
331,
16,
11,
7377,
116,
16,
4008,
796,
7716,
62,
16680,
291,
31172,
7,
3064,
11,
220,
642,
11,
513,
8,
628,
220,
220,
220,
7377,
119,
796,
657,
13,
20,
198,
220,
220,
220,
7377,
111,
796,
657,
13,
17,
628,
220,
220,
220,
1395,
83,
796,
10373,
41,
14881,
13,
11487,
7,
55,
8,
198,
220,
220,
220,
331,
66,
796,
10373,
41,
14881,
13,
66,
2397,
12409,
7,
88,
16,
8,
628,
220,
220,
220,
36650,
796,
7854,
259,
49070,
9487,
7483,
7,
50033,
28,
39377,
11,
34236,
28,
42063,
11,
4197,
62,
3849,
984,
28,
9562,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5046,
62,
3617,
6017,
62,
4480,
62,
82,
12629,
796,
3991,
8,
198,
220,
220,
220,
1216,
11,
796,
10373,
41,
14881,
13,
11147,
7,
23209,
11,
352,
11,
1395,
83,
11,
331,
66,
8,
628,
220,
220,
220,
3235,
796,
10373,
41,
14881,
13,
30243,
7,
23209,
11,
1395,
83,
11,
331,
66,
8,
198,
220,
220,
220,
10373,
41,
14881,
13,
11147,
0,
7,
76,
620,
8,
198,
220,
220,
220,
277,
79,
796,
10373,
41,
14881,
13,
38631,
62,
37266,
7,
76,
620,
8,
198,
220,
220,
220,
2488,
9288,
4129,
7,
46428,
13,
1073,
891,
82,
8,
6624,
642,
628,
220,
220,
220,
331,
136,
224,
796,
10373,
41,
14881,
13,
79,
17407,
7,
23209,
11,
1216,
11,
1395,
83,
8,
198,
220,
220,
220,
331,
136,
224,
796,
10373,
41,
14881,
13,
14171,
12195,
88,
136,
224,
8,
628,
220,
220,
220,
285,
6098,
796,
10373,
41,
14881,
13,
25413,
4871,
2649,
62,
4873,
7,
88,
136,
224,
11,
331,
66,
8,
198,
220,
220,
220,
2488,
9288,
285,
6098,
41305,
657,
13,
18,
198,
437,
198,
198,
2,
766,
2071,
3740,
1378,
12567,
13,
785,
14,
25786,
12,
83,
870,
12,
8625,
3678,
14,
5805,
41,
13,
20362,
14,
37165,
14,
32220,
198,
31,
9288,
2617,
366,
10100,
12,
13940,
23650,
1,
2221,
198,
220,
220,
220,
2746,
796,
5972,
2569,
9487,
7483,
7,
3617,
6017,
2625,
75,
16,
4943,
198,
220,
220,
220,
2488,
9288,
2746,
13,
3617,
6017,
6624,
366,
75,
16,
1,
198,
220,
220,
220,
1036,
796,
10373,
41,
14993,
451,
5841,
1424,
13,
4743,
81,
7,
19849,
11,
362,
8,
198,
220,
220,
220,
2488,
9288,
1036,
318,
64,
10188,
49,
198,
220,
220,
220,
2488,
9288,
1036,
13,
3617,
6017,
318,
64,
1446,
3021,
25553,
6017,
90,
43,
16,
25553,
6017,
92,
198,
437,
198,
198,
2,
766,
2071,
1303,
4869,
198,
31,
9288,
2617,
366,
11187,
2569,
12,
76,
1,
2221,
198,
220,
220,
220,
1395,
11,
331,
796,
10373,
41,
14881,
13,
15883,
62,
2436,
8158,
7,
1087,
364,
28,
18,
8,
198,
220,
220,
220,
2746,
796,
5972,
2569,
9487,
7483,
3419,
198,
220,
220,
220,
3235,
796,
10373,
41,
14881,
13,
30243,
7,
19849,
11,
1395,
11,
331,
8,
198,
220,
220,
220,
10373,
41,
14881,
13,
11147,
0,
7,
76,
620,
8,
198,
220,
220,
220,
277,
79,
796,
10373,
41,
14881,
13,
38631,
62,
37266,
7,
76,
620,
8,
198,
220,
220,
220,
2488,
9288,
3748,
7,
46428,
13,
37724,
8,
6624,
685,
16,
11,
17,
11,
18,
60,
198,
437,
198
] | 1.920775 | 1,136 |
<reponame>mkratochvil/PowerSimulations.jl<filename>src/services/service_models/services.jl
abstract type AbstractServiceFormulation end
abstract type AbstractReservesForm <: AbstractServiceFormulation end
abstract type AbstractRegulationReserveForm <: AbstractReservesForm end
struct RampLimitedReserve <: AbstractReservesForm end
struct LoadProportionalReserve <: AbstractReservesForm end | [
27,
7856,
261,
480,
29,
28015,
10366,
5374,
2991,
14,
13434,
8890,
5768,
13,
20362,
27,
34345,
29,
10677,
14,
30416,
14,
15271,
62,
27530,
14,
30416,
13,
20362,
198,
397,
8709,
2099,
27741,
16177,
8479,
1741,
886,
198,
198,
397,
8709,
2099,
27741,
4965,
11184,
8479,
1279,
25,
27741,
16177,
8479,
1741,
886,
198,
198,
397,
8709,
2099,
27741,
8081,
1741,
4965,
3760,
8479,
1279,
25,
27741,
4965,
11184,
8479,
886,
198,
198,
7249,
26882,
37214,
4965,
3760,
1279,
25,
27741,
4965,
11184,
8479,
886,
198,
198,
7249,
8778,
2964,
634,
1538,
4965,
3760,
1279,
25,
27741,
4965,
11184,
8479,
886
] | 3.852941 | 102 |
#################### Variate ####################
#################### Conversions ####################
Base.convert(::Type{Bool}, v::ScalarVariate) = convert(Bool, v.value)
Base.convert{T<:Integer}(::Type{T}, v::ScalarVariate) = convert(T, v.value)
Base.convert{T<:AbstractFloat}(::Type{T}, v::ScalarVariate) =
convert(T, v.value)
Base.convert(::Type{Matrix}, v::MatrixVariate) = v.value
Base.convert(::Type{Vector}, v::VectorVariate) = v.value
Base.convert{T<:Real, N}(::Union{Type{Array{T}}, Type{Array{T, N}}},
v::ArrayVariate{N}) = convert(Array{T, N}, v.value)
Base.unsafe_convert{T<:Real}(::Type{Ptr{T}}, v::ArrayVariate) = pointer(v.value)
macro promote_scalarvariate(V)
quote
Base.promote_rule{T<:Real}(::Type{$V}, ::Type{T}) = Float64
end
end
#################### Base Functions ####################
Base.size(v::AbstractVariate) = size(v.value)
Base.stride(v::ArrayVariate, k::Int) = stride(v.value, k)
#################### Indexing ####################
Base.getindex(v::ScalarVariate, ind::Int) = v.value[ind]
Base.getindex(v::ScalarVariate, inds::Union{Range{Int}, Vector{Int}}) =
Float64[v[i] for i in inds]
Base.getindex(v::ArrayVariate, inds::Int...) = getindex(v.value, inds...)
Base.setindex!(v::ScalarVariate, x::Real, ind::Int) = (v.value = x[ind])
function Base.setindex!{T<:Real}(v::ScalarVariate, x::Vector{T},
inds::Union{Range{Int}, Vector{Int}})
nx = length(x)
ninds = length(inds)
nx == ninds ||
throw(DimensionMismatch(
"tried to assign $nx elements to $ninds destinations"
))
for i in 1:nx
v[inds[i]] = x[i]
end
end
Base.setindex!(v::ArrayVariate, x, inds::Int...) =
setindex!(v.value, x, inds...)
#################### I/O ####################
function Base.show(io::IO, v::AbstractVariate)
print(io, "Object of type \"$(summary(v))\"\n")
show(io, v.value)
end
function Base.showcompact(io::IO, v::AbstractVariate)
showcompact(io, v.value)
end
#################### Auxiliary Functions ####################
function names(v::ScalarVariate, prefix)
AbstractString[string(prefix)]
end
function names(v::ArrayVariate, prefix)
offset = ndims(v) > 1 ? 1 : 2
values = similar(v.value, AbstractString)
for i in 1:length(v)
s = string(ind2sub(size(v), i))
values[i] = string(prefix, "[", s[2:(end - offset)], "]")
end
values
end
#################### Mathematical Operators ####################
const BinaryScalarMethods = [
:(Base.:+),
:(Base.:-),
:(Base.:*),
:(Base.:/),
:(Base.:\),
:(Base.:^),
:(Base.:(==)),
:(Base.:(!=)),
:(Base.:<),
:(Base.:(<=)),
:(Base.:>),
:(Base.:(>=)),
:(Base.cld),
:(Base.div),
:(Base.divrem),
:(Base.fld),
:(Base.mod),
:(Base.rem)
]
for op in BinaryScalarMethods
@eval ($op)(x::ScalarVariate, y::ScalarVariate) = ($op)(x.value, y.value)
end
const RoundScalarMethods = [
:(Base.ceil),
:(Base.floor),
:(Base.round),
:(Base.trunc)
]
for op in RoundScalarMethods
@eval ($op)(x::ScalarVariate) = ($op)(x.value)
@eval ($op){T}(::Type{T}, x::ScalarVariate) = ($op)(T, x.value)
end
const UnaryScalarMethods = [
:(Base.:+),
:(Base.:-),
:(Base.abs),
:(Base.isfinite),
:(Base.isinf),
:(Base.isinteger),
:(Base.isnan),
:(Base.mod2pi),
:(Base.one),
:(Base.sign),
:(Base.zero)
]
for op in UnaryScalarMethods
@eval ($op)(x::ScalarVariate) = ($op)(x.value)
end
| [
14468,
4242,
15965,
378,
1303,
14468,
21017,
198,
198,
14468,
4242,
32200,
507,
1303,
14468,
21017,
198,
198,
14881,
13,
1102,
1851,
7,
3712,
6030,
90,
33,
970,
5512,
410,
3712,
3351,
282,
283,
23907,
378,
8,
796,
10385,
7,
33,
970,
11,
410,
13,
8367,
8,
198,
14881,
13,
1102,
1851,
90,
51,
27,
25,
46541,
92,
7,
3712,
6030,
90,
51,
5512,
410,
3712,
3351,
282,
283,
23907,
378,
8,
796,
10385,
7,
51,
11,
410,
13,
8367,
8,
198,
14881,
13,
1102,
1851,
90,
51,
27,
25,
23839,
43879,
92,
7,
3712,
6030,
90,
51,
5512,
410,
3712,
3351,
282,
283,
23907,
378,
8,
796,
198,
220,
10385,
7,
51,
11,
410,
13,
8367,
8,
198,
198,
14881,
13,
1102,
1851,
7,
3712,
6030,
90,
46912,
5512,
410,
3712,
46912,
23907,
378,
8,
796,
410,
13,
8367,
198,
14881,
13,
1102,
1851,
7,
3712,
6030,
90,
38469,
5512,
410,
3712,
38469,
23907,
378,
8,
796,
410,
13,
8367,
198,
14881,
13,
1102,
1851,
90,
51,
27,
25,
15633,
11,
399,
92,
7,
3712,
38176,
90,
6030,
90,
19182,
90,
51,
92,
5512,
5994,
90,
19182,
90,
51,
11,
399,
11709,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
410,
3712,
19182,
23907,
378,
90,
45,
30072,
796,
10385,
7,
19182,
90,
51,
11,
399,
5512,
410,
13,
8367,
8,
198,
198,
14881,
13,
13271,
8635,
62,
1102,
1851,
90,
51,
27,
25,
15633,
92,
7,
3712,
6030,
90,
46745,
90,
51,
92,
5512,
410,
3712,
19182,
23907,
378,
8,
796,
17562,
7,
85,
13,
8367,
8,
628,
198,
20285,
305,
7719,
62,
1416,
282,
283,
25641,
378,
7,
53,
8,
198,
220,
9577,
198,
220,
220,
220,
7308,
13,
16963,
1258,
62,
25135,
90,
51,
27,
25,
15633,
92,
7,
3712,
6030,
90,
3,
53,
5512,
7904,
6030,
90,
51,
30072,
796,
48436,
2414,
198,
220,
886,
198,
437,
628,
198,
14468,
4242,
7308,
40480,
1303,
14468,
21017,
198,
198,
14881,
13,
7857,
7,
85,
3712,
23839,
23907,
378,
8,
796,
2546,
7,
85,
13,
8367,
8,
198,
198,
14881,
13,
2536,
485,
7,
85,
3712,
19182,
23907,
378,
11,
479,
3712,
5317,
8,
796,
33769,
7,
85,
13,
8367,
11,
479,
8,
628,
198,
14468,
4242,
12901,
278,
1303,
14468,
21017,
198,
198,
14881,
13,
1136,
9630,
7,
85,
3712,
3351,
282,
283,
23907,
378,
11,
773,
3712,
5317,
8,
796,
410,
13,
8367,
58,
521,
60,
198,
198,
14881,
13,
1136,
9630,
7,
85,
3712,
3351,
282,
283,
23907,
378,
11,
773,
82,
3712,
38176,
90,
17257,
90,
5317,
5512,
20650,
90,
5317,
11709,
8,
796,
198,
220,
48436,
2414,
58,
85,
58,
72,
60,
329,
1312,
287,
773,
82,
60,
198,
198,
14881,
13,
1136,
9630,
7,
85,
3712,
19182,
23907,
378,
11,
773,
82,
3712,
5317,
23029,
796,
651,
9630,
7,
85,
13,
8367,
11,
773,
82,
23029,
628,
198,
14881,
13,
2617,
9630,
0,
7,
85,
3712,
3351,
282,
283,
23907,
378,
11,
2124,
3712,
15633,
11,
773,
3712,
5317,
8,
796,
357,
85,
13,
8367,
796,
2124,
58,
521,
12962,
198,
198,
8818,
7308,
13,
2617,
9630,
0,
90,
51,
27,
25,
15633,
92,
7,
85,
3712,
3351,
282,
283,
23907,
378,
11,
2124,
3712,
38469,
90,
51,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
773,
82,
3712,
38176,
90,
17257,
90,
5317,
5512,
20650,
90,
5317,
11709,
8,
198,
220,
299,
87,
796,
4129,
7,
87,
8,
198,
220,
299,
521,
82,
796,
4129,
7,
521,
82,
8,
198,
220,
299,
87,
6624,
299,
521,
82,
8614,
198,
220,
220,
220,
3714,
7,
29271,
3004,
44,
1042,
963,
7,
198,
220,
220,
220,
220,
220,
366,
83,
2228,
284,
8333,
720,
77,
87,
4847,
284,
720,
77,
521,
82,
23982,
1,
198,
220,
220,
220,
15306,
628,
220,
329,
1312,
287,
352,
25,
77,
87,
198,
220,
220,
220,
410,
58,
521,
82,
58,
72,
11907,
796,
2124,
58,
72,
60,
198,
220,
886,
198,
437,
198,
198,
14881,
13,
2617,
9630,
0,
7,
85,
3712,
19182,
23907,
378,
11,
2124,
11,
773,
82,
3712,
5317,
23029,
796,
198,
220,
900,
9630,
0,
7,
85,
13,
8367,
11,
2124,
11,
773,
82,
23029,
628,
198,
14468,
4242,
314,
14,
46,
1303,
14468,
21017,
198,
198,
8818,
7308,
13,
12860,
7,
952,
3712,
9399,
11,
410,
3712,
23839,
23907,
378,
8,
198,
220,
3601,
7,
952,
11,
366,
10267,
286,
2099,
19990,
3,
7,
49736,
7,
85,
4008,
7879,
59,
77,
4943,
198,
220,
905,
7,
952,
11,
410,
13,
8367,
8,
198,
437,
198,
198,
8818,
7308,
13,
12860,
5589,
529,
7,
952,
3712,
9399,
11,
410,
3712,
23839,
23907,
378,
8,
198,
220,
905,
5589,
529,
7,
952,
11,
410,
13,
8367,
8,
198,
437,
628,
198,
14468,
4242,
47105,
28129,
40480,
1303,
14468,
21017,
198,
198,
8818,
3891,
7,
85,
3712,
3351,
282,
283,
23907,
378,
11,
21231,
8,
198,
220,
27741,
10100,
58,
8841,
7,
40290,
15437,
198,
437,
198,
198,
8818,
3891,
7,
85,
3712,
19182,
23907,
378,
11,
21231,
8,
198,
220,
11677,
796,
299,
67,
12078,
7,
85,
8,
1875,
352,
5633,
352,
1058,
362,
198,
220,
3815,
796,
2092,
7,
85,
13,
8367,
11,
27741,
10100,
8,
198,
220,
329,
1312,
287,
352,
25,
13664,
7,
85,
8,
198,
220,
220,
220,
264,
796,
4731,
7,
521,
17,
7266,
7,
7857,
7,
85,
828,
1312,
4008,
198,
220,
220,
220,
3815,
58,
72,
60,
796,
4731,
7,
40290,
11,
12878,
1600,
264,
58,
17,
37498,
437,
532,
11677,
8,
4357,
366,
60,
4943,
198,
220,
886,
198,
220,
3815,
198,
437,
628,
198,
14468,
4242,
30535,
605,
6564,
2024,
1303,
14468,
21017,
198,
198,
9979,
45755,
3351,
282,
283,
46202,
796,
685,
198,
220,
36147,
14881,
11207,
10,
828,
198,
220,
36147,
14881,
11207,
12,
828,
198,
220,
36147,
14881,
11207,
9,
828,
198,
220,
36147,
14881,
11207,
14,
828,
198,
220,
36147,
14881,
13,
7479,
828,
198,
220,
36147,
14881,
11207,
61,
828,
198,
220,
36147,
14881,
11207,
7,
855,
36911,
198,
220,
36147,
14881,
11207,
7,
0,
28,
36911,
198,
220,
36147,
14881,
11207,
27,
828,
198,
220,
36147,
14881,
11207,
7,
27,
28,
36911,
198,
220,
36147,
14881,
11207,
29,
828,
198,
220,
36147,
14881,
11207,
7,
29,
28,
36911,
198,
220,
36147,
14881,
13,
66,
335,
828,
198,
220,
36147,
14881,
13,
7146,
828,
198,
220,
36147,
14881,
13,
7146,
2787,
828,
198,
220,
36147,
14881,
13,
69,
335,
828,
198,
220,
36147,
14881,
13,
4666,
828,
198,
220,
36147,
14881,
13,
2787,
8,
198,
60,
198,
198,
1640,
1034,
287,
45755,
3351,
282,
283,
46202,
198,
220,
2488,
18206,
7198,
404,
5769,
87,
3712,
3351,
282,
283,
23907,
378,
11,
331,
3712,
3351,
282,
283,
23907,
378,
8,
796,
7198,
404,
5769,
87,
13,
8367,
11,
331,
13,
8367,
8,
198,
437,
198,
198,
9979,
10485,
3351,
282,
283,
46202,
796,
685,
198,
220,
36147,
14881,
13,
344,
346,
828,
198,
220,
36147,
14881,
13,
28300,
828,
198,
220,
36147,
14881,
13,
744,
828,
198,
220,
36147,
14881,
13,
2213,
19524,
8,
198,
60,
198,
198,
1640,
1034,
287,
10485,
3351,
282,
283,
46202,
198,
220,
2488,
18206,
7198,
404,
5769,
87,
3712,
3351,
282,
283,
23907,
378,
8,
796,
7198,
404,
5769,
87,
13,
8367,
8,
198,
220,
2488,
18206,
7198,
404,
19953,
51,
92,
7,
3712,
6030,
90,
51,
5512,
2124,
3712,
3351,
282,
283,
23907,
378,
8,
796,
7198,
404,
5769,
51,
11,
2124,
13,
8367,
8,
198,
437,
198,
198,
9979,
791,
560,
3351,
282,
283,
46202,
796,
685,
198,
220,
36147,
14881,
11207,
10,
828,
198,
220,
36147,
14881,
11207,
12,
828,
198,
220,
36147,
14881,
13,
8937,
828,
198,
220,
36147,
14881,
13,
4468,
9504,
828,
198,
220,
36147,
14881,
13,
271,
10745,
828,
198,
220,
36147,
14881,
13,
271,
41433,
828,
198,
220,
36147,
14881,
13,
271,
12647,
828,
198,
220,
36147,
14881,
13,
4666,
17,
14415,
828,
198,
220,
36147,
14881,
13,
505,
828,
198,
220,
36147,
14881,
13,
12683,
828,
198,
220,
36147,
14881,
13,
22570,
8,
198,
60,
198,
198,
1640,
1034,
287,
791,
560,
3351,
282,
283,
46202,
198,
220,
2488,
18206,
7198,
404,
5769,
87,
3712,
3351,
282,
283,
23907,
378,
8,
796,
7198,
404,
5769,
87,
13,
8367,
8,
198,
437,
198
] | 2.412096 | 1,422 |
<filename>test/SEED/test_dataless.jl<gh_stars>10-100
printstyled(" dataless SEED\n", color=:light_green)
redirect_stdout(out) do
metafile = path*"/SampleFiles/SEED/jones.hood.dataless"
S = read_meta("dataless", metafile, v=3,
s="2008-01-01T00:00:00",
t="2008-02-01T00:00:00",
units=true)
S2 = read_dataless( metafile, v=3,
s=DateTime("2008-01-01T00:00:00"),
t=DateTime("2008-02-01T00:00:00"),
units=true)
@test S == S2
files = ls(path*"/SampleFiles/SEED/*.dataless")
for i in files
println("Reading file ", i)
S = read_meta("dataless", i, v=0, units=false)
S = read_meta("dataless", i, v=1, units=false)
S = read_meta("dataless", i, v=2, units=false)
S = read_meta("dataless", i, v=3, units=false)
S = read_meta("dataless", i, v=3, units=true)
end
end
| [
27,
34345,
29,
9288,
14,
5188,
1961,
14,
9288,
62,
67,
10254,
408,
13,
20362,
27,
456,
62,
30783,
29,
940,
12,
3064,
198,
4798,
34365,
992,
7203,
220,
4818,
282,
408,
7946,
1961,
59,
77,
1600,
3124,
28,
25,
2971,
62,
14809,
8,
198,
445,
1060,
62,
19282,
448,
7,
448,
8,
466,
198,
220,
1138,
1878,
576,
796,
3108,
9,
1,
14,
36674,
25876,
14,
5188,
1961,
14,
73,
1952,
13,
2894,
13,
67,
10254,
408,
1,
198,
220,
311,
796,
1100,
62,
28961,
7203,
67,
10254,
408,
1600,
1138,
1878,
576,
11,
410,
28,
18,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
2625,
11528,
12,
486,
12,
486,
51,
405,
25,
405,
25,
405,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
256,
2625,
11528,
12,
2999,
12,
486,
51,
405,
25,
405,
25,
405,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4991,
28,
7942,
8,
198,
220,
311,
17,
796,
1100,
62,
67,
10254,
408,
7,
1138,
1878,
576,
11,
410,
28,
18,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
28,
10430,
7575,
7203,
11528,
12,
486,
12,
486,
51,
405,
25,
405,
25,
405,
12340,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
256,
28,
10430,
7575,
7203,
11528,
12,
2999,
12,
486,
51,
405,
25,
405,
25,
405,
12340,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4991,
28,
7942,
8,
198,
220,
2488,
9288,
311,
6624,
311,
17,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
3696,
796,
43979,
7,
6978,
9,
1,
14,
36674,
25876,
14,
5188,
1961,
15211,
13,
67,
10254,
408,
4943,
198,
220,
329,
1312,
287,
3696,
198,
220,
220,
220,
44872,
7203,
36120,
2393,
33172,
1312,
8,
198,
220,
220,
220,
311,
796,
1100,
62,
28961,
7203,
67,
10254,
408,
1600,
1312,
11,
410,
28,
15,
11,
4991,
28,
9562,
8,
198,
220,
220,
220,
311,
796,
1100,
62,
28961,
7203,
67,
10254,
408,
1600,
1312,
11,
410,
28,
16,
11,
4991,
28,
9562,
8,
198,
220,
220,
220,
311,
796,
1100,
62,
28961,
7203,
67,
10254,
408,
1600,
1312,
11,
410,
28,
17,
11,
4991,
28,
9562,
8,
198,
220,
220,
220,
311,
796,
1100,
62,
28961,
7203,
67,
10254,
408,
1600,
1312,
11,
410,
28,
18,
11,
4991,
28,
9562,
8,
198,
220,
220,
220,
311,
796,
1100,
62,
28961,
7203,
67,
10254,
408,
1600,
1312,
11,
410,
28,
18,
11,
4991,
28,
7942,
8,
198,
220,
886,
198,
437,
198
] | 1.868952 | 496 |
using Enzyme
using Test
@testset "ABI & Calling convention" begin
f(x) = x
# GhostType -> Nothing
res = autodiff(f, Const(nothing))
@test res === nothing
# ConstType -> Type{Int}
res = autodiff(f, Const(Int))
@test res === nothing
cres, = Enzyme.autodiff(f, Active(1.5 + 0.7im))
@test cres ≈ 1.0 + 0.0im
unused(_, y) = y
res0, = autodiff(unused, Const(nothing), Active(2.0))
@test res0 ≈ 1.0
# Multi arg => sret
mul(x, y) = x * y
pair = autodiff(mul, Active(2.0), Active(3.0))
@test pair[1] ≈ 3.0
@test pair[2] ≈ 2.0
# SequentialType
struct Foo
baz::Int
qux::Float64
end
g(x) = x.qux
res2, = autodiff(g, Active(Foo(3, 1.2)))
@test res2.qux ≈ 1.0
unused2(_, y) = y.qux
resF, = autodiff(unused2, Const(nothing), Active(Foo(3, 2.0)))
@test resF.qux ≈ 1.0
h(x, y) = x.qux * y.qux
res3 = autodiff(h, Active(Foo(3, 1.2)), Active(Foo(5, 3.4)))
@test res3[1].qux ≈ 3.4
@test res3[2].qux ≈ 1.2
caller(f, x) = f(x)
res4, = autodiff(caller, (x)->x, Active(3.0))
@test res4 ≈ 1.0
struct LList
next::Union{LList,Nothing}
val::Float64
end
function sumlist(n::LList)
sum = 0.0
while n !== nothing
sum += n.val
n = n.next
end
sum
end
regular = LList(LList(nothing, 1.0), 2.0)
shadow = LList(LList(nothing, 0.0), 0.0)
ad = autodiff(sumlist, Duplicated(regular, shadow))
@test ad === nothing
@test shadow.val ≈ 1.0 && shadow.next.val ≈ 1.0
mulr(x, y) = x[] * y[]
x = Ref(2.0)
y = Ref(3.0)
dx = Ref(0.0)
dy = Ref(0.0)
n = autodiff(mulr, Duplicated(x, dx), Duplicated(y, dy))
@test n === nothing
@test dx[] ≈ 3.0
@test dy[] ≈ 2.0
mid, = Enzyme.autodiff((fs, x) -> fs[1](x), (x->x*x,), Active(2.0))
@test mid ≈ 4.0
mid, = Enzyme.autodiff((fs, x) -> fs[1](x), [x->x*x], Active(2.0))
@test mid ≈ 4.0
# deserves_argbox yes and no
struct Bar
r::Ref{Int}
end
# ConstType
# primitive type Int128, Float64, Float128
# returns: sret, const/ghost, !deserve_retbox
end
@testset "Callable ABI" begin
function method(f, x)
return f(x)
end
struct AFoo
x::Float64
end
function (f::AFoo)(x::Float64)
return f.x * x
end
@test Enzyme.autodiff(method, AFoo(2.0), Active(3.0))[1]≈ 2.0
@test Enzyme.autodiff(AFoo(2.0), Active(3.0))[1]≈ 2.0
struct ABar
end
function (f::ABar)(x::Float64)
return 2.0 * x
end
@test Enzyme.autodiff(method, ABar(), Active(3.0))[1]≈ 2.0
@test Enzyme.autodiff(ABar(), Active(3.0))[1]≈ 2.0
end
| [
3500,
2039,
24266,
198,
3500,
6208,
198,
198,
31,
9288,
2617,
366,
32,
3483,
1222,
32677,
9831,
1,
2221,
628,
220,
220,
220,
277,
7,
87,
8,
796,
2124,
628,
220,
220,
220,
1303,
9897,
6030,
4613,
10528,
198,
220,
220,
220,
581,
796,
1960,
375,
733,
7,
69,
11,
4757,
7,
22366,
4008,
198,
220,
220,
220,
2488,
9288,
581,
24844,
2147,
628,
220,
220,
220,
1303,
4757,
6030,
4613,
5994,
90,
5317,
92,
198,
220,
220,
220,
581,
796,
1960,
375,
733,
7,
69,
11,
4757,
7,
5317,
4008,
198,
220,
220,
220,
2488,
9288,
581,
24844,
2147,
628,
198,
220,
220,
220,
269,
411,
11,
220,
796,
2039,
24266,
13,
2306,
375,
733,
7,
69,
11,
14199,
7,
16,
13,
20,
1343,
657,
13,
22,
320,
4008,
198,
220,
220,
220,
2488,
9288,
269,
411,
15139,
230,
352,
13,
15,
1343,
657,
13,
15,
320,
628,
220,
220,
220,
21958,
28264,
11,
331,
8,
796,
331,
198,
220,
220,
220,
581,
15,
11,
796,
1960,
375,
733,
7,
403,
1484,
11,
4757,
7,
22366,
828,
14199,
7,
17,
13,
15,
4008,
198,
220,
220,
220,
2488,
9288,
581,
15,
15139,
230,
352,
13,
15,
628,
220,
220,
220,
1303,
15237,
1822,
5218,
264,
1186,
198,
220,
220,
220,
35971,
7,
87,
11,
331,
8,
796,
2124,
1635,
331,
198,
220,
220,
220,
5166,
796,
1960,
375,
733,
7,
76,
377,
11,
14199,
7,
17,
13,
15,
828,
14199,
7,
18,
13,
15,
4008,
198,
220,
220,
220,
2488,
9288,
5166,
58,
16,
60,
15139,
230,
513,
13,
15,
198,
220,
220,
220,
2488,
9288,
5166,
58,
17,
60,
15139,
230,
362,
13,
15,
628,
220,
220,
220,
1303,
24604,
1843,
6030,
198,
220,
220,
220,
2878,
36080,
198,
220,
220,
220,
220,
220,
220,
220,
275,
1031,
3712,
5317,
198,
220,
220,
220,
220,
220,
220,
220,
627,
87,
3712,
43879,
2414,
198,
220,
220,
220,
886,
628,
220,
220,
220,
308,
7,
87,
8,
796,
2124,
13,
421,
87,
198,
220,
220,
220,
581,
17,
11,
220,
796,
1960,
375,
733,
7,
70,
11,
14199,
7,
37,
2238,
7,
18,
11,
352,
13,
17,
22305,
198,
220,
220,
220,
2488,
9288,
581,
17,
13,
421,
87,
15139,
230,
352,
13,
15,
628,
198,
220,
220,
220,
21958,
17,
28264,
11,
331,
8,
796,
331,
13,
421,
87,
198,
220,
220,
220,
581,
37,
11,
796,
1960,
375,
733,
7,
403,
1484,
17,
11,
4757,
7,
22366,
828,
14199,
7,
37,
2238,
7,
18,
11,
362,
13,
15,
22305,
198,
220,
220,
220,
2488,
9288,
581,
37,
13,
421,
87,
15139,
230,
352,
13,
15,
628,
220,
220,
220,
289,
7,
87,
11,
331,
8,
796,
2124,
13,
421,
87,
1635,
331,
13,
421,
87,
198,
220,
220,
220,
581,
18,
796,
1960,
375,
733,
7,
71,
11,
14199,
7,
37,
2238,
7,
18,
11,
352,
13,
17,
36911,
14199,
7,
37,
2238,
7,
20,
11,
513,
13,
19,
22305,
198,
220,
220,
220,
2488,
9288,
581,
18,
58,
16,
4083,
421,
87,
15139,
230,
513,
13,
19,
198,
220,
220,
220,
2488,
9288,
581,
18,
58,
17,
4083,
421,
87,
15139,
230,
352,
13,
17,
628,
220,
220,
220,
24955,
7,
69,
11,
2124,
8,
796,
277,
7,
87,
8,
198,
220,
220,
220,
581,
19,
11,
796,
1960,
375,
733,
7,
13345,
263,
11,
357,
87,
8,
3784,
87,
11,
14199,
7,
18,
13,
15,
4008,
198,
220,
220,
220,
2488,
9288,
581,
19,
15139,
230,
352,
13,
15,
628,
220,
220,
220,
2878,
406,
8053,
198,
220,
220,
220,
220,
220,
220,
220,
1306,
3712,
38176,
90,
3069,
396,
11,
18465,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1188,
3712,
43879,
2414,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2163,
2160,
4868,
7,
77,
3712,
3069,
396,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2160,
796,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
981,
299,
5145,
855,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2160,
15853,
299,
13,
2100,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
796,
299,
13,
19545,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
2160,
198,
220,
220,
220,
886,
628,
220,
220,
220,
3218,
796,
406,
8053,
7,
3069,
396,
7,
22366,
11,
352,
13,
15,
828,
362,
13,
15,
8,
198,
220,
220,
220,
9082,
220,
796,
406,
8053,
7,
3069,
396,
7,
22366,
11,
657,
13,
15,
828,
657,
13,
15,
8,
198,
220,
220,
220,
512,
796,
1960,
375,
733,
7,
16345,
4868,
11,
49821,
3474,
7,
16338,
11,
9082,
4008,
198,
220,
220,
220,
2488,
9288,
512,
24844,
2147,
198,
220,
220,
220,
2488,
9288,
9082,
13,
2100,
15139,
230,
352,
13,
15,
11405,
9082,
13,
19545,
13,
2100,
15139,
230,
352,
13,
15,
628,
198,
220,
220,
220,
35971,
81,
7,
87,
11,
331,
8,
796,
2124,
21737,
1635,
331,
21737,
198,
220,
220,
220,
2124,
796,
6524,
7,
17,
13,
15,
8,
198,
220,
220,
220,
331,
796,
6524,
7,
18,
13,
15,
8,
198,
220,
220,
220,
44332,
796,
6524,
7,
15,
13,
15,
8,
198,
220,
220,
220,
20268,
796,
6524,
7,
15,
13,
15,
8,
198,
220,
220,
220,
299,
796,
1960,
375,
733,
7,
76,
377,
81,
11,
49821,
3474,
7,
87,
11,
44332,
828,
49821,
3474,
7,
88,
11,
20268,
4008,
198,
220,
220,
220,
2488,
9288,
299,
24844,
2147,
198,
220,
220,
220,
2488,
9288,
44332,
21737,
15139,
230,
513,
13,
15,
198,
220,
220,
220,
2488,
9288,
20268,
21737,
15139,
230,
362,
13,
15,
628,
220,
220,
220,
3095,
11,
796,
2039,
24266,
13,
2306,
375,
733,
19510,
9501,
11,
2124,
8,
4613,
43458,
58,
16,
16151,
87,
828,
357,
87,
3784,
87,
9,
87,
11,
828,
14199,
7,
17,
13,
15,
4008,
198,
220,
220,
220,
2488,
9288,
3095,
15139,
230,
604,
13,
15,
628,
220,
220,
220,
3095,
11,
796,
2039,
24266,
13,
2306,
375,
733,
19510,
9501,
11,
2124,
8,
4613,
43458,
58,
16,
16151,
87,
828,
685,
87,
3784,
87,
9,
87,
4357,
14199,
7,
17,
13,
15,
4008,
198,
220,
220,
220,
2488,
9288,
3095,
15139,
230,
604,
13,
15,
628,
220,
220,
220,
1303,
14071,
62,
853,
3524,
3763,
290,
645,
198,
220,
220,
220,
2878,
2409,
198,
220,
220,
220,
220,
220,
220,
220,
374,
3712,
8134,
90,
5317,
92,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1303,
4757,
6030,
628,
220,
220,
220,
1303,
20049,
2099,
2558,
12762,
11,
48436,
2414,
11,
48436,
12762,
628,
220,
220,
220,
1303,
5860,
25,
264,
1186,
11,
1500,
14,
38933,
11,
5145,
8906,
3760,
62,
1186,
3524,
198,
437,
628,
198,
31,
9288,
2617,
366,
14134,
540,
317,
3483,
1,
2221,
198,
220,
220,
220,
2163,
2446,
7,
69,
11,
2124,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
277,
7,
87,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2878,
12341,
2238,
198,
220,
220,
220,
220,
220,
220,
2124,
3712,
43879,
2414,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2163,
357,
69,
3712,
8579,
2238,
5769,
87,
3712,
43879,
2414,
8,
198,
220,
220,
220,
220,
220,
220,
1441,
277,
13,
87,
1635,
2124,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
2039,
24266,
13,
2306,
375,
733,
7,
24396,
11,
12341,
2238,
7,
17,
13,
15,
828,
14199,
7,
18,
13,
15,
4008,
58,
16,
60,
35705,
230,
362,
13,
15,
198,
220,
220,
220,
2488,
9288,
2039,
24266,
13,
2306,
375,
733,
7,
8579,
2238,
7,
17,
13,
15,
828,
14199,
7,
18,
13,
15,
4008,
58,
16,
60,
35705,
230,
362,
13,
15,
628,
198,
220,
220,
220,
2878,
9564,
283,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2163,
357,
69,
3712,
6242,
283,
5769,
87,
3712,
43879,
2414,
8,
198,
220,
220,
220,
220,
220,
220,
1441,
362,
13,
15,
1635,
2124,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
2039,
24266,
13,
2306,
375,
733,
7,
24396,
11,
9564,
283,
22784,
14199,
7,
18,
13,
15,
4008,
58,
16,
60,
35705,
230,
362,
13,
15,
198,
220,
220,
220,
2488,
9288,
2039,
24266,
13,
2306,
375,
733,
7,
6242,
283,
22784,
14199,
7,
18,
13,
15,
4008,
58,
16,
60,
35705,
230,
362,
13,
15,
198,
437,
198
] | 1.942594 | 1,411 |
# Chemfiles.jl, a modern library for chemistry file reading and writing
# Copyright (C) <NAME> and contributors -- BSD license
export mass, set_mass!, charge, set_charge!, name, set_name!, type, set_type!
export vdw_radius, covalent_radius, atomic_number
export set_property!, property, properties_count, list_properties
__ptr(atom::Atom) = __ptr(atom.__handle)
__const_ptr(atom::Atom) = __const_ptr(atom.__handle)
"""
Create an atom with the given ``name`` and set the atom ``type`` to be the same
as ``name``.
"""
function Atom(name::String)
ptr = @__check_ptr(lib.chfl_atom(pointer(name)))
return Atom(CxxPointer(ptr, is_const=false))
end
"""
Get a copy of the ``atom`` at the given ``index`` from a ``frame``.
"""
function Atom(frame::Frame, index::Integer)
ptr = @__check_ptr(lib.chfl_atom_from_frame(__ptr(frame), UInt64(index)))
atom = Atom(CxxPointer(ptr, is_const=false))
copy = deepcopy(atom)
finalize(atom)
return copy
end
"""
Get a copy of the ``atom`` at the given ``index`` from a ``topology``.
"""
function Atom(topology::Topology, index::Integer)
ptr = @__check_ptr(lib.chfl_atom_from_topology(__ptr(topology), UInt64(index)))
atom = Atom(CxxPointer(ptr, is_const=false))
copy = deepcopy(atom)
finalize(atom)
return copy
end
"""
Get the mass of an ``atom`` in atomic mass units.
"""
function mass(atom::Atom)
result = Ref{Float64}(0)
__check(lib.chfl_atom_mass(__const_ptr(atom), result))
return result[]
end
"""
Set the mass of an ``atom`` to ``mass``.
The mass must be in atomic mass units.
"""
function set_mass!(atom::Atom, mass)
__check(lib.chfl_atom_set_mass(__ptr(atom), Float64(mass)))
return nothing
end
"""
Get the charge of an ``atom`` in number of the electron charge *e*.
"""
function charge(atom::Atom)
result = Ref{Float64}(0)
__check(lib.chfl_atom_charge(__const_ptr(atom), result))
return result[]
end
"""
Set the charge of an ``atom`` to ``charge``.
The charge must be in number of the electron charge *e*.
"""
function set_charge!(atom::Atom, charge)
__check(lib.chfl_atom_set_charge(__ptr(atom), Float64(charge)))
return nothing
end
"""
Get the name of an ``atom``.
"""
function name(atom::Atom)
return __call_with_growing_buffer(
(buffer, size) -> __check(lib.chfl_atom_name(__const_ptr(atom), buffer, size))
)
end
"""
Set the name of an ``atom`` to ``name``.
"""
function set_name!(atom::Atom, name::String)
__check(lib.chfl_atom_set_name(__ptr(atom), pointer(name)))
return nothing
end
"""
Get the type of an ``atom``.
"""
function type(atom::Atom)
return __call_with_growing_buffer(
(buffer, size) -> __check(lib.chfl_atom_type(__const_ptr(atom), buffer, size))
)
end
"""
Set the type of an ``atom`` to ``type``.
"""
function set_type!(atom::Atom, type::String)
__check(lib.chfl_atom_set_type(__ptr(atom), pointer(type)))
return nothing
end
"""
Get the full name of an ``atom`` from the atom type.
For example, the full name of an atom with type "He" is "Helium".
"""
function Base.fullname(atom::Atom)
return __call_with_growing_buffer(
(buffer, size) -> __check(lib.chfl_atom_full_name(
__const_ptr(atom), buffer, size)
)
)
end
"""
Get the van der Waals radius of an ``atom`` from the atom type.
If the radius can not be found, this function returns 0.
"""
function vdw_radius(atom::Atom)
radius = Ref{Float64}(0)
__check(lib.chfl_atom_vdw_radius(__const_ptr(atom), radius))
return radius[]
end
"""
Get the covalent radius of an ``atom`` from the atom type.
If the radius can not be found, returns 0.
"""
function covalent_radius(atom::Atom)
radius = Ref{Float64}(0)
__check(lib.chfl_atom_covalent_radius(__const_ptr(atom), radius))
return radius[]
end
"""
Get the atomic number of an ``atom`` from the atom type.
If the atomic number can not be found, returns 0.
"""
function atomic_number(atom::Atom)
number = Ref{UInt64}(0)
__check(lib.chfl_atom_atomic_number(__const_ptr(atom), number))
return number[]
end
"""
Set a named property for the given atom.
"""
function set_property!(atom::Atom, name::String, value)
property = Property(value)
__check(lib.chfl_atom_set_property(
__ptr(atom), pointer(name), __const_ptr(property)
))
return nothing
end
"""
Get a named property for the given atom.
"""
function property(atom::Atom, name::String)
ptr = lib.chfl_atom_get_property(__const_ptr(atom), pointer(name))
return extract(Property(CxxPointer(ptr, is_const=false)))
end
"""
Get the number of properties associated with an atom.
"""
function properties_count(atom::Atom)
count = Ref{UInt64}(0)
__check(lib.chfl_atom_properties_count(__const_ptr(atom), count))
return count[]
end
"""
Get the names of all properties associated with an atom.
"""
function list_properties(atom::Atom)
count = properties_count(atom)
names = Array{Ptr{UInt8}}(undef, count)
__check(lib.chfl_atom_list_properties(__const_ptr(atom), pointer(names), count))
return map(unsafe_string, names)
end
"""
Make a deep copy of an ``atom``.
"""
function Base.deepcopy(atom::Atom)
ptr = lib.chfl_atom_copy(__const_ptr(atom))
return Atom(CxxPointer(ptr, is_const=false))
end
| [
2,
12870,
16624,
13,
20362,
11,
257,
3660,
5888,
329,
16585,
2393,
3555,
290,
3597,
198,
2,
15069,
357,
34,
8,
1279,
20608,
29,
290,
20420,
1377,
347,
10305,
5964,
198,
198,
39344,
2347,
11,
900,
62,
22208,
28265,
3877,
11,
900,
62,
10136,
28265,
1438,
11,
900,
62,
3672,
28265,
2099,
11,
900,
62,
4906,
0,
198,
39344,
410,
67,
86,
62,
42172,
11,
269,
8325,
298,
62,
42172,
11,
17226,
62,
17618,
198,
39344,
900,
62,
26745,
28265,
3119,
11,
6608,
62,
9127,
11,
1351,
62,
48310,
198,
198,
834,
20692,
7,
37696,
3712,
2953,
296,
8,
796,
11593,
20692,
7,
37696,
13,
834,
28144,
8,
198,
834,
9979,
62,
20692,
7,
37696,
3712,
2953,
296,
8,
796,
11593,
9979,
62,
20692,
7,
37696,
13,
834,
28144,
8,
198,
198,
37811,
198,
16447,
281,
22037,
351,
262,
1813,
7559,
3672,
15506,
290,
900,
262,
22037,
7559,
4906,
15506,
284,
307,
262,
976,
198,
292,
7559,
3672,
15506,
13,
198,
37811,
198,
8818,
33102,
7,
3672,
3712,
10100,
8,
198,
220,
220,
220,
50116,
796,
2488,
834,
9122,
62,
20692,
7,
8019,
13,
354,
2704,
62,
37696,
7,
29536,
7,
3672,
22305,
198,
220,
220,
220,
1441,
33102,
7,
34,
5324,
18833,
3849,
7,
20692,
11,
318,
62,
9979,
28,
9562,
4008,
198,
437,
198,
198,
37811,
198,
3855,
257,
4866,
286,
262,
7559,
37696,
15506,
379,
262,
1813,
7559,
9630,
15506,
422,
257,
7559,
14535,
15506,
13,
198,
37811,
198,
8818,
33102,
7,
14535,
3712,
19778,
11,
6376,
3712,
46541,
8,
198,
220,
220,
220,
50116,
796,
2488,
834,
9122,
62,
20692,
7,
8019,
13,
354,
2704,
62,
37696,
62,
6738,
62,
14535,
7,
834,
20692,
7,
14535,
828,
471,
5317,
2414,
7,
9630,
22305,
198,
220,
220,
220,
22037,
796,
33102,
7,
34,
5324,
18833,
3849,
7,
20692,
11,
318,
62,
9979,
28,
9562,
4008,
198,
220,
220,
220,
4866,
796,
2769,
30073,
7,
37696,
8,
198,
220,
220,
220,
2457,
1096,
7,
37696,
8,
198,
220,
220,
220,
1441,
4866,
198,
437,
198,
198,
37811,
198,
3855,
257,
4866,
286,
262,
7559,
37696,
15506,
379,
262,
1813,
7559,
9630,
15506,
422,
257,
7559,
4852,
1435,
15506,
13,
198,
37811,
198,
8818,
33102,
7,
4852,
1435,
3712,
9126,
1435,
11,
6376,
3712,
46541,
8,
198,
220,
220,
220,
50116,
796,
2488,
834,
9122,
62,
20692,
7,
8019,
13,
354,
2704,
62,
37696,
62,
6738,
62,
4852,
1435,
7,
834,
20692,
7,
4852,
1435,
828,
471,
5317,
2414,
7,
9630,
22305,
198,
220,
220,
220,
22037,
796,
33102,
7,
34,
5324,
18833,
3849,
7,
20692,
11,
318,
62,
9979,
28,
9562,
4008,
198,
220,
220,
220,
4866,
796,
2769,
30073,
7,
37696,
8,
198,
220,
220,
220,
2457,
1096,
7,
37696,
8,
198,
220,
220,
220,
1441,
4866,
198,
437,
198,
198,
37811,
198,
3855,
262,
2347,
286,
281,
7559,
37696,
15506,
287,
17226,
2347,
4991,
13,
198,
37811,
198,
8818,
2347,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
1255,
796,
6524,
90,
43879,
2414,
92,
7,
15,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
22208,
7,
834,
9979,
62,
20692,
7,
37696,
828,
1255,
4008,
198,
220,
220,
220,
1441,
1255,
21737,
198,
437,
198,
198,
37811,
198,
7248,
262,
2347,
286,
281,
7559,
37696,
15506,
284,
7559,
22208,
15506,
13,
198,
198,
464,
2347,
1276,
307,
287,
17226,
2347,
4991,
13,
198,
37811,
198,
8818,
900,
62,
22208,
0,
7,
37696,
3712,
2953,
296,
11,
2347,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
2617,
62,
22208,
7,
834,
20692,
7,
37696,
828,
48436,
2414,
7,
22208,
22305,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
37811,
198,
3855,
262,
3877,
286,
281,
7559,
37696,
15506,
287,
1271,
286,
262,
11538,
3877,
1635,
68,
24620,
198,
37811,
198,
8818,
3877,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
1255,
796,
6524,
90,
43879,
2414,
92,
7,
15,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
10136,
7,
834,
9979,
62,
20692,
7,
37696,
828,
1255,
4008,
198,
220,
220,
220,
1441,
1255,
21737,
198,
437,
198,
198,
37811,
198,
7248,
262,
3877,
286,
281,
7559,
37696,
15506,
284,
7559,
10136,
15506,
13,
198,
198,
464,
3877,
1276,
307,
287,
1271,
286,
262,
11538,
3877,
1635,
68,
24620,
198,
37811,
198,
8818,
900,
62,
10136,
0,
7,
37696,
3712,
2953,
296,
11,
3877,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
2617,
62,
10136,
7,
834,
20692,
7,
37696,
828,
48436,
2414,
7,
10136,
22305,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
37811,
198,
3855,
262,
1438,
286,
281,
7559,
37696,
15506,
13,
198,
37811,
198,
8818,
1438,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
1441,
11593,
13345,
62,
4480,
62,
25167,
62,
22252,
7,
198,
220,
220,
220,
220,
220,
220,
220,
357,
22252,
11,
2546,
8,
4613,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
3672,
7,
834,
9979,
62,
20692,
7,
37696,
828,
11876,
11,
2546,
4008,
198,
220,
220,
220,
1267,
198,
437,
198,
198,
37811,
198,
7248,
262,
1438,
286,
281,
7559,
37696,
15506,
284,
7559,
3672,
15506,
13,
198,
37811,
198,
8818,
900,
62,
3672,
0,
7,
37696,
3712,
2953,
296,
11,
1438,
3712,
10100,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
2617,
62,
3672,
7,
834,
20692,
7,
37696,
828,
17562,
7,
3672,
22305,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
37811,
198,
3855,
262,
2099,
286,
281,
7559,
37696,
15506,
13,
198,
37811,
198,
8818,
2099,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
1441,
11593,
13345,
62,
4480,
62,
25167,
62,
22252,
7,
198,
220,
220,
220,
220,
220,
220,
220,
357,
22252,
11,
2546,
8,
4613,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
4906,
7,
834,
9979,
62,
20692,
7,
37696,
828,
11876,
11,
2546,
4008,
198,
220,
220,
220,
1267,
198,
437,
198,
198,
37811,
198,
7248,
262,
2099,
286,
281,
7559,
37696,
15506,
284,
7559,
4906,
15506,
13,
198,
37811,
198,
8818,
900,
62,
4906,
0,
7,
37696,
3712,
2953,
296,
11,
2099,
3712,
10100,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
2617,
62,
4906,
7,
834,
20692,
7,
37696,
828,
17562,
7,
4906,
22305,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
37811,
198,
3855,
262,
1336,
1438,
286,
281,
7559,
37696,
15506,
422,
262,
22037,
2099,
13,
198,
198,
1890,
1672,
11,
262,
1336,
1438,
286,
281,
22037,
351,
2099,
366,
1544,
1,
318,
366,
12621,
1505,
1911,
198,
37811,
198,
8818,
7308,
13,
12853,
3672,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
1441,
11593,
13345,
62,
4480,
62,
25167,
62,
22252,
7,
198,
220,
220,
220,
220,
220,
220,
220,
357,
22252,
11,
2546,
8,
4613,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
12853,
62,
3672,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11593,
9979,
62,
20692,
7,
37696,
828,
11876,
11,
2546,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
1267,
198,
437,
198,
198,
37811,
198,
3855,
262,
5719,
4587,
15329,
874,
16874,
286,
281,
7559,
37696,
15506,
422,
262,
22037,
2099,
13,
198,
198,
1532,
262,
16874,
460,
407,
307,
1043,
11,
428,
2163,
5860,
657,
13,
198,
37811,
198,
8818,
410,
67,
86,
62,
42172,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
16874,
796,
6524,
90,
43879,
2414,
92,
7,
15,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
20306,
86,
62,
42172,
7,
834,
9979,
62,
20692,
7,
37696,
828,
16874,
4008,
198,
220,
220,
220,
1441,
16874,
21737,
198,
437,
198,
198,
37811,
198,
3855,
262,
269,
8325,
298,
16874,
286,
281,
7559,
37696,
15506,
422,
262,
22037,
2099,
13,
198,
198,
1532,
262,
16874,
460,
407,
307,
1043,
11,
5860,
657,
13,
198,
37811,
198,
8818,
269,
8325,
298,
62,
42172,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
16874,
796,
6524,
90,
43879,
2414,
92,
7,
15,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
66,
8325,
298,
62,
42172,
7,
834,
9979,
62,
20692,
7,
37696,
828,
16874,
4008,
198,
220,
220,
220,
1441,
16874,
21737,
198,
437,
198,
198,
37811,
198,
3855,
262,
17226,
1271,
286,
281,
7559,
37696,
15506,
422,
262,
22037,
2099,
13,
198,
198,
1532,
262,
17226,
1271,
460,
407,
307,
1043,
11,
5860,
657,
13,
198,
37811,
198,
8818,
17226,
62,
17618,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
1271,
796,
6524,
90,
52,
5317,
2414,
92,
7,
15,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
47116,
62,
17618,
7,
834,
9979,
62,
20692,
7,
37696,
828,
1271,
4008,
198,
220,
220,
220,
1441,
1271,
21737,
198,
437,
198,
198,
37811,
198,
7248,
257,
3706,
3119,
329,
262,
1813,
22037,
13,
198,
37811,
198,
8818,
900,
62,
26745,
0,
7,
37696,
3712,
2953,
296,
11,
1438,
3712,
10100,
11,
1988,
8,
198,
220,
220,
220,
3119,
796,
14161,
7,
8367,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
2617,
62,
26745,
7,
198,
220,
220,
220,
220,
220,
220,
220,
11593,
20692,
7,
37696,
828,
17562,
7,
3672,
828,
11593,
9979,
62,
20692,
7,
26745,
8,
198,
220,
220,
220,
15306,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
37811,
198,
3855,
257,
3706,
3119,
329,
262,
1813,
22037,
13,
198,
37811,
198,
8818,
3119,
7,
37696,
3712,
2953,
296,
11,
1438,
3712,
10100,
8,
198,
220,
220,
220,
50116,
796,
9195,
13,
354,
2704,
62,
37696,
62,
1136,
62,
26745,
7,
834,
9979,
62,
20692,
7,
37696,
828,
17562,
7,
3672,
4008,
198,
220,
220,
220,
1441,
7925,
7,
21746,
7,
34,
5324,
18833,
3849,
7,
20692,
11,
318,
62,
9979,
28,
9562,
22305,
198,
437,
198,
198,
37811,
198,
3855,
262,
1271,
286,
6608,
3917,
351,
281,
22037,
13,
198,
37811,
198,
8818,
6608,
62,
9127,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
954,
796,
6524,
90,
52,
5317,
2414,
92,
7,
15,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
48310,
62,
9127,
7,
834,
9979,
62,
20692,
7,
37696,
828,
954,
4008,
198,
220,
220,
220,
1441,
954,
21737,
198,
437,
198,
198,
37811,
198,
3855,
262,
3891,
286,
477,
6608,
3917,
351,
281,
22037,
13,
198,
37811,
198,
8818,
1351,
62,
48310,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
954,
796,
6608,
62,
9127,
7,
37696,
8,
198,
220,
220,
220,
3891,
796,
15690,
90,
46745,
90,
52,
5317,
23,
11709,
7,
917,
891,
11,
954,
8,
198,
220,
220,
220,
11593,
9122,
7,
8019,
13,
354,
2704,
62,
37696,
62,
4868,
62,
48310,
7,
834,
9979,
62,
20692,
7,
37696,
828,
17562,
7,
14933,
828,
954,
4008,
198,
220,
220,
220,
1441,
3975,
7,
13271,
8635,
62,
8841,
11,
3891,
8,
198,
437,
198,
198,
37811,
198,
12050,
257,
2769,
4866,
286,
281,
7559,
37696,
15506,
13,
198,
37811,
198,
8818,
7308,
13,
22089,
30073,
7,
37696,
3712,
2953,
296,
8,
198,
220,
220,
220,
50116,
796,
9195,
13,
354,
2704,
62,
37696,
62,
30073,
7,
834,
9979,
62,
20692,
7,
37696,
4008,
198,
220,
220,
220,
1441,
33102,
7,
34,
5324,
18833,
3849,
7,
20692,
11,
318,
62,
9979,
28,
9562,
4008,
198,
437,
198
] | 2.705732 | 1,954 |
<reponame>UnofficialJuliaMirrorSnapshots/CompilerTools.jl-98f049d2-a028-5a73-bd4d-a8c50ff59ab5
#=
Copyright (c) 2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
=#
import CompilerTools.AstWalker
export constant_fold
binops = Set([:+; :-; :*; :/])
function constant_folder(node, symbol_table, top_level_number, is_top_level, read)
if isa(node, Expr)
if node.head == :(=)
rhs = AstWalker.AstWalk(node.args[2], constant_folder, symbol_table)
if isa(rhs, Number)
symbol_table[node.args[1]] = rhs
end
return node
elseif node.head == :call
if in(node.args[1], binops) && length(node.args)==3
node.args[2] = AstWalker.AstWalk(node.args[2], constant_folder, symbol_table)[1]
node.args[3] = AstWalker.AstWalk(node.args[3], constant_folder, symbol_table)[1]
if isa(node.args[2], Number) && isa(node.args[3], Number)
return eval(node)
end
end
end
elseif isa(node, Symbol)
if haskey(symbol_table, node)
return symbol_table[node]
end
elseif isa(node, Number)
return node
end
return CompilerTools.AstWalker.ASTWALK_RECURSE
end
function constant_fold(fn)
symbol_table = Dict{Symbol, Number}()
fn = AstWalker.AstWalk(fn, constant_folder, symbol_table)
return fn
end
#=
macro constant_fold(fn)
symbol_table = Dict{Symbol, Number}()
AstWalker.AstWalk(fn, constant_folder, symbol_table)
println(symbol_table)
println(fn)
return esc(fn)
end
@constant_fold function test(z)
a = 3
b = 4
c = a - b
d = z + c
return d
end
=#
| [
27,
7856,
261,
480,
29,
3118,
16841,
16980,
544,
27453,
1472,
43826,
20910,
14,
7293,
5329,
33637,
13,
20362,
12,
4089,
69,
15,
2920,
67,
17,
12,
64,
46957,
12,
20,
64,
4790,
12,
17457,
19,
67,
12,
64,
23,
66,
1120,
487,
3270,
397,
20,
198,
2,
28,
198,
15269,
357,
66,
8,
1853,
11,
8180,
10501,
198,
3237,
2489,
10395,
13,
198,
198,
7738,
396,
3890,
290,
779,
287,
2723,
290,
13934,
5107,
11,
351,
393,
1231,
198,
4666,
2649,
11,
389,
10431,
2810,
326,
262,
1708,
3403,
389,
1138,
25,
198,
12,
2297,
396,
2455,
507,
286,
2723,
2438,
1276,
12377,
262,
2029,
6634,
4003,
11,
198,
220,
428,
1351,
286,
3403,
290,
262,
1708,
37592,
13,
198,
12,
2297,
396,
2455,
507,
287,
13934,
1296,
1276,
22919,
262,
2029,
6634,
4003,
11,
198,
220,
428,
1351,
286,
3403,
290,
262,
1708,
37592,
287,
262,
10314,
198,
220,
290,
14,
273,
584,
5696,
2810,
351,
262,
6082,
13,
198,
198,
43559,
47466,
3180,
36592,
2389,
1961,
11050,
3336,
27975,
38162,
9947,
367,
15173,
4877,
5357,
27342,
9865,
3843,
20673,
366,
1921,
3180,
1,
198,
6981,
15529,
7788,
32761,
6375,
8959,
49094,
34764,
11015,
11,
47783,
2751,
11,
21728,
5626,
40880,
5390,
11,
3336,
198,
3955,
49094,
34764,
11015,
3963,
34482,
3398,
1565,
5603,
25382,
5357,
376,
46144,
7473,
317,
16652,
2149,
37232,
33079,
48933,
198,
12203,
13954,
48778,
1961,
13,
3268,
8005,
49261,
50163,
3336,
27975,
38162,
9947,
49707,
14418,
6375,
27342,
9865,
3843,
20673,
9348,
198,
43,
3539,
19146,
7473,
15529,
42242,
11,
3268,
17931,
23988,
11,
19387,
25256,
1847,
11,
38846,
11,
7788,
3620,
6489,
13153,
11,
6375,
198,
10943,
5188,
10917,
3525,
12576,
29506,
25552,
357,
1268,
39149,
2751,
11,
21728,
5626,
40880,
5390,
11,
41755,
11335,
10979,
3963,
198,
50,
10526,
2257,
2043,
37780,
21090,
50,
6375,
49254,
26,
406,
18420,
3963,
23210,
11,
42865,
11,
6375,
4810,
19238,
29722,
26,
6375,
43949,
44180,
198,
41358,
49,
8577,
24131,
8,
29630,
36,
5959,
7257,
2937,
1961,
5357,
6177,
15529,
3336,
15513,
3963,
43031,
25382,
11,
7655,
2767,
16879,
3268,
198,
10943,
5446,
10659,
11,
19269,
18379,
43031,
25382,
11,
6375,
309,
9863,
357,
1268,
39149,
2751,
399,
7156,
43,
3528,
18310,
6375,
25401,
54,
24352,
8,
198,
1503,
1797,
2751,
3268,
15529,
34882,
16289,
3963,
3336,
23210,
3963,
12680,
47466,
11,
45886,
16876,
5984,
29817,
1961,
3963,
198,
10970,
28069,
11584,
25382,
3963,
13558,
3398,
29506,
11879,
13,
198,
46249,
198,
198,
11748,
3082,
5329,
33637,
13,
33751,
39950,
198,
39344,
6937,
62,
11379,
198,
198,
8800,
2840,
796,
5345,
26933,
25,
10,
26,
1058,
12,
26,
1058,
9,
26,
1058,
14,
12962,
198,
198,
8818,
6937,
62,
43551,
7,
17440,
11,
6194,
62,
11487,
11,
1353,
62,
5715,
62,
17618,
11,
318,
62,
4852,
62,
5715,
11,
1100,
8,
198,
220,
611,
318,
64,
7,
17440,
11,
1475,
1050,
8,
198,
220,
220,
220,
611,
10139,
13,
2256,
6624,
36147,
28,
8,
198,
220,
220,
220,
220,
220,
9529,
82,
796,
8304,
39950,
13,
33751,
35963,
7,
17440,
13,
22046,
58,
17,
4357,
6937,
62,
43551,
11,
6194,
62,
11487,
8,
198,
220,
220,
220,
220,
220,
611,
318,
64,
7,
81,
11994,
11,
7913,
8,
198,
220,
220,
220,
220,
220,
220,
220,
6194,
62,
11487,
58,
17440,
13,
22046,
58,
16,
11907,
796,
9529,
82,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
1441,
10139,
198,
220,
220,
220,
2073,
361,
10139,
13,
2256,
6624,
1058,
13345,
198,
220,
220,
220,
220,
220,
611,
287,
7,
17440,
13,
22046,
58,
16,
4357,
9874,
2840,
8,
11405,
4129,
7,
17440,
13,
22046,
8,
855,
18,
198,
197,
220,
220,
220,
220,
220,
10139,
13,
22046,
58,
17,
60,
796,
8304,
39950,
13,
33751,
35963,
7,
17440,
13,
22046,
58,
17,
4357,
6937,
62,
43551,
11,
6194,
62,
11487,
38381,
16,
60,
198,
197,
220,
220,
220,
220,
220,
10139,
13,
22046,
58,
18,
60,
796,
8304,
39950,
13,
33751,
35963,
7,
17440,
13,
22046,
58,
18,
4357,
6937,
62,
43551,
11,
6194,
62,
11487,
38381,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
611,
318,
64,
7,
17440,
13,
22046,
58,
17,
4357,
7913,
8,
11405,
318,
64,
7,
17440,
13,
22046,
58,
18,
4357,
7913,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
5418,
7,
17440,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
2073,
361,
318,
64,
7,
17440,
11,
38357,
8,
198,
220,
220,
220,
611,
468,
2539,
7,
1837,
23650,
62,
11487,
11,
10139,
8,
198,
220,
220,
220,
220,
220,
1441,
6194,
62,
11487,
58,
17440,
60,
198,
220,
220,
220,
886,
198,
220,
2073,
361,
318,
64,
7,
17440,
11,
7913,
8,
198,
220,
220,
220,
1441,
10139,
198,
220,
886,
198,
220,
1441,
3082,
5329,
33637,
13,
33751,
39950,
13,
11262,
54,
28082,
62,
38827,
4261,
5188,
198,
437,
198,
198,
8818,
6937,
62,
11379,
7,
22184,
8,
198,
197,
1837,
23650,
62,
11487,
796,
360,
713,
90,
13940,
23650,
11,
7913,
92,
3419,
198,
197,
22184,
796,
8304,
39950,
13,
33751,
35963,
7,
22184,
11,
6937,
62,
43551,
11,
6194,
62,
11487,
8,
198,
197,
7783,
24714,
198,
437,
198,
198,
2,
28,
198,
20285,
305,
6937,
62,
11379,
7,
22184,
8,
198,
197,
1837,
23650,
62,
11487,
796,
360,
713,
90,
13940,
23650,
11,
7913,
92,
3419,
198,
197,
33751,
39950,
13,
33751,
35963,
7,
22184,
11,
6937,
62,
43551,
11,
6194,
62,
11487,
8,
198,
220,
44872,
7,
1837,
23650,
62,
11487,
8,
198,
220,
44872,
7,
22184,
8,
198,
220,
1441,
3671,
7,
22184,
8,
198,
437,
198,
198,
31,
9979,
415,
62,
11379,
2163,
1332,
7,
89,
8,
198,
220,
257,
796,
513,
198,
220,
275,
796,
604,
198,
220,
269,
796,
257,
532,
275,
198,
220,
288,
796,
1976,
1343,
269,
198,
220,
1441,
288,
198,
437,
198,
46249,
198
] | 2.78979 | 999 |
@doc """
S = read_hdf5(filestr, s::TimeSpec, t::TimeSpec, [, keywords])
read_hdf5!(S, filestr, s::TimeSpec, t::TimeSpec, [, keywords])
Read data in seismic HDF5 format from files matching pattern `filestr`.
`s`, `t` are required arguments but can be any Type ∈ (DateTime, Real, String);
type `?TimeSpec` for more information about how these are interpreted.
|KW | Type | Default | Meaning |
|:--- |:--- |:--- |:--- |
| id | String | "*" | id pattern, formated nn.sss.ll.ccc |
| | | | (net.sta.loc.cha); FDSN wildcards [^1] |
| msr | Bool | true | read full (MultiStageResp) instrument resp? |
| v | Integer | 0 | verbosity |
[^1] A question mark ('?') is a wildcard for a single character; an asterisk ('*') is a wildcard for zero or more characters
See also: `TimeSpec`, `parsetimewin`, `read_data`
""" read_hdf5!
function read_hdf5!(S::GphysData, fpat::String, s::TimeSpec, t::TimeSpec;
fmt ::String = "asdf", # data format
id ::Union{String, Regex} = "*", # id string
msr ::Bool = true, # read multistage response?
v ::Integer = KW.v # verbosity
)
N = S.n
filestr = abspath(fpat)
one_file = safe_isfile(filestr)
if fmt == "asdf"
if one_file
append!(S, read_asdf(filestr, id, s, t, msr, v))
else
files = ls(filestr)
for fname in files
append!(S, read_asdf(fname, id, s, t, msr, v))
end
end
else
error("Unknown file format (possibly NYI)!")
end
new_chan_src = view(S.src, N+1:S.n)
fill!(new_chan_src, filestr)
note!(S, N+1:S.n, string( " ¦ +source ¦ read_hdf5!(S, ",
"\"", fmt, "\", ",
"\"", s, "\", ",
"\"", t, "\", ",
"fmt=\"", fmt, "\", ",
"id=\"", id, "\", ",
"msr=", msr, ", ",
"v=", KW.v, ")")
)
return nothing
end
@doc (@doc read_hdf5!)
function read_hdf5(filestr::String, s::TimeSpec, t::TimeSpec;
fmt ::String = "asdf", # data format
id ::Union{String, Regex} = "*", # id string
msr ::Bool = true, # read multistage response?
v ::Integer = KW.v # verbosity
)
S = SeisData()
read_hdf5!(S, filestr, s, t,
fmt = fmt,
id = id,
msr = msr,
v = v
)
return S
end
| [
31,
15390,
37227,
198,
220,
220,
220,
311,
796,
1100,
62,
71,
7568,
20,
7,
10379,
395,
81,
11,
264,
3712,
7575,
22882,
11,
256,
3712,
7575,
22882,
11,
685,
11,
26286,
12962,
198,
220,
220,
220,
1100,
62,
71,
7568,
20,
0,
7,
50,
11,
1226,
395,
81,
11,
264,
3712,
7575,
22882,
11,
256,
3712,
7575,
22882,
11,
685,
11,
26286,
12962,
198,
198,
5569,
1366,
287,
37463,
5572,
37,
20,
5794,
422,
3696,
12336,
3912,
4600,
10379,
395,
81,
44646,
198,
198,
63,
82,
47671,
4600,
83,
63,
389,
2672,
7159,
475,
460,
307,
597,
5994,
18872,
230,
357,
10430,
7575,
11,
6416,
11,
10903,
1776,
198,
4906,
4600,
30,
7575,
22882,
63,
329,
517,
1321,
546,
703,
777,
389,
16173,
13,
198,
198,
91,
42,
54,
220,
220,
220,
220,
930,
5994,
220,
220,
220,
220,
220,
930,
15161,
220,
220,
930,
30563,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
930,
198,
91,
25,
6329,
220,
220,
930,
25,
6329,
220,
220,
220,
220,
220,
220,
930,
25,
6329,
220,
220,
220,
220,
220,
220,
930,
25,
6329,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
930,
198,
91,
4686,
220,
220,
220,
930,
10903,
220,
220,
220,
930,
366,
9,
1,
220,
220,
220,
220,
220,
220,
930,
4686,
3912,
11,
1296,
515,
299,
77,
13,
824,
82,
13,
297,
13,
535,
66,
220,
220,
220,
220,
220,
220,
220,
220,
220,
930,
198,
91,
220,
220,
220,
220,
220,
220,
930,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
930,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
930,
220,
357,
3262,
13,
38031,
13,
17946,
13,
11693,
1776,
376,
5258,
45,
4295,
27761,
685,
61,
16,
60,
220,
220,
220,
220,
930,
198,
91,
13845,
81,
220,
220,
930,
347,
970,
220,
220,
220,
220,
220,
930,
2081,
220,
220,
220,
220,
220,
930,
1100,
1336,
357,
29800,
29391,
19309,
8,
8875,
1217,
30,
930,
198,
91,
410,
220,
220,
220,
220,
930,
34142,
220,
220,
930,
657,
220,
220,
220,
220,
220,
220,
220,
220,
930,
15942,
16579,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
930,
198,
198,
58,
61,
16,
60,
317,
1808,
1317,
19203,
8348,
8,
318,
257,
4295,
9517,
329,
257,
2060,
2095,
26,
281,
18503,
1984,
19203,
9,
11537,
318,
257,
4295,
9517,
329,
6632,
393,
517,
3435,
198,
198,
6214,
635,
25,
4600,
7575,
22882,
47671,
4600,
79,
945,
316,
320,
413,
259,
47671,
4600,
961,
62,
7890,
63,
198,
37811,
1100,
62,
71,
7568,
20,
0,
198,
8818,
1100,
62,
71,
7568,
20,
0,
7,
50,
3712,
38,
34411,
6601,
11,
277,
8071,
3712,
10100,
11,
264,
3712,
7575,
22882,
11,
256,
3712,
7575,
22882,
26,
198,
220,
46996,
7904,
10100,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
796,
366,
292,
7568,
1600,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1366,
5794,
198,
220,
4686,
220,
7904,
38176,
90,
10100,
11,
797,
25636,
92,
220,
796,
366,
9,
1600,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
4686,
4731,
198,
220,
13845,
81,
7904,
33,
970,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
796,
2081,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1100,
1963,
396,
496,
2882,
30,
198,
220,
410,
220,
220,
7904,
46541,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
796,
509,
54,
13,
85,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
15942,
16579,
198,
220,
1267,
628,
220,
399,
796,
311,
13,
77,
198,
220,
1226,
395,
81,
796,
2352,
6978,
7,
69,
8071,
8,
198,
220,
530,
62,
7753,
796,
3338,
62,
4468,
576,
7,
10379,
395,
81,
8,
628,
220,
611,
46996,
6624,
366,
292,
7568,
1,
198,
220,
220,
220,
611,
530,
62,
7753,
198,
220,
220,
220,
220,
220,
24443,
0,
7,
50,
11,
1100,
62,
292,
7568,
7,
10379,
395,
81,
11,
4686,
11,
264,
11,
256,
11,
13845,
81,
11,
410,
4008,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
3696,
796,
43979,
7,
10379,
395,
81,
8,
198,
220,
220,
220,
220,
220,
329,
277,
3672,
287,
3696,
198,
220,
220,
220,
220,
220,
220,
220,
24443,
0,
7,
50,
11,
1100,
62,
292,
7568,
7,
69,
3672,
11,
4686,
11,
264,
11,
256,
11,
13845,
81,
11,
410,
4008,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
2073,
198,
220,
220,
220,
4049,
7203,
20035,
2393,
5794,
357,
39363,
6645,
40,
8,
2474,
8,
198,
220,
886,
628,
220,
649,
62,
3147,
62,
10677,
796,
1570,
7,
50,
13,
10677,
11,
399,
10,
16,
25,
50,
13,
77,
8,
198,
220,
6070,
0,
7,
3605,
62,
3147,
62,
10677,
11,
1226,
395,
81,
8,
198,
220,
3465,
0,
7,
50,
11,
399,
10,
16,
25,
50,
13,
77,
11,
4731,
7,
366,
1587,
99,
1343,
10459,
1587,
99,
1100,
62,
71,
7568,
20,
0,
7,
50,
11,
33172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
7879,
1600,
46996,
11,
366,
34607,
33172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
7879,
1600,
264,
11,
366,
34607,
33172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
7879,
1600,
256,
11,
366,
34607,
33172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
69,
16762,
17553,
1600,
46996,
11,
366,
34607,
33172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
312,
17553,
1600,
4686,
11,
366,
34607,
33172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
907,
81,
28,
1600,
13845,
81,
11,
33172,
33172,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
85,
28,
1600,
509,
54,
13,
85,
11,
366,
8,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
1441,
2147,
198,
437,
198,
198,
31,
15390,
4275,
15390,
1100,
62,
71,
7568,
20,
8133,
198,
8818,
1100,
62,
71,
7568,
20,
7,
10379,
395,
81,
3712,
10100,
11,
264,
3712,
7575,
22882,
11,
256,
3712,
7575,
22882,
26,
198,
220,
46996,
7904,
10100,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
796,
366,
292,
7568,
1600,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1366,
5794,
198,
220,
4686,
220,
7904,
38176,
90,
10100,
11,
797,
25636,
92,
220,
796,
366,
9,
1600,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
4686,
4731,
198,
220,
13845,
81,
7904,
33,
970,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
796,
2081,
11,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1100,
1963,
396,
496,
2882,
30,
198,
220,
410,
220,
220,
7904,
46541,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
796,
509,
54,
13,
85,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
15942,
16579,
198,
220,
1267,
628,
220,
311,
796,
1001,
271,
6601,
3419,
198,
220,
1100,
62,
71,
7568,
20,
0,
7,
50,
11,
1226,
395,
81,
11,
264,
11,
256,
11,
198,
220,
220,
220,
46996,
220,
220,
220,
220,
796,
46996,
11,
198,
220,
220,
220,
4686,
220,
220,
220,
220,
220,
796,
4686,
11,
198,
220,
220,
220,
13845,
81,
220,
220,
220,
220,
796,
13845,
81,
11,
198,
220,
220,
220,
410,
220,
220,
220,
220,
220,
220,
796,
410,
198,
220,
220,
220,
1267,
198,
220,
1441,
311,
198,
437,
198
] | 1.774585 | 1,566 |
"""
cilc_weights(cij, a, b)
This function returns weights (a vector of the number of frequency channels) of the constrained ILC (CILC) method.
*Reference*: Equation (20) of Remazeilles, Delabrouille, Cardoso, MNRAS, 410, 2481 (2011)
# Arguments
- `cij::Array{<:AbstractFloat,2}`: symmetric covariance matrix with the dimention of `(nν, nν)` where `nν` is the number of frequency bands.
- `a::Array{<:AbstractFloat,1}`: vector of the frequency response, for the component to be extracted. E.g., `a = [1,...,1]` for CMB.
- `b::Array{<:AbstractFloat,1}`: vector of the frequency response, for the component to be nulled.
"""
function cilc_weights(
cij::Array{T,2},
a::Array{T,1},
b::Array{T,1},
) where {T<:AbstractFloat}
if size(cij)[1] ≠ size(cij)[2]
throw(DimensionMismatch("covariance matrix must be a square matrix"))
elseif size(cij)[1] ≠ length(a) || size(cij)[1] ≠ length(b)
throw(DimensionMismatch("dimensions of the covariance matrix and the frequency response vector do not match"))
elseif a ≈ b
throw(ErrorException("vectors of the frequency response are too similar"))
else
M = Symmetric(cij)
end
x = M \ a # R^-1 a
y = M \ b # R^-1 b
w = (b'y * x - a'y * y) / (a'x * b'y - (a'y)^2) # ILC weights
end
"""
cilc_weights(cijℓ, a, b[, ℓid=3])
This function returns weights (a `nν`-by-`nℓ` matrix) of the constrained ILC (CILC) method.
Here, `nν` is the number of frequency channels and `nℓ` is the number of elements in the relevant domain, e.g., multipoles, band-power bins, pixels, etc.
*Reference*: Equation (20) of Remazeilles, Delabrouille, Cardoso, MNRAS, 410, 2481 (2011)
# Arguments
- `cijℓ::Array{<:AbstractFloat,3}`: symmetric covariance matrix with the dimention of `(nℓ, nν, nν)`, `(nν, nℓ, nν)` or `(nν, nν, nℓ)` (default).
- `a::Array{<:AbstractFloat,1}`: vector of the frequency response, for the component to be extracted. E.g., `a = [1,...,1]` for CMB.
- `b::Array{<:AbstractFloat,1}`: vector of the frequency response, for the component to be nulled.
# Optional Arguments
- `ℓid::Integer=3`: location of the index for the `nℓ` domain. `ℓid=1` if `cijℓ[nℓ,nν,nν]`, `ℓid=2` if `cijℓ[nν,nℓ,nν]`, and `ℓid=3` (the default value) if `cijℓ[nν,nν,nℓ]`.
"""
function cilc_weights(
cijℓ::Array{T,3},
a::Array{T,1},
b::Array{T,1},
ℓid::Integer = 3,
) where {T<:AbstractFloat}
if ℓid > 3 || ℓid < 1
throw(DomainError(ℓid, "ℓid must be 1, 2, or 3"))
end
if (ℓid == 3 && size(cijℓ)[1] ≠ size(cijℓ)[2]) ||
(ℓid == 2 && size(cijℓ)[1] ≠ size(cijℓ)[3]) ||
(ℓid == 1 && size(cijℓ)[2] ≠ size(cijℓ)[3])
throw(DimensionMismatch("covariance matrix must be a square matrix"))
end
nℓ = size(cijℓ)[ℓid]
nν = ifelse(ℓid == 3, size(cijℓ)[1], size(cijℓ)[3])
if length(a) ≠ nν || length(b) ≠ nν
throw(DimensionMismatch("dimensions of the covariance matrix and the frequency response vector do not match"))
elseif a ≈ b
throw(ErrorException("vectors of the frequency response are too similar"))
else
end
wℓ = zeros(nν, nℓ) # ILC weights
for iℓ = 1:nℓ
if ℓid == 3
M = Symmetric(cijℓ[:, :, iℓ])
elseif ℓid == 2
M = Symmetric(cijℓ[:, iℓ, :])
else
M = Symmetric(cijℓ[iℓ, :, :])
end
x = M \ a # R^-1 a
y = M \ b # R^-1 b
wℓ[:, iℓ] = (b'y * x - a'y * y) / (a'x * b'y - (a'y)^2)
end
return wℓ
end
| [
37811,
198,
220,
220,
220,
269,
346,
66,
62,
43775,
7,
979,
73,
11,
257,
11,
275,
8,
198,
198,
1212,
2163,
5860,
19590,
357,
64,
15879,
286,
262,
1271,
286,
8373,
9619,
8,
286,
262,
31070,
314,
5639,
357,
34,
4146,
34,
8,
2446,
13,
198,
198,
9,
26687,
47026,
7889,
341,
357,
1238,
8,
286,
3982,
6201,
21718,
11,
4216,
397,
472,
8270,
11,
5172,
28213,
11,
337,
24723,
1921,
11,
32921,
11,
1987,
6659,
357,
9804,
8,
198,
198,
2,
20559,
2886,
198,
12,
4600,
979,
73,
3712,
19182,
90,
27,
25,
23839,
43879,
11,
17,
92,
63,
25,
23606,
19482,
44829,
590,
17593,
351,
262,
5391,
1463,
286,
4600,
7,
77,
26180,
11,
299,
26180,
8,
63,
810,
4600,
77,
26180,
63,
318,
262,
1271,
286,
8373,
11760,
13,
198,
12,
4600,
64,
3712,
19182,
90,
27,
25,
23839,
43879,
11,
16,
92,
63,
25,
15879,
286,
262,
8373,
2882,
11,
329,
262,
7515,
284,
307,
21242,
13,
412,
13,
70,
1539,
4600,
64,
796,
685,
16,
42303,
11,
16,
60,
63,
329,
327,
10744,
13,
198,
12,
4600,
65,
3712,
19182,
90,
27,
25,
23839,
43879,
11,
16,
92,
63,
25,
15879,
286,
262,
8373,
2882,
11,
329,
262,
7515,
284,
307,
9242,
276,
13,
198,
37811,
198,
8818,
269,
346,
66,
62,
43775,
7,
198,
220,
220,
220,
269,
2926,
3712,
19182,
90,
51,
11,
17,
5512,
198,
220,
220,
220,
257,
3712,
19182,
90,
51,
11,
16,
5512,
198,
220,
220,
220,
275,
3712,
19182,
90,
51,
11,
16,
5512,
198,
8,
810,
1391,
51,
27,
25,
23839,
43879,
92,
198,
220,
220,
220,
611,
2546,
7,
979,
73,
38381,
16,
60,
15139,
254,
2546,
7,
979,
73,
38381,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
29271,
3004,
44,
1042,
963,
7203,
66,
709,
2743,
590,
17593,
1276,
307,
257,
6616,
17593,
48774,
198,
220,
220,
220,
2073,
361,
2546,
7,
979,
73,
38381,
16,
60,
15139,
254,
4129,
7,
64,
8,
8614,
2546,
7,
979,
73,
38381,
16,
60,
15139,
254,
4129,
7,
65,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
29271,
3004,
44,
1042,
963,
7203,
27740,
5736,
286,
262,
44829,
590,
17593,
290,
262,
8373,
2882,
15879,
466,
407,
2872,
48774,
198,
220,
220,
220,
2073,
361,
257,
15139,
230,
275,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
12331,
16922,
7203,
303,
5217,
286,
262,
8373,
2882,
389,
1165,
2092,
48774,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
337,
796,
1632,
3020,
19482,
7,
979,
73,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2124,
796,
337,
3467,
257,
1303,
371,
61,
12,
16,
257,
198,
220,
220,
220,
331,
796,
337,
3467,
275,
1303,
371,
61,
12,
16,
275,
198,
220,
220,
220,
266,
796,
357,
65,
6,
88,
1635,
2124,
532,
257,
6,
88,
1635,
331,
8,
1220,
357,
64,
6,
87,
1635,
275,
6,
88,
532,
357,
64,
6,
88,
8,
61,
17,
8,
1303,
314,
5639,
19590,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
269,
346,
66,
62,
43775,
7,
979,
73,
158,
226,
241,
11,
257,
11,
275,
58,
11,
2343,
226,
241,
312,
28,
18,
12962,
198,
198,
1212,
2163,
5860,
19590,
357,
64,
4600,
77,
26180,
63,
12,
1525,
12,
63,
77,
158,
226,
241,
63,
17593,
8,
286,
262,
31070,
314,
5639,
357,
34,
4146,
34,
8,
2446,
13,
198,
198,
4342,
11,
4600,
77,
26180,
63,
318,
262,
1271,
286,
8373,
9619,
290,
4600,
77,
158,
226,
241,
63,
318,
262,
1271,
286,
4847,
287,
262,
5981,
7386,
11,
304,
13,
70,
1539,
18540,
4316,
11,
4097,
12,
6477,
41701,
11,
17848,
11,
3503,
13,
198,
198,
9,
26687,
47026,
7889,
341,
357,
1238,
8,
286,
3982,
6201,
21718,
11,
4216,
397,
472,
8270,
11,
5172,
28213,
11,
337,
24723,
1921,
11,
32921,
11,
1987,
6659,
357,
9804,
8,
198,
198,
2,
20559,
2886,
198,
12,
4600,
979,
73,
158,
226,
241,
3712,
19182,
90,
27,
25,
23839,
43879,
11,
18,
92,
63,
25,
23606,
19482,
44829,
590,
17593,
351,
262,
5391,
1463,
286,
4600,
7,
77,
158,
226,
241,
11,
299,
26180,
11,
299,
26180,
8,
47671,
4600,
7,
77,
26180,
11,
299,
158,
226,
241,
11,
299,
26180,
8,
63,
393,
4600,
7,
77,
26180,
11,
299,
26180,
11,
299,
158,
226,
241,
8,
63,
357,
12286,
737,
198,
12,
4600,
64,
3712,
19182,
90,
27,
25,
23839,
43879,
11,
16,
92,
63,
25,
15879,
286,
262,
8373,
2882,
11,
329,
262,
7515,
284,
307,
21242,
13,
412,
13,
70,
1539,
4600,
64,
796,
685,
16,
42303,
11,
16,
60,
63,
329,
327,
10744,
13,
198,
12,
4600,
65,
3712,
19182,
90,
27,
25,
23839,
43879,
11,
16,
92,
63,
25,
15879,
286,
262,
8373,
2882,
11,
329,
262,
7515,
284,
307,
9242,
276,
13,
198,
198,
2,
32233,
20559,
2886,
198,
12,
4600,
158,
226,
241,
312,
3712,
46541,
28,
18,
63,
25,
4067,
286,
262,
6376,
329,
262,
4600,
77,
158,
226,
241,
63,
7386,
13,
4600,
158,
226,
241,
312,
28,
16,
63,
611,
4600,
979,
73,
158,
226,
241,
58,
77,
158,
226,
241,
11,
77,
26180,
11,
77,
26180,
60,
47671,
4600,
158,
226,
241,
312,
28,
17,
63,
611,
4600,
979,
73,
158,
226,
241,
58,
77,
26180,
11,
77,
158,
226,
241,
11,
77,
26180,
60,
47671,
290,
4600,
158,
226,
241,
312,
28,
18,
63,
357,
1169,
4277,
1988,
8,
611,
4600,
979,
73,
158,
226,
241,
58,
77,
26180,
11,
77,
26180,
11,
77,
158,
226,
241,
60,
44646,
198,
37811,
198,
8818,
269,
346,
66,
62,
43775,
7,
198,
220,
220,
220,
269,
2926,
158,
226,
241,
3712,
19182,
90,
51,
11,
18,
5512,
198,
220,
220,
220,
257,
3712,
19182,
90,
51,
11,
16,
5512,
198,
220,
220,
220,
275,
3712,
19182,
90,
51,
11,
16,
5512,
198,
220,
220,
220,
2343,
226,
241,
312,
3712,
46541,
796,
513,
11,
198,
8,
810,
1391,
51,
27,
25,
23839,
43879,
92,
198,
220,
220,
220,
611,
2343,
226,
241,
312,
1875,
513,
8614,
2343,
226,
241,
312,
1279,
352,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
43961,
12331,
7,
158,
226,
241,
312,
11,
366,
158,
226,
241,
312,
1276,
307,
352,
11,
362,
11,
393,
513,
48774,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
357,
158,
226,
241,
312,
6624,
513,
11405,
2546,
7,
979,
73,
158,
226,
241,
38381,
16,
60,
15139,
254,
2546,
7,
979,
73,
158,
226,
241,
38381,
17,
12962,
8614,
198,
220,
220,
220,
220,
220,
220,
357,
158,
226,
241,
312,
6624,
362,
11405,
2546,
7,
979,
73,
158,
226,
241,
38381,
16,
60,
15139,
254,
2546,
7,
979,
73,
158,
226,
241,
38381,
18,
12962,
8614,
198,
220,
220,
220,
220,
220,
220,
357,
158,
226,
241,
312,
6624,
352,
11405,
2546,
7,
979,
73,
158,
226,
241,
38381,
17,
60,
15139,
254,
2546,
7,
979,
73,
158,
226,
241,
38381,
18,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
29271,
3004,
44,
1042,
963,
7203,
66,
709,
2743,
590,
17593,
1276,
307,
257,
6616,
17593,
48774,
198,
220,
220,
220,
886,
198,
220,
220,
220,
299,
158,
226,
241,
796,
2546,
7,
979,
73,
158,
226,
241,
38381,
158,
226,
241,
312,
60,
198,
220,
220,
220,
299,
26180,
796,
611,
17772,
7,
158,
226,
241,
312,
6624,
513,
11,
2546,
7,
979,
73,
158,
226,
241,
38381,
16,
4357,
2546,
7,
979,
73,
158,
226,
241,
38381,
18,
12962,
198,
220,
220,
220,
611,
4129,
7,
64,
8,
15139,
254,
299,
26180,
8614,
4129,
7,
65,
8,
15139,
254,
299,
26180,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
29271,
3004,
44,
1042,
963,
7203,
27740,
5736,
286,
262,
44829,
590,
17593,
290,
262,
8373,
2882,
15879,
466,
407,
2872,
48774,
198,
220,
220,
220,
2073,
361,
257,
15139,
230,
275,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
12331,
16922,
7203,
303,
5217,
286,
262,
8373,
2882,
389,
1165,
2092,
48774,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
886,
198,
220,
220,
220,
266,
158,
226,
241,
796,
1976,
27498,
7,
77,
26180,
11,
299,
158,
226,
241,
8,
1303,
314,
5639,
19590,
198,
220,
220,
220,
329,
1312,
158,
226,
241,
796,
352,
25,
77,
158,
226,
241,
198,
220,
220,
220,
220,
220,
220,
220,
611,
2343,
226,
241,
312,
6624,
513,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
337,
796,
1632,
3020,
19482,
7,
979,
73,
158,
226,
241,
58,
45299,
1058,
11,
1312,
158,
226,
241,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
2343,
226,
241,
312,
6624,
362,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
337,
796,
1632,
3020,
19482,
7,
979,
73,
158,
226,
241,
58,
45299,
1312,
158,
226,
241,
11,
1058,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
337,
796,
1632,
3020,
19482,
7,
979,
73,
158,
226,
241,
58,
72,
158,
226,
241,
11,
1058,
11,
1058,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
796,
337,
3467,
257,
1303,
371,
61,
12,
16,
257,
198,
220,
220,
220,
220,
220,
220,
220,
331,
796,
337,
3467,
275,
1303,
371,
61,
12,
16,
275,
198,
220,
220,
220,
220,
220,
220,
220,
266,
158,
226,
241,
58,
45299,
1312,
158,
226,
241,
60,
796,
357,
65,
6,
88,
1635,
2124,
532,
257,
6,
88,
1635,
331,
8,
1220,
357,
64,
6,
87,
1635,
275,
6,
88,
532,
357,
64,
6,
88,
8,
61,
17,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
266,
158,
226,
241,
198,
437,
198
] | 2.100602 | 1,660 |
using POMDPModels
using Test
using POMDPTesting
let
problem = SimpleGridWorld()
policy = RandomPolicy(problem)
sim = HistoryRecorder(rng=MersenneTwister(1), max_steps=1000)
hist = simulate(sim, problem, policy, GWPos(1,1))
for (s, a) in zip(state_hist(hist), action_hist(hist))
td = transition(problem, s, a)
if td isa SparseCat
@test sum(td.probs) ≈ 1.0 atol=0.01
for p in td.probs
@test p >= 0.0
end
end
end
sv = convert_s(Array{Float64}, GWPos(1,1), problem)
@test sv == [1.0, 1.0]
sv = convert_s(Array{Float64}, GWPos(5,3), problem)
@test sv == [5.0, 3.0]
s = convert_s(GWPos, sv, problem)
@test s == GWPos(5, 3)
av = convert_a(Array{Float64}, :up, problem)
@test av == [1.0]
a = convert_a(Symbol, av, problem)
@test a == :up
@test has_consistent_transition_distributions(problem)
pol = FunctionPolicy(x->:up)
stp = first(stepthrough(problem, pol, "s,a", max_steps=1))
POMDPModelTools.render(problem, stp)
POMDPModelTools.render(problem, NamedTuple())
POMDPModelTools.render(problem, stp, color=s->reward(problem,s))
POMDPModelTools.render(problem, stp, color=s->rand())
POMDPModelTools.render(problem, stp, color=s->"yellow")
POMDPModelTools.render(problem, stp, color=s->reward(problem,s), colormin=-1.0, colormax=1.0)
ss = collect(states(problem))
isd = initialstate(problem)
for s in ss
if !isterminal(problem, s)
@test s in support(isd)
@test pdf(isd, s) > 0.0
end
end
end
let
@warn("NBInclude tests skipped")
# @nbinclude(joinpath(dirname(@__FILE__), "..", "notebooks", "GridWorld Visualization.ipynb"))
end
| [
3500,
350,
2662,
6322,
5841,
1424,
198,
3500,
6208,
198,
3500,
350,
2662,
6322,
44154,
198,
198,
1616,
198,
220,
220,
220,
1917,
796,
17427,
41339,
10603,
3419,
628,
220,
220,
220,
2450,
796,
14534,
36727,
7,
45573,
8,
628,
220,
220,
220,
985,
796,
7443,
6690,
2875,
7,
81,
782,
28,
44,
364,
29727,
5080,
1694,
7,
16,
828,
3509,
62,
20214,
28,
12825,
8,
628,
220,
220,
220,
1554,
796,
29308,
7,
14323,
11,
1917,
11,
2450,
11,
27164,
21604,
7,
16,
11,
16,
4008,
628,
220,
220,
220,
329,
357,
82,
11,
257,
8,
287,
19974,
7,
5219,
62,
10034,
7,
10034,
828,
2223,
62,
10034,
7,
10034,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
41560,
796,
6801,
7,
45573,
11,
264,
11,
257,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
41560,
318,
64,
1338,
17208,
21979,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2160,
7,
8671,
13,
1676,
1443,
8,
15139,
230,
352,
13,
15,
379,
349,
28,
15,
13,
486,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
279,
287,
41560,
13,
1676,
1443,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
279,
18189,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
38487,
796,
10385,
62,
82,
7,
19182,
90,
43879,
2414,
5512,
27164,
21604,
7,
16,
11,
16,
828,
1917,
8,
198,
220,
220,
220,
2488,
9288,
38487,
6624,
685,
16,
13,
15,
11,
352,
13,
15,
60,
198,
220,
220,
220,
38487,
796,
10385,
62,
82,
7,
19182,
90,
43879,
2414,
5512,
27164,
21604,
7,
20,
11,
18,
828,
1917,
8,
198,
220,
220,
220,
2488,
9288,
38487,
6624,
685,
20,
13,
15,
11,
513,
13,
15,
60,
198,
220,
220,
220,
264,
796,
10385,
62,
82,
7,
33191,
21604,
11,
38487,
11,
1917,
8,
198,
220,
220,
220,
2488,
9288,
264,
6624,
27164,
21604,
7,
20,
11,
513,
8,
628,
220,
220,
220,
1196,
796,
10385,
62,
64,
7,
19182,
90,
43879,
2414,
5512,
1058,
929,
11,
1917,
8,
198,
220,
220,
220,
2488,
9288,
1196,
6624,
685,
16,
13,
15,
60,
198,
220,
220,
220,
257,
796,
10385,
62,
64,
7,
13940,
23650,
11,
1196,
11,
1917,
8,
198,
220,
220,
220,
2488,
9288,
257,
6624,
1058,
929,
628,
220,
220,
220,
2488,
9288,
468,
62,
5936,
7609,
62,
7645,
653,
62,
17080,
2455,
507,
7,
45573,
8,
628,
220,
220,
220,
755,
796,
15553,
36727,
7,
87,
3784,
25,
929,
8,
198,
220,
220,
220,
336,
79,
796,
717,
7,
9662,
9579,
7,
45573,
11,
755,
11,
366,
82,
11,
64,
1600,
3509,
62,
20214,
28,
16,
4008,
198,
220,
220,
220,
350,
2662,
6322,
17633,
33637,
13,
13287,
7,
45573,
11,
336,
79,
8,
198,
220,
220,
220,
350,
2662,
6322,
17633,
33637,
13,
13287,
7,
45573,
11,
34441,
51,
29291,
28955,
198,
220,
220,
220,
350,
2662,
6322,
17633,
33637,
13,
13287,
7,
45573,
11,
336,
79,
11,
3124,
28,
82,
3784,
260,
904,
7,
45573,
11,
82,
4008,
198,
220,
220,
220,
350,
2662,
6322,
17633,
33637,
13,
13287,
7,
45573,
11,
336,
79,
11,
3124,
28,
82,
3784,
25192,
28955,
198,
220,
220,
220,
350,
2662,
6322,
17633,
33637,
13,
13287,
7,
45573,
11,
336,
79,
11,
3124,
28,
82,
3784,
1,
36022,
4943,
198,
220,
220,
220,
350,
2662,
6322,
17633,
33637,
13,
13287,
7,
45573,
11,
336,
79,
11,
3124,
28,
82,
3784,
260,
904,
7,
45573,
11,
82,
828,
951,
579,
259,
10779,
16,
13,
15,
11,
951,
579,
897,
28,
16,
13,
15,
8,
628,
220,
220,
220,
37786,
796,
2824,
7,
27219,
7,
45573,
4008,
198,
220,
220,
220,
318,
67,
796,
4238,
5219,
7,
45573,
8,
198,
220,
220,
220,
329,
264,
287,
37786,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5145,
1694,
1084,
282,
7,
45573,
11,
264,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
264,
287,
1104,
7,
9409,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
37124,
7,
9409,
11,
264,
8,
1875,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
1616,
198,
220,
220,
220,
2488,
40539,
7203,
32819,
818,
9152,
5254,
26684,
4943,
198,
220,
220,
220,
1303,
2488,
77,
8800,
9152,
7,
22179,
6978,
7,
15908,
3672,
7,
31,
834,
25664,
834,
828,
366,
492,
1600,
366,
11295,
12106,
1600,
366,
41339,
10603,
15612,
1634,
13,
541,
2047,
65,
48774,
198,
437,
198
] | 2.205736 | 802 |
# --------------------------------------------------------------------------
# ACE1.jl: Julia implementation of the Atomic Cluster Expansion
# Copyright (c) 2019 <NAME> <<EMAIL>>
# Licensed under ASL - see ASL.md for terms and conditions.
# --------------------------------------------------------------------------
@testset "RPIBasis" begin
#---
using ACE1
using Random, Printf, Test, LinearAlgebra, JuLIP, JuLIP.Testing
using JuLIP: evaluate, evaluate_d, evaluate_ed
using JuLIP.MLIPs: combine
#---
@info("Basic test of RPIBasis construction and evaluation")
maxdeg = 15
N = 3
r0 = 1.0
rcut = 3.0
trans = PolyTransform(1, r0)
Pr = transformed_jacobi(maxdeg, trans, rcut; pcut = 2)
D = SparsePSHDegree()
P1 = BasicPSH1pBasis(Pr; species = :X, D = D)
#---
pibasis = PIBasis(P1, N, D, maxdeg)
rpibasis = RPIBasis(P1, N, D, maxdeg)
#---
@info("Basis construction and evaluation checks")
@info("check single species")
Nat = 15
Rs, Zs, z0 = rand_nhd(Nat, Pr, :X)
B = evaluate(rpibasis, Rs, Zs, z0)
println(@test(length(rpibasis) == length(B)))
dB = evaluate_d(rpibasis, Rs, Zs, z0)
println(@test(size(dB) == (length(rpibasis), length(Rs))))
B_, dB_ = evaluate_ed(rpibasis, Rs, Zs, z0)
println(@test (B_ ≈ B) && (dB_ ≈ dB))
#---
@info("check multi-species")
maxdeg = 5
Pr = transformed_jacobi(maxdeg, trans, rcut; pcut = 2)
species = [:C, :O, :H]
P1 = ACE1.BasicPSH1pBasis(Pr; species = species, D = D)
basis = ACE1.RPIBasis(P1, N, D, maxdeg)
Rs, Zs, z0 = ACE1.rand_nhd(Nat, Pr, species)
B = evaluate(basis, Rs, Zs, z0)
println(@test(length(basis) == length(B)))
dB = evaluate_d(basis, Rs, Zs, z0)
println(@test(size(dB) == (length(basis), length(Rs))))
B_, dB_ = evaluate_ed(basis, Rs, Zs, z0)
println(@test (B_ ≈ B) && (dB_ ≈ dB))
#---
degrees = [ 12, 10, 8, 8, 8, 8 ]
@info("Check a few basis properties ")
# for species in (:X, :Si) # , [:C, :O, :H])
for species in (:X, :Si, [:C, :O, :H]), N = 1:length(degrees)
local Rs, Zs, z0, B, dB, basis, D, P1, Nat
Nat = 15
D = SparsePSHDegree()
P1 = ACE1.BasicPSH1pBasis(Pr; species = species)
basis = ACE1.RPIBasis(P1, N, D, degrees[N])
@info("species = $species; N = $N; deg = $(degrees[N]); len = $(length(basis))")
@info(" check (de-)serialization")
println(@test(all(JuLIP.Testing.test_fio(basis))))
@info(" isometry and permutation invariance")
for ntest = 1:30
Rs, Zs, z0 = ACE1.rand_nhd(Nat, Pr, species)
Rsp, Zsp = ACE1.rand_sym(Rs, Zs)
print_tf(@test(evaluate(basis, Rs, Zs, z0) ≈
evaluate(basis, Rsp, Zsp, z0)))
end
println()
@info(" check derivatives")
for ntest = 1:30
Rs, Zs, z0 = ACE1.rand_nhd(Nat, Pr, species)
B = evaluate(basis, Rs, Zs, z0)
dB = evaluate_d(basis, Rs, Zs, z0)
Us = [ rand(eltype(Rs)) .- 0.5 for _=1:length(Rs) ]
dB_dUs = transpose.(dB) * Us
errs = []
for p = 2:12
h = 0.1^p
B_h = evaluate(basis, Rs + h * Us, Zs, z0)
dB_h = (B_h - B) / h
# @show norm(dAA_h - dAA_dUs, Inf)
push!(errs, norm(dB_h - dB_dUs, Inf))
end
success = (/(extrema(errs)...) < 1e-3) || (minimum(errs) < 1e-10)
print_tf(@test success)
end
println()
@info(" check combine")
coeffs = randcoeffs(basis)
V = combine(basis, coeffs)
Vst = standardevaluator(V)
for ntest = 1:30
Rs, Zs, z0 = ACE1.rand_nhd(Nat, Pr, species)
v = evaluate(V, Rs, Zs, z0)
vst = evaluate(Vst, Rs, Zs, z0)
cdotB = dot(coeffs, evaluate(basis, Rs, Zs, z0))
print_tf(@test v ≈ cdotB ≈ vst)
end
println()
@info(" check graph evaluator")
basisst = standardevaluator(basis)
for ntest = 1:30
env = ACE1.rand_nhd(Nat, Pr, species)
print_tf(@test evaluate(basisst, env...) ≈ evaluate(basis, env...))
print_tf(@test evaluate_d(basisst, env...) ≈ evaluate_d(basis, env...))
end
println()
end
#---
end
| [
198,
2,
16529,
35937,
198,
2,
40488,
16,
13,
20362,
25,
22300,
7822,
286,
262,
28976,
38279,
25042,
198,
2,
15069,
357,
66,
8,
13130,
1279,
20608,
29,
9959,
27630,
4146,
4211,
198,
2,
49962,
739,
7054,
43,
532,
766,
7054,
43,
13,
9132,
329,
2846,
290,
3403,
13,
198,
2,
16529,
35937,
628,
198,
31,
9288,
2617,
366,
20031,
9865,
17765,
1,
220,
2221,
198,
198,
2,
6329,
628,
198,
3500,
40488,
16,
198,
3500,
14534,
11,
12578,
69,
11,
6208,
11,
44800,
2348,
29230,
11,
12585,
43,
4061,
11,
12585,
43,
4061,
13,
44154,
198,
3500,
12585,
43,
4061,
25,
13446,
11,
13446,
62,
67,
11,
13446,
62,
276,
198,
3500,
12585,
43,
4061,
13,
5805,
4061,
82,
25,
12082,
628,
198,
2,
6329,
198,
198,
31,
10951,
7203,
26416,
1332,
286,
25812,
9865,
17765,
5103,
290,
12660,
4943,
198,
9806,
13500,
796,
1315,
198,
45,
796,
513,
198,
81,
15,
796,
352,
13,
15,
198,
6015,
315,
796,
513,
13,
15,
198,
7645,
796,
12280,
41762,
7,
16,
11,
374,
15,
8,
198,
6836,
796,
14434,
62,
30482,
13411,
7,
9806,
13500,
11,
1007,
11,
374,
8968,
26,
279,
8968,
796,
362,
8,
198,
35,
796,
1338,
17208,
3705,
10227,
1533,
631,
3419,
198,
47,
16,
796,
14392,
3705,
39,
16,
79,
15522,
271,
7,
6836,
26,
4693,
796,
1058,
55,
11,
360,
796,
360,
8,
198,
198,
2,
6329,
198,
198,
79,
571,
17765,
796,
350,
9865,
17765,
7,
47,
16,
11,
399,
11,
360,
11,
3509,
13500,
8,
198,
81,
79,
571,
17765,
796,
25812,
9865,
17765,
7,
47,
16,
11,
399,
11,
360,
11,
3509,
13500,
8,
198,
198,
2,
6329,
198,
31,
10951,
7203,
15522,
271,
5103,
290,
12660,
8794,
4943,
198,
31,
10951,
7203,
9122,
2060,
4693,
4943,
198,
47849,
796,
1315,
198,
31273,
11,
1168,
82,
11,
1976,
15,
796,
43720,
62,
77,
31298,
7,
47849,
11,
1736,
11,
1058,
55,
8,
198,
33,
796,
13446,
7,
81,
79,
571,
17765,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
35235,
7,
31,
9288,
7,
13664,
7,
81,
79,
571,
17765,
8,
6624,
4129,
7,
33,
22305,
198,
36077,
796,
13446,
62,
67,
7,
81,
79,
571,
17765,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
35235,
7,
31,
9288,
7,
7857,
7,
36077,
8,
6624,
357,
13664,
7,
81,
79,
571,
17765,
828,
4129,
7,
31273,
35514,
198,
33,
62,
11,
30221,
62,
796,
13446,
62,
276,
7,
81,
79,
571,
17765,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
35235,
7,
31,
9288,
357,
33,
62,
15139,
230,
347,
8,
11405,
357,
36077,
62,
15139,
230,
30221,
4008,
198,
198,
2,
6329,
198,
31,
10951,
7203,
9122,
5021,
12,
35448,
4943,
198,
9806,
13500,
796,
642,
198,
6836,
796,
14434,
62,
30482,
13411,
7,
9806,
13500,
11,
1007,
11,
374,
8968,
26,
279,
8968,
796,
362,
8,
198,
35448,
796,
685,
25,
34,
11,
1058,
46,
11,
1058,
39,
60,
198,
47,
16,
796,
40488,
16,
13,
26416,
3705,
39,
16,
79,
15522,
271,
7,
6836,
26,
4693,
796,
4693,
11,
360,
796,
360,
8,
198,
12093,
271,
796,
40488,
16,
13,
20031,
9865,
17765,
7,
47,
16,
11,
399,
11,
360,
11,
3509,
13500,
8,
198,
31273,
11,
1168,
82,
11,
1976,
15,
796,
40488,
16,
13,
25192,
62,
77,
31298,
7,
47849,
11,
1736,
11,
4693,
8,
198,
33,
796,
13446,
7,
12093,
271,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
35235,
7,
31,
9288,
7,
13664,
7,
12093,
271,
8,
6624,
4129,
7,
33,
22305,
198,
36077,
796,
13446,
62,
67,
7,
12093,
271,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
35235,
7,
31,
9288,
7,
7857,
7,
36077,
8,
6624,
357,
13664,
7,
12093,
271,
828,
4129,
7,
31273,
35514,
198,
33,
62,
11,
30221,
62,
796,
13446,
62,
276,
7,
12093,
271,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
35235,
7,
31,
9288,
357,
33,
62,
15139,
230,
347,
8,
11405,
357,
36077,
62,
15139,
230,
30221,
4008,
198,
198,
2,
6329,
198,
198,
13500,
6037,
796,
685,
1105,
11,
838,
11,
807,
11,
807,
11,
807,
11,
807,
2361,
198,
198,
31,
10951,
7203,
9787,
257,
1178,
4308,
6608,
366,
8,
198,
2,
329,
4693,
287,
357,
25,
55,
11,
1058,
42801,
8,
1303,
837,
685,
25,
34,
11,
1058,
46,
11,
1058,
39,
12962,
198,
1640,
4693,
287,
357,
25,
55,
11,
1058,
42801,
11,
685,
25,
34,
11,
1058,
46,
11,
1058,
39,
46570,
399,
796,
352,
25,
13664,
7,
13500,
6037,
8,
198,
220,
220,
1957,
12820,
11,
1168,
82,
11,
1976,
15,
11,
347,
11,
30221,
11,
4308,
11,
360,
11,
350,
16,
11,
14393,
198,
220,
220,
14393,
796,
1315,
198,
220,
220,
360,
796,
1338,
17208,
3705,
10227,
1533,
631,
3419,
198,
220,
220,
350,
16,
796,
40488,
16,
13,
26416,
3705,
39,
16,
79,
15522,
271,
7,
6836,
26,
4693,
796,
4693,
8,
198,
220,
220,
4308,
796,
40488,
16,
13,
20031,
9865,
17765,
7,
47,
16,
11,
399,
11,
360,
11,
7370,
58,
45,
12962,
198,
220,
220,
2488,
10951,
7203,
35448,
796,
720,
35448,
26,
399,
796,
720,
45,
26,
3396,
796,
29568,
13500,
6037,
58,
45,
36563,
18896,
796,
29568,
13664,
7,
12093,
271,
4008,
4943,
198,
220,
220,
2488,
10951,
7203,
220,
220,
2198,
357,
2934,
25106,
46911,
1634,
4943,
198,
220,
220,
44872,
7,
31,
9288,
7,
439,
7,
33018,
43,
4061,
13,
44154,
13,
9288,
62,
69,
952,
7,
12093,
271,
35514,
198,
220,
220,
2488,
10951,
7203,
220,
220,
318,
15748,
290,
9943,
7094,
25275,
590,
4943,
198,
220,
220,
329,
299,
9288,
796,
352,
25,
1270,
198,
220,
220,
220,
220,
220,
12820,
11,
1168,
82,
11,
1976,
15,
796,
40488,
16,
13,
25192,
62,
77,
31298,
7,
47849,
11,
1736,
11,
4693,
8,
198,
220,
220,
220,
220,
220,
371,
2777,
11,
1168,
2777,
796,
40488,
16,
13,
25192,
62,
37047,
7,
31273,
11,
1168,
82,
8,
198,
220,
220,
220,
220,
220,
3601,
62,
27110,
7,
31,
9288,
7,
49786,
7,
12093,
271,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
15139,
230,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13446,
7,
12093,
271,
11,
371,
2777,
11,
1168,
2777,
11,
1976,
15,
22305,
198,
220,
220,
886,
198,
220,
220,
44872,
3419,
198,
220,
220,
2488,
10951,
7203,
220,
220,
2198,
28486,
4943,
198,
220,
220,
329,
299,
9288,
796,
352,
25,
1270,
198,
220,
220,
220,
220,
220,
12820,
11,
1168,
82,
11,
1976,
15,
796,
40488,
16,
13,
25192,
62,
77,
31298,
7,
47849,
11,
1736,
11,
4693,
8,
198,
220,
220,
220,
220,
220,
347,
796,
13446,
7,
12093,
271,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
220,
220,
220,
220,
220,
30221,
796,
13446,
62,
67,
7,
12093,
271,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
220,
220,
220,
220,
220,
4021,
796,
685,
43720,
7,
417,
4906,
7,
31273,
4008,
764,
12,
657,
13,
20,
329,
4808,
28,
16,
25,
13664,
7,
31273,
8,
2361,
198,
220,
220,
220,
220,
220,
30221,
62,
67,
5842,
796,
1007,
3455,
12195,
36077,
8,
1635,
4021,
198,
220,
220,
220,
220,
220,
1931,
3808,
796,
17635,
198,
220,
220,
220,
220,
220,
329,
279,
796,
362,
25,
1065,
198,
220,
220,
220,
220,
220,
220,
220,
220,
289,
796,
657,
13,
16,
61,
79,
198,
220,
220,
220,
220,
220,
220,
220,
220,
347,
62,
71,
796,
13446,
7,
12093,
271,
11,
12820,
1343,
289,
1635,
4021,
11,
1168,
82,
11,
1976,
15,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
30221,
62,
71,
796,
357,
33,
62,
71,
532,
347,
8,
1220,
289,
198,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2488,
12860,
2593,
7,
67,
3838,
62,
71,
532,
288,
3838,
62,
67,
5842,
11,
4806,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
263,
3808,
11,
2593,
7,
36077,
62,
71,
532,
30221,
62,
67,
5842,
11,
4806,
4008,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
1943,
796,
357,
29006,
2302,
260,
2611,
7,
263,
3808,
8,
23029,
1279,
352,
68,
12,
18,
8,
8614,
357,
39504,
7,
263,
3808,
8,
1279,
352,
68,
12,
940,
8,
198,
220,
220,
220,
220,
220,
3601,
62,
27110,
7,
31,
9288,
1943,
8,
198,
220,
220,
886,
198,
220,
220,
44872,
3419,
198,
220,
220,
2488,
10951,
7203,
220,
220,
2198,
12082,
4943,
198,
220,
220,
763,
14822,
82,
796,
43720,
1073,
14822,
82,
7,
12093,
271,
8,
198,
220,
220,
569,
796,
12082,
7,
12093,
271,
11,
763,
14822,
82,
8,
198,
220,
220,
569,
301,
796,
3210,
18206,
84,
1352,
7,
53,
8,
198,
220,
220,
329,
299,
9288,
796,
352,
25,
1270,
198,
220,
220,
220,
220,
220,
12820,
11,
1168,
82,
11,
1976,
15,
796,
40488,
16,
13,
25192,
62,
77,
31298,
7,
47849,
11,
1736,
11,
4693,
8,
198,
220,
220,
220,
220,
220,
410,
796,
13446,
7,
53,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
220,
220,
220,
220,
220,
410,
301,
796,
13446,
7,
53,
301,
11,
12820,
11,
1168,
82,
11,
1976,
15,
8,
198,
220,
220,
220,
220,
220,
22927,
313,
33,
796,
16605,
7,
1073,
14822,
82,
11,
13446,
7,
12093,
271,
11,
12820,
11,
1168,
82,
11,
1976,
15,
4008,
198,
220,
220,
220,
220,
220,
3601,
62,
27110,
7,
31,
9288,
410,
15139,
230,
22927,
313,
33,
15139,
230,
410,
301,
8,
198,
220,
220,
886,
198,
220,
220,
44872,
3419,
198,
220,
220,
2488,
10951,
7203,
220,
220,
2198,
4823,
5418,
84,
1352,
4943,
198,
220,
220,
4308,
301,
796,
3210,
18206,
84,
1352,
7,
12093,
271,
8,
198,
220,
220,
329,
299,
9288,
796,
352,
25,
1270,
198,
220,
220,
220,
220,
220,
17365,
796,
40488,
16,
13,
25192,
62,
77,
31298,
7,
47849,
11,
1736,
11,
4693,
8,
198,
220,
220,
220,
220,
220,
3601,
62,
27110,
7,
31,
9288,
13446,
7,
12093,
271,
301,
11,
17365,
23029,
15139,
230,
13446,
7,
12093,
271,
11,
17365,
986,
4008,
198,
220,
220,
220,
220,
220,
3601,
62,
27110,
7,
31,
9288,
13446,
62,
67,
7,
12093,
271,
301,
11,
17365,
23029,
15139,
230,
13446,
62,
67,
7,
12093,
271,
11,
17365,
986,
4008,
198,
220,
220,
886,
198,
220,
220,
44872,
3419,
198,
437,
628,
198,
2,
6329,
198,
198,
437,
198
] | 2.213356 | 1,767 |
@noinline function old_cfunction(f, r, a)
ccall(:jl_function_ptr, Ptr{Cvoid}, (Any, Any, Any), f, r, a)
end
## Common Interface Solve Functions
mutable struct CommonFunction{F,P}
func::F
p::P
neq::Cint
end
function commonfun(t::T1,y::T2,yp::T3,comfun::CommonFunction) where {T1,T2,T3}
y_ = unsafe_wrap(Array,y,comfun.neq)
ydot_ = unsafe_wrap(Array,yp,comfun.neq)
comfun.func(ydot_,y_,comfun.p,t)
return Int32(0)
end
function DiffEqBase.__solve(
prob::DiffEqBase.AbstractODEProblem{uType,tupType,isinplace},
alg::LSODAAlgorithm,
timeseries=[],ts=[],ks=[];
verbose=true,
abstol=1/10^6,reltol=1/10^3,
tstops=Float64[],
saveat=Float64[], maxiter=Int(1e5),
callback=nothing,
timeseries_errors=true,
save_everystep=isempty(saveat),
save_start = save_everystep || isempty(saveat) || typeof(saveat) <: Number ? true : prob.tspan[1] in saveat,
userdata=nothing,
alias_u0=false,
kwargs...) where {uType,tupType,isinplace}
tType = eltype(tupType)
if verbose
warned = !isempty(kwargs) && check_keywords(alg, kwargs, warnlist)
if !(typeof(prob.f) <: DiffEqBase.AbstractParameterizedFunction)
if DiffEqBase.has_tgrad(prob.f)
@warn("Explicit t-gradient given to this stiff solver is ignored.")
warned = true
end
if DiffEqBase.has_jac(prob.f)
@warn("Explicit Jacobian given to this stiff solver is ignored.")
warned = true
end
end
warned && warn_compat()
end
if prob.f.mass_matrix != I
error("This solver is not able to use mass matrices.")
end
if callback != nothing || :callback in keys(prob.kwargs)
error("LSODA is not compatible with callbacks.")
end
tspan = prob.tspan
t0 = tspan[1]
T = tspan[end]
if typeof(saveat) <: Number
if (tspan[1]:saveat:tspan[end])[end] == tspan[end]
saveat_vec = convert(Vector{tType},collect(tType,tspan[1]+saveat:saveat:tspan[end]))
else
saveat_vec = convert(Vector{tType},collect(tType,tspan[1]+saveat:saveat:(tspan[end]-saveat)))
end
else
saveat_vec = convert(Vector{tType},collect(saveat))
end
if !isempty(saveat_vec) && saveat_vec[end] == tspan[2]
pop!(saveat_vec)
end
if !isempty(saveat_vec) && saveat_vec[1] == tspan[1]
save_ts = sort(unique([saveat_vec;T]))
else
save_ts = sort(unique([t0;saveat_vec;T]))
end
if T < save_ts[end]
error("Final saving timepoint is past the solving timespan")
end
if t0 > save_ts[1]
error("First saving timepoint is before the solving timespan")
end
if !isempty(tstops)
error("tstops is not supported for this solver. Please use saveat instead")
end
if typeof(prob.u0) <: Number
u0 = [prob.u0]
else
if alias_u0
u0 = vec(prob.u0)
else
u0 = vec(deepcopy(prob.u0))
end
end
sizeu = size(prob.u0)
### Fix the more general function to Sundials allowed style
if !isinplace && (typeof(prob.u0)<:Vector{Float64} || typeof(prob.u0)<:Number)
f! = (du,u,p,t) -> (du[:] = prob.f(u,p,t); nothing)
elseif !isinplace && typeof(prob.u0)<:AbstractArray
f! = (du,u,p,t) -> (du[:] = vec(prob.f(reshape(u,sizeu),p,t)); nothing)
elseif typeof(prob.u0)<:Vector{Float64}
f! = prob.f
else # Then it's an in-place function on an abstract array
f! = (du,u,p,t) -> (prob.f(reshape(du,sizeu),reshape(u,sizeu),p,t); nothing)
end
ures = Vector{Float64}[]
push!(ures,u0)
utmp = copy(u0)
utmp2= copy(u0)
ttmp = [t0]
t = [t0]
t2 = [t0]
save_start ? ts = [t0] : ts = typeof(t0)[]
neq = Int32(length(u0))
comfun = CommonFunction(f!,prob.p,neq)
atol = ones(Float64,neq)
rtol = ones(Float64,neq)
if typeof(abstol) == Float64
atol *= abstol
else
atol = copy(abstol)
end
if typeof(reltol) == Float64
rtol *= reltol
else
rtol = copy(reltol)
end
GC.@preserve comfun atol rtol begin
global ___ref = comfun
opt = lsoda_opt_t(mxstep = maxiter)
opt.ixpr = 0
opt.rtol = pointer(rtol)
opt.atol = pointer(atol)
if save_everystep
itask_tmp = 2
else
itask_tmp = 1
end
opt.itask = itask_tmp
function get_cfunction(comfun::T) where T
@cfunction commonfun Cint (Cdouble, Ptr{Cdouble}, Ptr{Cdouble}, Ref{T})
end
fex_c = get_cfunction(comfun)
ctx = lsoda_context_t()
ctx.function_ = fex_c
ctx.neq = neq
ctx.state = 1
ctx.data = pointer_from_objref(comfun)
ch = ContextHandle(ctx)
lsoda_prepare(ctx,opt)
for k in 2:length(save_ts)
ttmp[1] = save_ts[k]
if t[1] < ttmp[1]
while t[1] < ttmp[1]
lsoda(ctx, utmp, t, ttmp[1])
if t[1] > ttmp[1] # overstepd, interpolate back
t2[1] = t[1] # save step values
copyto!(utmp2,utmp) # save step values
opt.itask = 1 # change to interpolating
lsoda(ctx, utmp, t, ttmp[1])
opt.itask = itask_tmp
push!(ures, copy(utmp))
push!(ts, t[1])
# don't overstep the last timestep
if k != length(save_ts) && save_ts[k+1] > t2[1]
push!(ures, copy(utmp2))
push!(ts, t2[1])
end
copyto!(utmp, utmp2)
t[1] = t2[1]
else
push!(ures, copy(utmp))
push!(ts,t[1])
end
end
else
t2[1] = t[1] # save step values
copyto!(utmp2, utmp) # save step values
opt.itask = 1 # change to interpolating
lsoda(ctx, utmp, t, ttmp[1])
opt.itask = itask_tmp
push!(ures, copy(utmp))
push!(ts, t[1])
if k != length(save_ts) && save_ts[k+1] > t2[1] # don't overstep the last timestep
push!(ures,copy(utmp2))
push!(ts,t2[1])
end
copyto!(utmp,utmp2)
t[1] = t2[1]
end
end
### Finishing Routine
timeseries = uType[]
save_start ? start_idx = 1 : start_idx = 2
if typeof(prob.u0)<:Number
for i=start_idx:length(ures)
push!(timeseries,ures[i][1])
end
else
for i=start_idx:length(ures)
push!(timeseries,reshape(ures[i],sizeu))
end
end
lsoda_free(ch)
global ___ref = nothing
end
DiffEqBase.build_solution(prob, alg, ts, timeseries,
timeseries_errors = timeseries_errors,
retcode = :Success)
end
| [
31,
3919,
45145,
2163,
1468,
62,
66,
8818,
7,
69,
11,
374,
11,
257,
8,
198,
220,
269,
13345,
7,
25,
20362,
62,
8818,
62,
20692,
11,
350,
2213,
90,
34,
19382,
5512,
357,
7149,
11,
4377,
11,
4377,
828,
277,
11,
374,
11,
257,
8,
198,
437,
198,
198,
2235,
8070,
26491,
4294,
303,
40480,
198,
198,
76,
18187,
2878,
8070,
22203,
90,
37,
11,
47,
92,
198,
220,
220,
220,
25439,
3712,
37,
198,
220,
220,
220,
279,
3712,
47,
198,
220,
220,
220,
497,
80,
3712,
34,
600,
198,
437,
198,
198,
8818,
2219,
12543,
7,
83,
3712,
51,
16,
11,
88,
3712,
51,
17,
11,
4464,
3712,
51,
18,
11,
785,
12543,
3712,
17227,
22203,
8,
810,
1391,
51,
16,
11,
51,
17,
11,
51,
18,
92,
198,
220,
331,
62,
796,
21596,
62,
37150,
7,
19182,
11,
88,
11,
785,
12543,
13,
710,
80,
8,
198,
220,
331,
26518,
62,
796,
21596,
62,
37150,
7,
19182,
11,
4464,
11,
785,
12543,
13,
710,
80,
8,
198,
220,
401,
12543,
13,
20786,
7,
5173,
313,
62,
11,
88,
62,
11,
785,
12543,
13,
79,
11,
83,
8,
198,
220,
1441,
2558,
2624,
7,
15,
8,
198,
437,
198,
198,
8818,
10631,
36,
80,
14881,
13,
834,
82,
6442,
7,
198,
220,
220,
220,
1861,
3712,
28813,
36,
80,
14881,
13,
23839,
16820,
40781,
90,
84,
6030,
11,
83,
929,
6030,
11,
45763,
5372,
5512,
198,
220,
220,
220,
435,
70,
3712,
6561,
3727,
32,
2348,
42289,
11,
198,
220,
220,
220,
1661,
10640,
41888,
4357,
912,
41888,
4357,
591,
41888,
11208,
628,
220,
220,
220,
15942,
577,
28,
7942,
11,
198,
220,
220,
220,
16552,
349,
28,
16,
14,
940,
61,
21,
11,
2411,
83,
349,
28,
16,
14,
940,
61,
18,
11,
198,
220,
220,
220,
256,
301,
2840,
28,
43879,
2414,
58,
4357,
198,
220,
220,
220,
3613,
265,
28,
43879,
2414,
58,
4357,
3509,
2676,
28,
5317,
7,
16,
68,
20,
828,
198,
220,
220,
220,
23838,
28,
22366,
11,
198,
220,
220,
220,
1661,
10640,
62,
48277,
28,
7942,
11,
198,
220,
220,
220,
3613,
62,
16833,
9662,
28,
271,
28920,
7,
21928,
265,
828,
198,
220,
220,
220,
3613,
62,
9688,
796,
3613,
62,
16833,
9662,
8614,
318,
28920,
7,
21928,
265,
8,
8614,
2099,
1659,
7,
21928,
265,
8,
1279,
25,
7913,
5633,
2081,
1058,
1861,
13,
912,
6839,
58,
16,
60,
287,
3613,
265,
11,
198,
220,
220,
220,
2836,
7890,
28,
22366,
11,
198,
220,
220,
220,
16144,
62,
84,
15,
28,
9562,
11,
198,
220,
220,
220,
479,
86,
22046,
23029,
810,
1391,
84,
6030,
11,
83,
929,
6030,
11,
45763,
5372,
92,
628,
220,
220,
220,
256,
6030,
796,
1288,
4906,
7,
83,
929,
6030,
8,
628,
220,
220,
220,
611,
15942,
577,
198,
220,
220,
220,
220,
220,
220,
220,
7728,
796,
5145,
271,
28920,
7,
46265,
22046,
8,
11405,
2198,
62,
2539,
10879,
7,
14016,
11,
479,
86,
22046,
11,
9828,
4868,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5145,
7,
4906,
1659,
7,
1676,
65,
13,
69,
8,
1279,
25,
10631,
36,
80,
14881,
13,
23839,
36301,
1143,
22203,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
10631,
36,
80,
14881,
13,
10134,
62,
83,
9744,
7,
1676,
65,
13,
69,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
40539,
7203,
18438,
3628,
256,
12,
49607,
1813,
284,
428,
15175,
1540,
332,
318,
9514,
19570,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7728,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
10631,
36,
80,
14881,
13,
10134,
62,
30482,
7,
1676,
65,
13,
69,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
40539,
7203,
18438,
3628,
12806,
666,
1813,
284,
428,
15175,
1540,
332,
318,
9514,
19570,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7728,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
7728,
11405,
9828,
62,
5589,
265,
3419,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
1861,
13,
69,
13,
22208,
62,
6759,
8609,
14512,
314,
198,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
1212,
1540,
332,
318,
407,
1498,
284,
779,
2347,
2603,
45977,
19570,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
23838,
14512,
2147,
8614,
1058,
47423,
287,
8251,
7,
1676,
65,
13,
46265,
22046,
8,
198,
220,
220,
220,
220,
220,
4049,
7203,
6561,
3727,
32,
318,
407,
11670,
351,
869,
10146,
19570,
198,
220,
220,
220,
886,
628,
220,
220,
220,
256,
12626,
796,
1861,
13,
912,
6839,
198,
220,
220,
220,
256,
15,
796,
256,
12626,
58,
16,
60,
198,
220,
220,
220,
309,
796,
256,
12626,
58,
437,
60,
628,
220,
220,
220,
611,
2099,
1659,
7,
21928,
265,
8,
1279,
25,
7913,
198,
220,
220,
220,
220,
220,
220,
220,
611,
357,
912,
6839,
58,
16,
5974,
21928,
265,
25,
912,
6839,
58,
437,
12962,
58,
437,
60,
6624,
256,
12626,
58,
437,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3613,
265,
62,
35138,
796,
10385,
7,
38469,
90,
83,
6030,
5512,
33327,
7,
83,
6030,
11,
912,
6839,
58,
16,
48688,
21928,
265,
25,
21928,
265,
25,
912,
6839,
58,
437,
60,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3613,
265,
62,
35138,
796,
10385,
7,
38469,
90,
83,
6030,
5512,
33327,
7,
83,
6030,
11,
912,
6839,
58,
16,
48688,
21928,
265,
25,
21928,
265,
37498,
912,
6839,
58,
437,
45297,
21928,
265,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
265,
62,
35138,
796,
220,
10385,
7,
38469,
90,
83,
6030,
5512,
33327,
7,
21928,
265,
4008,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
5145,
271,
28920,
7,
21928,
265,
62,
35138,
8,
11405,
3613,
265,
62,
35138,
58,
437,
60,
6624,
256,
12626,
58,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
1461,
0,
7,
21928,
265,
62,
35138,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
5145,
271,
28920,
7,
21928,
265,
62,
35138,
8,
11405,
3613,
265,
62,
35138,
58,
16,
60,
6624,
256,
12626,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
62,
912,
796,
3297,
7,
34642,
26933,
21928,
265,
62,
35138,
26,
51,
60,
4008,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
3613,
62,
912,
796,
3297,
7,
34642,
26933,
83,
15,
26,
21928,
265,
62,
35138,
26,
51,
60,
4008,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
309,
1279,
3613,
62,
912,
58,
437,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
19006,
8914,
640,
4122,
318,
1613,
262,
18120,
1661,
6839,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
256,
15,
1875,
3613,
62,
912,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
5962,
8914,
640,
4122,
318,
878,
262,
18120,
1661,
6839,
4943,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
5145,
271,
28920,
7,
83,
301,
2840,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
83,
301,
2840,
318,
407,
4855,
329,
428,
1540,
332,
13,
4222,
779,
3613,
265,
2427,
4943,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
2099,
1659,
7,
1676,
65,
13,
84,
15,
8,
1279,
25,
7913,
198,
220,
220,
220,
220,
220,
220,
220,
334,
15,
796,
685,
1676,
65,
13,
84,
15,
60,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
611,
16144,
62,
84,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
334,
15,
796,
43030,
7,
1676,
65,
13,
84,
15,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
334,
15,
796,
43030,
7,
22089,
30073,
7,
1676,
65,
13,
84,
15,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2546,
84,
796,
2546,
7,
1676,
65,
13,
84,
15,
8,
628,
220,
220,
220,
44386,
13268,
262,
517,
2276,
2163,
284,
3309,
8231,
3142,
3918,
198,
220,
220,
220,
611,
5145,
45763,
5372,
11405,
357,
4906,
1659,
7,
1676,
65,
13,
84,
15,
8,
27,
25,
38469,
90,
43879,
2414,
92,
8614,
2099,
1659,
7,
1676,
65,
13,
84,
15,
8,
27,
25,
15057,
8,
198,
220,
220,
220,
220,
220,
220,
220,
277,
0,
796,
357,
646,
11,
84,
11,
79,
11,
83,
8,
4613,
357,
646,
58,
47715,
796,
1861,
13,
69,
7,
84,
11,
79,
11,
83,
1776,
2147,
8,
198,
220,
220,
220,
2073,
361,
5145,
45763,
5372,
11405,
2099,
1659,
7,
1676,
65,
13,
84,
15,
8,
27,
25,
23839,
19182,
198,
220,
220,
220,
220,
220,
220,
220,
277,
0,
796,
357,
646,
11,
84,
11,
79,
11,
83,
8,
4613,
357,
646,
58,
47715,
796,
43030,
7,
1676,
65,
13,
69,
7,
3447,
1758,
7,
84,
11,
7857,
84,
828,
79,
11,
83,
18125,
2147,
8,
198,
220,
220,
220,
2073,
361,
2099,
1659,
7,
1676,
65,
13,
84,
15,
8,
27,
25,
38469,
90,
43879,
2414,
92,
198,
220,
220,
220,
220,
220,
220,
220,
277,
0,
796,
1861,
13,
69,
198,
220,
220,
220,
2073,
1303,
3244,
340,
338,
281,
287,
12,
5372,
2163,
319,
281,
12531,
7177,
198,
220,
220,
220,
220,
220,
220,
220,
277,
0,
796,
357,
646,
11,
84,
11,
79,
11,
83,
8,
4613,
357,
1676,
65,
13,
69,
7,
3447,
1758,
7,
646,
11,
7857,
84,
828,
3447,
1758,
7,
84,
11,
7857,
84,
828,
79,
11,
83,
1776,
2147,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
334,
411,
796,
20650,
90,
43879,
2414,
92,
21737,
198,
220,
220,
220,
4574,
0,
7,
942,
11,
84,
15,
8,
198,
220,
220,
220,
3384,
3149,
796,
4866,
7,
84,
15,
8,
198,
220,
220,
220,
3384,
3149,
17,
28,
4866,
7,
84,
15,
8,
198,
220,
220,
220,
256,
22065,
796,
685,
83,
15,
60,
198,
220,
220,
220,
256,
220,
220,
220,
796,
685,
83,
15,
60,
198,
220,
220,
220,
256,
17,
220,
220,
796,
685,
83,
15,
60,
198,
220,
220,
220,
3613,
62,
9688,
5633,
40379,
796,
685,
83,
15,
60,
1058,
40379,
796,
2099,
1659,
7,
83,
15,
8,
21737,
628,
220,
220,
220,
497,
80,
796,
2558,
2624,
7,
13664,
7,
84,
15,
4008,
198,
220,
220,
220,
401,
12543,
796,
8070,
22203,
7,
69,
28265,
1676,
65,
13,
79,
11,
710,
80,
8,
198,
220,
220,
220,
379,
349,
796,
3392,
7,
43879,
2414,
11,
710,
80,
8,
198,
220,
220,
220,
374,
83,
349,
796,
3392,
7,
43879,
2414,
11,
710,
80,
8,
628,
220,
220,
220,
611,
2099,
1659,
7,
397,
301,
349,
8,
6624,
48436,
2414,
198,
220,
220,
220,
220,
220,
220,
220,
379,
349,
1635,
28,
16552,
349,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
379,
349,
796,
4866,
7,
397,
301,
349,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
2099,
1659,
7,
2411,
83,
349,
8,
6624,
48436,
2414,
198,
220,
220,
220,
220,
220,
220,
220,
374,
83,
349,
1635,
28,
823,
83,
349,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
374,
83,
349,
796,
4866,
7,
2411,
83,
349,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
20145,
13,
31,
18302,
3760,
401,
12543,
379,
349,
374,
83,
349,
2221,
628,
220,
220,
220,
3298,
46444,
5420,
796,
401,
12543,
628,
220,
220,
220,
2172,
796,
43979,
11329,
62,
8738,
62,
83,
7,
36802,
9662,
796,
3509,
2676,
8,
198,
220,
220,
220,
2172,
13,
844,
1050,
796,
657,
198,
220,
220,
220,
2172,
13,
17034,
349,
796,
17562,
7,
17034,
349,
8,
198,
220,
220,
220,
2172,
13,
265,
349,
796,
17562,
7,
265,
349,
8,
198,
220,
220,
220,
611,
3613,
62,
16833,
9662,
198,
220,
220,
220,
220,
220,
220,
220,
340,
2093,
62,
22065,
796,
362,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
340,
2093,
62,
22065,
796,
352,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2172,
13,
270,
2093,
796,
340,
2093,
62,
22065,
628,
220,
220,
220,
2163,
651,
62,
66,
8818,
7,
785,
12543,
3712,
51,
8,
810,
309,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
66,
8818,
2219,
12543,
327,
600,
357,
34,
23352,
11,
350,
2213,
90,
34,
23352,
5512,
350,
2213,
90,
34,
23352,
5512,
6524,
90,
51,
30072,
198,
220,
220,
220,
886,
628,
220,
220,
220,
730,
87,
62,
66,
796,
651,
62,
66,
8818,
7,
785,
12543,
8,
628,
220,
220,
220,
269,
17602,
796,
43979,
11329,
62,
22866,
62,
83,
3419,
198,
220,
220,
220,
269,
17602,
13,
8818,
62,
796,
730,
87,
62,
66,
198,
220,
220,
220,
269,
17602,
13,
710,
80,
796,
497,
80,
198,
220,
220,
220,
269,
17602,
13,
5219,
796,
352,
198,
220,
220,
220,
269,
17602,
13,
7890,
796,
17562,
62,
6738,
62,
26801,
5420,
7,
785,
12543,
8,
628,
220,
220,
220,
442,
796,
30532,
37508,
7,
49464,
8,
628,
220,
220,
220,
43979,
11329,
62,
46012,
533,
7,
49464,
11,
8738,
8,
628,
220,
220,
220,
329,
479,
287,
362,
25,
13664,
7,
21928,
62,
912,
8,
198,
220,
220,
220,
220,
220,
220,
220,
256,
22065,
58,
16,
60,
796,
3613,
62,
912,
58,
74,
60,
198,
220,
220,
220,
220,
220,
220,
220,
611,
256,
58,
16,
60,
1279,
256,
22065,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
981,
256,
58,
16,
60,
1279,
256,
22065,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
43979,
11329,
7,
49464,
11,
3384,
3149,
11,
256,
11,
256,
22065,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
256,
58,
16,
60,
1875,
256,
22065,
58,
16,
60,
1303,
625,
9662,
67,
11,
39555,
378,
736,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
256,
17,
58,
16,
60,
796,
256,
58,
16,
60,
1303,
3613,
2239,
3815,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4866,
1462,
0,
7,
315,
3149,
17,
11,
315,
3149,
8,
1303,
3613,
2239,
3815,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2172,
13,
270,
2093,
796,
352,
1303,
1487,
284,
39555,
803,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
43979,
11329,
7,
49464,
11,
3384,
3149,
11,
256,
11,
256,
22065,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2172,
13,
270,
2093,
796,
340,
2093,
62,
22065,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
942,
11,
4866,
7,
315,
3149,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
912,
11,
256,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
836,
470,
625,
9662,
262,
938,
4628,
395,
538,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
479,
14512,
4129,
7,
21928,
62,
912,
8,
11405,
3613,
62,
912,
58,
74,
10,
16,
60,
1875,
256,
17,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
942,
11,
4866,
7,
315,
3149,
17,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
912,
11,
256,
17,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4866,
1462,
0,
7,
315,
3149,
11,
3384,
3149,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
256,
58,
16,
60,
796,
256,
17,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
942,
11,
4866,
7,
315,
3149,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
912,
11,
83,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
256,
17,
58,
16,
60,
796,
256,
58,
16,
60,
1303,
3613,
2239,
3815,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4866,
1462,
0,
7,
315,
3149,
17,
11,
3384,
3149,
8,
1303,
3613,
2239,
3815,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2172,
13,
270,
2093,
796,
352,
1303,
1487,
284,
39555,
803,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
43979,
11329,
7,
49464,
11,
3384,
3149,
11,
256,
11,
256,
22065,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2172,
13,
270,
2093,
796,
340,
2093,
62,
22065,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
942,
11,
4866,
7,
315,
3149,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
912,
11,
256,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
479,
14512,
4129,
7,
21928,
62,
912,
8,
11405,
3613,
62,
912,
58,
74,
10,
16,
60,
1875,
256,
17,
58,
16,
60,
1303,
836,
470,
625,
9662,
262,
938,
4628,
395,
538,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
942,
11,
30073,
7,
315,
3149,
17,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
912,
11,
83,
17,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4866,
1462,
0,
7,
315,
3149,
11,
315,
3149,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
256,
58,
16,
60,
796,
256,
17,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
44386,
4463,
3929,
371,
28399,
628,
220,
220,
220,
1661,
10640,
796,
334,
6030,
21737,
198,
220,
220,
220,
3613,
62,
9688,
5633,
923,
62,
312,
87,
796,
352,
1058,
923,
62,
312,
87,
796,
362,
198,
220,
220,
220,
611,
2099,
1659,
7,
1676,
65,
13,
84,
15,
8,
27,
25,
15057,
198,
220,
220,
220,
220,
220,
220,
220,
329,
1312,
28,
9688,
62,
312,
87,
25,
13664,
7,
942,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
22355,
10640,
11,
942,
58,
72,
7131,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
329,
1312,
28,
9688,
62,
312,
87,
25,
13664,
7,
942,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
22355,
10640,
11,
3447,
1758,
7,
942,
58,
72,
4357,
7857,
84,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
43979,
11329,
62,
5787,
7,
354,
8,
198,
220,
220,
220,
3298,
46444,
5420,
796,
2147,
198,
220,
220,
220,
886,
628,
198,
220,
220,
220,
10631,
36,
80,
14881,
13,
11249,
62,
82,
2122,
7,
1676,
65,
11,
435,
70,
11,
40379,
11,
1661,
10640,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1661,
10640,
62,
48277,
796,
1661,
10640,
62,
48277,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1005,
8189,
796,
1058,
33244,
8,
198,
437,
198
] | 1.897702 | 3,656 |
__precompile__()
module TestOriginal
using OpenEphysLoader
using Main.TestUtilities
using Test, Dates
export write_fheader_fun,
verify_header
### Helper functions ###
function write_bad_fheader(badtype::Symbol, nbytes::Integer = 1024)
local outfun
if badtype == :version
outfun = write_fheader_fun(nbytes, "header_wrongversion.txt")
elseif badtype == :format
outfun = write_fheader_fun(nbytes, "header_wrongformat.txt")
elseif badtype == :noise
baddata = rand(UInt8, nbytes)
outfun = io::IOStream -> write(io, baddata)
else
error("badtype unrecognized")
end
return outfun
end
function write_fheader_fun(
nbytes::Integer = 1024,
headerfile::String = "header.txt"
)
local head
headerpath = joinpath(dirname(@__FILE__), "data", headerfile)
@assert isfile(headerpath) "Could not load header file"
open(headerpath, "r") do readio
@assert stat(readio).size >= nbytes "Header not long enough"
head = read(readio, String)
end
trunchead = head[1:nbytes]
return io::IOStream -> write(io, trunchead)
end
function verify_header(header::OriginalHeader)
@test header.format == "Open Ephys Data Format"
@test header.version == v"0.4"
@test header.headerbytes == 1024
@test header.description == "each record contains one 64-bit timestamp, one 16-bit sample count (N), 1 uint16 recordingNumber, N 16-bit samples, and one 10-byte record marker (0 1 2 3 4 5 6 7 8 255)"
@test header.created == DateTime("21-Jul-2015 145012", Dates.DateFormat("d-u-y HHMMSS"))
@test header.channel == "CH30"
@test header.channeltype == "Continuous"
@test header.samplerate == 30000
@test header.blocklength == 1024
@test header.buffersize == 1024
@test isapprox(header.bitvolts, 0.195)
end
### Tests ###
@testset "OriginalHeader" begin
# OriginalHeader constructor
filecontext(write_fheader_fun()) do io
header = OriginalHeader(io)
verify_header(header)
@test (show(devnull, header); true) # test that it does not error
@test (OpenEphysLoader.showcompact(devnull, header); true)
end
@test (showerror(devnull, CorruptedException("test")); true)
# truncated header
filecontext(write_fheader_fun(512)) do io
@test_throws CorruptedException OriginalHeader(io)
end
# Header with bad content
filecontext(write_bad_fheader(:noise)) do io
@test_throws CorruptedException OriginalHeader(io)
end
filecontext(write_bad_fheader(:version)) do io
@test_throws CorruptedException OriginalHeader(io)
end
filecontext(write_bad_fheader(:format)) do io
@test_throws CorruptedException OriginalHeader(io)
end
end
end
| [
834,
3866,
5589,
576,
834,
3419,
198,
21412,
6208,
20556,
198,
3500,
4946,
36,
34411,
17401,
198,
3500,
8774,
13,
14402,
18274,
2410,
198,
198,
3500,
6208,
11,
44712,
198,
198,
39344,
3551,
62,
69,
25677,
62,
12543,
11,
198,
220,
220,
220,
11767,
62,
25677,
198,
198,
21017,
5053,
525,
5499,
44386,
198,
8818,
3551,
62,
14774,
62,
69,
25677,
7,
14774,
4906,
3712,
13940,
23650,
11,
299,
33661,
3712,
46541,
796,
28119,
8,
198,
220,
220,
220,
1957,
503,
12543,
198,
220,
220,
220,
611,
2089,
4906,
6624,
1058,
9641,
198,
220,
220,
220,
220,
220,
220,
220,
503,
12543,
796,
3551,
62,
69,
25677,
62,
12543,
7,
77,
33661,
11,
366,
25677,
62,
36460,
9641,
13,
14116,
4943,
198,
220,
220,
220,
2073,
361,
2089,
4906,
6624,
1058,
18982,
198,
220,
220,
220,
220,
220,
220,
220,
503,
12543,
796,
3551,
62,
69,
25677,
62,
12543,
7,
77,
33661,
11,
366,
25677,
62,
36460,
18982,
13,
14116,
4943,
198,
220,
220,
220,
2073,
361,
2089,
4906,
6624,
1058,
3919,
786,
198,
220,
220,
220,
220,
220,
220,
220,
2089,
7890,
796,
43720,
7,
52,
5317,
23,
11,
299,
33661,
8,
198,
220,
220,
220,
220,
220,
220,
220,
503,
12543,
796,
33245,
3712,
9399,
12124,
4613,
3551,
7,
952,
11,
2089,
7890,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
14774,
4906,
43483,
1143,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
503,
12543,
198,
437,
198,
198,
8818,
3551,
62,
69,
25677,
62,
12543,
7,
198,
220,
220,
220,
299,
33661,
3712,
46541,
796,
28119,
11,
198,
220,
220,
220,
13639,
7753,
3712,
10100,
796,
366,
25677,
13,
14116,
1,
198,
8,
198,
220,
220,
220,
1957,
1182,
198,
220,
220,
220,
13639,
6978,
796,
4654,
6978,
7,
15908,
3672,
7,
31,
834,
25664,
834,
828,
366,
7890,
1600,
13639,
7753,
8,
198,
220,
220,
220,
2488,
30493,
318,
7753,
7,
25677,
6978,
8,
366,
23722,
407,
3440,
13639,
2393,
1,
198,
220,
220,
220,
1280,
7,
25677,
6978,
11,
366,
81,
4943,
466,
1100,
952,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
30493,
1185,
7,
961,
952,
737,
7857,
18189,
299,
33661,
366,
39681,
407,
890,
1576,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1182,
796,
1100,
7,
961,
952,
11,
10903,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
40122,
2256,
796,
1182,
58,
16,
25,
77,
33661,
60,
198,
220,
220,
220,
1441,
33245,
3712,
9399,
12124,
4613,
3551,
7,
952,
11,
40122,
2256,
8,
198,
437,
198,
198,
8818,
11767,
62,
25677,
7,
25677,
3712,
20556,
39681,
8,
198,
220,
220,
220,
2488,
9288,
13639,
13,
18982,
6624,
366,
11505,
412,
34411,
6060,
18980,
1,
198,
220,
220,
220,
2488,
9288,
13639,
13,
9641,
6624,
410,
1,
15,
13,
19,
1,
198,
220,
220,
220,
2488,
9288,
13639,
13,
25677,
33661,
6624,
28119,
198,
220,
220,
220,
2488,
9288,
13639,
13,
11213,
6624,
366,
27379,
1700,
4909,
530,
5598,
12,
2545,
41033,
11,
530,
1467,
12,
2545,
6291,
954,
357,
45,
828,
352,
20398,
1433,
8296,
15057,
11,
399,
1467,
12,
2545,
8405,
11,
290,
530,
838,
12,
26327,
1700,
18364,
357,
15,
352,
362,
513,
604,
642,
718,
767,
807,
14280,
16725,
198,
220,
220,
220,
2488,
9288,
13639,
13,
25598,
6624,
7536,
7575,
7203,
2481,
12,
16980,
12,
4626,
20299,
30206,
1600,
44712,
13,
10430,
26227,
7203,
67,
12,
84,
12,
88,
47138,
12038,
5432,
48774,
198,
220,
220,
220,
2488,
9288,
13639,
13,
17620,
6624,
366,
3398,
1270,
1,
198,
220,
220,
220,
2488,
9288,
13639,
13,
17620,
4906,
6624,
366,
17875,
5623,
1,
198,
220,
220,
220,
2488,
9288,
13639,
13,
37687,
20053,
378,
6624,
513,
2388,
198,
220,
220,
220,
2488,
9288,
13639,
13,
9967,
13664,
6624,
28119,
198,
220,
220,
220,
2488,
9288,
13639,
13,
36873,
364,
1096,
6624,
28119,
198,
220,
220,
220,
2488,
9288,
318,
1324,
13907,
7,
25677,
13,
2545,
10396,
912,
11,
657,
13,
22186,
8,
198,
437,
198,
198,
21017,
30307,
44386,
198,
31,
9288,
2617,
366,
20556,
39681,
1,
2221,
198,
220,
220,
220,
1303,
13745,
39681,
23772,
198,
220,
220,
220,
2393,
22866,
7,
13564,
62,
69,
25677,
62,
12543,
28955,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
13639,
796,
13745,
39681,
7,
952,
8,
198,
220,
220,
220,
220,
220,
220,
220,
11767,
62,
25677,
7,
25677,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
357,
12860,
7,
7959,
8423,
11,
13639,
1776,
2081,
8,
1303,
1332,
326,
340,
857,
407,
4049,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
357,
11505,
36,
34411,
17401,
13,
12860,
5589,
529,
7,
7959,
8423,
11,
13639,
1776,
2081,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
357,
1477,
789,
1472,
7,
7959,
8423,
11,
2744,
31590,
16922,
7203,
9288,
4943,
1776,
2081,
8,
628,
220,
220,
220,
1303,
40122,
515,
13639,
198,
220,
220,
220,
2393,
22866,
7,
13564,
62,
69,
25677,
62,
12543,
7,
25836,
4008,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
2744,
31590,
16922,
13745,
39681,
7,
952,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1303,
48900,
351,
2089,
2695,
198,
220,
220,
220,
2393,
22866,
7,
13564,
62,
14774,
62,
69,
25677,
7,
25,
3919,
786,
4008,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
2744,
31590,
16922,
13745,
39681,
7,
952,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2393,
22866,
7,
13564,
62,
14774,
62,
69,
25677,
7,
25,
9641,
4008,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
2744,
31590,
16922,
13745,
39681,
7,
952,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2393,
22866,
7,
13564,
62,
14774,
62,
69,
25677,
7,
25,
18982,
4008,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
2744,
31590,
16922,
13745,
39681,
7,
952,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
437,
198
] | 2.693659 | 1,025 |
<reponame>jondeuce/TOMLConfig
using Test
using TOMLConfig
using Dates, Random
struct NoException <: Exception end
macro test_nothrow(ex)
esc(:(@test_throws NoException ($(ex); throw(NoException()))))
end
function check_keys(toml::Dict{String}, has, doesnt)
for key in has
@test haskey(toml, key)
end
for key in doesnt
@test !haskey(toml, key)
end
end
function typed_isequal(toml1::Dict{String}, toml2::Dict{String})
@test toml1 == toml2
for k in keys(toml1)
v1, v2 = toml1[k], toml2[k]
if v1 isa AbstractDict && v2 isa AbstractDict
@test typeof(v1) == typeof(v2)
typed_isequal(v1, v2)
else
@test typeof(v1) == typeof(v2)
end
end
end
@testset "basic parsing" begin
template = TOML.parse(
"""
a = 0
b = 0.0
[sec1]
c = [1, 2]
[sec1.sub1]
d = [1.0, 2.0]
e = true
[sec1.sub2]
f = 2010-05-17
g = 2013-01-01T00:00:00
h = 01:00:00
""")
function check_parsed_types(toml::Dict{String})
@test typeof(toml["a"]) == Int
@test typeof(toml["b"]) == Float64
@test typeof(toml["sec1"]["c"]) == Vector{Int}
@test typeof(toml["sec1"]["sub1"]["d"]) == Vector{Float64}
@test typeof(toml["sec1"]["sub1"]["e"]) == Bool
@test typeof(toml["sec1"]["sub2"]["f"]) == Date
@test typeof(toml["sec1"]["sub2"]["g"]) == DateTime
@test typeof(toml["sec1"]["sub2"]["h"]) == Time
end
@testset "no args passed" begin
parsed_args = parse_args(String[], Config(deepcopy(template)); as_dict = true)
expected_parsed = deepcopy(template)
check_parsed_types(parsed_args)
check_parsed_types(expected_parsed)
typed_isequal(parsed_args, expected_parsed)
end
@testset "args passed" begin
args_list = [
"--a", "1",
"--sec1.c", "3", "4", "5",
"--sec1.sub1.d", "5.5",
"--sec1.sub2.f", "2021-06-01",
"--sec1.sub2.g", "2021-06-01T12:34:56",
"--sec1.sub2.h", "01:23:45",
]
parsed_args = parse_args(args_list, Config(deepcopy(template)); as_dict = true)
expected_parsed = deepcopy(template)
expected_parsed["a"] = 1
expected_parsed["sec1"]["c"] = [3,4,5]
expected_parsed["sec1"]["sub1"]["d"] = [5.5]
expected_parsed["sec1"]["sub2"]["f"] = Date("2021-06-01")
expected_parsed["sec1"]["sub2"]["g"] = DateTime("2021-06-01T12:34:56")
expected_parsed["sec1"]["sub2"]["h"] = Time("01:23:45")
check_parsed_types(parsed_args)
check_parsed_types(expected_parsed)
typed_isequal(parsed_args, expected_parsed)
end
@testset "mistyped args" begin
for args_list in [
["--a", "1.5"],
["--b", "e"],
["--sec1.c", "3.5", "4"],
["--sec1.sub1.d", "f", "g", "h"],
["--sec1.sub2.f", "01:00:00"],
["--sec1.sub2.g", "01:00:00"],
["--sec1.sub2.h", "2013-01-01"],
]
settings = ArgParseSettings(exc_handler = ArgParse.debug_handler)
@test_throws ArgParseError parse_args(args_list, settings, Config(deepcopy(template)))
end
end
end
@testset "nested field inheritance" begin
template = TOML.parse(
"""
a = 0
b = 0.0
c = "c"
[sec1]
_INHERIT_ = "_PARENT_"
a = 1
[sec1.sub1]
_INHERIT_ = "_PARENT_"
c = "d"
[sec1.sub2]
_INHERIT_ = "_PARENT_"
b = "_PARENT_"
c = "d"
""")
function check_parsed_keys(toml::Dict{String})
check_keys(toml, ["a", "b", "c"], ["_INHERIT_"])
check_keys(toml["sec1"], ["a", "b", "c"], ["_INHERIT_"])
check_keys(toml["sec1"]["sub1"], ["a", "c"], ["_INHERIT_", "b"])
check_keys(toml["sec1"]["sub2"], ["a", "b", "c"], ["_INHERIT_"])
end
@testset "no args passed" begin
parsed_args = parse_args(String[], Config(deepcopy(template)); as_dict = true)
expected_parsed = TOML.parse(
"""
a = 0
b = 0.0
c = "c"
[sec1]
a = 1
b = 0.0
c = "c"
[sec1.sub1]
a = 1
c = "d"
[sec1.sub2]
a = 1
b = 0.0
c = "d"
""")
check_parsed_keys(parsed_args)
typed_isequal(parsed_args, expected_parsed)
end
@testset "args passed" begin
args_list = ["--b=1.0", "--sec1.a=2", "--sec1.sub2.c=e"]
parsed_args = parse_args(args_list, Config(deepcopy(template)); as_dict = true)
expected_parsed = TOML.parse(
"""
a = 0
b = 1.0
c = "c"
[sec1]
a = 2
b = 1.0
c = "c"
[sec1.sub1]
a = 2
c = "d"
[sec1.sub2]
a = 2
b = 1.0
c = "e"
""")
check_parsed_keys(parsed_args)
typed_isequal(parsed_args, expected_parsed)
end
end
@testset "customizing arg table" begin
template = TOML.parse(
"""
a = [0]
b = 0.0
c = "c"
[sec1]
_INHERIT_ = "_PARENT_"
a = [1]
[sec1.sub1]
_INHERIT_ = "_PARENT_"
c = "d"
[sec1.sub2]
_INHERIT_ = "_PARENT_"
b = "_PARENT_"
c = "d"
""")
function randomly_insert_arg_dicts!(toml)
seed = 0
for node in TOMLConfig.StatelessBFS(Config(toml))
for (k,v) in TOMLConfig.contents(node)
k == TOMLConfig.inherit_all_key() && continue # can't replace _INHERIT_ with arg dict
!TOMLConfig.is_arg(v) && continue # only replace args, not child dicts
rand(MersenneTwister(seed += 1)) > 0.5 && continue # flip coin
TOMLConfig.contents(node)[k] = !TOMLConfig.is_dict_arg(v) ?
Dict{String, Any}(TOMLConfig.arg_key() => TOMLConfig.arg_value(v)) :
TOMLConfig.arg_value(v)
end
end
return toml
end
@testset "arg dict equivalence" begin
for args_list in [
String[],
["--a", "1", "2", "--c", "cat"],
["--b", "2.0", "--sec1.b", "3.0", "--sec1.sub1.a", "5"],
]
template′ = randomly_insert_arg_dicts!(deepcopy(template))
parsed_args = parse_args(args_list, Config(deepcopy(template)); as_dict = true)
parsed_args′ = parse_args(args_list, Config(deepcopy(template′)); as_dict = true)
typed_isequal(parsed_args, parsed_args′)
end
end
template = TOML.parse(
"""
[a]
_ARG_ = "_REQUIRED_"
nargs = 2
arg_type = "Int"
required = true
help = "help string"
[b]
_ARG_ = [1.0, 2.0]
nargs = "+"
help = "help string"
""")
@testset "arg dict properties" begin
debug_parse_args = (args_list) -> parse_args(args_list, ArgParseSettings(exc_handler = ArgParse.debug_handler), Config(deepcopy(template)))
@test_throws ArgParseError debug_parse_args(String[]) # --a is required
@test_throws ArgParseError debug_parse_args(["--a", "3.0", "4.0"]) # --a must be Int
@test_throws ArgParseError debug_parse_args(["--a", "3"]) # --a requires two args
@test_throws ArgParseError debug_parse_args(["--a", "1", "2", "--b"]) # --b requires at least one arg
@test_nothrow debug_parse_args(["--a", "1", "2", "--b", "5.0"])
@test_nothrow debug_parse_args(["--a", "1", "2", "--b", "5", "10"]) # --b should allow conversion Int -> Float64
end
end
| [
27,
7856,
261,
480,
29,
73,
14378,
7234,
14,
51,
2662,
43,
16934,
198,
3500,
6208,
198,
3500,
41526,
43,
16934,
198,
3500,
44712,
11,
14534,
198,
198,
7249,
1400,
16922,
1279,
25,
35528,
886,
198,
198,
20285,
305,
1332,
62,
77,
849,
808,
7,
1069,
8,
198,
220,
220,
220,
3671,
7,
37498,
31,
9288,
62,
400,
8516,
1400,
16922,
7198,
7,
1069,
1776,
3714,
7,
2949,
16922,
3419,
35514,
198,
437,
198,
198,
8818,
2198,
62,
13083,
7,
39532,
75,
3712,
35,
713,
90,
10100,
5512,
468,
11,
46701,
8,
198,
220,
220,
220,
329,
1994,
287,
468,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
468,
2539,
7,
39532,
75,
11,
1994,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
329,
1994,
287,
46701,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
5145,
10134,
2539,
7,
39532,
75,
11,
1994,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
25683,
62,
786,
13255,
7,
39532,
75,
16,
3712,
35,
713,
90,
10100,
5512,
284,
4029,
17,
3712,
35,
713,
90,
10100,
30072,
198,
220,
220,
220,
2488,
9288,
284,
4029,
16,
6624,
284,
4029,
17,
198,
220,
220,
220,
329,
479,
287,
8251,
7,
39532,
75,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
410,
16,
11,
410,
17,
796,
284,
4029,
16,
58,
74,
4357,
284,
4029,
17,
58,
74,
60,
198,
220,
220,
220,
220,
220,
220,
220,
611,
410,
16,
318,
64,
27741,
35,
713,
11405,
410,
17,
318,
64,
27741,
35,
713,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
85,
16,
8,
6624,
2099,
1659,
7,
85,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
25683,
62,
786,
13255,
7,
85,
16,
11,
410,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
85,
16,
8,
6624,
2099,
1659,
7,
85,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
31,
9288,
2617,
366,
35487,
32096,
1,
2221,
198,
220,
220,
220,
11055,
796,
41526,
43,
13,
29572,
7,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
257,
796,
657,
198,
220,
220,
220,
275,
796,
657,
13,
15,
198,
220,
220,
220,
685,
2363,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
269,
796,
685,
16,
11,
362,
60,
198,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
288,
796,
685,
16,
13,
15,
11,
362,
13,
15,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
304,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
277,
796,
3050,
12,
2713,
12,
1558,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
308,
796,
2211,
12,
486,
12,
486,
51,
405,
25,
405,
25,
405,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
289,
796,
5534,
25,
405,
25,
405,
198,
220,
220,
220,
13538,
4943,
628,
220,
220,
220,
2163,
2198,
62,
79,
945,
276,
62,
19199,
7,
39532,
75,
3712,
35,
713,
90,
10100,
30072,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
39532,
75,
14692,
64,
8973,
8,
6624,
2558,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
39532,
75,
14692,
65,
8973,
8,
6624,
48436,
2414,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
39532,
75,
14692,
2363,
16,
1,
7131,
1,
66,
8973,
8,
6624,
20650,
90,
5317,
92,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
39532,
75,
14692,
2363,
16,
1,
7131,
1,
7266,
16,
1,
7131,
1,
67,
8973,
8,
6624,
20650,
90,
43879,
2414,
92,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
39532,
75,
14692,
2363,
16,
1,
7131,
1,
7266,
16,
1,
7131,
1,
68,
8973,
8,
6624,
347,
970,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
39532,
75,
14692,
2363,
16,
1,
7131,
1,
7266,
17,
1,
7131,
1,
69,
8973,
8,
6624,
7536,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
39532,
75,
14692,
2363,
16,
1,
7131,
1,
7266,
17,
1,
7131,
1,
70,
8973,
8,
6624,
7536,
7575,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
2099,
1659,
7,
39532,
75,
14692,
2363,
16,
1,
7131,
1,
7266,
17,
1,
7131,
1,
71,
8973,
8,
6624,
3862,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
2617,
366,
3919,
26498,
3804,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
44267,
62,
22046,
796,
21136,
62,
22046,
7,
10100,
58,
4357,
17056,
7,
22089,
30073,
7,
28243,
18125,
355,
62,
11600,
796,
2081,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
796,
2769,
30073,
7,
28243,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
79,
945,
276,
62,
19199,
7,
79,
945,
276,
62,
22046,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
79,
945,
276,
62,
19199,
7,
40319,
62,
79,
945,
276,
8,
198,
220,
220,
220,
220,
220,
220,
220,
25683,
62,
786,
13255,
7,
79,
945,
276,
62,
22046,
11,
2938,
62,
79,
945,
276,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
2617,
366,
22046,
3804,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
26498,
62,
4868,
796,
685,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
438,
64,
1600,
366,
16,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
438,
2363,
16,
13,
66,
1600,
366,
18,
1600,
366,
19,
1600,
366,
20,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
438,
2363,
16,
13,
7266,
16,
13,
67,
1600,
366,
20,
13,
20,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
438,
2363,
16,
13,
7266,
17,
13,
69,
1600,
366,
1238,
2481,
12,
3312,
12,
486,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
438,
2363,
16,
13,
7266,
17,
13,
70,
1600,
366,
1238,
2481,
12,
3312,
12,
486,
51,
1065,
25,
2682,
25,
3980,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
438,
2363,
16,
13,
7266,
17,
13,
71,
1600,
366,
486,
25,
1954,
25,
2231,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
2361,
198,
220,
220,
220,
220,
220,
220,
220,
44267,
62,
22046,
796,
21136,
62,
22046,
7,
22046,
62,
4868,
11,
17056,
7,
22089,
30073,
7,
28243,
18125,
355,
62,
11600,
796,
2081,
8,
628,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
796,
2769,
30073,
7,
28243,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
14692,
64,
8973,
796,
352,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
14692,
2363,
16,
1,
7131,
1,
66,
8973,
796,
685,
18,
11,
19,
11,
20,
60,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
14692,
2363,
16,
1,
7131,
1,
7266,
16,
1,
7131,
1,
67,
8973,
796,
685,
20,
13,
20,
60,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
14692,
2363,
16,
1,
7131,
1,
7266,
17,
1,
7131,
1,
69,
8973,
796,
7536,
7203,
1238,
2481,
12,
3312,
12,
486,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
14692,
2363,
16,
1,
7131,
1,
7266,
17,
1,
7131,
1,
70,
8973,
796,
7536,
7575,
7203,
1238,
2481,
12,
3312,
12,
486,
51,
1065,
25,
2682,
25,
3980,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
14692,
2363,
16,
1,
7131,
1,
7266,
17,
1,
7131,
1,
71,
8973,
796,
3862,
7203,
486,
25,
1954,
25,
2231,
4943,
628,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
79,
945,
276,
62,
19199,
7,
79,
945,
276,
62,
22046,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
79,
945,
276,
62,
19199,
7,
40319,
62,
79,
945,
276,
8,
198,
220,
220,
220,
220,
220,
220,
220,
25683,
62,
786,
13255,
7,
79,
945,
276,
62,
22046,
11,
2938,
62,
79,
945,
276,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
2617,
366,
37980,
4464,
276,
26498,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
329,
26498,
62,
4868,
287,
685,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
64,
1600,
366,
16,
13,
20,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
65,
1600,
366,
68,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
2363,
16,
13,
66,
1600,
366,
18,
13,
20,
1600,
366,
19,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
2363,
16,
13,
7266,
16,
13,
67,
1600,
366,
69,
1600,
366,
70,
1600,
366,
71,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
2363,
16,
13,
7266,
17,
13,
69,
1600,
366,
486,
25,
405,
25,
405,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
2363,
16,
13,
7266,
17,
13,
70,
1600,
366,
486,
25,
405,
25,
405,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
2363,
16,
13,
7266,
17,
13,
71,
1600,
366,
6390,
12,
486,
12,
486,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
2361,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6460,
796,
20559,
10044,
325,
26232,
7,
41194,
62,
30281,
796,
20559,
10044,
325,
13,
24442,
62,
30281,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
20559,
10044,
325,
12331,
21136,
62,
22046,
7,
22046,
62,
4868,
11,
6460,
11,
17056,
7,
22089,
30073,
7,
28243,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
31,
9288,
2617,
366,
77,
7287,
2214,
24155,
1,
2221,
198,
220,
220,
220,
11055,
796,
41526,
43,
13,
29572,
7,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
257,
796,
657,
198,
220,
220,
220,
275,
796,
657,
13,
15,
198,
220,
220,
220,
269,
796,
366,
66,
1,
198,
220,
220,
220,
685,
2363,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
1268,
16879,
2043,
62,
796,
45434,
27082,
3525,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
257,
796,
352,
198,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4808,
1268,
16879,
2043,
62,
796,
45434,
27082,
3525,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
67,
1,
198,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4808,
1268,
16879,
2043,
62,
796,
45434,
27082,
3525,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
275,
796,
45434,
27082,
3525,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
67,
1,
198,
220,
220,
220,
13538,
4943,
628,
220,
220,
220,
2163,
2198,
62,
79,
945,
276,
62,
13083,
7,
39532,
75,
3712,
35,
713,
90,
10100,
30072,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
13083,
7,
39532,
75,
11,
14631,
64,
1600,
366,
65,
1600,
366,
66,
33116,
14631,
62,
1268,
16879,
2043,
62,
8973,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
13083,
7,
39532,
75,
14692,
2363,
16,
33116,
14631,
64,
1600,
366,
65,
1600,
366,
66,
33116,
14631,
62,
1268,
16879,
2043,
62,
8973,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
13083,
7,
39532,
75,
14692,
2363,
16,
1,
7131,
1,
7266,
16,
33116,
14631,
64,
1600,
366,
66,
33116,
14631,
62,
1268,
16879,
2043,
62,
1600,
366,
65,
8973,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
13083,
7,
39532,
75,
14692,
2363,
16,
1,
7131,
1,
7266,
17,
33116,
14631,
64,
1600,
366,
65,
1600,
366,
66,
33116,
14631,
62,
1268,
16879,
2043,
62,
8973,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
2617,
366,
3919,
26498,
3804,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
44267,
62,
22046,
796,
21136,
62,
22046,
7,
10100,
58,
4357,
17056,
7,
22089,
30073,
7,
28243,
18125,
355,
62,
11600,
796,
2081,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
796,
41526,
43,
13,
29572,
7,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
257,
796,
657,
198,
220,
220,
220,
220,
220,
220,
220,
275,
796,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
66,
1,
198,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
257,
796,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
275,
796,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
66,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
257,
796,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
67,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
257,
796,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
275,
796,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
67,
1,
198,
220,
220,
220,
220,
220,
220,
220,
13538,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
79,
945,
276,
62,
13083,
7,
79,
945,
276,
62,
22046,
8,
198,
220,
220,
220,
220,
220,
220,
220,
25683,
62,
786,
13255,
7,
79,
945,
276,
62,
22046,
11,
2938,
62,
79,
945,
276,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
2617,
366,
22046,
3804,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
26498,
62,
4868,
796,
14631,
438,
65,
28,
16,
13,
15,
1600,
366,
438,
2363,
16,
13,
64,
28,
17,
1600,
366,
438,
2363,
16,
13,
7266,
17,
13,
66,
28,
68,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
44267,
62,
22046,
796,
21136,
62,
22046,
7,
22046,
62,
4868,
11,
17056,
7,
22089,
30073,
7,
28243,
18125,
355,
62,
11600,
796,
2081,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2938,
62,
79,
945,
276,
796,
41526,
43,
13,
29572,
7,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
257,
796,
657,
198,
220,
220,
220,
220,
220,
220,
220,
275,
796,
352,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
66,
1,
198,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
257,
796,
362,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
275,
796,
352,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
66,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
257,
796,
362,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
67,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
257,
796,
362,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
275,
796,
352,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
68,
1,
198,
220,
220,
220,
220,
220,
220,
220,
13538,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
79,
945,
276,
62,
13083,
7,
79,
945,
276,
62,
22046,
8,
198,
220,
220,
220,
220,
220,
220,
220,
25683,
62,
786,
13255,
7,
79,
945,
276,
62,
22046,
11,
2938,
62,
79,
945,
276,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
31,
9288,
2617,
366,
23144,
2890,
1822,
3084,
1,
2221,
198,
220,
220,
220,
11055,
796,
41526,
43,
13,
29572,
7,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
257,
796,
685,
15,
60,
198,
220,
220,
220,
275,
796,
657,
13,
15,
198,
220,
220,
220,
269,
796,
366,
66,
1,
198,
220,
220,
220,
685,
2363,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
1268,
16879,
2043,
62,
796,
45434,
27082,
3525,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
257,
796,
685,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4808,
1268,
16879,
2043,
62,
796,
45434,
27082,
3525,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
67,
1,
198,
220,
220,
220,
220,
220,
220,
220,
685,
2363,
16,
13,
7266,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4808,
1268,
16879,
2043,
62,
796,
45434,
27082,
3525,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
275,
796,
45434,
27082,
3525,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
796,
366,
67,
1,
198,
220,
220,
220,
13538,
4943,
628,
220,
220,
220,
2163,
15456,
62,
28463,
62,
853,
62,
11600,
82,
0,
7,
39532,
75,
8,
198,
220,
220,
220,
220,
220,
220,
220,
9403,
796,
657,
198,
220,
220,
220,
220,
220,
220,
220,
329,
10139,
287,
41526,
43,
16934,
13,
9012,
1203,
33,
10652,
7,
16934,
7,
39532,
75,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
357,
74,
11,
85,
8,
287,
41526,
43,
16934,
13,
3642,
658,
7,
17440,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
479,
6624,
41526,
43,
16934,
13,
259,
372,
270,
62,
439,
62,
2539,
3419,
11405,
2555,
1303,
460,
470,
6330,
4808,
1268,
16879,
2043,
62,
351,
1822,
8633,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5145,
51,
2662,
43,
16934,
13,
271,
62,
853,
7,
85,
8,
11405,
2555,
1303,
691,
6330,
26498,
11,
407,
1200,
8633,
82,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
43720,
7,
44,
364,
29727,
5080,
1694,
7,
28826,
15853,
352,
4008,
1875,
657,
13,
20,
11405,
2555,
1303,
14283,
10752,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
41526,
43,
16934,
13,
3642,
658,
7,
17440,
38381,
74,
60,
796,
5145,
51,
2662,
43,
16934,
13,
271,
62,
11600,
62,
853,
7,
85,
8,
5633,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
360,
713,
90,
10100,
11,
4377,
92,
7,
51,
2662,
43,
16934,
13,
853,
62,
2539,
3419,
5218,
41526,
43,
16934,
13,
853,
62,
8367,
7,
85,
4008,
1058,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
41526,
43,
16934,
13,
853,
62,
8367,
7,
85,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
284,
4029,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2488,
9288,
2617,
366,
853,
8633,
6854,
594,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
329,
26498,
62,
4868,
287,
685,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10903,
58,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
64,
1600,
366,
16,
1600,
366,
17,
1600,
366,
438,
66,
1600,
366,
9246,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14631,
438,
65,
1600,
366,
17,
13,
15,
1600,
366,
438,
2363,
16,
13,
65,
1600,
366,
18,
13,
15,
1600,
366,
438,
2363,
16,
13,
7266,
16,
13,
64,
1600,
366,
20,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
2361,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11055,
17478,
796,
15456,
62,
28463,
62,
853,
62,
11600,
82,
0,
7,
22089,
30073,
7,
28243,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44267,
62,
22046,
796,
21136,
62,
22046,
7,
22046,
62,
4868,
11,
17056,
7,
22089,
30073,
7,
28243,
18125,
355,
62,
11600,
796,
2081,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44267,
62,
22046,
17478,
796,
21136,
62,
22046,
7,
22046,
62,
4868,
11,
17056,
7,
22089,
30073,
7,
28243,
17478,
18125,
355,
62,
11600,
796,
2081,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
25683,
62,
786,
13255,
7,
79,
945,
276,
62,
22046,
11,
44267,
62,
22046,
17478,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
11055,
796,
41526,
43,
13,
29572,
7,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
685,
64,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
1503,
38,
62,
796,
45434,
2200,
10917,
37819,
62,
1,
198,
220,
220,
220,
220,
220,
220,
220,
299,
22046,
796,
362,
198,
220,
220,
220,
220,
220,
220,
220,
1822,
62,
4906,
796,
366,
5317,
1,
198,
220,
220,
220,
220,
220,
220,
220,
2672,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
1037,
796,
366,
16794,
4731,
1,
198,
220,
220,
220,
685,
65,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
1503,
38,
62,
796,
685,
16,
13,
15,
11,
362,
13,
15,
60,
198,
220,
220,
220,
220,
220,
220,
220,
299,
22046,
796,
43825,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1037,
796,
366,
16794,
4731,
1,
198,
220,
220,
220,
13538,
4943,
198,
220,
220,
220,
2488,
9288,
2617,
366,
853,
8633,
6608,
1,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
14257,
62,
29572,
62,
22046,
796,
357,
22046,
62,
4868,
8,
4613,
21136,
62,
22046,
7,
22046,
62,
4868,
11,
20559,
10044,
325,
26232,
7,
41194,
62,
30281,
796,
20559,
10044,
325,
13,
24442,
62,
30281,
828,
17056,
7,
22089,
30073,
7,
28243,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
20559,
10044,
325,
12331,
14257,
62,
29572,
62,
22046,
7,
10100,
58,
12962,
1303,
1377,
64,
318,
2672,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
20559,
10044,
325,
12331,
14257,
62,
29572,
62,
22046,
7,
14692,
438,
64,
1600,
366,
18,
13,
15,
1600,
366,
19,
13,
15,
8973,
8,
1303,
1377,
64,
1276,
307,
2558,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
20559,
10044,
325,
12331,
14257,
62,
29572,
62,
22046,
7,
14692,
438,
64,
1600,
366,
18,
8973,
8,
1303,
1377,
64,
4433,
734,
26498,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
400,
8516,
20559,
10044,
325,
12331,
14257,
62,
29572,
62,
22046,
7,
14692,
438,
64,
1600,
366,
16,
1600,
366,
17,
1600,
366,
438,
65,
8973,
8,
1303,
1377,
65,
4433,
379,
1551,
530,
1822,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
77,
849,
808,
14257,
62,
29572,
62,
22046,
7,
14692,
438,
64,
1600,
366,
16,
1600,
366,
17,
1600,
366,
438,
65,
1600,
366,
20,
13,
15,
8973,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
9288,
62,
77,
849,
808,
14257,
62,
29572,
62,
22046,
7,
14692,
438,
64,
1600,
366,
16,
1600,
366,
17,
1600,
366,
438,
65,
1600,
366,
20,
1600,
366,
940,
8973,
8,
1303,
1377,
65,
815,
1249,
11315,
2558,
4613,
48436,
2414,
198,
220,
220,
220,
886,
198,
437,
198
] | 1.817361 | 4,320 |
<filename>src/io/input.jl
"""
loadFCSHeader(fn::String)::Tuple{Vector{Int}, Dict{String,String}}
Efficiently extract data offsets and keyword dictionary from an FCS file.
"""
function loadFCSHeader(fn::String)::Tuple{Vector{Int},Dict{String,String}}
open(fn) do io
offsets = FCSFiles.parse_header(io)
params = FCSFiles.parse_text(io, offsets[1], offsets[2])
FCSFiles.verify_text(params)
(offsets, params)
end
end
"""
getFCSSize(offsets, params)::Tuple{Int,Int}
Convert the offsets and keywords from an FCS file to cell and parameter count,
respectively.
"""
function getFCSSize(offsets, params)::Tuple{Int,Int}
nData = parse(Int, params["\$TOT"])
nParams = parse(Int, params["\$PAR"])
if params["\$DATATYPE"] != "F"
@error "Only float32 FCS files are currently supported"
error("Unsupported FCS format")
end
beginData = parse(Int, params["\$BEGINDATA"])
endData = parse(Int, params["\$ENDDATA"])
#check that the $TOT and $PAR look okay
if !(offsets[3] == 0 && offsets[4] == 0) && (
(
1 + offsets[4] - offsets[3] != nData * nParams * 4 &&
offsets[4] - offsets[3] != nData * nParams * 4
) ||
offsets[3] != beginData ||
offsets[4] != endData
)
@warn "Data size mismatch, FCS is likely broken."
end
return (nData, nParams)
end
"""
loadFCSSizes(fns::Vector{String})
Load cell counts in many FCS files at once. Useful as input for `slicesof`.
"""
function loadFCSSizes(fns::Vector{String})::Vector{Int}
[(
begin
o, s = loadFCSHeader(fn)
getFCSSize(o, s)[1]
end
) for fn in fns]
end
"""
loadFCS(fn::String; applyCompensation::Bool=true)::Tuple{Dict{String,String}, Matrix{Float64}}
Read a FCS file. Return a tuple that contains in order:
- dictionary of the keywords contained in the file
- raw column names
- prettified and annotated column names
- raw data matrix
If `applyCompensation` is set, the function parses and retrieves a spillover
matrix (if any valid keyword in the FCS is found that would contain it) and
applies it to compensate the data.
"""
function loadFCS(
fn::String;
applyCompensation::Bool = true,
)::Tuple{Dict{String,String},Matrix{Float64}}
fcs = FileIO.load(fn)
meta = getMetaData(fcs.params)
data = hcat(map(x -> Vector{Float64}(fcs.data[x]), meta[:, :N])...)
if applyCompensation
spill = getSpillover(fcs.params)
if spill != nothing
names, mtx = spill
cols = indexin(names, meta[:, :N])
if any(cols .== nothing)
@error "Unknown columns in compensation matrix" names cols
error("Invalid compensation matrix")
end
compensate!(data, mtx, Vector{Int}(cols))
end
end
return (fcs.params, data)
end
"""
loadFCSSet(name::Symbol, fns::Vector{String}, pids=workers(); applyCompensation=true, postLoad=(d,i)->d)::LoadedDataInfo
This runs the FCS loading machinery in a distributed way, so that the files
`fns` (with full path) are sliced into equal parts and saved as a distributed
variable `name` on workers specified by `pids`.
`applyCompensation` is passed to loadFCS function.
See `slicesof` for description of the slicing.
`postLoad` is applied to the loaded FCS file data (and the index) -- use this
function to e.g. filter out certain columns right on loading, using `selectFCSColumns`.
The loaded dataset can be manipulated by the distributed functions, e.g.
- `dselect` for removing columns
- `dscale` for normalization
- `dtransform_asinh` (and others) for transformation
- etc.
"""
function loadFCSSet(
name::Symbol,
fns::Vector{String},
pids = workers();
applyCompensation = true,
postLoad = (d, i) -> d,
)::LoadedDataInfo
slices = slicesof(loadFCSSizes(fns), length(pids))
distributed_foreach(
slices,
(slice) -> Base.eval(
Main,
:(
begin
$name = vcollectSlice(
(i) -> last($postLoad(
loadFCS($fns[i]; applyCompensation = $applyCompensation),
i,
)),
$slice,
)
nothing
end
),
),
pids,
)
return LoadedDataInfo(name, pids)
end
"""
selectFCSColumns(selectColnames::Vector{String})
Return a function useful with `loadFCSSet`, which loads only the specified
(prettified) column names from the FCS files. Use `getMetaData`,
`getMarkerNames` and `cleanNames!` to retrieve the usable column names for a
FCS.
"""
function selectFCSColumns(selectColnames::Vector{String})
((metadata, data), idx) -> begin
_, names = getMarkerNames(getMetaData(metadata))
cleanNames!(names)
colIdxs = indexin(selectColnames, names)
if any(colIdxs .== nothing)
@error "Some columns were not found"
error("unknown column")
end
(metadata, data[:, colIdxs])
end
end
"""
distributeFCSFileVector(name::Symbol, fns::Vector{String}, pids=workers())::LoadedDataInfo
Distribute a vector of integers among the workers that describes which file
from `fns` the cell comes from. Useful for producing per-file statistics. The
vector is saved on workers specified by `pids` as a distributed variable
`name`.
"""
function distributeFCSFileVector(
name::Symbol,
fns::Vector{String},
pids = workers(),
)::LoadedDataInfo
sizes = loadFCSSizes(fns)
slices = slicesof(sizes, length(pids))
return distributeFileVector(name, sizes, slices, pids)
end
"""
distributeFileVector(name::Symbol, sizes::Vector{Int}, slices::Vector{Tuple{Int,Int,Int,Int}}, pids=workers())::LoadedDataInfo
Generalized version of `distributeFCSFileVector` that produces the integer
vector from any `sizes` and `slices`.
"""
function distributeFileVector(
name::Symbol,
sizes::Vector{Int},
slices::Vector{Tuple{Int,Int,Int,Int}},
pids = workers(),
)::LoadedDataInfo
distributed_foreach(
slices,
(slice) ->
Base.eval(Main, :($name = collectSlice((i) -> fill(i, $sizes[i]), $slice))),
pids,
)
return LoadedDataInfo(name, pids)
end
"""
function getCSVSize(fn::String; args...)::Tuple{Int,Int}
Read the dimensions (number of rows and columns, respectively) from a CSV file
`fn`. `args` are passed to function `CSV.file`.
# Example
getCSVSize("test.csv", header=false)
"""
function getCSVSize(fn::String; args...)::Tuple{Int,Int}
n = 0
k = 0
# ideally, this will not try to load the whole CSV in the memory
for row in CSV.File(fn, type = Float64; args...)
n += 1
if length(row) > k
k = length(row)
end
end
return (n, k)
end
"""
function loadCSVSizes(fns::Vector{String}; args...)::Vector{Int}
Determine number of rows in a list of CSV files (passed as `fns`). Equivalent
to `loadFCSSizes`.
"""
function loadCSVSizes(fns::Vector{String}; args...)::Vector{Int}
[getCSVSize(fn, type = Float64; args...)[1] for fn in fns]
end
"""
function loadCSV(fn::String; args...)::Matrix{Float64}
CSV equivalent of `loadFCS`. The metadata (header, column names) are not
extracted. `args` are passed to `CSV.read`.
"""
function loadCSV(fn::String; args...)::Matrix{Float64}
CSV.read(fn, DataFrame, type = Float64; args...) |> Matrix{Float64}
end
"""
function loadCSVSet(
name::Symbol,
fns::Vector{String},
pids = workers();
postLoad = (d, i) -> d,
csvargs...,
)::LoadedDataInfo
CSV equivalent of `loadFCSSet`. `csvargs` are passed as keyword arguments to
CSV-loading functions.
"""
function loadCSVSet(
name::Symbol,
fns::Vector{String},
pids = workers();
postLoad = (d, i) -> d,
csvargs...,
)::LoadedDataInfo
slices = slicesof(loadCSVSizes(fns; csvargs...), length(pids))
distributed_foreach(
slices,
(slice) -> Base.eval(
Main,
:(
begin
$name = vcollectSlice(
(i) -> $postLoad(loadCSV($fns[i]; $csvargs...), i),
$slice,
)
nothing
end
),
),
pids,
)
return LoadedDataInfo(name, pids)
end
| [
27,
34345,
29,
10677,
14,
952,
14,
15414,
13,
20362,
198,
37811,
198,
220,
220,
220,
3440,
4851,
9693,
1329,
263,
7,
22184,
3712,
10100,
2599,
25,
51,
29291,
90,
38469,
90,
5317,
5512,
360,
713,
90,
10100,
11,
10100,
11709,
198,
198,
36,
5632,
306,
7925,
1366,
49005,
290,
21179,
22155,
422,
281,
376,
7902,
2393,
13,
198,
37811,
198,
8818,
3440,
4851,
9693,
1329,
263,
7,
22184,
3712,
10100,
2599,
25,
51,
29291,
90,
38469,
90,
5317,
5512,
35,
713,
90,
10100,
11,
10100,
11709,
198,
220,
220,
220,
1280,
7,
22184,
8,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
49005,
796,
376,
7902,
25876,
13,
29572,
62,
25677,
7,
952,
8,
198,
220,
220,
220,
220,
220,
220,
220,
42287,
796,
376,
7902,
25876,
13,
29572,
62,
5239,
7,
952,
11,
49005,
58,
16,
4357,
49005,
58,
17,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
376,
7902,
25876,
13,
332,
1958,
62,
5239,
7,
37266,
8,
198,
220,
220,
220,
220,
220,
220,
220,
357,
8210,
1039,
11,
42287,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
651,
4851,
5432,
1096,
7,
8210,
1039,
11,
42287,
2599,
25,
51,
29291,
90,
5317,
11,
5317,
92,
198,
198,
3103,
1851,
262,
49005,
290,
26286,
422,
281,
376,
7902,
2393,
284,
2685,
290,
11507,
954,
11,
198,
15008,
2280,
13,
198,
37811,
198,
8818,
651,
4851,
5432,
1096,
7,
8210,
1039,
11,
42287,
2599,
25,
51,
29291,
90,
5317,
11,
5317,
92,
198,
220,
220,
220,
299,
6601,
796,
21136,
7,
5317,
11,
42287,
14692,
59,
3,
51,
2394,
8973,
8,
198,
220,
220,
220,
299,
10044,
4105,
796,
21136,
7,
5317,
11,
42287,
14692,
59,
3,
27082,
8973,
8,
628,
220,
220,
220,
611,
42287,
14692,
59,
3,
35,
1404,
1404,
56,
11401,
8973,
14512,
366,
37,
1,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
18224,
366,
10049,
12178,
2624,
376,
7902,
3696,
389,
3058,
4855,
1,
198,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
3118,
15999,
376,
7902,
5794,
4943,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2221,
6601,
796,
21136,
7,
5317,
11,
42287,
14692,
59,
3,
33,
7156,
12115,
13563,
8973,
8,
198,
220,
220,
220,
886,
6601,
796,
21136,
7,
5317,
11,
42287,
14692,
59,
3,
10619,
26947,
8973,
8,
628,
220,
220,
220,
1303,
9122,
326,
262,
720,
51,
2394,
290,
720,
27082,
804,
8788,
198,
220,
220,
220,
611,
5145,
7,
8210,
1039,
58,
18,
60,
6624,
657,
11405,
49005,
58,
19,
60,
6624,
657,
8,
11405,
357,
198,
220,
220,
220,
220,
220,
220,
220,
357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
352,
1343,
49005,
58,
19,
60,
532,
49005,
58,
18,
60,
14512,
299,
6601,
1635,
299,
10044,
4105,
1635,
604,
11405,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
49005,
58,
19,
60,
532,
49005,
58,
18,
60,
14512,
299,
6601,
1635,
299,
10044,
4105,
1635,
604,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
8614,
198,
220,
220,
220,
220,
220,
220,
220,
49005,
58,
18,
60,
14512,
2221,
6601,
8614,
198,
220,
220,
220,
220,
220,
220,
220,
49005,
58,
19,
60,
14512,
886,
6601,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
40539,
366,
6601,
2546,
46318,
11,
376,
7902,
318,
1884,
5445,
526,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
357,
77,
6601,
11,
299,
10044,
4105,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3440,
4851,
5432,
4340,
7,
69,
5907,
3712,
38469,
90,
10100,
30072,
198,
198,
8912,
2685,
9853,
287,
867,
376,
7902,
3696,
379,
1752,
13,
49511,
355,
5128,
329,
4600,
82,
677,
274,
1659,
44646,
198,
37811,
198,
8818,
3440,
4851,
5432,
4340,
7,
69,
5907,
3712,
38469,
90,
10100,
92,
2599,
25,
38469,
90,
5317,
92,
198,
220,
220,
220,
47527,
198,
220,
220,
220,
220,
220,
220,
220,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
11,
264,
796,
3440,
4851,
9693,
1329,
263,
7,
22184,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
651,
4851,
5432,
1096,
7,
78,
11,
264,
38381,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
1267,
329,
24714,
287,
277,
5907,
60,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3440,
4851,
50,
7,
22184,
3712,
10100,
26,
4174,
7293,
25742,
3712,
33,
970,
28,
7942,
2599,
25,
51,
29291,
90,
35,
713,
90,
10100,
11,
10100,
5512,
24936,
90,
43879,
2414,
11709,
198,
198,
5569,
257,
376,
7902,
2393,
13,
8229,
257,
46545,
326,
4909,
287,
1502,
25,
198,
198,
12,
22155,
286,
262,
26286,
7763,
287,
262,
2393,
198,
12,
8246,
5721,
3891,
198,
12,
46442,
1431,
290,
24708,
515,
5721,
3891,
198,
12,
8246,
1366,
17593,
198,
198,
1532,
4600,
39014,
7293,
25742,
63,
318,
900,
11,
262,
2163,
13544,
274,
290,
13236,
1158,
257,
19431,
2502,
198,
6759,
8609,
357,
361,
597,
4938,
21179,
287,
262,
376,
7902,
318,
1043,
326,
561,
3994,
340,
8,
290,
198,
1324,
13508,
340,
284,
21392,
262,
1366,
13,
198,
37811,
198,
8818,
3440,
4851,
50,
7,
198,
220,
220,
220,
24714,
3712,
10100,
26,
198,
220,
220,
220,
4174,
7293,
25742,
3712,
33,
970,
796,
2081,
11,
198,
2599,
25,
51,
29291,
90,
35,
713,
90,
10100,
11,
10100,
5512,
46912,
90,
43879,
2414,
11709,
198,
220,
220,
220,
277,
6359,
796,
9220,
9399,
13,
2220,
7,
22184,
8,
198,
220,
220,
220,
13634,
796,
651,
48526,
6601,
7,
69,
6359,
13,
37266,
8,
198,
220,
220,
220,
1366,
796,
289,
9246,
7,
8899,
7,
87,
4613,
20650,
90,
43879,
2414,
92,
7,
69,
6359,
13,
7890,
58,
87,
46570,
13634,
58,
45299,
1058,
45,
12962,
23029,
198,
220,
220,
220,
611,
4174,
7293,
25742,
198,
220,
220,
220,
220,
220,
220,
220,
19431,
796,
651,
4561,
359,
2502,
7,
69,
6359,
13,
37266,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
19431,
14512,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3891,
11,
285,
17602,
796,
19431,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
951,
82,
796,
6376,
259,
7,
14933,
11,
13634,
58,
45299,
1058,
45,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
597,
7,
4033,
82,
764,
855,
2147,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
18224,
366,
20035,
15180,
287,
9836,
17593,
1,
3891,
951,
82,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
44651,
9836,
17593,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
21392,
0,
7,
7890,
11,
285,
17602,
11,
20650,
90,
5317,
92,
7,
4033,
82,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
357,
69,
6359,
13,
37266,
11,
1366,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3440,
4851,
5432,
316,
7,
3672,
3712,
13940,
23650,
11,
277,
5907,
3712,
38469,
90,
10100,
5512,
279,
2340,
28,
22896,
9783,
4174,
7293,
25742,
28,
7942,
11,
1281,
8912,
16193,
67,
11,
72,
8,
3784,
67,
2599,
25,
8912,
276,
6601,
12360,
198,
198,
1212,
4539,
262,
376,
7902,
11046,
20230,
287,
257,
9387,
835,
11,
523,
326,
262,
3696,
198,
63,
69,
5907,
63,
357,
4480,
1336,
3108,
8,
389,
26790,
656,
4961,
3354,
290,
7448,
355,
257,
9387,
198,
45286,
4600,
3672,
63,
319,
3259,
7368,
416,
4600,
79,
2340,
44646,
198,
198,
63,
39014,
7293,
25742,
63,
318,
3804,
284,
3440,
4851,
50,
2163,
13,
198,
198,
6214,
4600,
82,
677,
274,
1659,
63,
329,
6764,
286,
262,
49289,
13,
198,
198,
63,
7353,
8912,
63,
318,
5625,
284,
262,
9639,
376,
7902,
2393,
1366,
357,
392,
262,
6376,
8,
1377,
779,
428,
198,
8818,
284,
304,
13,
70,
13,
8106,
503,
1728,
15180,
826,
319,
11046,
11,
1262,
4600,
19738,
4851,
50,
39470,
82,
44646,
198,
198,
464,
9639,
27039,
460,
307,
25036,
416,
262,
9387,
5499,
11,
304,
13,
70,
13,
198,
12,
4600,
67,
19738,
63,
329,
10829,
15180,
198,
12,
4600,
67,
9888,
63,
329,
3487,
1634,
198,
12,
4600,
67,
35636,
62,
47337,
71,
63,
357,
392,
1854,
8,
329,
13389,
198,
12,
3503,
13,
198,
37811,
198,
8818,
3440,
4851,
5432,
316,
7,
198,
220,
220,
220,
1438,
3712,
13940,
23650,
11,
198,
220,
220,
220,
277,
5907,
3712,
38469,
90,
10100,
5512,
198,
220,
220,
220,
279,
2340,
796,
3259,
9783,
198,
220,
220,
220,
4174,
7293,
25742,
796,
2081,
11,
198,
220,
220,
220,
1281,
8912,
796,
357,
67,
11,
1312,
8,
4613,
288,
11,
198,
2599,
25,
8912,
276,
6601,
12360,
198,
220,
220,
220,
24314,
796,
24314,
1659,
7,
2220,
4851,
5432,
4340,
7,
69,
5907,
828,
4129,
7,
79,
2340,
4008,
198,
220,
220,
220,
9387,
62,
754,
620,
7,
198,
220,
220,
220,
220,
220,
220,
220,
24314,
11,
198,
220,
220,
220,
220,
220,
220,
220,
357,
48369,
8,
4613,
7308,
13,
18206,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8774,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36147,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
720,
3672,
796,
410,
33327,
11122,
501,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
72,
8,
4613,
938,
16763,
7353,
8912,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3440,
4851,
50,
16763,
69,
5907,
58,
72,
11208,
4174,
7293,
25742,
796,
720,
39014,
7293,
25742,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1312,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
720,
48369,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
279,
2340,
11,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
1441,
42485,
6601,
12360,
7,
3672,
11,
279,
2340,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
2922,
4851,
50,
39470,
82,
7,
19738,
5216,
14933,
3712,
38469,
90,
10100,
30072,
198,
198,
13615,
257,
2163,
4465,
351,
4600,
2220,
4851,
5432,
316,
47671,
543,
15989,
691,
262,
7368,
198,
7,
3866,
926,
1431,
8,
5721,
3891,
422,
262,
376,
7902,
3696,
13,
5765,
4600,
1136,
48526,
6601,
47671,
198,
63,
1136,
9704,
263,
36690,
63,
290,
4600,
27773,
36690,
0,
63,
284,
19818,
262,
24284,
5721,
3891,
329,
257,
198,
4851,
50,
13,
198,
37811,
198,
8818,
2922,
4851,
50,
39470,
82,
7,
19738,
5216,
14933,
3712,
38469,
90,
10100,
30072,
198,
220,
220,
220,
14808,
38993,
11,
1366,
828,
4686,
87,
8,
4613,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
11,
3891,
796,
651,
9704,
263,
36690,
7,
1136,
48526,
6601,
7,
38993,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
3424,
36690,
0,
7,
14933,
8,
198,
220,
220,
220,
220,
220,
220,
220,
951,
7390,
34223,
796,
6376,
259,
7,
19738,
5216,
14933,
11,
3891,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
597,
7,
4033,
7390,
34223,
764,
855,
2147,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
18224,
366,
4366,
15180,
547,
407,
1043,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4049,
7203,
34680,
5721,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
357,
38993,
11,
1366,
58,
45299,
951,
7390,
34223,
12962,
198,
220,
220,
220,
886,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
14983,
4851,
50,
8979,
38469,
7,
3672,
3712,
13940,
23650,
11,
277,
5907,
3712,
38469,
90,
10100,
5512,
279,
2340,
28,
22896,
3419,
2599,
25,
8912,
276,
6601,
12360,
198,
198,
20344,
4163,
257,
15879,
286,
37014,
1871,
262,
3259,
326,
8477,
543,
2393,
198,
6738,
4600,
69,
5907,
63,
262,
2685,
2058,
422,
13,
49511,
329,
9194,
583,
12,
7753,
7869,
13,
383,
198,
31364,
318,
7448,
319,
3259,
7368,
416,
4600,
79,
2340,
63,
355,
257,
9387,
7885,
198,
63,
3672,
44646,
198,
37811,
198,
8818,
14983,
4851,
50,
8979,
38469,
7,
198,
220,
220,
220,
1438,
3712,
13940,
23650,
11,
198,
220,
220,
220,
277,
5907,
3712,
38469,
90,
10100,
5512,
198,
220,
220,
220,
279,
2340,
796,
3259,
22784,
198,
2599,
25,
8912,
276,
6601,
12360,
198,
220,
220,
220,
10620,
796,
3440,
4851,
5432,
4340,
7,
69,
5907,
8,
198,
220,
220,
220,
24314,
796,
24314,
1659,
7,
82,
4340,
11,
4129,
7,
79,
2340,
4008,
198,
220,
220,
220,
1441,
14983,
8979,
38469,
7,
3672,
11,
10620,
11,
24314,
11,
279,
2340,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
14983,
8979,
38469,
7,
3672,
3712,
13940,
23650,
11,
10620,
3712,
38469,
90,
5317,
5512,
24314,
3712,
38469,
90,
51,
29291,
90,
5317,
11,
5317,
11,
5317,
11,
5317,
92,
5512,
279,
2340,
28,
22896,
3419,
2599,
25,
8912,
276,
6601,
12360,
198,
198,
12218,
1143,
2196,
286,
4600,
17080,
4163,
4851,
50,
8979,
38469,
63,
326,
11073,
262,
18253,
198,
31364,
422,
597,
4600,
82,
4340,
63,
290,
4600,
82,
677,
274,
44646,
198,
37811,
198,
8818,
14983,
8979,
38469,
7,
198,
220,
220,
220,
1438,
3712,
13940,
23650,
11,
198,
220,
220,
220,
10620,
3712,
38469,
90,
5317,
5512,
198,
220,
220,
220,
24314,
3712,
38469,
90,
51,
29291,
90,
5317,
11,
5317,
11,
5317,
11,
5317,
92,
5512,
198,
220,
220,
220,
279,
2340,
796,
3259,
22784,
198,
2599,
25,
8912,
276,
6601,
12360,
198,
220,
220,
220,
9387,
62,
754,
620,
7,
198,
220,
220,
220,
220,
220,
220,
220,
24314,
11,
198,
220,
220,
220,
220,
220,
220,
220,
357,
48369,
8,
4613,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
18206,
7,
13383,
11,
1058,
16763,
3672,
796,
2824,
11122,
501,
19510,
72,
8,
4613,
6070,
7,
72,
11,
720,
82,
4340,
58,
72,
46570,
720,
48369,
4008,
828,
198,
220,
220,
220,
220,
220,
220,
220,
279,
2340,
11,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
1441,
42485,
6601,
12360,
7,
3672,
11,
279,
2340,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
2163,
651,
7902,
53,
10699,
7,
22184,
3712,
10100,
26,
26498,
986,
2599,
25,
51,
29291,
90,
5317,
11,
5317,
92,
198,
198,
5569,
262,
15225,
357,
17618,
286,
15274,
290,
15180,
11,
8148,
8,
422,
257,
44189,
2393,
198,
63,
22184,
44646,
4600,
22046,
63,
389,
3804,
284,
2163,
4600,
7902,
53,
13,
7753,
44646,
198,
198,
2,
17934,
628,
220,
220,
220,
651,
7902,
53,
10699,
7203,
9288,
13,
40664,
1600,
13639,
28,
9562,
8,
198,
37811,
198,
8818,
651,
7902,
53,
10699,
7,
22184,
3712,
10100,
26,
26498,
986,
2599,
25,
51,
29291,
90,
5317,
11,
5317,
92,
198,
220,
220,
220,
299,
796,
657,
198,
220,
220,
220,
479,
796,
657,
198,
220,
220,
220,
1303,
30274,
11,
428,
481,
407,
1949,
284,
3440,
262,
2187,
44189,
287,
262,
4088,
198,
220,
220,
220,
329,
5752,
287,
44189,
13,
8979,
7,
22184,
11,
2099,
796,
48436,
2414,
26,
26498,
23029,
198,
220,
220,
220,
220,
220,
220,
220,
299,
15853,
352,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4129,
7,
808,
8,
1875,
479,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
479,
796,
4129,
7,
808,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
357,
77,
11,
479,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
2163,
3440,
7902,
20304,
4340,
7,
69,
5907,
3712,
38469,
90,
10100,
19629,
26498,
986,
2599,
25,
38469,
90,
5317,
92,
198,
198,
35,
2357,
3810,
1271,
286,
15274,
287,
257,
1351,
286,
44189,
3696,
357,
6603,
276,
355,
4600,
69,
5907,
63,
737,
7889,
29540,
198,
1462,
4600,
2220,
4851,
5432,
4340,
44646,
198,
37811,
198,
8818,
3440,
7902,
20304,
4340,
7,
69,
5907,
3712,
38469,
90,
10100,
19629,
26498,
986,
2599,
25,
38469,
90,
5317,
92,
198,
220,
220,
220,
685,
1136,
7902,
53,
10699,
7,
22184,
11,
2099,
796,
48436,
2414,
26,
26498,
23029,
58,
16,
60,
329,
24714,
287,
277,
5907,
60,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
2163,
3440,
7902,
53,
7,
22184,
3712,
10100,
26,
26498,
986,
2599,
25,
46912,
90,
43879,
2414,
92,
198,
198,
7902,
53,
7548,
286,
4600,
2220,
4851,
50,
44646,
383,
20150,
357,
25677,
11,
5721,
3891,
8,
389,
407,
198,
2302,
20216,
13,
4600,
22046,
63,
389,
3804,
284,
4600,
7902,
53,
13,
961,
44646,
198,
37811,
198,
8818,
3440,
7902,
53,
7,
22184,
3712,
10100,
26,
26498,
986,
2599,
25,
46912,
90,
43879,
2414,
92,
198,
220,
220,
220,
44189,
13,
961,
7,
22184,
11,
6060,
19778,
11,
2099,
796,
48436,
2414,
26,
26498,
23029,
930,
29,
24936,
90,
43879,
2414,
92,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
2163,
3440,
7902,
53,
7248,
7,
198,
220,
220,
220,
220,
220,
220,
220,
1438,
3712,
13940,
23650,
11,
198,
220,
220,
220,
220,
220,
220,
220,
277,
5907,
3712,
38469,
90,
10100,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
279,
2340,
796,
3259,
9783,
198,
220,
220,
220,
220,
220,
220,
220,
1281,
8912,
796,
357,
67,
11,
1312,
8,
4613,
288,
11,
198,
220,
220,
220,
220,
220,
220,
220,
269,
21370,
22046,
986,
11,
198,
220,
220,
220,
1267,
3712,
8912,
276,
6601,
12360,
198,
198,
7902,
53,
7548,
286,
4600,
2220,
4851,
5432,
316,
44646,
4600,
40664,
22046,
63,
389,
3804,
355,
21179,
7159,
284,
198,
7902,
53,
12,
25138,
5499,
13,
198,
37811,
198,
8818,
3440,
7902,
53,
7248,
7,
198,
220,
220,
220,
1438,
3712,
13940,
23650,
11,
198,
220,
220,
220,
277,
5907,
3712,
38469,
90,
10100,
5512,
198,
220,
220,
220,
279,
2340,
796,
3259,
9783,
198,
220,
220,
220,
1281,
8912,
796,
357,
67,
11,
1312,
8,
4613,
288,
11,
198,
220,
220,
220,
269,
21370,
22046,
986,
11,
198,
2599,
25,
8912,
276,
6601,
12360,
198,
220,
220,
220,
24314,
796,
24314,
1659,
7,
2220,
7902,
20304,
4340,
7,
69,
5907,
26,
269,
21370,
22046,
986,
828,
4129,
7,
79,
2340,
4008,
198,
220,
220,
220,
9387,
62,
754,
620,
7,
198,
220,
220,
220,
220,
220,
220,
220,
24314,
11,
198,
220,
220,
220,
220,
220,
220,
220,
357,
48369,
8,
4613,
7308,
13,
18206,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8774,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36147,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
720,
3672,
796,
410,
33327,
11122,
501,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
72,
8,
4613,
720,
7353,
8912,
7,
2220,
7902,
53,
16763,
69,
5907,
58,
72,
11208,
720,
40664,
22046,
986,
828,
1312,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
720,
48369,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
279,
2340,
11,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
1441,
42485,
6601,
12360,
7,
3672,
11,
279,
2340,
8,
198,
437,
198
] | 2.367205 | 3,592 |
# Most of the code here is copied from the Juno codebase
using REPL
using REPL.LineEdit
isREPL() = isdefined(Base, :active_repl) &&
isdefined(Base.active_repl, :interface) &&
isdefined(Base.active_repl.interface, :modes) &&
isdefined(Base.active_repl, :mistate) &&
isdefined(Base.active_repl.mistate, :current_mode)
juliaprompt = "julia> "
current_prompt = juliaprompt
function get_main_mode(repl=Base.active_repl)
mode = repl.interface.modes[1]
mode isa LineEdit.Prompt || error("no julia repl mode found")
mode
end
function hideprompt(f)
isREPL() || return f()
repl = Base.active_repl
mistate = repl.mistate
mode = mistate.current_mode
buf = String(take!(copy(LineEdit.buffer(mistate))))
# clear input buffer
truncate(LineEdit.buffer(mistate), 0)
LineEdit.refresh_multi_line(mistate)
print(stdout, "\e[1K\r")
r = f()
flush(stdout)
flush(stderr)
sleep(0.05)
# TODO Fix this
# pos = @rpc cursorpos()
pos = 1, 1
pos[1] != 0 && println()
# restore prompt
if applicable(LineEdit.write_prompt, stdout, mode)
LineEdit.write_prompt(stdout, mode)
elseif mode isa LineEdit.PrefixHistoryPrompt || :parent_prompt in fieldnames(typeof(mode))
LineEdit.write_prompt(stdout, mode.parent_prompt)
else
printstyled(stdout, current_prompt, color=:green)
end
truncate(LineEdit.buffer(mistate), 0)
# restore input buffer
LineEdit.edit_insert(LineEdit.buffer(mistate), buf)
LineEdit.refresh_multi_line(mistate)
r
end
const HAS_REPL_TRANSFORM = Ref{Bool}(false)
function hook_repl(repl)
if HAS_REPL_TRANSFORM[]
return
end
@debug "installing REPL hook"
if !isdefined(repl, :interface)
repl.interface = REPL.setup_interface(repl)
end
main_mode = get_main_mode(repl)
if VERSION > v"1.5-"
for _ in 1:20 # repl backend should be set up after 10s -- fall back to the pre-ast-transform approach otherwise
isdefined(Base, :active_repl_backend) && continue
sleep(0.5)
end
if isdefined(Base, :active_repl_backend)
push!(Base.active_repl_backend.ast_transforms, ast -> transform_backend(ast, repl, main_mode))
HAS_REPL_TRANSFORM[] = true
@debug "REPL AST transform installed"
return
end
end
main_mode.on_done = REPL.respond(repl, main_mode; pass_empty=false) do line
quote
$(evalrepl)(Main, $line, $repl, $main_mode)
end
end
@debug "legacy REPL hook installed"
HAS_REPL_TRANSFORM[] = true
return nothing
end
function transform_backend(ast, repl, main_mode)
quote
$(evalrepl)(Main, $(QuoteNode(ast)), $repl, $main_mode)
end
end
function evalrepl(m, line, repl, main_mode)
did_notify = false
return try
try
JSONRPC.send_notification(conn_endpoint[], "repl/starteval", nothing)
did_notify = true
catch err
@debug "Could not send repl/starteval notification" exception=(err, catch_backtrace())
end
r = run_with_backend() do
fix_displays()
f = () -> repleval(m, line, REPL.repl_filename(repl, main_mode.hist))
PROGRESS_ENABLED[] ? Logging.with_logger(f, VSCodeLogger()) : f()
end
if r isa EvalError
display_repl_error(stderr, r.err, r.bt)
nothing
elseif r isa EvalErrorStack
display_repl_error(stderr, r)
nothing
else
r
end
catch err
# This is for internal errors only.
Base.display_error(stderr, err, catch_backtrace())
nothing
finally
if did_notify
try
JSONRPC.send_notification(conn_endpoint[], "repl/finisheval", nothing)
catch err
@debug "Could not send repl/finisheval notification" exception=(err, catch_backtrace())
end
end
end
end
# don't inline this so we can find it in the stacktrace
@noinline function repleval(m, code::String, file)
args = VERSION >= v"1.5" ? (REPL.softscope, m, code, file) : (m, code, file)
return include_string(args...)
end
@noinline function repleval(m, code, _)
return Base.eval(m, code)
end
# basically the same as Base's `display_error`, with internal frames removed
function display_repl_error(io, err, bt)
st = stacktrace(crop_backtrace(bt))
printstyled(io, "ERROR: "; bold=true, color=Base.error_color())
showerror(IOContext(io, :limit => true), err, st)
println(io)
end
display_repl_error(io, err::LoadError, bt) = display_repl_error(io, err.error, bt)
function display_repl_error(io, stack::EvalErrorStack)
printstyled(io, "ERROR: "; bold=true, color=Base.error_color())
for (i, (err, bt)) in enumerate(reverse(stack.stack))
i !== 1 && print(io, "\ncaused by: ")
st = stacktrace(crop_backtrace(bt))
showerror(IOContext(io, :limit => true), err, st)
println(io)
end
end
function withpath(f, path)
tls = task_local_storage()
hassource = haskey(tls, :SOURCE_PATH)
hassource && (path′ = tls[:SOURCE_PATH])
tls[:SOURCE_PATH] = path
try
return f()
finally
hassource ? (tls[:SOURCE_PATH] = path′) : delete!(tls, :SOURCE_PATH)
end
end
| [
2,
4042,
286,
262,
2438,
994,
318,
18984,
422,
262,
49458,
2438,
8692,
198,
198,
3500,
45285,
198,
3500,
45285,
13,
13949,
18378,
198,
198,
271,
2200,
6489,
3419,
796,
318,
23211,
7,
14881,
11,
1058,
5275,
62,
35666,
8,
11405,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
23211,
7,
14881,
13,
5275,
62,
35666,
11,
1058,
39994,
8,
11405,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
23211,
7,
14881,
13,
5275,
62,
35666,
13,
39994,
11,
1058,
76,
4147,
8,
11405,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
23211,
7,
14881,
13,
5275,
62,
35666,
11,
1058,
37980,
378,
8,
11405,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
23211,
7,
14881,
13,
5275,
62,
35666,
13,
37980,
378,
11,
1058,
14421,
62,
14171,
8,
198,
198,
73,
32176,
499,
45700,
796,
366,
73,
43640,
29,
366,
198,
198,
14421,
62,
16963,
457,
796,
474,
32176,
499,
45700,
198,
198,
8818,
651,
62,
12417,
62,
14171,
7,
35666,
28,
14881,
13,
5275,
62,
35666,
8,
198,
220,
220,
220,
4235,
796,
2186,
13,
39994,
13,
76,
4147,
58,
16,
60,
198,
220,
220,
220,
4235,
318,
64,
6910,
18378,
13,
24129,
457,
8614,
4049,
7203,
3919,
474,
43640,
2186,
4235,
1043,
4943,
198,
220,
220,
220,
4235,
198,
437,
198,
198,
8818,
7808,
16963,
457,
7,
69,
8,
198,
220,
220,
220,
318,
2200,
6489,
3419,
8614,
1441,
277,
3419,
628,
220,
220,
220,
2186,
796,
7308,
13,
5275,
62,
35666,
198,
220,
220,
220,
4020,
378,
796,
2186,
13,
37980,
378,
198,
220,
220,
220,
4235,
796,
4020,
378,
13,
14421,
62,
14171,
628,
220,
220,
220,
42684,
796,
10903,
7,
20657,
0,
7,
30073,
7,
13949,
18378,
13,
22252,
7,
37980,
378,
35514,
628,
220,
220,
220,
1303,
1598,
5128,
11876,
198,
220,
220,
220,
40122,
378,
7,
13949,
18378,
13,
22252,
7,
37980,
378,
828,
657,
8,
198,
220,
220,
220,
6910,
18378,
13,
5420,
3447,
62,
41684,
62,
1370,
7,
37980,
378,
8,
628,
220,
220,
220,
3601,
7,
19282,
448,
11,
37082,
68,
58,
16,
42,
59,
81,
4943,
198,
220,
220,
220,
374,
796,
277,
3419,
628,
220,
220,
220,
24773,
7,
19282,
448,
8,
198,
220,
220,
220,
24773,
7,
301,
1082,
81,
8,
198,
220,
220,
220,
3993,
7,
15,
13,
2713,
8,
628,
220,
220,
220,
1303,
16926,
46,
13268,
428,
198,
220,
220,
220,
1303,
1426,
796,
2488,
81,
14751,
23493,
1930,
3419,
198,
220,
220,
220,
1426,
796,
352,
11,
352,
198,
220,
220,
220,
1426,
58,
16,
60,
14512,
657,
11405,
44872,
3419,
628,
220,
220,
220,
1303,
11169,
6152,
198,
220,
220,
220,
611,
9723,
7,
13949,
18378,
13,
13564,
62,
16963,
457,
11,
14367,
448,
11,
4235,
8,
198,
220,
220,
220,
220,
220,
220,
220,
6910,
18378,
13,
13564,
62,
16963,
457,
7,
19282,
448,
11,
4235,
8,
198,
220,
220,
220,
2073,
361,
4235,
318,
64,
6910,
18378,
13,
36698,
844,
18122,
24129,
457,
8614,
1058,
8000,
62,
16963,
457,
287,
2214,
14933,
7,
4906,
1659,
7,
14171,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
6910,
18378,
13,
13564,
62,
16963,
457,
7,
19282,
448,
11,
4235,
13,
8000,
62,
16963,
457,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
34365,
992,
7,
19282,
448,
11,
1459,
62,
16963,
457,
11,
3124,
28,
25,
14809,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
40122,
378,
7,
13949,
18378,
13,
22252,
7,
37980,
378,
828,
657,
8,
628,
220,
220,
220,
1303,
11169,
5128,
11876,
198,
220,
220,
220,
6910,
18378,
13,
19312,
62,
28463,
7,
13949,
18378,
13,
22252,
7,
37980,
378,
828,
42684,
8,
198,
220,
220,
220,
6910,
18378,
13,
5420,
3447,
62,
41684,
62,
1370,
7,
37980,
378,
8,
198,
220,
220,
220,
374,
198,
437,
198,
198,
9979,
33930,
62,
2200,
6489,
62,
5446,
15037,
21389,
796,
6524,
90,
33,
970,
92,
7,
9562,
8,
198,
8818,
8011,
62,
35666,
7,
35666,
8,
198,
220,
220,
220,
611,
33930,
62,
2200,
6489,
62,
5446,
15037,
21389,
21737,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2488,
24442,
366,
8625,
9221,
45285,
8011,
1,
198,
220,
220,
220,
611,
5145,
271,
23211,
7,
35666,
11,
1058,
39994,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2186,
13,
39994,
796,
45285,
13,
40406,
62,
39994,
7,
35666,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1388,
62,
14171,
796,
651,
62,
12417,
62,
14171,
7,
35666,
8,
628,
220,
220,
220,
611,
44156,
2849,
1875,
410,
1,
16,
13,
20,
21215,
198,
220,
220,
220,
220,
220,
220,
220,
329,
4808,
287,
352,
25,
1238,
1303,
2186,
30203,
815,
307,
900,
510,
706,
838,
82,
1377,
2121,
736,
284,
262,
662,
12,
459,
12,
35636,
3164,
4306,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
23211,
7,
14881,
11,
1058,
5275,
62,
35666,
62,
1891,
437,
8,
11405,
2555,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3993,
7,
15,
13,
20,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
611,
318,
23211,
7,
14881,
11,
1058,
5275,
62,
35666,
62,
1891,
437,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
14881,
13,
5275,
62,
35666,
62,
1891,
437,
13,
459,
62,
7645,
23914,
11,
6468,
4613,
6121,
62,
1891,
437,
7,
459,
11,
2186,
11,
1388,
62,
14171,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
33930,
62,
2200,
6489,
62,
5446,
15037,
21389,
21737,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
24442,
366,
2200,
6489,
29273,
6121,
6589,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1388,
62,
14171,
13,
261,
62,
28060,
796,
45285,
13,
5546,
7,
35666,
11,
1388,
62,
14171,
26,
1208,
62,
28920,
28,
9562,
8,
466,
1627,
198,
220,
220,
220,
220,
220,
220,
220,
9577,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
29568,
18206,
35666,
5769,
13383,
11,
720,
1370,
11,
720,
35666,
11,
720,
12417,
62,
14171,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2488,
24442,
366,
1455,
1590,
45285,
8011,
6589,
1,
198,
220,
220,
220,
33930,
62,
2200,
6489,
62,
5446,
15037,
21389,
21737,
796,
2081,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
8818,
6121,
62,
1891,
437,
7,
459,
11,
2186,
11,
1388,
62,
14171,
8,
198,
220,
220,
220,
9577,
198,
220,
220,
220,
220,
220,
220,
220,
29568,
18206,
35666,
5769,
13383,
11,
29568,
25178,
19667,
7,
459,
36911,
720,
35666,
11,
720,
12417,
62,
14171,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
5418,
35666,
7,
76,
11,
1627,
11,
2186,
11,
1388,
62,
14171,
8,
198,
220,
220,
220,
750,
62,
1662,
1958,
796,
3991,
198,
220,
220,
220,
1441,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19449,
49,
5662,
13,
21280,
62,
1662,
2649,
7,
37043,
62,
437,
4122,
58,
4357,
366,
35666,
14,
9688,
18206,
1600,
2147,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
750,
62,
1662,
1958,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
4929,
11454,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
24442,
366,
23722,
407,
3758,
2186,
14,
9688,
18206,
14483,
1,
6631,
16193,
8056,
11,
4929,
62,
1891,
40546,
28955,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
374,
796,
1057,
62,
4480,
62,
1891,
437,
3419,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4259,
62,
6381,
26024,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
277,
796,
7499,
4613,
1128,
293,
2100,
7,
76,
11,
1627,
11,
45285,
13,
35666,
62,
34345,
7,
35666,
11,
1388,
62,
14171,
13,
10034,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
38688,
49,
7597,
62,
1677,
6242,
30465,
21737,
5633,
5972,
2667,
13,
4480,
62,
6404,
1362,
7,
69,
11,
569,
6173,
1098,
11187,
1362,
28955,
1058,
277,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
611,
374,
318,
64,
26439,
12331,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3359,
62,
35666,
62,
18224,
7,
301,
1082,
81,
11,
374,
13,
8056,
11,
374,
13,
18347,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
374,
318,
64,
26439,
12331,
25896,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3359,
62,
35666,
62,
18224,
7,
301,
1082,
81,
11,
374,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
374,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
4929,
11454,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
770,
318,
329,
5387,
8563,
691,
13,
198,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
13812,
62,
18224,
7,
301,
1082,
81,
11,
11454,
11,
4929,
62,
1891,
40546,
28955,
198,
220,
220,
220,
220,
220,
220,
220,
2147,
198,
220,
220,
220,
3443,
198,
220,
220,
220,
220,
220,
220,
220,
611,
750,
62,
1662,
1958,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19449,
49,
5662,
13,
21280,
62,
1662,
2649,
7,
37043,
62,
437,
4122,
58,
4357,
366,
35666,
14,
15643,
271,
258,
2100,
1600,
2147,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4929,
11454,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
24442,
366,
23722,
407,
3758,
2186,
14,
15643,
271,
258,
2100,
14483,
1,
6631,
16193,
8056,
11,
4929,
62,
1891,
40546,
28955,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2,
836,
470,
26098,
428,
523,
356,
460,
1064,
340,
287,
262,
8931,
40546,
198,
31,
3919,
45145,
2163,
1128,
293,
2100,
7,
76,
11,
2438,
3712,
10100,
11,
2393,
8,
198,
220,
220,
220,
26498,
796,
44156,
2849,
18189,
410,
1,
16,
13,
20,
1,
5633,
357,
2200,
6489,
13,
4215,
29982,
11,
285,
11,
2438,
11,
2393,
8,
1058,
357,
76,
11,
2438,
11,
2393,
8,
198,
220,
220,
220,
1441,
2291,
62,
8841,
7,
22046,
23029,
198,
437,
198,
198,
31,
3919,
45145,
2163,
1128,
293,
2100,
7,
76,
11,
2438,
11,
4808,
8,
198,
220,
220,
220,
1441,
7308,
13,
18206,
7,
76,
11,
2438,
8,
198,
437,
198,
198,
2,
6209,
262,
976,
355,
7308,
338,
4600,
13812,
62,
18224,
47671,
351,
5387,
13431,
4615,
198,
8818,
3359,
62,
35666,
62,
18224,
7,
952,
11,
11454,
11,
275,
83,
8,
198,
220,
220,
220,
336,
796,
8931,
40546,
7,
31476,
62,
1891,
40546,
7,
18347,
4008,
198,
220,
220,
220,
3601,
34365,
992,
7,
952,
11,
366,
24908,
25,
366,
26,
10758,
28,
7942,
11,
3124,
28,
14881,
13,
18224,
62,
8043,
28955,
198,
220,
220,
220,
14643,
1472,
7,
9399,
21947,
7,
952,
11,
1058,
32374,
5218,
2081,
828,
11454,
11,
336,
8,
198,
220,
220,
220,
44872,
7,
952,
8,
198,
437,
198,
13812,
62,
35666,
62,
18224,
7,
952,
11,
11454,
3712,
8912,
12331,
11,
275,
83,
8,
796,
3359,
62,
35666,
62,
18224,
7,
952,
11,
11454,
13,
18224,
11,
275,
83,
8,
198,
198,
8818,
3359,
62,
35666,
62,
18224,
7,
952,
11,
8931,
3712,
36,
2100,
12331,
25896,
8,
198,
220,
220,
220,
3601,
34365,
992,
7,
952,
11,
366,
24908,
25,
366,
26,
10758,
28,
7942,
11,
3124,
28,
14881,
13,
18224,
62,
8043,
28955,
198,
220,
220,
220,
329,
357,
72,
11,
357,
8056,
11,
275,
83,
4008,
287,
27056,
378,
7,
50188,
7,
25558,
13,
25558,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1312,
5145,
855,
352,
11405,
3601,
7,
952,
11,
37082,
77,
6888,
1484,
416,
25,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
336,
796,
8931,
40546,
7,
31476,
62,
1891,
40546,
7,
18347,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
14643,
1472,
7,
9399,
21947,
7,
952,
11,
1058,
32374,
5218,
2081,
828,
11454,
11,
336,
8,
198,
220,
220,
220,
220,
220,
220,
220,
44872,
7,
952,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
351,
6978,
7,
69,
11,
3108,
8,
198,
220,
220,
220,
256,
7278,
796,
4876,
62,
12001,
62,
35350,
3419,
198,
220,
220,
220,
468,
10459,
796,
468,
2539,
7,
83,
7278,
11,
1058,
47690,
62,
34219,
8,
198,
220,
220,
220,
468,
10459,
11405,
357,
6978,
17478,
796,
256,
7278,
58,
25,
47690,
62,
34219,
12962,
198,
220,
220,
220,
256,
7278,
58,
25,
47690,
62,
34219,
60,
796,
3108,
198,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
277,
3419,
198,
220,
220,
220,
3443,
198,
220,
220,
220,
220,
220,
220,
220,
468,
10459,
5633,
357,
83,
7278,
58,
25,
47690,
62,
34219,
60,
796,
3108,
17478,
8,
1058,
12233,
0,
7,
83,
7278,
11,
1058,
47690,
62,
34219,
8,
198,
220,
220,
220,
886,
198,
437,
198
] | 2.288494 | 2,364 |
using StackOverflow
"""
searcherror(intitle::String)
Adding the ability to search for an error through StackOverflow.jl while in the Julia Terminal.
"""
function searcherror(intitle::String)
data = replace(intitle, " " => "%20")
r = HTTP.request("GET", "https://api.stackexchange.com/2.2/search?order=desc&sort=activity&intitle=$(data)&site=stackoverflow")
json_obj = StackOverflow.convert_HTTP_Response_To_JSON(r)
makequestionsarray(json_obj)
end
| [
3500,
23881,
5886,
11125,
198,
198,
37811,
198,
220,
220,
220,
9622,
2044,
1472,
7,
600,
2578,
3712,
10100,
8,
198,
198,
32901,
262,
2694,
284,
2989,
329,
281,
4049,
832,
23881,
5886,
11125,
13,
20362,
981,
287,
262,
22300,
24523,
13,
198,
37811,
198,
8818,
9622,
2044,
1472,
7,
600,
2578,
3712,
10100,
8,
198,
220,
220,
220,
1366,
796,
6330,
7,
600,
2578,
11,
366,
366,
5218,
36521,
1238,
4943,
198,
220,
220,
220,
374,
796,
14626,
13,
25927,
7203,
18851,
1600,
366,
5450,
1378,
15042,
13,
301,
330,
365,
87,
3803,
13,
785,
14,
17,
13,
17,
14,
12947,
30,
2875,
28,
20147,
5,
30619,
28,
21797,
5,
600,
2578,
43641,
7,
7890,
8,
5,
15654,
28,
25558,
2502,
11125,
4943,
198,
220,
220,
220,
33918,
62,
26801,
796,
23881,
5886,
11125,
13,
1102,
1851,
62,
40717,
62,
31077,
62,
2514,
62,
40386,
7,
81,
8,
198,
220,
220,
220,
787,
6138,
507,
18747,
7,
17752,
62,
26801,
8,
198,
437,
198
] | 2.848485 | 165 |
<reponame>alpv95/RobotDojo.jl
@testset "Simulator: simulate" begin
## hopper
q1 = nominal_configuration(hopper)
v1 = zeros(hopper.nq)
h = 0.01
T = 100
# simulator
s = Simulator(hopper, T, h=h, diff_sol=true, sim_opts=RoboDojo.SimulatorOptions(record=true))
# step
q2 = step!(s, q1, v1, zeros(hopper.nu), 1)
@test sum(q2) != 0.0
# simulate
status = simulate!(s, q1, v1, reset_traj=true)
@test status
## quadruped
q1 = nominal_configuration(quadruped)
v1 = zeros(quadruped.nq)
h = 0.01
T = 100
# simulator
s = Simulator(quadruped, T, h=h, diff_sol=true, sim_opts=RoboDojo.SimulatorOptions(record=true))
# step
q2 = step!(s, q1, v1, zeros(quadruped.nu), 1)
@test sum(q2) != 0.0
# simulate
status = simulate!(s, q1, v1, reset_traj=true)
@test status
## biped
q1 = nominal_configuration(biped)
v1 = zeros(biped.nq)
h = 0.01
T = 100
# simulator
s = Simulator(biped, T, h=h, diff_sol=true, sim_opts=RoboDojo.SimulatorOptions(record=true))
# step
q2 = step!(s, q1, v1, zeros(biped.nu), 1)
@test sum(q2) != 0.0
# simulate
status = simulate!(s, q1, v1, reset_traj=true)
@test status
# process timing results
RoboDojo.process!(s.stats, 1)
@test sum(s.stats.policy_time) > 0.0
@test s.stats.policy_mean[1] > 0.0
@test sum(s.stats.sim_time) > 0.0
@test s.stats.sim_mean[1] > 0.0
end
| [
27,
7856,
261,
480,
29,
282,
79,
85,
3865,
14,
14350,
313,
5211,
7639,
13,
20362,
198,
31,
9288,
2617,
366,
8890,
8927,
25,
29308,
1,
2221,
220,
198,
220,
220,
220,
22492,
8169,
2848,
198,
220,
220,
220,
10662,
16,
796,
26934,
62,
11250,
3924,
7,
8873,
2848,
8,
198,
220,
220,
220,
410,
16,
796,
1976,
27498,
7,
8873,
2848,
13,
77,
80,
8,
628,
220,
220,
220,
289,
796,
657,
13,
486,
198,
220,
220,
220,
309,
796,
1802,
628,
220,
220,
220,
1303,
35375,
220,
198,
220,
220,
220,
264,
796,
13942,
7,
8873,
2848,
11,
309,
11,
289,
28,
71,
11,
814,
62,
34453,
28,
7942,
11,
985,
62,
404,
912,
28,
14350,
78,
5211,
7639,
13,
8890,
8927,
29046,
7,
22105,
28,
7942,
4008,
628,
220,
220,
220,
1303,
2239,
198,
220,
220,
220,
10662,
17,
796,
2239,
0,
7,
82,
11,
10662,
16,
11,
410,
16,
11,
1976,
27498,
7,
8873,
2848,
13,
28803,
828,
352,
8,
198,
220,
220,
220,
2488,
9288,
2160,
7,
80,
17,
8,
14512,
657,
13,
15,
628,
220,
220,
220,
1303,
29308,
198,
220,
220,
220,
3722,
796,
29308,
0,
7,
82,
11,
10662,
16,
11,
410,
16,
11,
13259,
62,
9535,
73,
28,
7942,
8,
198,
220,
220,
220,
2488,
9288,
3722,
628,
220,
220,
220,
22492,
40977,
9124,
198,
220,
220,
220,
10662,
16,
796,
26934,
62,
11250,
3924,
7,
47003,
622,
9124,
8,
198,
220,
220,
220,
410,
16,
796,
1976,
27498,
7,
47003,
622,
9124,
13,
77,
80,
8,
628,
220,
220,
220,
289,
796,
657,
13,
486,
198,
220,
220,
220,
309,
796,
1802,
628,
220,
220,
220,
1303,
35375,
220,
198,
220,
220,
220,
264,
796,
13942,
7,
47003,
622,
9124,
11,
309,
11,
289,
28,
71,
11,
814,
62,
34453,
28,
7942,
11,
985,
62,
404,
912,
28,
14350,
78,
5211,
7639,
13,
8890,
8927,
29046,
7,
22105,
28,
7942,
4008,
628,
220,
220,
220,
1303,
2239,
198,
220,
220,
220,
10662,
17,
796,
2239,
0,
7,
82,
11,
10662,
16,
11,
410,
16,
11,
1976,
27498,
7,
47003,
622,
9124,
13,
28803,
828,
352,
8,
198,
220,
220,
220,
2488,
9288,
2160,
7,
80,
17,
8,
14512,
657,
13,
15,
628,
220,
220,
220,
1303,
29308,
198,
220,
220,
220,
3722,
796,
29308,
0,
7,
82,
11,
10662,
16,
11,
410,
16,
11,
13259,
62,
9535,
73,
28,
7942,
8,
198,
220,
220,
220,
2488,
9288,
3722,
628,
220,
220,
220,
22492,
14141,
276,
220,
198,
220,
220,
220,
10662,
16,
796,
26934,
62,
11250,
3924,
7,
65,
46647,
8,
198,
220,
220,
220,
410,
16,
796,
1976,
27498,
7,
65,
46647,
13,
77,
80,
8,
628,
220,
220,
220,
289,
796,
657,
13,
486,
198,
220,
220,
220,
309,
796,
1802,
628,
220,
220,
220,
1303,
35375,
220,
198,
220,
220,
220,
264,
796,
13942,
7,
65,
46647,
11,
309,
11,
289,
28,
71,
11,
814,
62,
34453,
28,
7942,
11,
985,
62,
404,
912,
28,
14350,
78,
5211,
7639,
13,
8890,
8927,
29046,
7,
22105,
28,
7942,
4008,
628,
220,
220,
220,
1303,
2239,
198,
220,
220,
220,
10662,
17,
796,
2239,
0,
7,
82,
11,
10662,
16,
11,
410,
16,
11,
1976,
27498,
7,
65,
46647,
13,
28803,
828,
352,
8,
198,
220,
220,
220,
2488,
9288,
2160,
7,
80,
17,
8,
14512,
657,
13,
15,
628,
220,
220,
220,
1303,
29308,
198,
220,
220,
220,
3722,
796,
29308,
0,
7,
82,
11,
10662,
16,
11,
410,
16,
11,
13259,
62,
9535,
73,
28,
7942,
8,
198,
220,
220,
220,
2488,
9288,
3722,
628,
220,
220,
220,
1303,
1429,
10576,
2482,
198,
220,
220,
220,
39702,
5211,
7639,
13,
14681,
0,
7,
82,
13,
34242,
11,
352,
8,
198,
220,
220,
220,
2488,
9288,
2160,
7,
82,
13,
34242,
13,
30586,
62,
2435,
8,
1875,
657,
13,
15,
198,
220,
220,
220,
2488,
9288,
264,
13,
34242,
13,
30586,
62,
32604,
58,
16,
60,
1875,
657,
13,
15,
628,
220,
220,
220,
2488,
9288,
2160,
7,
82,
13,
34242,
13,
14323,
62,
2435,
8,
1875,
657,
13,
15,
198,
220,
220,
220,
2488,
9288,
264,
13,
34242,
13,
14323,
62,
32604,
58,
16,
60,
1875,
657,
13,
15,
198,
437,
198
] | 2.086525 | 705 |
<reponame>mcabbott/TensorCast.jl
using TensorCast
using Test
using LinearAlgebra
using Logging
using StaticArrays
using OffsetArrays
using Einsum
using Strided
using LazyArrays
using LoopVectorization
@testset "ex-@shape" begin include("shape.jl") end
@testset "@reduce" begin include("reduce.jl") end
@testset "@cast" begin include("casting.jl") end
@testset "@matmul" begin include("mul.jl") end
@testset "slice/view" begin include("cat.jl") end
@testset "old readmes" begin include("old.jl") end
@testset "new in 0.2" begin include("two.jl") end
@testset "new in 0.4" begin include("four.jl") end | [
27,
7856,
261,
480,
29,
23209,
6485,
1252,
14,
51,
22854,
19248,
13,
20362,
198,
198,
3500,
309,
22854,
19248,
198,
198,
3500,
6208,
198,
3500,
44800,
2348,
29230,
198,
3500,
5972,
2667,
198,
198,
3500,
36125,
3163,
20477,
198,
3500,
3242,
2617,
3163,
20477,
198,
3500,
412,
1040,
388,
198,
3500,
4285,
1384,
198,
3500,
406,
12582,
3163,
20477,
198,
3500,
26304,
38469,
1634,
198,
198,
31,
9288,
2617,
366,
1069,
12,
31,
43358,
1,
2221,
2291,
7203,
43358,
13,
20362,
4943,
886,
198,
31,
9288,
2617,
44212,
445,
7234,
1,
2221,
2291,
7203,
445,
7234,
13,
20362,
4943,
220,
886,
198,
31,
9288,
2617,
44212,
2701,
1,
220,
220,
2221,
2291,
7203,
19913,
13,
20362,
4943,
886,
198,
31,
9288,
2617,
44212,
6759,
76,
377,
1,
2221,
2291,
7203,
76,
377,
13,
20362,
4943,
220,
220,
220,
220,
886,
198,
198,
31,
9288,
2617,
366,
48369,
14,
1177,
1,
220,
2221,
2291,
7203,
9246,
13,
20362,
4943,
886,
198,
31,
9288,
2617,
366,
727,
1100,
6880,
1,
2221,
2291,
7203,
727,
13,
20362,
4943,
886,
198,
31,
9288,
2617,
366,
3605,
287,
657,
13,
17,
1,
220,
2221,
2291,
7203,
11545,
13,
20362,
4943,
886,
198,
31,
9288,
2617,
366,
3605,
287,
657,
13,
19,
1,
2221,
2291,
7203,
14337,
13,
20362,
4943,
886
] | 2.837963 | 216 |
<filename>profile/profile_meanfield.jl
using cascadeddecay, QuantumOptics, meanfield
const γ = 1.
const e_dipole = [0,0,1.]
const T = [0:0.05:10]
#atoms = Atom[Atom(position, e_dipole) for position=cube(0.627)]
#atoms = Atom[Atom(position, e_dipole) for position=cube(0.2)]
atoms = Atom[Atom(position, e_dipole) for position=chain(0.4,30)]
system = CascadedDecaySystem(atoms, γ)
# Meanfield timeevolution
N = length(system.atoms)
sz0 = zeros(ComplexF64, N)
sp0 = zeros(ComplexF64, N) .- 0.5
println("meanfield +z")
@time T_mf, sz_mf, sp_mf = meanfield_timeevolution(T, system, sz0, sp0)
@time T_mf, sz_mf, sp_mf = meanfield_timeevolution(T, system, sz0, sp0)
# Meanfield xyz timeevolution
N = length(system.atoms)
sx0 = zeros(Float64, N) .- 1
sy0 = zeros(Float64, N)
sz0 = zeros(Float64, N)
println("meanfield xyz")
@time T_xmf, sx_xmf, sy_xmf, sz_xmf= meanfield.meanfield_timeevolution2(T, system, sx0, sy0, sz0)
@time T_xmf, sx_xmf, sy_xmf, sz_xmf= meanfield.meanfield_timeevolution2(T, system, sx0, sy0, sz0)
# Correlation included timeevolution
N = length(system.atoms)
sz0 = zeros(ComplexF64, N)
sp0 = zeros(ComplexF64, N) .- 0.5
Cpm0 = zeros(ComplexF64, N, N)
Cpz0 = zeros(ComplexF64, N, N)
Cpp0 = zeros(ComplexF64, N, N)
Czz0 = zeros(ComplexF64, N, N)
println("correlation +z")
@time T_cor, sz_cor, sp_cor = correlation_timeevolution(T, system, sz0, sp0, Cpm0, Cpz0, Cpp0, Czz0)
@time T_cor, sz_cor, sp_cor = correlation_timeevolution(T, system, sz0, sp0, Cpm0, Cpz0, Cpp0, Czz0)
# Correlation included timeevolution xyz
N = length(system.atoms)
sx0 = zeros(Float64, N) .- 1
sy0 = zeros(Float64, N)
sz0 = zeros(Float64, N)
C0 = Dict{AbstractString, Matrix{Float64}}()
C0["xx"] = zeros(Float64, N, N) .+ 1
C0["yy"] = zeros(Float64, N, N)
C0["zz"] = zeros(Float64, N, N)
C0["xy"] = zeros(Float64, N, N)
C0["xz"] = zeros(Float64, N, N)
C0["yz"] = zeros(Float64, N, N)
#@time T_xcor, sx_xcor, sy_xcor, sz_xcor, C_xcor = meanfield.correlation_timeevolution2(T, system, sx0, sy0, sz0, C0)
#@time T_xcor, sx_xcor, sy_xcor, sz_xcor, C_xcor = meanfield.correlation_timeevolution2(T, system, sx0, sy0, sz0, C0)
println("correlation xyz")
@time T_xcor, sx_xcor, sy_xcor, sz_xcor, C_xcor = meanfield.correlation_timeevolution3(T, system, sx0, sy0, sz0, C0)
@time T_xcor, sx_xcor, sy_xcor, sz_xcor, C_xcor = meanfield.correlation_timeevolution3(T, system, sx0, sy0, sz0, C0)
println(norm(sz_xcor[end]-sz_cor[end])) | [
27,
34345,
29,
13317,
14,
13317,
62,
32604,
3245,
13,
20362,
198,
3500,
49164,
5286,
12501,
323,
11,
29082,
27871,
873,
11,
1612,
3245,
628,
198,
9979,
7377,
111,
796,
352,
13,
198,
9979,
304,
62,
67,
541,
2305,
796,
685,
15,
11,
15,
11,
16,
8183,
198,
9979,
309,
796,
685,
15,
25,
15,
13,
2713,
25,
940,
60,
198,
198,
2,
265,
3150,
796,
33102,
58,
2953,
296,
7,
9150,
11,
304,
62,
67,
541,
2305,
8,
329,
2292,
28,
40296,
7,
15,
13,
49856,
15437,
198,
2,
265,
3150,
796,
33102,
58,
2953,
296,
7,
9150,
11,
304,
62,
67,
541,
2305,
8,
329,
2292,
28,
40296,
7,
15,
13,
17,
15437,
198,
265,
3150,
796,
33102,
58,
2953,
296,
7,
9150,
11,
304,
62,
67,
541,
2305,
8,
329,
2292,
28,
7983,
7,
15,
13,
19,
11,
1270,
15437,
198,
10057,
796,
327,
3372,
5286,
10707,
323,
11964,
7,
265,
3150,
11,
7377,
111,
8,
628,
198,
2,
22728,
3245,
640,
1990,
2122,
198,
45,
796,
4129,
7,
10057,
13,
265,
3150,
8,
198,
82,
89,
15,
796,
1976,
27498,
7,
5377,
11141,
37,
2414,
11,
399,
8,
198,
2777,
15,
796,
1976,
27498,
7,
5377,
11141,
37,
2414,
11,
399,
8,
764,
12,
657,
13,
20,
198,
198,
35235,
7203,
32604,
3245,
1343,
89,
4943,
198,
31,
2435,
309,
62,
76,
69,
11,
264,
89,
62,
76,
69,
11,
599,
62,
76,
69,
796,
1612,
3245,
62,
2435,
1990,
2122,
7,
51,
11,
1080,
11,
264,
89,
15,
11,
599,
15,
8,
198,
31,
2435,
309,
62,
76,
69,
11,
264,
89,
62,
76,
69,
11,
599,
62,
76,
69,
796,
1612,
3245,
62,
2435,
1990,
2122,
7,
51,
11,
1080,
11,
264,
89,
15,
11,
599,
15,
8,
198,
198,
2,
22728,
3245,
2124,
45579,
640,
1990,
2122,
198,
45,
796,
4129,
7,
10057,
13,
265,
3150,
8,
198,
82,
87,
15,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
8,
764,
12,
352,
198,
1837,
15,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
8,
198,
82,
89,
15,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
8,
198,
198,
35235,
7203,
32604,
3245,
2124,
45579,
4943,
198,
31,
2435,
309,
62,
87,
76,
69,
11,
264,
87,
62,
87,
76,
69,
11,
827,
62,
87,
76,
69,
11,
264,
89,
62,
87,
76,
69,
28,
1612,
3245,
13,
32604,
3245,
62,
2435,
1990,
2122,
17,
7,
51,
11,
1080,
11,
264,
87,
15,
11,
827,
15,
11,
264,
89,
15,
8,
198,
31,
2435,
309,
62,
87,
76,
69,
11,
264,
87,
62,
87,
76,
69,
11,
827,
62,
87,
76,
69,
11,
264,
89,
62,
87,
76,
69,
28,
1612,
3245,
13,
32604,
3245,
62,
2435,
1990,
2122,
17,
7,
51,
11,
1080,
11,
264,
87,
15,
11,
827,
15,
11,
264,
89,
15,
8,
198,
198,
2,
2744,
49501,
3017,
640,
1990,
2122,
198,
45,
796,
4129,
7,
10057,
13,
265,
3150,
8,
198,
82,
89,
15,
796,
1976,
27498,
7,
5377,
11141,
37,
2414,
11,
399,
8,
198,
2777,
15,
796,
1976,
27498,
7,
5377,
11141,
37,
2414,
11,
399,
8,
764,
12,
657,
13,
20,
198,
34,
4426,
15,
796,
1976,
27498,
7,
5377,
11141,
37,
2414,
11,
399,
11,
399,
8,
198,
34,
79,
89,
15,
796,
1976,
27498,
7,
5377,
11141,
37,
2414,
11,
399,
11,
399,
8,
198,
34,
381,
15,
796,
1976,
27498,
7,
5377,
11141,
37,
2414,
11,
399,
11,
399,
8,
198,
34,
3019,
15,
796,
1976,
27498,
7,
5377,
11141,
37,
2414,
11,
399,
11,
399,
8,
198,
198,
35235,
7203,
10215,
49501,
1343,
89,
4943,
198,
31,
2435,
309,
62,
10215,
11,
264,
89,
62,
10215,
11,
599,
62,
10215,
796,
16096,
62,
2435,
1990,
2122,
7,
51,
11,
1080,
11,
264,
89,
15,
11,
599,
15,
11,
327,
4426,
15,
11,
327,
79,
89,
15,
11,
327,
381,
15,
11,
327,
3019,
15,
8,
198,
31,
2435,
309,
62,
10215,
11,
264,
89,
62,
10215,
11,
599,
62,
10215,
796,
16096,
62,
2435,
1990,
2122,
7,
51,
11,
1080,
11,
264,
89,
15,
11,
599,
15,
11,
327,
4426,
15,
11,
327,
79,
89,
15,
11,
327,
381,
15,
11,
327,
3019,
15,
8,
198,
198,
2,
2744,
49501,
3017,
640,
1990,
2122,
2124,
45579,
198,
45,
796,
4129,
7,
10057,
13,
265,
3150,
8,
198,
82,
87,
15,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
8,
764,
12,
352,
198,
1837,
15,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
8,
198,
82,
89,
15,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
8,
198,
34,
15,
796,
360,
713,
90,
23839,
10100,
11,
24936,
90,
43879,
2414,
11709,
3419,
198,
34,
15,
14692,
5324,
8973,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
11,
399,
8,
764,
10,
352,
198,
34,
15,
14692,
22556,
8973,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
11,
399,
8,
198,
34,
15,
14692,
3019,
8973,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
11,
399,
8,
198,
34,
15,
14692,
5431,
8973,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
11,
399,
8,
198,
34,
15,
14692,
87,
89,
8973,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
11,
399,
8,
198,
34,
15,
14692,
45579,
8973,
796,
1976,
27498,
7,
43879,
2414,
11,
399,
11,
399,
8,
198,
198,
2,
31,
2435,
309,
62,
87,
10215,
11,
264,
87,
62,
87,
10215,
11,
827,
62,
87,
10215,
11,
264,
89,
62,
87,
10215,
11,
327,
62,
87,
10215,
796,
1612,
3245,
13,
10215,
49501,
62,
2435,
1990,
2122,
17,
7,
51,
11,
1080,
11,
264,
87,
15,
11,
827,
15,
11,
264,
89,
15,
11,
327,
15,
8,
198,
2,
31,
2435,
309,
62,
87,
10215,
11,
264,
87,
62,
87,
10215,
11,
827,
62,
87,
10215,
11,
264,
89,
62,
87,
10215,
11,
327,
62,
87,
10215,
796,
1612,
3245,
13,
10215,
49501,
62,
2435,
1990,
2122,
17,
7,
51,
11,
1080,
11,
264,
87,
15,
11,
827,
15,
11,
264,
89,
15,
11,
327,
15,
8,
198,
198,
35235,
7203,
10215,
49501,
2124,
45579,
4943,
198,
31,
2435,
309,
62,
87,
10215,
11,
264,
87,
62,
87,
10215,
11,
827,
62,
87,
10215,
11,
264,
89,
62,
87,
10215,
11,
327,
62,
87,
10215,
796,
1612,
3245,
13,
10215,
49501,
62,
2435,
1990,
2122,
18,
7,
51,
11,
1080,
11,
264,
87,
15,
11,
827,
15,
11,
264,
89,
15,
11,
327,
15,
8,
198,
31,
2435,
309,
62,
87,
10215,
11,
264,
87,
62,
87,
10215,
11,
827,
62,
87,
10215,
11,
264,
89,
62,
87,
10215,
11,
327,
62,
87,
10215,
796,
1612,
3245,
13,
10215,
49501,
62,
2435,
1990,
2122,
18,
7,
51,
11,
1080,
11,
264,
87,
15,
11,
827,
15,
11,
264,
89,
15,
11,
327,
15,
8,
198,
198,
35235,
7,
27237,
7,
82,
89,
62,
87,
10215,
58,
437,
45297,
82,
89,
62,
10215,
58,
437,
60,
4008
] | 2.089733 | 1,159 |
# Geometric Utilities
# Areas
export triangle_area, circle_area, annulus_area
triangle_area(a, b, c) =
let s = (a + b + c)/2.0
sqrt(max(0.0, s*(s - a)*(s - b)*(s - c)))
end
circle_area(r) = π*r^2
annulus_area(rₒ, rᵢ) = π*(rₒ^2 - rᵢ^2)
project_to_world(surf) =
transform(surf, inverse_transformation(frame_at(surf, 0, 0)))
#=
Given a poligonal line described by its vertices, we need to compute another
polygonal line that is parallel to the first one.
=#
v_in_v(v0, v1) =
let v = v0 + v1
v*dot(v0, v0)/dot(v, v0)
end
rotated_v(v, alpha) =
vpol(pol_rho(v), pol_phi(v) + alpha)
centered_rectangle(p0, w, p1) =
let v0 = p1 - p0,
v1 = rotated_v(v0, pi/2),
c = loc_from_o_vx_vy(p0, v0, v1)
rectangle(c-vy(w/2, c.cs), distance(p0, p1), w)
end
offset_vertices(ps::Locs, d::Real, closed) =
let qs = closed ? [ps[end], ps..., ps[1]] : ps,
vs = map((p0, p1) -> rotated_v(unitized(p1 - p0)*d, pi/2), qs[1:end-1], qs[2:end]),
ws = map(v_in_v, vs[1:end-1], vs[2:end])
map(+, ps, closed ? ws : [vs[1], ws..., vs[end]])
end
offset(path, d::Real) = d == 0 ? path : nonzero_offset(path, d)
nonzero_offset(path::RectangularPath, d::Real) =
rectangular_path(add_xy(path.corner, d, d), path.dx - 2d, path.dy - 2d)
nonzero_offset(path::OpenPolygonalPath, d::Real) =
open_polygonal_path(offset_vertices(path.vertices, d, false))
nonzero_offset(path::ClosedPolygonalPath, d::Real) =
closed_polygonal_path(offset_vertices(path.vertices, d, true))
nonzero_offset(path::CircularPath, d::Real) =
circular_path(path.center, path.radius - d)
nonzero_offset(path::ArcPath, d::Real) =
arc_path(path.center, path.radius - d, path.start_angle, path.amplitude)
export offset
# Polygon combination
closest_vertices_indexes(pts1, pts2) =
# This is a brute force method. There are better algorithms to do this.
let min_dist = Inf,
min_i = nothing,
min_j = nothing
for (i, pt1) in enumerate(pts1), (j, pt2) in enumerate(pts2)
let dist = distance(pt1, pt2)
if dist < min_dist
min_dist = dist
min_i = i
min_j = j
end
end
end
min_i, min_j
end
point_in_segment(r, p, q) =
let pr = r-p,
pq = q-p,
rx = cx(pr)/cx(pq),
ry = cy(pr)/cy(pq)
isapprox(rx, ry) && isapprox(ry, cz(pr)/cz(pq))
end
collinear_segments(p1, p2, q1, q2) =
point_in_segment(q1, p1, p2) &&
point_in_segment(q2, p1, p2)
collinear_vertices_indexes(pts1, pts2) =
for (i1, p1) in enumerate(pts1)
let i2 = i1%length(pts1)+1,
p2 = pts1[i2]
for (j1, q1) in enumerate(pts2)
let j2 = j1%length(pts2)+1,
q2 = pts2[j2]
if collinear_segments(p1, p2, q1, q2)
return (i1, j1)
end
end
end
end
end
subtract_polygon_vertices(pts1, pts2) =
let ij = collinear_vertices_indexes(pts1, pts2)
isnothing(ij) ?
inject_polygon_vertices_at_indexes(pts1, pts2, closest_vertices_indexes(pts1, pts2)) :
splice_polygon_vertices_at_indexes(pts1, pts2, ij)
end
inject_polygon_vertices_at_indexes(pts1, pts2, (i, j)) =
[pts1[1:i]..., reverse([pts2[j:end]..., pts2[1:j]...])..., pts1[i:end]...]
export closest_vertices_indexes, inject_polygon_vertices_at_indexes, subtract_polygon_vertices
# Intersection
segments_intersection(p0, p1, p2, p3) =
let denom = (p3.y - p2.y)*(p1.x - p0.x) - (p3.x - p2.x)*(p1.y - p0.y)
if denom == 0
nothing
else
let u = ((p3.x - p2.x)*(p0.y - p2.y) - (p3.y - p2.y)*(p0.x - p2.x))/denom,
v = ((p1.x - p0.x)*(p0.y - p2.y) - (p1.y - p0.y)*(p0.x - p2.x))/denom
if 0 <= u <= 1 && 0 <= v <= 1
xy(p0.x + u*(p1.x - p0.x), p0.y + u*(p1.y - p0.y))
else
nothing
end
end
end
end
lines_intersection(p0, p1, p2, p3) =
let denom = (p3.y - p2.y)*(p1.x - p0.x) - (p3.x - p2.x)*(p1.y - p0.y)
if denom == 0
nothing
else
let u = ((p3.x - p2.x)*(p0.y - p2.y) - (p3.y - p2.y)*(p0.x - p2.x))/denom,
v = ((p1.x - p0.x)*(p0.y - p2.y) - (p1.y - p0.y)*(p0.x - p2.x))/denom
xy(p0.x + u*(p1.x - p0.x), p0.y + u*(p1.y - p0.y))
end
end
end
export epsilon, nearest_point_from_lines, circle_from_three_points
const epsilon = Parameter(1e-8)
nearest_point_from_lines(l0p0::Loc, l0p1::Loc, l1p0::Loc, l1p1::Loc) =
let u = l0p1-l0p0,
v = l1p1-l1p0,
w = l0p0-l1p0,
a = dot(u, u),
b = dot(u, v),
c = dot(v, v),
d = dot(u, w),
e = dot(v, w),
D = a*c-b*b,
(sc, tc) = D < epsilon() ?
#almost parallel
(0.0, b > c ? d/b : e/c) :
((b*e-c*d)/D, (a*e-b*d)/D),
(p0, p1) = (l0p0+u*sc, l1p0+v*tc)
intermediate_loc(p0, p1)
end
circle_from_three_points_2d(v0::Loc, v1::Loc, v2::Loc) =
let v1sv0 = v1-v0,
v2sv0 = v2-v0,
v2sv1 = v2-v1,
v1pv0 = v1+(v0-u0()),
v2pv0 = v2+(v0-u0()),
a = v1sv0.x,
b = v1sv0.y,
c = v2sv0.x,
d = v2sv0.y,
e = a*v1pv0.x+b*v1pv0.y,
f = c*v2pv0.x+d*v2pv0.y,
g = 2.0*(a*v2sv1.y-b*v2sv1.x),
iscolinear = abs(g) < 1e-8,
(cx, cy, dx, dy) = iscolinear ?
let minx = min(v0.x, v1.x, v2.x),
miny = min(v0.y, v1.y, v2.y),
maxx = max(v0.x, v1.x, v2.x),
maxy = max(v0.y, v1.y, v2.y),
x = (minx+maxx)/2,
y = (miny+maxy)/2
(x, y, x-minx, y-miny)
end :
let x = (d*e-b*f)/g,
y = (a*f-c*e)/g
(x, y, x-v0.x, y-v0.y)
end,
radius_squared = dx*dx+dy*dy,
radius = sqrt(radius_squared)
(xy(cx, cy), radius)
end
circle_from_three_points(p0::Loc, p1::Loc, p2::Loc) =
let cs = cs_from_o_vx_vy(p0, p1-p0, p2-p0)
with(current_cs, cs) do
c, r = circle_from_three_points_2d(in_cs(p0, cs),
in_cs(p1, cs),
in_cs(p2, cs))
(c, r)
end
end
const collinearity_tolerance = Parameter(1e-2)
# are the three points sufficiently collinear?
collinear_points(p0, pm, p1, epsilon=collinearity_tolerance()) =
let a = distance(p0, pm),
b = distance(pm, p1),
c = distance(p1, p0)
triangle_area(a, b, c) < epsilon
end
#=
export sweep_path_with_path
sweep_path_with_path(path, profile) =
let vertices = in_world.(path_frames(profile)),
frames = path_frames(path)
#show_cs.(frames, 0.1)
surface_grid([[xyz(cx(p), cy(p), cz(p), frame.cs) for p in vertices]
for frame in frames],
is_closed_path(profile),
is_closed_path(path),
is_smooth_path(profile),
is_smooth_path(path))
end
=#
export quad_grid, quad_grid_indexes
quad_grid(quad, points, closed_u, closed_v) =
let pts = in_world.(points),
si = size(pts, 1),
sj = size(pts, 2)
for i in 1:si-1
for j in 1:sj-1
quad(pts[i,j], pts[i+1,j], pts[i+1,j+1], pts[i,j+1])
end
if closed_v
quad(pts[i,sj], pts[i+1,sj], pts[i+1,1], pts[i,1])
end
end
if closed_u
for j in 1:sj-1
quad(pts[si,j], pts[1,j], pts[si,j+1], pts[si,j+1])
end
if closed_v
quad(pts[si,sj], pts[1,sj], pts[1,1], pts[si,1])
end
end
end
quad_grid_indexes(si, sj, closed_u, closed_v) =
let idx(i,j) = (i-1)*sj+(j-1),
idxs = Vector{Int}[],
quad(a,b,c,d) = (push!(idxs, [a, b, d]); push!(idxs, [d, b, c]))
for i in 1:si-1
for j in 1:sj-1
quad(idx(i,j), idx(i+1,j), idx(i+1,j+1), idx(i,j+1))
end
if closed_v
quad(idx(i,sj), idx(i+1,sj), idx(i+1,1), idx(i,1))
end
end
if closed_u
for j in 1:sj-1
quad(idx(si,j), idx(1,j), idx(1,j+1), idx(si,j+1))
end
if closed_v
quad(idx(si,sj), idx(1,sj), idx(1,1), idx(si,1))
end
end
idxs
end
export illustrate_path
illustrate_path(path) =
begin
for (i, v) in enumerate(path_vertices(path))
sphere(v, 0.01)
text(string(i), v+vxy(0.05, 0.05), 0.1)
end
stroke(path)
end
illustrate_expr(expr) =
:(let p = $(esc(expr)); text($(string(expr)), p); p end)
export illustrate
macro illustrate(exprs...)
:(tuple($([illustrate_expr(expr) for expr in exprs]...)))
end
| [
2,
2269,
16996,
41086,
198,
2,
38662,
198,
39344,
22950,
62,
20337,
11,
9197,
62,
20337,
11,
1529,
23515,
62,
20337,
198,
198,
28461,
9248,
62,
20337,
7,
64,
11,
275,
11,
269,
8,
796,
198,
220,
1309,
264,
796,
357,
64,
1343,
275,
1343,
269,
20679,
17,
13,
15,
198,
220,
220,
220,
19862,
17034,
7,
9806,
7,
15,
13,
15,
11,
264,
9,
7,
82,
532,
257,
27493,
7,
82,
532,
275,
27493,
7,
82,
532,
269,
22305,
198,
220,
886,
198,
45597,
62,
20337,
7,
81,
8,
796,
18074,
222,
9,
81,
61,
17,
198,
1236,
23515,
62,
20337,
7,
81,
158,
224,
240,
11,
374,
39611,
95,
8,
796,
18074,
222,
9,
7,
81,
158,
224,
240,
61,
17,
532,
374,
39611,
95,
61,
17,
8,
198,
198,
16302,
62,
1462,
62,
6894,
7,
11793,
69,
8,
796,
198,
220,
220,
220,
6121,
7,
11793,
69,
11,
34062,
62,
7645,
1161,
7,
14535,
62,
265,
7,
11793,
69,
11,
657,
11,
657,
22305,
198,
198,
2,
28,
198,
198,
15056,
257,
755,
328,
20996,
1627,
3417,
416,
663,
9421,
1063,
11,
356,
761,
284,
24061,
1194,
198,
35428,
14520,
282,
1627,
326,
318,
10730,
284,
262,
717,
530,
13,
198,
198,
46249,
198,
198,
85,
62,
259,
62,
85,
7,
85,
15,
11,
410,
16,
8,
796,
198,
220,
1309,
410,
796,
410,
15,
1343,
410,
16,
198,
220,
220,
220,
410,
9,
26518,
7,
85,
15,
11,
410,
15,
20679,
26518,
7,
85,
11,
410,
15,
8,
198,
220,
886,
198,
198,
10599,
515,
62,
85,
7,
85,
11,
17130,
8,
796,
198,
220,
410,
16104,
7,
16104,
62,
81,
8873,
7,
85,
828,
755,
62,
34846,
7,
85,
8,
1343,
17130,
8,
198,
198,
38050,
62,
2554,
9248,
7,
79,
15,
11,
266,
11,
279,
16,
8,
796,
198,
220,
1309,
410,
15,
796,
279,
16,
532,
279,
15,
11,
198,
220,
220,
220,
220,
220,
410,
16,
796,
38375,
62,
85,
7,
85,
15,
11,
31028,
14,
17,
828,
198,
220,
220,
220,
220,
220,
269,
796,
1179,
62,
6738,
62,
78,
62,
85,
87,
62,
7670,
7,
79,
15,
11,
410,
15,
11,
410,
16,
8,
198,
220,
220,
220,
35991,
7,
66,
12,
7670,
7,
86,
14,
17,
11,
269,
13,
6359,
828,
5253,
7,
79,
15,
11,
279,
16,
828,
266,
8,
198,
220,
886,
198,
198,
28968,
62,
1851,
1063,
7,
862,
3712,
33711,
82,
11,
288,
3712,
15633,
11,
4838,
8,
796,
198,
220,
1309,
10662,
82,
796,
4838,
5633,
685,
862,
58,
437,
4357,
26692,
986,
11,
26692,
58,
16,
11907,
1058,
26692,
11,
198,
220,
220,
220,
220,
220,
3691,
796,
3975,
19510,
79,
15,
11,
279,
16,
8,
4613,
38375,
62,
85,
7,
20850,
1143,
7,
79,
16,
532,
279,
15,
27493,
67,
11,
31028,
14,
17,
828,
10662,
82,
58,
16,
25,
437,
12,
16,
4357,
10662,
82,
58,
17,
25,
437,
46570,
198,
220,
220,
220,
220,
220,
266,
82,
796,
3975,
7,
85,
62,
259,
62,
85,
11,
3691,
58,
16,
25,
437,
12,
16,
4357,
3691,
58,
17,
25,
437,
12962,
198,
220,
220,
220,
3975,
7,
28200,
26692,
11,
4838,
5633,
266,
82,
1058,
685,
14259,
58,
16,
4357,
266,
82,
986,
11,
3691,
58,
437,
11907,
8,
198,
220,
886,
198,
198,
28968,
7,
6978,
11,
288,
3712,
15633,
8,
796,
288,
6624,
657,
5633,
3108,
1058,
1729,
22570,
62,
28968,
7,
6978,
11,
288,
8,
198,
13159,
22570,
62,
28968,
7,
6978,
3712,
45474,
21413,
15235,
11,
288,
3712,
15633,
8,
796,
198,
220,
36954,
62,
6978,
7,
2860,
62,
5431,
7,
6978,
13,
10215,
1008,
11,
288,
11,
288,
828,
3108,
13,
34350,
532,
362,
67,
11,
3108,
13,
9892,
532,
362,
67,
8,
198,
13159,
22570,
62,
28968,
7,
6978,
3712,
11505,
34220,
14520,
282,
15235,
11,
288,
3712,
15633,
8,
796,
198,
220,
1280,
62,
35428,
14520,
282,
62,
6978,
7,
28968,
62,
1851,
1063,
7,
6978,
13,
1851,
1063,
11,
288,
11,
3991,
4008,
198,
13159,
22570,
62,
28968,
7,
6978,
3712,
2601,
1335,
34220,
14520,
282,
15235,
11,
288,
3712,
15633,
8,
796,
198,
220,
4838,
62,
35428,
14520,
282,
62,
6978,
7,
28968,
62,
1851,
1063,
7,
6978,
13,
1851,
1063,
11,
288,
11,
2081,
4008,
198,
13159,
22570,
62,
28968,
7,
6978,
3712,
31560,
934,
15235,
11,
288,
3712,
15633,
8,
796,
198,
220,
18620,
62,
6978,
7,
6978,
13,
16159,
11,
3108,
13,
42172,
532,
288,
8,
198,
13159,
22570,
62,
28968,
7,
6978,
3712,
24021,
15235,
11,
288,
3712,
15633,
8,
796,
198,
220,
10389,
62,
6978,
7,
6978,
13,
16159,
11,
3108,
13,
42172,
532,
288,
11,
3108,
13,
9688,
62,
9248,
11,
3108,
13,
321,
489,
3984,
8,
198,
198,
39344,
11677,
198,
198,
2,
12280,
14520,
6087,
198,
198,
565,
418,
395,
62,
1851,
1063,
62,
9630,
274,
7,
457,
82,
16,
11,
43344,
17,
8,
796,
198,
220,
1303,
770,
318,
257,
33908,
2700,
2446,
13,
1318,
389,
1365,
16113,
284,
466,
428,
13,
198,
220,
1309,
949,
62,
17080,
796,
4806,
11,
198,
220,
220,
220,
220,
220,
949,
62,
72,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
949,
62,
73,
796,
2147,
198,
220,
220,
220,
329,
357,
72,
11,
42975,
16,
8,
287,
27056,
378,
7,
457,
82,
16,
828,
357,
73,
11,
42975,
17,
8,
287,
27056,
378,
7,
457,
82,
17,
8,
198,
220,
220,
220,
220,
220,
1309,
1233,
796,
5253,
7,
457,
16,
11,
42975,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1233,
1279,
949,
62,
17080,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
949,
62,
17080,
796,
1233,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
949,
62,
72,
796,
1312,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
949,
62,
73,
796,
474,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
949,
62,
72,
11,
949,
62,
73,
198,
220,
886,
198,
198,
4122,
62,
259,
62,
325,
5154,
7,
81,
11,
279,
11,
10662,
8,
796,
198,
220,
1309,
778,
796,
374,
12,
79,
11,
198,
220,
220,
220,
220,
220,
279,
80,
796,
10662,
12,
79,
11,
198,
220,
220,
220,
220,
220,
374,
87,
796,
43213,
7,
1050,
20679,
66,
87,
7,
79,
80,
828,
198,
220,
220,
220,
220,
220,
374,
88,
796,
3075,
7,
1050,
20679,
948,
7,
79,
80,
8,
198,
220,
220,
220,
318,
1324,
13907,
7,
40914,
11,
374,
88,
8,
11405,
318,
1324,
13907,
7,
563,
11,
24785,
7,
1050,
20679,
26691,
7,
79,
80,
4008,
198,
220,
886,
198,
198,
26000,
259,
451,
62,
325,
11726,
7,
79,
16,
11,
279,
17,
11,
10662,
16,
11,
10662,
17,
8,
796,
198,
220,
966,
62,
259,
62,
325,
5154,
7,
80,
16,
11,
279,
16,
11,
279,
17,
8,
11405,
198,
220,
966,
62,
259,
62,
325,
5154,
7,
80,
17,
11,
279,
16,
11,
279,
17,
8,
198,
198,
26000,
259,
451,
62,
1851,
1063,
62,
9630,
274,
7,
457,
82,
16,
11,
43344,
17,
8,
796,
198,
220,
329,
357,
72,
16,
11,
279,
16,
8,
287,
27056,
378,
7,
457,
82,
16,
8,
198,
220,
220,
220,
1309,
1312,
17,
796,
1312,
16,
4,
13664,
7,
457,
82,
16,
47762,
16,
11,
198,
220,
220,
220,
220,
220,
220,
220,
279,
17,
796,
43344,
16,
58,
72,
17,
60,
198,
220,
220,
220,
220,
220,
329,
357,
73,
16,
11,
10662,
16,
8,
287,
27056,
378,
7,
457,
82,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1309,
474,
17,
796,
474,
16,
4,
13664,
7,
457,
82,
17,
47762,
16,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10662,
17,
796,
43344,
17,
58,
73,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
2927,
259,
451,
62,
325,
11726,
7,
79,
16,
11,
279,
17,
11,
10662,
16,
11,
10662,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
72,
16,
11,
474,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
886,
198,
198,
7266,
83,
974,
62,
35428,
14520,
62,
1851,
1063,
7,
457,
82,
16,
11,
43344,
17,
8,
796,
198,
220,
1309,
1312,
73,
796,
2927,
259,
451,
62,
1851,
1063,
62,
9630,
274,
7,
457,
82,
16,
11,
43344,
17,
8,
198,
220,
220,
220,
318,
22366,
7,
2926,
8,
5633,
198,
220,
220,
220,
220,
220,
8677,
62,
35428,
14520,
62,
1851,
1063,
62,
265,
62,
9630,
274,
7,
457,
82,
16,
11,
43344,
17,
11,
11706,
62,
1851,
1063,
62,
9630,
274,
7,
457,
82,
16,
11,
43344,
17,
4008,
1058,
198,
220,
220,
220,
220,
220,
4328,
501,
62,
35428,
14520,
62,
1851,
1063,
62,
265,
62,
9630,
274,
7,
457,
82,
16,
11,
43344,
17,
11,
1312,
73,
8,
198,
220,
886,
198,
198,
259,
752,
62,
35428,
14520,
62,
1851,
1063,
62,
265,
62,
9630,
274,
7,
457,
82,
16,
11,
43344,
17,
11,
357,
72,
11,
474,
4008,
796,
198,
220,
685,
457,
82,
16,
58,
16,
25,
72,
60,
986,
11,
9575,
26933,
457,
82,
17,
58,
73,
25,
437,
60,
986,
11,
43344,
17,
58,
16,
25,
73,
60,
986,
12962,
986,
11,
43344,
16,
58,
72,
25,
437,
60,
22345,
198,
198,
39344,
11706,
62,
1851,
1063,
62,
9630,
274,
11,
8677,
62,
35428,
14520,
62,
1851,
1063,
62,
265,
62,
9630,
274,
11,
34128,
62,
35428,
14520,
62,
1851,
1063,
198,
198,
2,
4225,
5458,
198,
198,
325,
11726,
62,
3849,
5458,
7,
79,
15,
11,
279,
16,
11,
279,
17,
11,
279,
18,
8,
796,
198,
220,
1309,
2853,
296,
796,
357,
79,
18,
13,
88,
532,
279,
17,
13,
88,
27493,
7,
79,
16,
13,
87,
532,
279,
15,
13,
87,
8,
532,
357,
79,
18,
13,
87,
532,
279,
17,
13,
87,
27493,
7,
79,
16,
13,
88,
532,
279,
15,
13,
88,
8,
198,
220,
220,
220,
611,
2853,
296,
6624,
657,
198,
220,
220,
220,
220,
220,
2147,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
1309,
334,
796,
14808,
79,
18,
13,
87,
532,
279,
17,
13,
87,
27493,
7,
79,
15,
13,
88,
532,
279,
17,
13,
88,
8,
532,
357,
79,
18,
13,
88,
532,
279,
17,
13,
88,
27493,
7,
79,
15,
13,
87,
532,
279,
17,
13,
87,
4008,
14,
6559,
296,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
410,
796,
14808,
79,
16,
13,
87,
532,
279,
15,
13,
87,
27493,
7,
79,
15,
13,
88,
532,
279,
17,
13,
88,
8,
532,
357,
79,
16,
13,
88,
532,
279,
15,
13,
88,
27493,
7,
79,
15,
13,
87,
532,
279,
17,
13,
87,
4008,
14,
6559,
296,
198,
220,
220,
220,
220,
220,
220,
220,
611,
657,
19841,
334,
19841,
352,
11405,
657,
19841,
410,
19841,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
88,
7,
79,
15,
13,
87,
1343,
334,
9,
7,
79,
16,
13,
87,
532,
279,
15,
13,
87,
828,
279,
15,
13,
88,
1343,
334,
9,
7,
79,
16,
13,
88,
532,
279,
15,
13,
88,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
886,
198,
198,
6615,
62,
3849,
5458,
7,
79,
15,
11,
279,
16,
11,
279,
17,
11,
279,
18,
8,
796,
198,
220,
1309,
2853,
296,
796,
357,
79,
18,
13,
88,
532,
279,
17,
13,
88,
27493,
7,
79,
16,
13,
87,
532,
279,
15,
13,
87,
8,
532,
357,
79,
18,
13,
87,
532,
279,
17,
13,
87,
27493,
7,
79,
16,
13,
88,
532,
279,
15,
13,
88,
8,
198,
220,
220,
220,
611,
2853,
296,
6624,
657,
198,
220,
220,
220,
220,
220,
2147,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
1309,
334,
796,
14808,
79,
18,
13,
87,
532,
279,
17,
13,
87,
27493,
7,
79,
15,
13,
88,
532,
279,
17,
13,
88,
8,
532,
357,
79,
18,
13,
88,
532,
279,
17,
13,
88,
27493,
7,
79,
15,
13,
87,
532,
279,
17,
13,
87,
4008,
14,
6559,
296,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
410,
796,
14808,
79,
16,
13,
87,
532,
279,
15,
13,
87,
27493,
7,
79,
15,
13,
88,
532,
279,
17,
13,
88,
8,
532,
357,
79,
16,
13,
88,
532,
279,
15,
13,
88,
27493,
7,
79,
15,
13,
87,
532,
279,
17,
13,
87,
4008,
14,
6559,
296,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
88,
7,
79,
15,
13,
87,
1343,
334,
9,
7,
79,
16,
13,
87,
532,
279,
15,
13,
87,
828,
279,
15,
13,
88,
1343,
334,
9,
7,
79,
16,
13,
88,
532,
279,
15,
13,
88,
4008,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
886,
198,
198,
39344,
304,
862,
33576,
11,
16936,
62,
4122,
62,
6738,
62,
6615,
11,
9197,
62,
6738,
62,
15542,
62,
13033,
198,
9979,
304,
862,
33576,
796,
25139,
2357,
7,
16,
68,
12,
23,
8,
198,
198,
710,
12423,
62,
4122,
62,
6738,
62,
6615,
7,
75,
15,
79,
15,
3712,
33711,
11,
300,
15,
79,
16,
3712,
33711,
11,
300,
16,
79,
15,
3712,
33711,
11,
300,
16,
79,
16,
3712,
33711,
8,
796,
198,
220,
1309,
334,
796,
300,
15,
79,
16,
12,
75,
15,
79,
15,
11,
198,
220,
220,
220,
220,
220,
410,
796,
300,
16,
79,
16,
12,
75,
16,
79,
15,
11,
198,
220,
220,
220,
220,
220,
266,
796,
300,
15,
79,
15,
12,
75,
16,
79,
15,
11,
198,
220,
220,
220,
220,
220,
257,
796,
16605,
7,
84,
11,
334,
828,
198,
220,
220,
220,
220,
220,
275,
796,
16605,
7,
84,
11,
410,
828,
198,
220,
220,
220,
220,
220,
269,
796,
16605,
7,
85,
11,
410,
828,
198,
220,
220,
220,
220,
220,
288,
796,
16605,
7,
84,
11,
266,
828,
198,
220,
220,
220,
220,
220,
304,
796,
16605,
7,
85,
11,
266,
828,
198,
220,
220,
220,
220,
220,
360,
796,
257,
9,
66,
12,
65,
9,
65,
11,
198,
220,
220,
220,
220,
220,
357,
1416,
11,
37096,
8,
796,
360,
1279,
304,
862,
33576,
3419,
5633,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
28177,
10730,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
15,
13,
15,
11,
275,
1875,
269,
5633,
288,
14,
65,
1058,
304,
14,
66,
8,
1058,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14808,
65,
9,
68,
12,
66,
9,
67,
20679,
35,
11,
357,
64,
9,
68,
12,
65,
9,
67,
20679,
35,
828,
198,
220,
220,
220,
220,
220,
357,
79,
15,
11,
279,
16,
8,
796,
357,
75,
15,
79,
15,
10,
84,
9,
1416,
11,
300,
16,
79,
15,
10,
85,
9,
23047,
8,
198,
220,
220,
220,
19898,
62,
17946,
7,
79,
15,
11,
279,
16,
8,
198,
220,
886,
198,
198,
45597,
62,
6738,
62,
15542,
62,
13033,
62,
17,
67,
7,
85,
15,
3712,
33711,
11,
410,
16,
3712,
33711,
11,
410,
17,
3712,
33711,
8,
796,
198,
220,
1309,
410,
16,
21370,
15,
796,
410,
16,
12,
85,
15,
11,
198,
220,
220,
220,
220,
220,
410,
17,
21370,
15,
796,
410,
17,
12,
85,
15,
11,
198,
220,
220,
220,
220,
220,
410,
17,
21370,
16,
796,
410,
17,
12,
85,
16,
11,
198,
220,
220,
220,
220,
220,
410,
16,
79,
85,
15,
796,
410,
16,
33747,
85,
15,
12,
84,
15,
3419,
828,
198,
220,
220,
220,
220,
220,
410,
17,
79,
85,
15,
796,
410,
17,
33747,
85,
15,
12,
84,
15,
3419,
828,
198,
220,
220,
220,
220,
220,
257,
796,
410,
16,
21370,
15,
13,
87,
11,
198,
220,
220,
220,
220,
220,
275,
796,
410,
16,
21370,
15,
13,
88,
11,
198,
220,
220,
220,
220,
220,
269,
796,
410,
17,
21370,
15,
13,
87,
11,
198,
220,
220,
220,
220,
220,
288,
796,
410,
17,
21370,
15,
13,
88,
11,
198,
220,
220,
220,
220,
220,
304,
796,
257,
9,
85,
16,
79,
85,
15,
13,
87,
10,
65,
9,
85,
16,
79,
85,
15,
13,
88,
11,
198,
220,
220,
220,
220,
220,
277,
796,
269,
9,
85,
17,
79,
85,
15,
13,
87,
10,
67,
9,
85,
17,
79,
85,
15,
13,
88,
11,
198,
220,
220,
220,
220,
220,
308,
796,
362,
13,
15,
9,
7,
64,
9,
85,
17,
21370,
16,
13,
88,
12,
65,
9,
85,
17,
21370,
16,
13,
87,
828,
198,
220,
220,
220,
220,
220,
318,
4033,
259,
451,
796,
2352,
7,
70,
8,
1279,
352,
68,
12,
23,
11,
198,
220,
220,
220,
220,
220,
357,
66,
87,
11,
3075,
11,
44332,
11,
20268,
8,
796,
318,
4033,
259,
451,
5633,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1309,
949,
87,
796,
949,
7,
85,
15,
13,
87,
11,
410,
16,
13,
87,
11,
410,
17,
13,
87,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
949,
88,
796,
949,
7,
85,
15,
13,
88,
11,
410,
16,
13,
88,
11,
410,
17,
13,
88,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3509,
87,
796,
3509,
7,
85,
15,
13,
87,
11,
410,
16,
13,
87,
11,
410,
17,
13,
87,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3509,
88,
796,
3509,
7,
85,
15,
13,
88,
11,
410,
16,
13,
88,
11,
410,
17,
13,
88,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
796,
357,
1084,
87,
10,
9806,
87,
20679,
17,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
331,
796,
357,
1084,
88,
10,
76,
6969,
20679,
17,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
87,
11,
331,
11,
2124,
12,
1084,
87,
11,
331,
12,
1084,
88,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
1058,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1309,
2124,
796,
357,
67,
9,
68,
12,
65,
9,
69,
20679,
70,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
331,
796,
357,
64,
9,
69,
12,
66,
9,
68,
20679,
70,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
87,
11,
331,
11,
2124,
12,
85,
15,
13,
87,
11,
331,
12,
85,
15,
13,
88,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
11,
198,
220,
220,
220,
220,
220,
16874,
62,
16485,
1144,
796,
44332,
9,
34350,
10,
9892,
9,
9892,
11,
198,
220,
220,
220,
220,
220,
16874,
796,
19862,
17034,
7,
42172,
62,
16485,
1144,
8,
198,
220,
220,
220,
357,
5431,
7,
66,
87,
11,
3075,
828,
16874,
8,
198,
220,
886,
198,
198,
45597,
62,
6738,
62,
15542,
62,
13033,
7,
79,
15,
3712,
33711,
11,
279,
16,
3712,
33711,
11,
279,
17,
3712,
33711,
8,
796,
198,
220,
1309,
50115,
796,
50115,
62,
6738,
62,
78,
62,
85,
87,
62,
7670,
7,
79,
15,
11,
279,
16,
12,
79,
15,
11,
279,
17,
12,
79,
15,
8,
198,
220,
220,
220,
351,
7,
14421,
62,
6359,
11,
50115,
8,
466,
198,
220,
220,
220,
220,
220,
269,
11,
374,
796,
9197,
62,
6738,
62,
15542,
62,
13033,
62,
17,
67,
7,
259,
62,
6359,
7,
79,
15,
11,
50115,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
287,
62,
6359,
7,
79,
16,
11,
50115,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
287,
62,
6359,
7,
79,
17,
11,
50115,
4008,
198,
220,
220,
220,
220,
220,
357,
66,
11,
374,
8,
198,
220,
220,
220,
886,
198,
220,
886,
628,
198,
9979,
2927,
259,
451,
414,
62,
83,
37668,
796,
25139,
2357,
7,
16,
68,
12,
17,
8,
198,
2,
389,
262,
1115,
2173,
17338,
2927,
259,
451,
30,
198,
26000,
259,
451,
62,
13033,
7,
79,
15,
11,
9114,
11,
279,
16,
11,
304,
862,
33576,
28,
26000,
259,
451,
414,
62,
83,
37668,
28955,
796,
198,
220,
1309,
257,
796,
5253,
7,
79,
15,
11,
9114,
828,
198,
220,
220,
220,
220,
220,
275,
796,
5253,
7,
4426,
11,
279,
16,
828,
198,
220,
220,
220,
220,
220,
269,
796,
5253,
7,
79,
16,
11,
279,
15,
8,
198,
220,
220,
220,
22950,
62,
20337,
7,
64,
11,
275,
11,
269,
8,
1279,
304,
862,
33576,
198,
220,
886,
198,
198,
2,
28,
198,
39344,
16085,
62,
6978,
62,
4480,
62,
6978,
198,
46280,
538,
62,
6978,
62,
4480,
62,
6978,
7,
6978,
11,
7034,
8,
796,
198,
220,
1309,
9421,
1063,
796,
287,
62,
6894,
12195,
6978,
62,
37805,
7,
13317,
36911,
198,
220,
220,
220,
220,
220,
13431,
796,
3108,
62,
37805,
7,
6978,
8,
198,
220,
220,
220,
220,
220,
1303,
12860,
62,
6359,
12195,
37805,
11,
657,
13,
16,
8,
198,
220,
220,
220,
4417,
62,
25928,
26933,
58,
5431,
89,
7,
66,
87,
7,
79,
828,
3075,
7,
79,
828,
24785,
7,
79,
828,
5739,
13,
6359,
8,
329,
279,
287,
9421,
1063,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
5739,
287,
13431,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
62,
20225,
62,
6978,
7,
13317,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
62,
20225,
62,
6978,
7,
6978,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
62,
5796,
5226,
62,
6978,
7,
13317,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
62,
5796,
5226,
62,
6978,
7,
6978,
4008,
198,
220,
886,
198,
46249,
198,
39344,
15094,
62,
25928,
11,
15094,
62,
25928,
62,
9630,
274,
198,
47003,
62,
25928,
7,
47003,
11,
2173,
11,
4838,
62,
84,
11,
4838,
62,
85,
8,
796,
198,
220,
1309,
43344,
796,
287,
62,
6894,
12195,
13033,
828,
198,
220,
220,
220,
220,
220,
33721,
796,
2546,
7,
457,
82,
11,
352,
828,
198,
220,
220,
220,
220,
220,
264,
73,
796,
2546,
7,
457,
82,
11,
362,
8,
198,
220,
220,
220,
329,
1312,
287,
352,
25,
13396,
12,
16,
198,
220,
220,
220,
220,
220,
329,
474,
287,
352,
25,
82,
73,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
15094,
7,
457,
82,
58,
72,
11,
73,
4357,
43344,
58,
72,
10,
16,
11,
73,
4357,
43344,
58,
72,
10,
16,
11,
73,
10,
16,
4357,
43344,
58,
72,
11,
73,
10,
16,
12962,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
611,
4838,
62,
85,
198,
220,
220,
220,
220,
220,
220,
220,
15094,
7,
457,
82,
58,
72,
11,
82,
73,
4357,
43344,
58,
72,
10,
16,
11,
82,
73,
4357,
43344,
58,
72,
10,
16,
11,
16,
4357,
43344,
58,
72,
11,
16,
12962,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
4838,
62,
84,
198,
220,
220,
220,
220,
220,
329,
474,
287,
352,
25,
82,
73,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
15094,
7,
457,
82,
58,
13396,
11,
73,
4357,
43344,
58,
16,
11,
73,
4357,
43344,
58,
13396,
11,
73,
10,
16,
4357,
43344,
58,
13396,
11,
73,
10,
16,
12962,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
611,
4838,
62,
85,
198,
220,
220,
220,
220,
220,
220,
220,
15094,
7,
457,
82,
58,
13396,
11,
82,
73,
4357,
43344,
58,
16,
11,
82,
73,
4357,
43344,
58,
16,
11,
16,
4357,
43344,
58,
13396,
11,
16,
12962,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
886,
198,
198,
47003,
62,
25928,
62,
9630,
274,
7,
13396,
11,
264,
73,
11,
4838,
62,
84,
11,
4838,
62,
85,
8,
796,
198,
220,
1309,
4686,
87,
7,
72,
11,
73,
8,
796,
357,
72,
12,
16,
27493,
82,
73,
33747,
73,
12,
16,
828,
198,
220,
220,
220,
220,
220,
4686,
34223,
796,
20650,
90,
5317,
92,
58,
4357,
198,
220,
220,
220,
220,
220,
15094,
7,
64,
11,
65,
11,
66,
11,
67,
8,
796,
357,
14689,
0,
7,
312,
34223,
11,
685,
64,
11,
275,
11,
288,
36563,
4574,
0,
7,
312,
34223,
11,
685,
67,
11,
275,
11,
269,
60,
4008,
198,
220,
220,
220,
329,
1312,
287,
352,
25,
13396,
12,
16,
198,
220,
220,
220,
220,
220,
329,
474,
287,
352,
25,
82,
73,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
15094,
7,
312,
87,
7,
72,
11,
73,
828,
4686,
87,
7,
72,
10,
16,
11,
73,
828,
4686,
87,
7,
72,
10,
16,
11,
73,
10,
16,
828,
4686,
87,
7,
72,
11,
73,
10,
16,
4008,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
611,
4838,
62,
85,
198,
220,
220,
220,
220,
220,
220,
220,
15094,
7,
312,
87,
7,
72,
11,
82,
73,
828,
4686,
87,
7,
72,
10,
16,
11,
82,
73,
828,
4686,
87,
7,
72,
10,
16,
11,
16,
828,
4686,
87,
7,
72,
11,
16,
4008,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
4838,
62,
84,
198,
220,
220,
220,
220,
220,
329,
474,
287,
352,
25,
82,
73,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
15094,
7,
312,
87,
7,
13396,
11,
73,
828,
4686,
87,
7,
16,
11,
73,
828,
4686,
87,
7,
16,
11,
73,
10,
16,
828,
4686,
87,
7,
13396,
11,
73,
10,
16,
4008,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
611,
4838,
62,
85,
198,
220,
220,
220,
220,
220,
220,
220,
15094,
7,
312,
87,
7,
13396,
11,
82,
73,
828,
4686,
87,
7,
16,
11,
82,
73,
828,
4686,
87,
7,
16,
11,
16,
828,
4686,
87,
7,
13396,
11,
16,
4008,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4686,
34223,
198,
220,
886,
198,
198,
39344,
19418,
62,
6978,
198,
359,
436,
4873,
62,
6978,
7,
6978,
8,
796,
198,
220,
2221,
198,
220,
220,
220,
329,
357,
72,
11,
410,
8,
287,
27056,
378,
7,
6978,
62,
1851,
1063,
7,
6978,
4008,
198,
220,
220,
220,
220,
220,
16558,
7,
85,
11,
657,
13,
486,
8,
198,
220,
220,
220,
220,
220,
2420,
7,
8841,
7,
72,
828,
410,
10,
85,
5431,
7,
15,
13,
2713,
11,
657,
13,
2713,
828,
657,
13,
16,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
14000,
7,
6978,
8,
198,
220,
886,
198,
198,
359,
436,
4873,
62,
31937,
7,
31937,
8,
796,
198,
220,
36147,
1616,
279,
796,
29568,
3798,
7,
31937,
18125,
2420,
16763,
7,
8841,
7,
31937,
36911,
279,
1776,
279,
886,
8,
198,
198,
39344,
19418,
198,
20285,
305,
19418,
7,
31937,
82,
23029,
198,
220,
36147,
83,
29291,
16763,
26933,
359,
436,
4873,
62,
31937,
7,
31937,
8,
329,
44052,
287,
1033,
3808,
60,
986,
22305,
198,
437,
198
] | 1.723331 | 4,959 |
<reponame>TuringLang/HMC.jl
using Pkg
Pkg.update("TuringWeb")
using Documenter, TuringWeb
using AdvancedHMC
# cp(joinpath(@__DIR__, "../README.md"), joinpath(@__DIR__, "src/index.md"))
makedocs(
sitename = "AdvancedHMC",
format = Documenter.HTML(),
modules = [AdvancedHMC]
)
deploydocs(
repo = "github.com/TuringLang/AdvancedHMC.jl.git",
push_preview = true, # allow PR to deploy
)
| [
27,
7856,
261,
480,
29,
51,
870,
43,
648,
14,
39,
9655,
13,
20362,
198,
3500,
350,
10025,
198,
47,
10025,
13,
19119,
7203,
51,
870,
13908,
4943,
198,
198,
3500,
16854,
263,
11,
39141,
13908,
198,
3500,
13435,
39,
9655,
198,
198,
2,
31396,
7,
22179,
6978,
7,
31,
834,
34720,
834,
11,
366,
40720,
15675,
11682,
13,
9132,
12340,
4654,
6978,
7,
31,
834,
34720,
834,
11,
366,
10677,
14,
9630,
13,
9132,
48774,
198,
198,
76,
4335,
420,
82,
7,
198,
220,
220,
220,
1650,
12453,
796,
366,
28809,
39,
9655,
1600,
198,
220,
220,
220,
5794,
796,
16854,
263,
13,
28656,
22784,
198,
220,
220,
220,
13103,
796,
685,
28809,
39,
9655,
60,
198,
8,
198,
198,
2934,
1420,
31628,
7,
198,
220,
220,
220,
29924,
796,
366,
12567,
13,
785,
14,
51,
870,
43,
648,
14,
28809,
39,
9655,
13,
20362,
13,
18300,
1600,
198,
220,
220,
220,
4574,
62,
3866,
1177,
796,
2081,
11,
1303,
1249,
4810,
284,
6061,
198,
8,
198
] | 2.416667 | 168 |
<reponame>kskyten/MeasureTheory.jl
using Random
struct ResettableRNG{R,S} <: Random.AbstractRNG
rng::R
seed::S
end
function Base.show(io::IO, ::MIME"text/plain", r::ResettableRNG)
io = IOContext(io, :compact => true)
print(io, "ResettableRNG(::", constructor(r.rng), ", ", r.seed, ")")
end
function reset!(r::ResettableRNG)
Random.seed!(r.rng, r.seed)
end
# for f in [
# :(Base.rand)
# :(Base.randn)
# :(Random.rand!)
# :(Random.randcycle)
# :(Random.randcycle!)
# :(Random.randexp)
# :(Random.randexp!)
# :(Random.randn!)
# :(Random.randperm)
# :(Random.randperm!)
# :(Random.randstring)
# :(Random.randsubseq)
# :(Random.randsubseq!)
# :(Random.shuffle)
# :(Random.shuffle!)
# :(Random.seed!)
# ]
# @eval $f(r::ResettableRNG, args...) = $f(r.rng, args...)
# end
# Base.rand(r::ResettableRNG, d::AbstractMeasure) = rand(r.rng, d)
# Base.rand(r::ResettableRNG, ::Type{T}, d::AbstractMeasure) where {T} = rand(r.rng, T, d)
# Base.rand(r::ResettableRNG) = rand(r.rng, Float64)
Base.rand(r::ResettableRNG, ::Type{T}) where {T} = rand(r.rng, T)
Base.randn(r::ResettableRNG, ::Type{T}) where {T} = randn(r.rng, T)
Base.randn(r::ResettableRNG, ::Type{Float64}) where {T} = randn(r.rng, Float64)
function Base.iterate(r::ResettableRNG)
reset!(r)
return (rand(r), nothing)
end
Base.iterate(r::ResettableRNG, _) = (rand(r), nothing)
Base.IteratorSize(r::ResettableRNG) = Base.IsInfinite()
| [
27,
7856,
261,
480,
29,
591,
2584,
1452,
14,
47384,
464,
652,
13,
20362,
198,
3500,
14534,
198,
198,
7249,
1874,
3087,
540,
49,
10503,
90,
49,
11,
50,
92,
1279,
25,
14534,
13,
23839,
49,
10503,
198,
220,
220,
220,
374,
782,
3712,
49,
198,
220,
220,
220,
9403,
3712,
50,
198,
437,
198,
198,
8818,
7308,
13,
12860,
7,
952,
3712,
9399,
11,
7904,
44,
12789,
1,
5239,
14,
25638,
1600,
374,
3712,
4965,
3087,
540,
49,
10503,
8,
198,
220,
220,
220,
33245,
796,
24418,
21947,
7,
952,
11,
1058,
5589,
529,
5218,
2081,
8,
198,
220,
220,
220,
3601,
7,
952,
11,
366,
4965,
3087,
540,
49,
10503,
7,
3712,
1600,
23772,
7,
81,
13,
81,
782,
828,
33172,
33172,
374,
13,
28826,
11,
366,
8,
4943,
198,
437,
198,
198,
8818,
13259,
0,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
8,
198,
220,
220,
220,
14534,
13,
28826,
0,
7,
81,
13,
81,
782,
11,
374,
13,
28826,
8,
198,
437,
628,
198,
2,
329,
277,
287,
685,
198,
2,
220,
220,
220,
220,
36147,
14881,
13,
25192,
8,
198,
2,
220,
220,
220,
220,
36147,
14881,
13,
25192,
77,
8,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
8133,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
13696,
8,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
13696,
8133,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
11201,
8,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
11201,
8133,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
77,
8133,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
16321,
8,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
16321,
8133,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
25192,
8841,
8,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
81,
1746,
549,
41068,
8,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
81,
1746,
549,
41068,
8133,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
1477,
18137,
8,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
1477,
18137,
8133,
198,
2,
220,
220,
220,
220,
36147,
29531,
13,
28826,
8133,
198,
2,
2361,
220,
220,
220,
220,
198,
2,
220,
220,
220,
220,
2488,
18206,
720,
69,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
11,
26498,
23029,
796,
720,
69,
7,
81,
13,
81,
782,
11,
26498,
23029,
198,
2,
886,
628,
198,
2,
7308,
13,
25192,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
11,
288,
3712,
23839,
47384,
8,
796,
43720,
7,
81,
13,
81,
782,
11,
288,
8,
198,
2,
7308,
13,
25192,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
11,
7904,
6030,
90,
51,
5512,
288,
3712,
23839,
47384,
8,
810,
1391,
51,
92,
796,
43720,
7,
81,
13,
81,
782,
11,
309,
11,
288,
8,
198,
2,
7308,
13,
25192,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
8,
796,
43720,
7,
81,
13,
81,
782,
11,
48436,
2414,
8,
198,
14881,
13,
25192,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
11,
7904,
6030,
90,
51,
30072,
810,
1391,
51,
92,
796,
220,
43720,
7,
81,
13,
81,
782,
11,
309,
8,
198,
14881,
13,
25192,
77,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
11,
7904,
6030,
90,
51,
30072,
810,
1391,
51,
92,
796,
220,
43720,
77,
7,
81,
13,
81,
782,
11,
309,
8,
198,
14881,
13,
25192,
77,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
11,
7904,
6030,
90,
43879,
2414,
30072,
810,
1391,
51,
92,
796,
220,
43720,
77,
7,
81,
13,
81,
782,
11,
48436,
2414,
8,
198,
198,
8818,
7308,
13,
2676,
378,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
8,
198,
220,
220,
220,
13259,
0,
7,
81,
8,
198,
220,
220,
220,
1441,
357,
25192,
7,
81,
828,
2147,
8,
198,
437,
198,
198,
14881,
13,
2676,
378,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
11,
4808,
8,
796,
357,
25192,
7,
81,
828,
2147,
8,
198,
14881,
13,
37787,
10699,
7,
81,
3712,
4965,
3087,
540,
49,
10503,
8,
796,
7308,
13,
3792,
18943,
9504,
3419,
198
] | 2.146763 | 695 |
module AperturePhotometry
include("calibration.jl")
include("photometry.jl")
include("stacking.jl")
include("load_images.jl")
end # module
| [
21412,
317,
27286,
27248,
15748,
198,
198,
17256,
7203,
9948,
571,
1358,
13,
20362,
4943,
198,
17256,
7203,
38611,
15748,
13,
20362,
4943,
198,
17256,
7203,
301,
5430,
13,
20362,
4943,
198,
17256,
7203,
2220,
62,
17566,
13,
20362,
4943,
198,
198,
437,
1303,
8265,
198
] | 3.065217 | 46 |
function increase_tariff!(consumer::Consumer)
consumer.tariff.e_cost = [(block[1],block[2]*(1+consumer.tariff.increase)) for block in consumer.tariff.e_cost]
consumer.tariff.p_cost = [(block[1],block[2]*(1+consumer.tariff.increase)) for block in consumer.tariff.p_cost]
consumer.tariff.access = consumer.tariff.access*(consumer.tariff.access_increase)
end
function increase_tariff!(tariff::Tariff)
tariff.e_cost = [(block[1],block[2]*(1+tariff.increase)) for block in tariff.e_cost]
tariff.p_cost = [(block[1],block[2]*(1+tariff.increase)) for block in tariff.p_cost]
end | [
8818,
2620,
62,
18870,
733,
0,
7,
49827,
3712,
49106,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
7172,
13,
18870,
733,
13,
68,
62,
15805,
796,
47527,
9967,
58,
16,
4357,
9967,
58,
17,
60,
9,
7,
16,
10,
49827,
13,
18870,
733,
13,
24988,
589,
4008,
329,
2512,
287,
7172,
13,
18870,
733,
13,
68,
62,
15805,
60,
198,
220,
220,
220,
7172,
13,
18870,
733,
13,
79,
62,
15805,
796,
47527,
9967,
58,
16,
4357,
9967,
58,
17,
60,
9,
7,
16,
10,
49827,
13,
18870,
733,
13,
24988,
589,
4008,
329,
2512,
287,
7172,
13,
18870,
733,
13,
79,
62,
15805,
60,
198,
197,
49827,
13,
18870,
733,
13,
15526,
796,
7172,
13,
18870,
733,
13,
15526,
9,
7,
49827,
13,
18870,
733,
13,
15526,
62,
24988,
589,
8,
198,
220,
220,
220,
220,
198,
437,
198,
198,
8818,
2620,
62,
18870,
733,
0,
7,
18870,
733,
3712,
47079,
733,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
36427,
13,
68,
62,
15805,
796,
47527,
9967,
58,
16,
4357,
9967,
58,
17,
60,
9,
7,
16,
10,
18870,
733,
13,
24988,
589,
4008,
329,
2512,
287,
36427,
13,
68,
62,
15805,
60,
198,
220,
220,
220,
36427,
13,
79,
62,
15805,
796,
47527,
9967,
58,
16,
4357,
9967,
58,
17,
60,
9,
7,
16,
10,
18870,
733,
13,
24988,
589,
4008,
329,
2512,
287,
36427,
13,
79,
62,
15805,
60,
198,
220,
220,
220,
220,
198,
437
] | 2.485714 | 245 |
#Moore et al 2009 mean vectors:
M=Array{Any,1}(undef,8)
M[1]=vec([0.0234 0.0192 0.0129 0.0075 0.0031 0.0002])
M[2]=vec([0.0162 0.0141 0.0112 0.0073 0.0034 0.0002])
M[3]=vec([0.0107 0.0098 0.0092 0.0070 0.0039 0.0003])
M[4]=vec([0.0065 0.0064 0.0070 0.0064 0.0048 0.0006])
M[5]=vec([0.0033 0.0034 0.0042 0.0042 0.0043 0.0009])
M[6]=vec([0.0064 0.0074 0.0105 0.0116 0.0140 0.0041])
M[7]=vec([0.0121 0.0140 0.0192 0.0204 0.0231 0.0084])
M[8]=vec([0.0184 0.0230 0.0333 0.0359 0.0409 0.0137])
#Moore et al 2009 covariance matrices:
S=Array{Any,1}(undef,8)
S[1]=[0.00000959 0.00000556 0.00000138 -0.00000034 -0.00000024 -0.00000003;
0.00000556 0.00000493 0.00000193 0.00000060 0.00000023 0.00000001;
0.00000138 0.00000193 0.00000282 0.00000223 0.00000119 0.00000007;
-0.00000034 0.00000060 0.00000223 0.00000232 0.00000119 0.00000007;
-0.00000024 0.00000023 0.00000119 0.00000119 0.00000071 0.00000005;
-0.00000003 0.00000001 0.00000007 0.00000007 0.00000005 0.00000001]
S[2]=[0.00000346 0.00000186 -0.00000011 -0.00000060 -0.00000062 -0.00000005;
0.00000186 0.00000228 0.00000086 0.00000033 -0.00000007 0.00000003;
-0.00000011 0.00000086 0.00000231 0.00000221 0.00000145 0.00000023;
-0.00000060 0.00000033 0.00000221 0.00000266 0.00000191 0.00000034;
-0.00000062 -0.00000007 0.00000145 0.00000191 0.00000175 0.00000041;
-0.00000005 0.00000003 0.00000023 0.00000034 0.00000041 0.00000021]
S[3]=[0.00000241 0.00000144 0.00000035 -0.00000031 -0.00000063 -0.00000006;
0.00000144 0.00000138 0.00000076 0.00000015 -0.00000021 -0.00000001;
0.00000035 0.00000076 0.00000161 0.00000156 0.00000121 0.00000016;
-0.00000031 0.00000015 0.00000156 0.00000227 0.00000209 0.00000031;
-0.00000063 -0.00000021 0.00000121 0.00000209 0.00000225 0.00000037;
-0.00000006 -0.00000001 0.00000016 0.00000031 0.00000037 0.00000013]
S[4]=[0.00000166 0.00000091 0.00000034 -0.00000009 -0.00000080 -0.00000025;
0.00000091 0.00000097 0.00000071 0.00000025 -0.00000041 -0.00000015;
0.00000034 0.00000071 0.00000118 0.00000103 0.00000072 0.00000003;
-0.00000009 0.00000025 0.00000103 0.00000137 0.00000162 0.00000025;
-0.00000080 -0.00000041 0.00000072 0.00000162 0.00000290 0.00000065;
-0.00000025 -0.00000015 0.00000003 0.00000025 0.00000065 0.00000050]
S[5]=[0.00000178 0.00000132 0.00000104 0.00000081 0.00000018 -0.00000014;
0.00000132 0.00000127 0.00000121 0.00000099 0.00000034 -0.00000010;
0.00000104 0.00000121 0.00000150 0.00000142 0.00000110 0.00000013;
0.00000081 0.00000099 0.00000142 0.00000158 0.00000177 0.00000042;
0.00000018 0.00000034 0.00000110 0.00000177 0.00000351 0.00000131;
-0.00000014 -0.00000010 0.00000013 0.00000042 0.00000131 0.00000081]
S[6]=[0.00000715 0.00000586 0.00000409 0.00000292 0.00000005 -0.00000075;
0.00000586 0.00000589 0.00000520 0.00000398 0.00000027 -0.00000114;
0.00000409 0.00000520 0.00000634 0.00000541 0.00000188 -0.00000097;
0.00000292 0.00000398 0.00000541 0.00000528 0.00000392 0.00000070;
0.00000005 0.00000027 0.00000188 0.00000392 0.00000995 0.00000657;
-0.00000075 -0.00000114 -0.00000097 0.00000070 0.00000657 0.00000819]
S[7]=[0.00002625 0.00001981 0.00001058 0.00000544 -0.00000654 -0.00001122;
0.00001981 0.00001745 0.00001314 0.00000822 -0.00000431 -0.00001228;
0.00001058 0.00001314 0.00001629 0.00001226 0.00000035 -0.00001311;
0.00000544 0.00000822 0.00001226 0.00001170 0.00000742 -0.00000500;
-0.00000654 -0.00000431 0.00000035 0.00000742 0.00002241 0.00001782;
-0.00001122 -0.00001228 -0.00001311 -0.00000500 0.00001782 0.00003987]
S[8]=[0.00001186 0.00001134 0.00001139 0.00000919 0.00000395 -0.00000186;
0.00001134 0.00001484 0.00002034 0.00001907 0.00001531 0.00000087;
0.00001139 0.00002034 0.00003467 0.00003546 0.00003555 0.00000708;
0.00000919 0.00001907 0.00003546 0.00003907 0.00004604 0.00001733;
0.00000395 0.00001531 0.00003555 0.00004604 0.00007306 0.00004953;
-0.00000186 0.00000087 0.00000708 0.00001733 0.00004953 0.00006542];
| [
198,
2,
40049,
2123,
435,
3717,
1612,
30104,
25,
198,
44,
28,
19182,
90,
7149,
11,
16,
92,
7,
917,
891,
11,
23,
8,
198,
44,
58,
16,
22241,
35138,
26933,
15,
13,
15,
24409,
657,
13,
486,
5892,
657,
13,
486,
1959,
657,
13,
405,
2425,
657,
13,
405,
3132,
657,
13,
34215,
12962,
198,
44,
58,
17,
22241,
35138,
26933,
15,
13,
486,
5237,
657,
13,
486,
3901,
657,
13,
486,
1065,
657,
13,
405,
4790,
657,
13,
405,
2682,
657,
13,
34215,
12962,
198,
44,
58,
18,
22241,
35138,
26933,
15,
13,
486,
2998,
657,
13,
405,
4089,
657,
13,
405,
5892,
657,
13,
405,
2154,
657,
13,
405,
2670,
657,
13,
830,
18,
12962,
198,
44,
58,
19,
22241,
35138,
26933,
15,
13,
405,
2996,
657,
13,
405,
2414,
657,
13,
405,
2154,
657,
13,
405,
2414,
657,
13,
405,
2780,
657,
13,
830,
21,
12962,
198,
44,
58,
20,
22241,
35138,
26933,
15,
13,
405,
2091,
657,
13,
405,
2682,
657,
13,
405,
3682,
657,
13,
405,
3682,
657,
13,
405,
3559,
657,
13,
830,
24,
12962,
198,
44,
58,
21,
22241,
35138,
26933,
15,
13,
405,
2414,
657,
13,
405,
4524,
657,
13,
486,
2713,
657,
13,
486,
1433,
657,
13,
486,
1821,
657,
13,
405,
3901,
12962,
198,
44,
58,
22,
22241,
35138,
26933,
15,
13,
486,
2481,
657,
13,
486,
1821,
657,
13,
486,
5892,
657,
13,
15,
18638,
657,
13,
15,
25667,
657,
13,
405,
5705,
12962,
198,
44,
58,
23,
22241,
35138,
26933,
15,
13,
486,
5705,
657,
13,
2999,
1270,
657,
13,
15,
20370,
657,
13,
15,
30743,
657,
13,
15,
29416,
657,
13,
486,
2718,
12962,
198,
198,
2,
40049,
2123,
435,
3717,
44829,
590,
2603,
45977,
25,
198,
50,
28,
19182,
90,
7149,
11,
16,
92,
7,
917,
891,
11,
23,
8,
198,
50,
58,
16,
22241,
58,
15,
13,
20483,
24,
3270,
657,
13,
20483,
37864,
657,
13,
2388,
486,
2548,
532,
15,
13,
10535,
2682,
532,
15,
13,
10535,
1731,
532,
15,
13,
24598,
18,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
20483,
37864,
657,
13,
20483,
43134,
657,
13,
2388,
486,
6052,
657,
13,
10535,
1899,
657,
13,
10535,
1954,
657,
13,
10535,
486,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
486,
2548,
657,
13,
2388,
486,
6052,
657,
13,
20483,
32568,
657,
13,
20483,
22047,
657,
13,
2388,
486,
1129,
657,
13,
24598,
22,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
2682,
657,
13,
10535,
1899,
657,
13,
20483,
22047,
657,
13,
20483,
24339,
657,
13,
2388,
486,
1129,
657,
13,
24598,
22,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
1731,
657,
13,
10535,
1954,
657,
13,
2388,
486,
1129,
657,
13,
2388,
486,
1129,
657,
13,
10535,
4869,
657,
13,
24598,
20,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
24598,
18,
657,
13,
10535,
486,
657,
13,
24598,
22,
657,
13,
24598,
22,
657,
13,
24598,
20,
657,
13,
10535,
486,
60,
198,
50,
58,
17,
22241,
58,
15,
13,
20483,
30557,
657,
13,
2388,
486,
4521,
532,
15,
13,
10535,
1157,
532,
15,
13,
10535,
1899,
532,
15,
13,
10535,
5237,
532,
15,
13,
24598,
20,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
486,
4521,
657,
13,
20483,
23815,
657,
13,
10535,
4521,
657,
13,
10535,
2091,
532,
15,
13,
24598,
22,
657,
13,
24598,
18,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
1157,
657,
13,
10535,
4521,
657,
13,
20483,
25667,
657,
13,
20483,
26115,
657,
13,
2388,
486,
2231,
657,
13,
10535,
1954,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
1899,
657,
13,
10535,
2091,
657,
13,
20483,
26115,
657,
13,
20483,
25540,
657,
13,
2388,
486,
6420,
657,
13,
10535,
2682,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
5237,
532,
15,
13,
24598,
22,
657,
13,
2388,
486,
2231,
657,
13,
2388,
486,
6420,
657,
13,
2388,
486,
2425,
657,
13,
10535,
3901,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
24598,
20,
657,
13,
24598,
18,
657,
13,
10535,
1954,
657,
13,
10535,
2682,
657,
13,
10535,
3901,
657,
13,
10535,
2481,
60,
198,
50,
58,
18,
22241,
58,
15,
13,
20483,
28872,
657,
13,
2388,
486,
2598,
657,
13,
10535,
2327,
532,
15,
13,
10535,
3132,
532,
15,
13,
10535,
5066,
532,
15,
13,
24598,
21,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
486,
2598,
657,
13,
2388,
486,
2548,
657,
13,
10535,
4304,
657,
13,
10535,
1314,
532,
15,
13,
10535,
2481,
532,
15,
13,
10535,
486,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
10535,
2327,
657,
13,
10535,
4304,
657,
13,
2388,
486,
5333,
657,
13,
2388,
486,
3980,
657,
13,
2388,
486,
2481,
657,
13,
10535,
1433,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
3132,
657,
13,
10535,
1314,
657,
13,
2388,
486,
3980,
657,
13,
20483,
24403,
657,
13,
20483,
22567,
657,
13,
10535,
3132,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
5066,
532,
15,
13,
10535,
2481,
657,
13,
2388,
486,
2481,
657,
13,
20483,
22567,
657,
13,
20483,
18182,
657,
13,
10535,
2718,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
24598,
21,
532,
15,
13,
10535,
486,
657,
13,
10535,
1433,
657,
13,
10535,
3132,
657,
13,
10535,
2718,
657,
13,
10535,
1485,
60,
198,
50,
58,
19,
22241,
58,
15,
13,
2388,
486,
2791,
657,
13,
10535,
6420,
657,
13,
10535,
2682,
532,
15,
13,
24598,
24,
532,
15,
13,
10535,
1795,
532,
15,
13,
10535,
1495,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
10535,
6420,
657,
13,
10535,
5607,
657,
13,
10535,
4869,
657,
13,
10535,
1495,
532,
15,
13,
10535,
3901,
532,
15,
13,
10535,
1314,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
10535,
2682,
657,
13,
10535,
4869,
657,
13,
2388,
486,
1507,
657,
13,
2388,
486,
3070,
657,
13,
10535,
4761,
657,
13,
24598,
18,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
24598,
24,
657,
13,
10535,
1495,
657,
13,
2388,
486,
3070,
657,
13,
2388,
486,
2718,
657,
13,
2388,
486,
5237,
657,
13,
10535,
1495,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
1795,
532,
15,
13,
10535,
3901,
657,
13,
10535,
4761,
657,
13,
2388,
486,
5237,
657,
13,
20483,
24369,
657,
13,
10535,
2996,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
1495,
532,
15,
13,
10535,
1314,
657,
13,
24598,
18,
657,
13,
10535,
1495,
657,
13,
10535,
2996,
657,
13,
10535,
1120,
60,
198,
50,
58,
20,
22241,
58,
15,
13,
2388,
486,
3695,
657,
13,
2388,
486,
2624,
657,
13,
2388,
486,
3023,
657,
13,
10535,
6659,
657,
13,
10535,
1507,
532,
15,
13,
10535,
1415,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
486,
2624,
657,
13,
2388,
486,
1983,
657,
13,
2388,
486,
2481,
657,
13,
10535,
2079,
657,
13,
10535,
2682,
532,
15,
13,
10535,
940,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
486,
3023,
657,
13,
2388,
486,
2481,
657,
13,
2388,
486,
1120,
657,
13,
2388,
486,
3682,
657,
13,
2388,
486,
940,
657,
13,
10535,
1485,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
10535,
6659,
657,
13,
10535,
2079,
657,
13,
2388,
486,
3682,
657,
13,
2388,
486,
3365,
657,
13,
2388,
486,
3324,
657,
13,
10535,
3682,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
10535,
1507,
657,
13,
10535,
2682,
657,
13,
2388,
486,
940,
657,
13,
2388,
486,
3324,
657,
13,
20483,
35273,
657,
13,
2388,
486,
3132,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
1415,
532,
15,
13,
10535,
940,
657,
13,
10535,
1485,
657,
13,
10535,
3682,
657,
13,
2388,
486,
3132,
657,
13,
10535,
6659,
60,
198,
50,
58,
21,
22241,
58,
15,
13,
20483,
22,
1314,
657,
13,
20483,
29796,
657,
13,
20483,
29416,
657,
13,
20483,
32759,
657,
13,
24598,
20,
532,
15,
13,
10535,
2425,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
20483,
29796,
657,
13,
20483,
44169,
657,
13,
20483,
31211,
657,
13,
20483,
31952,
657,
13,
10535,
1983,
532,
15,
13,
2388,
486,
1415,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
20483,
29416,
657,
13,
20483,
31211,
657,
13,
20483,
21,
2682,
657,
13,
20483,
20,
3901,
657,
13,
2388,
486,
3459,
532,
15,
13,
10535,
5607,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
20483,
32759,
657,
13,
20483,
31952,
657,
13,
20483,
20,
3901,
657,
13,
20483,
49351,
657,
13,
20483,
32321,
657,
13,
10535,
2154,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
24598,
20,
657,
13,
10535,
1983,
657,
13,
2388,
486,
3459,
657,
13,
20483,
32321,
657,
13,
20483,
33438,
657,
13,
20483,
37680,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
10535,
2425,
532,
15,
13,
2388,
486,
1415,
532,
15,
13,
10535,
5607,
657,
13,
10535,
2154,
657,
13,
20483,
37680,
657,
13,
20483,
23,
1129,
60,
198,
50,
58,
22,
22241,
58,
15,
13,
2388,
2075,
1495,
657,
13,
2388,
35411,
657,
13,
2388,
940,
3365,
657,
13,
20483,
47576,
532,
15,
13,
20483,
39111,
532,
15,
13,
2388,
14686,
17,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
35411,
657,
13,
2388,
1558,
2231,
657,
13,
2388,
1485,
1415,
657,
13,
20483,
23,
1828,
532,
15,
13,
20483,
50080,
532,
15,
13,
2388,
1065,
2078,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
940,
3365,
657,
13,
2388,
1485,
1415,
657,
13,
2388,
1433,
1959,
657,
13,
2388,
1065,
2075,
657,
13,
10535,
2327,
532,
15,
13,
2388,
1485,
1157,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
20483,
47576,
657,
13,
20483,
23,
1828,
657,
13,
2388,
1065,
2075,
657,
13,
2388,
1157,
2154,
657,
13,
20483,
22,
3682,
532,
15,
13,
20483,
4059,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
20483,
39111,
532,
15,
13,
20483,
50080,
657,
13,
10535,
2327,
657,
13,
20483,
22,
3682,
657,
13,
2388,
24137,
16,
657,
13,
2388,
1558,
6469,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
2388,
14686,
17,
532,
15,
13,
2388,
1065,
2078,
532,
15,
13,
2388,
1485,
1157,
532,
15,
13,
20483,
4059,
657,
13,
2388,
1558,
6469,
657,
13,
2388,
2670,
5774,
60,
198,
50,
58,
23,
22241,
58,
15,
13,
2388,
1157,
4521,
657,
13,
2388,
1157,
2682,
657,
13,
2388,
1157,
2670,
657,
13,
20483,
24,
1129,
657,
13,
20483,
31010,
532,
15,
13,
2388,
486,
4521,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
1157,
2682,
657,
13,
2388,
1415,
5705,
657,
13,
2388,
1238,
2682,
657,
13,
2388,
1129,
2998,
657,
13,
2388,
1314,
3132,
657,
13,
10535,
5774,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
2388,
1157,
2670,
657,
13,
2388,
1238,
2682,
657,
13,
2388,
2682,
3134,
657,
13,
2388,
2327,
3510,
657,
13,
2388,
2327,
2816,
657,
13,
20483,
32583,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
20483,
24,
1129,
657,
13,
2388,
1129,
2998,
657,
13,
2388,
2327,
3510,
657,
13,
2388,
2670,
2998,
657,
13,
2388,
19,
31916,
657,
13,
2388,
1558,
2091,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
657,
13,
20483,
31010,
657,
13,
2388,
1314,
3132,
657,
13,
2388,
2327,
2816,
657,
13,
2388,
19,
31916,
657,
13,
44808,
20548,
657,
13,
2388,
2920,
4310,
26,
220,
198,
220,
220,
220,
220,
220,
220,
220,
532,
15,
13,
2388,
486,
4521,
657,
13,
10535,
5774,
657,
13,
20483,
32583,
657,
13,
2388,
1558,
2091,
657,
13,
2388,
2920,
4310,
657,
13,
2388,
2996,
3682,
11208,
628
] | 2.033094 | 2,085 |
<reponame>JuliaTagBot/ModelSelection.jl
"""
to_string
"""
function to_string(data::ModelSelection.ModelSelectionData, result::AllSubsetRegressionResult)
datanames_index = ModelSelection.create_datanames_index(result.datanames)
out = ""
out *= @sprintf("\n")
out *= @sprintf("══════════════════════════════════════════════════════════════════════════════\n")
out *= @sprintf(" Best model results \n")
out *= @sprintf("══════════════════════════════════════════════════════════════════════════════\n")
out *= @sprintf(" \n")
out *= @sprintf(" Dependent variable: %s \n", data.depvar)
out *= @sprintf(" ─────────────────────────────────────────\n")
out *= @sprintf(" \n")
out *= @sprintf(" Selected covariates Coef.")
if result.ttest
out *= @sprintf(" Std. t-test")
end
out *= @sprintf("\n")
out *= @sprintf("──────────────────────────────────────────────────────────────────────────────\n")
cols = ModelSelection.get_selected_variables(Int64(result.bestresult_data[datanames_index[:index]]), data.expvars, data.intercept)
for pos in cols
varname = data.expvars[pos]
out *= @sprintf(" %-35s", varname)
out *= @sprintf(" %-10f", result.bestresult_data[datanames_index[Symbol(string(varname, "_b"))]])
if result.ttest
out *= @sprintf(" %-10f", result.bestresult_data[datanames_index[Symbol(string(varname, "_bstd"))]])
out *= @sprintf(" %-10f", result.bestresult_data[datanames_index[Symbol(string(varname, "_t"))]])
end
out *= @sprintf("\n")
end
out *= @sprintf("──────────────────────────────────────────────────────────────────────────────\n")
out *= @sprintf(" Observations %-10d\n", result.bestresult_data[datanames_index[:nobs]])
out *= @sprintf(" F-statistic %-10f\n", result.bestresult_data[datanames_index[:F]])
if :r2adj in result.datanames
out *= @sprintf(" Adjusted R² %-10f\n", result.bestresult_data[datanames_index[:r2adj]])
end
for criteria in result.criteria
if AVAILABLE_CRITERIA[criteria]["verbose_show"] && criteria != :r2adj
out *= @sprintf(" %-30s %-10f\n", AVAILABLE_CRITERIA[criteria]["verbose_title"], result.bestresult_data[datanames_index[criteria]])
end
end
if !result.modelavg
out *= @sprintf("──────────────────────────────────────────────────────────────────────────────\n")
else
out *= @sprintf("\n")
out *= @sprintf("\n")
out *= @sprintf("══════════════════════════════════════════════════════════════════════════════\n")
out *= @sprintf(" Model averaging results \n")
out *= @sprintf("══════════════════════════════════════════════════════════════════════════════\n")
out *= @sprintf(" \n")
out *= @sprintf(" Dependent variable: %s \n", data.depvar)
out *= @sprintf(" ─────────────────────────────────────────\n")
out *= @sprintf(" \n")
out *= @sprintf(" Covariates Coef.")
if result.ttest
out *= @sprintf(" Std. t-test")
end
out *= @sprintf("\n")
out *= @sprintf("──────────────────────────────────────────────────────────────────────────────\n")
for varname in data.expvars
out *= @sprintf(" %-35s", varname)
out *= @sprintf(" %-10f", result.modelavg_data[datanames_index[Symbol(string(varname, "_b"))]])
if result.ttest
out *= @sprintf(" %-10f", result.modelavg_data[datanames_index[Symbol(string(varname, "_bstd"))]])
out *= @sprintf(" %-10f", result.modelavg_data[datanames_index[Symbol(string(varname, "_t"))]])
end
out *= @sprintf("\n")
end
out *= @sprintf("\n")
out *= @sprintf("──────────────────────────────────────────────────────────────────────────────\n")
out *= @sprintf(" Observations %-10d\n", result.modelavg_data[datanames_index[:nobs]])
out *= @sprintf(" Adjusted R² %-10f\n", result.modelavg_data[datanames_index[:r2adj]])
out *= @sprintf(" F-statistic %-10f\n", result.modelavg_data[datanames_index[:F]])
out *= @sprintf(" Combined criteria %-10f\n", result.modelavg_data[datanames_index[:order]])
out *= @sprintf("──────────────────────────────────────────────────────────────────────────────\n")
end
return out
end
| [
27,
7856,
261,
480,
29,
16980,
544,
24835,
20630,
14,
17633,
4653,
1564,
13,
20362,
198,
198,
37811,
198,
1462,
62,
8841,
198,
37811,
198,
8818,
284,
62,
8841,
7,
7890,
3712,
17633,
4653,
1564,
13,
17633,
4653,
1564,
6601,
11,
1255,
3712,
3237,
7004,
2617,
8081,
2234,
23004,
8,
198,
220,
220,
220,
4818,
272,
1047,
62,
9630,
796,
9104,
4653,
1564,
13,
17953,
62,
19608,
272,
1047,
62,
9630,
7,
20274,
13,
19608,
272,
1047,
8,
628,
220,
220,
220,
503,
796,
13538,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
59,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
59,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6705,
2746,
2482,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
59,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37947,
298,
7885,
25,
4064,
82,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
77,
1600,
1366,
13,
10378,
7785,
8,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13305,
222,
28542,
28542,
28542,
28542,
28542,
59,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
41344,
44829,
689,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1766,
891,
19570,
198,
220,
220,
220,
611,
1255,
13,
926,
395,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
520,
67,
13,
220,
220,
220,
220,
220,
220,
220,
220,
256,
12,
9288,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
59,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
16068,
8418,
59,
77,
4943,
628,
220,
220,
220,
951,
82,
796,
9104,
4653,
1564,
13,
1136,
62,
34213,
62,
25641,
2977,
7,
5317,
2414,
7,
20274,
13,
13466,
20274,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
25,
9630,
11907,
828,
1366,
13,
11201,
85,
945,
11,
1366,
13,
3849,
984,
8,
628,
220,
220,
220,
329,
1426,
287,
951,
82,
198,
220,
220,
220,
220,
220,
220,
220,
1401,
3672,
796,
1366,
13,
11201,
85,
945,
58,
1930,
60,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
4064,
12,
2327,
82,
1600,
1401,
3672,
8,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
4064,
12,
940,
69,
1600,
1255,
13,
13466,
20274,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
13940,
23650,
7,
8841,
7,
85,
1501,
480,
11,
45434,
65,
48774,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1255,
13,
926,
395,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
4064,
12,
940,
69,
1600,
1255,
13,
13466,
20274,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
13940,
23650,
7,
8841,
7,
85,
1501,
480,
11,
45434,
65,
19282,
48774,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
4064,
12,
940,
69,
1600,
1255,
13,
13466,
20274,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
13940,
23650,
7,
8841,
7,
85,
1501,
480,
11,
45434,
83,
48774,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
59,
77,
4943,
198,
220,
220,
220,
886,
628,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
16068,
8418,
59,
77,
4943,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
19243,
602,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
12,
940,
67,
59,
77,
1600,
1255,
13,
13466,
20274,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
25,
77,
8158,
11907,
8,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
376,
12,
14269,
2569,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
12,
940,
69,
59,
77,
1600,
1255,
13,
13466,
20274,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
25,
37,
11907,
8,
198,
220,
220,
220,
611,
1058,
81,
17,
41255,
287,
1255,
13,
19608,
272,
1047,
220,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
45624,
371,
31185,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
12,
940,
69,
59,
77,
1600,
1255,
13,
13466,
20274,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
25,
81,
17,
41255,
11907,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
329,
9987,
287,
1255,
13,
22213,
5142,
198,
220,
220,
220,
220,
220,
220,
220,
611,
317,
11731,
4146,
17534,
62,
9419,
2043,
1137,
3539,
58,
22213,
5142,
7131,
1,
19011,
577,
62,
12860,
8973,
11405,
9987,
14512,
1058,
81,
17,
41255,
198,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
4064,
12,
1270,
82,
220,
220,
220,
220,
220,
4064,
12,
940,
69,
59,
77,
1600,
317,
11731,
4146,
17534,
62,
9419,
2043,
1137,
3539,
58,
22213,
5142,
7131,
1,
19011,
577,
62,
7839,
33116,
1255,
13,
13466,
20274,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
22213,
5142,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
5145,
20274,
13,
19849,
615,
70,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
16068,
8418,
59,
77,
4943,
198,
220,
220,
220,
2073,
220,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9104,
20430,
2482,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
31732,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37947,
298,
7885,
25,
4064,
82,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
77,
1600,
1366,
13,
10378,
7785,
8,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13305,
222,
28542,
28542,
28542,
28542,
28542,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3467,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
39751,
2743,
689,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1766,
891,
19570,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1255,
13,
926,
395,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
220,
220,
220,
220,
220,
520,
67,
13,
220,
220,
220,
220,
220,
220,
220,
220,
256,
12,
9288,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
16068,
8418,
59,
77,
4943,
628,
220,
220,
220,
220,
220,
220,
220,
329,
1401,
3672,
287,
1366,
13,
11201,
85,
945,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
4064,
12,
2327,
82,
1600,
1401,
3672,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
4064,
12,
940,
69,
1600,
1255,
13,
19849,
615,
70,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
13940,
23650,
7,
8841,
7,
85,
1501,
480,
11,
45434,
65,
48774,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
1255,
13,
926,
395,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
4064,
12,
940,
69,
1600,
1255,
13,
19849,
615,
70,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
13940,
23650,
7,
8841,
7,
85,
1501,
480,
11,
45434,
65,
19282,
48774,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
220,
220,
4064,
12,
940,
69,
1600,
1255,
13,
19849,
615,
70,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
13940,
23650,
7,
8841,
7,
85,
1501,
480,
11,
45434,
83,
48774,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
16068,
8418,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
19243,
602,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
12,
940,
67,
59,
77,
1600,
1255,
13,
19849,
615,
70,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
25,
77,
8158,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
45624,
371,
31185,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
12,
940,
69,
59,
77,
1600,
1255,
13,
19849,
615,
70,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
25,
81,
17,
41255,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
376,
12,
14269,
2569,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
12,
940,
69,
59,
77,
1600,
1255,
13,
19849,
615,
70,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
25,
37,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
32028,
9987,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4064,
12,
940,
69,
59,
77,
1600,
1255,
13,
19849,
615,
70,
62,
7890,
58,
19608,
272,
1047,
62,
9630,
58,
25,
2875,
11907,
8,
198,
220,
220,
220,
220,
220,
220,
220,
503,
1635,
28,
2488,
82,
37435,
7203,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
28542,
16068,
8418,
59,
77,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
503,
198,
437,
198
] | 1.890529 | 2,777 |
export @bridge
"""
AbstractBridge
A bridge represents a bridged constraint in an `AbstractBridgeOptimizer`. It contains the indices of the constraints that it has created in the model.
These can be obtained using `MOI.NumberOfConstraints` and `MOI.ListOfConstraintIndices` and using the bridge in place of a `ModelLike`.
Attributes of the bridged model such as `MOI.ConstraintDual` and `MOI.ConstraintPrimal`, can be obtained using the bridge in place of the constraint index.
These calls are used by the `AbstractBridgeOptimizer` to communicate with the bridge so they should be implemented by the bridge.
"""
abstract type AbstractBridge end
function MOI.get(::MOI.ModelLike, attr::MOI.AbstractConstraintAttribute,
bridge::AbstractBridge)
throw(ArgumentError("Constraint bridge of type `$(typeof(bridge))` does not support accessing the attribute `$attr`."))
end
"""
MOI.get(b::AbstractBridge, ::MOI.NumberOfVariables)
The number of variables created by the bridge `b` in the model.
"""
MOI.get(b::AbstractBridge, ::MOI.NumberOfVariables) = 0
"""
MOI.get(b::AbstractBridge, ::MOI.NumberOfConstraints{F, S}) where {F, S}
The number of constraints of the type `F`-in-`S` created by the bridge `b` in the model.
"""
MOI.get(b::AbstractBridge, ::MOI.NumberOfConstraints) = 0
"""
MOI.get(b::AbstractBridge, ::MOI.NumberOfConstraints{F, S}) where {F, S}
A `Vector{ConstraintIndex{F,S}}` with indices of all constraints of
type `F`-in`S` created by the bride `b` in the model (i.e., of length equal to the value of `NumberOfConstraints{F,S}()`).
"""
MOI.get(b::AbstractBridge, ::MOI.ListOfConstraintIndices{F, S}) where {F, S} = CI{F, S}[]
"""
MOI.supports_constraint(BT::Type{<:AbstractBridge}, F::Type{<:MOI.AbstractFunction}, S::Type{<:MOI.AbstractSet})::Bool
Return a `Bool` indicating whether the bridges of type `BT` support bridging `F`-in-`S` constraints.
"""
MOI.supports_constraint(::Type{<:AbstractBridge}, ::Type{<:MOI.AbstractFunction}, ::Type{<:MOI.AbstractSet}) = false
"""
added_constraint_types(BT::Type{<:AbstractBridge}, F::Type{<:MOI.AbstractFunction}, S::Type{<:MOI.AbstractSet})::Bool
Return a list of the types of constraints that bridges of type `BT` add for
bridging an `F`-in-`S` constraints.
added_constraint_types(BT::Type{<:AbstractBridge})::Bool
Return a list of the types of constraints that bridges of concrete type `BT` add
for `F`-in-`S` constraints.
"""
function added_constraint_types(BT::Type{<:AbstractBridge},
F::Type{<:MOI.AbstractFunction},
S::Type{<:MOI.AbstractSet})
added_constraint_types(concrete_bridge_type(BT, F, S))
end
"""
concrete_bridge_type(BT::Type{<:AbstractBridge},
F::Type{<:MOI.AbstractFunction},
S::Type{<:MOI.AbstractSet})::DataType
Return the concrete type of the bridge supporting `F`-in-`S` constraints. This
function can only be called if `MOI.supports_constraint(BT, F, S)` is `true`.
## Examples
The following returns `SplitIntervalBridge{Float64, MOI.SingleVariable}`:
```julia
concrete_bridge_type(SplitIntervalBridge{Float64}, MOI.SingleVariable,
MOI.Interval{Float64})
```
"""
function concrete_bridge_type(bridge_type::DataType,
::Type{<:MOI.AbstractFunction},
::Type{<:MOI.AbstractSet})
return bridge_type
end
| [
39344,
2488,
9458,
198,
198,
37811,
198,
220,
220,
220,
27741,
37385,
198,
198,
32,
7696,
6870,
257,
38265,
2004,
32315,
287,
281,
4600,
23839,
37385,
27871,
320,
7509,
44646,
632,
4909,
262,
36525,
286,
262,
17778,
326,
340,
468,
2727,
287,
262,
2746,
13,
198,
4711,
460,
307,
6492,
1262,
4600,
11770,
40,
13,
15057,
5189,
3103,
2536,
6003,
63,
290,
4600,
11770,
40,
13,
8053,
5189,
3103,
2536,
2913,
5497,
1063,
63,
290,
1262,
262,
7696,
287,
1295,
286,
257,
4600,
17633,
7594,
44646,
198,
29021,
286,
262,
38265,
2004,
2746,
884,
355,
4600,
11770,
40,
13,
3103,
2536,
2913,
36248,
63,
290,
4600,
11770,
40,
13,
3103,
2536,
2913,
23828,
282,
47671,
460,
307,
6492,
1262,
262,
7696,
287,
1295,
286,
262,
32315,
6376,
13,
198,
4711,
3848,
389,
973,
416,
262,
4600,
23839,
37385,
27871,
320,
7509,
63,
284,
10996,
351,
262,
7696,
523,
484,
815,
307,
9177,
416,
262,
7696,
13,
198,
37811,
198,
397,
8709,
2099,
27741,
37385,
886,
628,
198,
8818,
13070,
40,
13,
1136,
7,
3712,
11770,
40,
13,
17633,
7594,
11,
708,
81,
3712,
11770,
40,
13,
23839,
3103,
2536,
2913,
33682,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7696,
3712,
23839,
37385,
8,
198,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
3103,
2536,
2913,
7696,
286,
2099,
4600,
3,
7,
4906,
1659,
7,
9458,
4008,
63,
857,
407,
1104,
22534,
262,
11688,
4600,
3,
35226,
63,
526,
4008,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
13070,
40,
13,
1136,
7,
65,
3712,
23839,
37385,
11,
7904,
11770,
40,
13,
15057,
5189,
23907,
2977,
8,
198,
198,
464,
1271,
286,
9633,
2727,
416,
262,
7696,
4600,
65,
63,
287,
262,
2746,
13,
198,
37811,
198,
11770,
40,
13,
1136,
7,
65,
3712,
23839,
37385,
11,
7904,
11770,
40,
13,
15057,
5189,
23907,
2977,
8,
796,
657,
198,
198,
37811,
198,
220,
220,
220,
13070,
40,
13,
1136,
7,
65,
3712,
23839,
37385,
11,
7904,
11770,
40,
13,
15057,
5189,
3103,
2536,
6003,
90,
37,
11,
311,
30072,
810,
1391,
37,
11,
311,
92,
198,
198,
464,
1271,
286,
17778,
286,
262,
2099,
4600,
37,
63,
12,
259,
12,
63,
50,
63,
2727,
416,
262,
7696,
4600,
65,
63,
287,
262,
2746,
13,
198,
37811,
198,
11770,
40,
13,
1136,
7,
65,
3712,
23839,
37385,
11,
7904,
11770,
40,
13,
15057,
5189,
3103,
2536,
6003,
8,
796,
657,
198,
198,
37811,
198,
220,
220,
220,
13070,
40,
13,
1136,
7,
65,
3712,
23839,
37385,
11,
7904,
11770,
40,
13,
15057,
5189,
3103,
2536,
6003,
90,
37,
11,
311,
30072,
810,
1391,
37,
11,
311,
92,
198,
198,
32,
4600,
38469,
90,
3103,
2536,
2913,
15732,
90,
37,
11,
50,
11709,
63,
351,
36525,
286,
477,
17778,
286,
198,
4906,
4600,
37,
63,
12,
259,
63,
50,
63,
2727,
416,
262,
26619,
4600,
65,
63,
287,
262,
2746,
357,
72,
13,
68,
1539,
286,
4129,
4961,
284,
262,
1988,
286,
4600,
15057,
5189,
3103,
2536,
6003,
90,
37,
11,
50,
92,
3419,
63,
737,
198,
37811,
198,
11770,
40,
13,
1136,
7,
65,
3712,
23839,
37385,
11,
7904,
11770,
40,
13,
8053,
5189,
3103,
2536,
2913,
5497,
1063,
90,
37,
11,
311,
30072,
810,
1391,
37,
11,
311,
92,
796,
14514,
90,
37,
11,
311,
92,
21737,
198,
198,
37811,
198,
220,
220,
220,
13070,
40,
13,
18608,
2096,
62,
1102,
2536,
2913,
7,
19313,
3712,
6030,
90,
27,
25,
23839,
37385,
5512,
376,
3712,
6030,
90,
27,
25,
11770,
40,
13,
23839,
22203,
5512,
311,
3712,
6030,
90,
27,
25,
11770,
40,
13,
23839,
7248,
92,
2599,
25,
33,
970,
198,
198,
13615,
257,
4600,
33,
970,
63,
12739,
1771,
262,
19432,
286,
2099,
4600,
19313,
63,
1104,
38265,
2667,
4600,
37,
63,
12,
259,
12,
63,
50,
63,
17778,
13,
198,
37811,
198,
11770,
40,
13,
18608,
2096,
62,
1102,
2536,
2913,
7,
3712,
6030,
90,
27,
25,
23839,
37385,
5512,
7904,
6030,
90,
27,
25,
11770,
40,
13,
23839,
22203,
5512,
7904,
6030,
90,
27,
25,
11770,
40,
13,
23839,
7248,
30072,
796,
3991,
198,
198,
37811,
198,
220,
220,
220,
2087,
62,
1102,
2536,
2913,
62,
19199,
7,
19313,
3712,
6030,
90,
27,
25,
23839,
37385,
5512,
376,
3712,
6030,
90,
27,
25,
11770,
40,
13,
23839,
22203,
5512,
311,
3712,
6030,
90,
27,
25,
11770,
40,
13,
23839,
7248,
92,
2599,
25,
33,
970,
198,
198,
13615,
257,
1351,
286,
262,
3858,
286,
17778,
326,
19432,
286,
2099,
4600,
19313,
63,
751,
329,
198,
10236,
2667,
281,
4600,
37,
63,
12,
259,
12,
63,
50,
63,
17778,
13,
628,
220,
220,
220,
2087,
62,
1102,
2536,
2913,
62,
19199,
7,
19313,
3712,
6030,
90,
27,
25,
23839,
37385,
92,
2599,
25,
33,
970,
198,
198,
13615,
257,
1351,
286,
262,
3858,
286,
17778,
326,
19432,
286,
10017,
2099,
4600,
19313,
63,
751,
198,
1640,
4600,
37,
63,
12,
259,
12,
63,
50,
63,
17778,
13,
198,
37811,
198,
8818,
2087,
62,
1102,
2536,
2913,
62,
19199,
7,
19313,
3712,
6030,
90,
27,
25,
23839,
37385,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
376,
3712,
6030,
90,
27,
25,
11770,
40,
13,
23839,
22203,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
311,
3712,
6030,
90,
27,
25,
11770,
40,
13,
23839,
7248,
30072,
198,
220,
220,
220,
2087,
62,
1102,
2536,
2913,
62,
19199,
7,
1102,
38669,
62,
9458,
62,
4906,
7,
19313,
11,
376,
11,
311,
4008,
198,
437,
628,
198,
37811,
198,
220,
220,
220,
10017,
62,
9458,
62,
4906,
7,
19313,
3712,
6030,
90,
27,
25,
23839,
37385,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
376,
3712,
6030,
90,
27,
25,
11770,
40,
13,
23839,
22203,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
311,
3712,
6030,
90,
27,
25,
11770,
40,
13,
23839,
7248,
92,
2599,
25,
6601,
6030,
198,
198,
13615,
262,
10017,
2099,
286,
262,
7696,
6493,
4600,
37,
63,
12,
259,
12,
63,
50,
63,
17778,
13,
770,
198,
8818,
460,
691,
307,
1444,
611,
4600,
11770,
40,
13,
18608,
2096,
62,
1102,
2536,
2913,
7,
19313,
11,
376,
11,
311,
8,
63,
318,
4600,
7942,
44646,
198,
198,
2235,
21066,
198,
198,
464,
1708,
5860,
4600,
41205,
9492,
2100,
37385,
90,
43879,
2414,
11,
13070,
40,
13,
28008,
43015,
92,
63,
25,
198,
15506,
63,
73,
43640,
198,
1102,
38669,
62,
9458,
62,
4906,
7,
41205,
9492,
2100,
37385,
90,
43879,
2414,
5512,
13070,
40,
13,
28008,
43015,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13070,
40,
13,
9492,
2100,
90,
43879,
2414,
30072,
198,
15506,
63,
198,
37811,
198,
8818,
10017,
62,
9458,
62,
4906,
7,
9458,
62,
4906,
3712,
6601,
6030,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7904,
6030,
90,
27,
25,
11770,
40,
13,
23839,
22203,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7904,
6030,
90,
27,
25,
11770,
40,
13,
23839,
7248,
30072,
198,
220,
220,
220,
1441,
7696,
62,
4906,
198,
437,
198
] | 2.595078 | 1,341 |
<reponame>thautwarm/MLFS.jl<filename>test/example.jl
x :: Type[Tag()]
x = Type
function f()
end | [
27,
7856,
261,
480,
29,
400,
2306,
31975,
14,
5805,
10652,
13,
20362,
27,
34345,
29,
9288,
14,
20688,
13,
20362,
198,
198,
87,
7904,
5994,
58,
24835,
3419,
60,
198,
87,
796,
5994,
198,
198,
8818,
277,
3419,
198,
198,
437
] | 2.333333 | 42 |
## Copyright (c) 2013 <NAME>
##
## This file is distributed under the 2-clause BSD License.
# Auxiliary, non-exported functions are declared here.
# convert marker string description to gnuplot's expected number
function pointtype(x::String)
x == "+" && return "1"
x == "x" && return "2"
x == "*" && return "3"
x == "esquare" && return "4"
x == "fsquare" && return "5"
x == "ecircle" && return "6"
x == "fcircle" && return "7"
x == "etrianup" && return "8"
x == "ftrianup" && return "9"
x == "etriandn" && return "10"
x == "ftriandn" && return "11"
x == "edmd" && return "12"
x == "fdmd" && return "13"
return "1"
end
# create a Z-coordinate matrix from x, y coordinates and a function
function meshgrid(x,y,f)
Z = zeros(length(x),length(y))
for k = 1:length(x)
Z[k,:] = [ f(i,j) for i=x[k], j=y ]
end
return Z
end
# create x,y coordinates for a histogram, from a sample vector, using a number
# of bins
function hist(s,bins)
# When adding an element s to a bin, we use an iequality m < s <= M.
# In order to account for elements s==m, we need to special-case
# the computation for the first bin
ms = minimum(s)
Ms = maximum(s)
bins = max(bins, 1)
if Ms == ms
# compute a "natural" scale
g = (10.0^floor(log10(abs(ms)+eps()))) / 2
ms, Ms = ms - g, ms + g
end
delta = (Ms-ms)/bins
x = ms:delta:Ms
y = zeros(bins)
# this is special-cased because we want to include the minimum in the
# first bin
y[1] = sum(ms .<= s .<= x[2])
for i in 2:length(x)-2
y[i] = sum(x[i] .< s .<= x[i+1])
end
# this is special-cased because there is no guarantee that x[end] == Ms
# (because of how ranges work)
if length(y) > 1 y[end] = sum(x[end-1] .< s .<= Ms) end
if bins != 1
# We want the left bin to start at ms and the right bin to end at Ms
x = (ms+delta/2):delta:Ms
else
# add two empty bins on the sides to provide a scale to gnuplot
x = (ms-delta/2):delta:(ms+delta/2)
y = [0.0, y[1], 0.0]
end
return x,y
end
function Base.show(io::IO, ::MIME"text/plain", x::Figure)
isempty(x) && return nothing
IsJupyterOrJuno && return nothing
llplot(x)
if config[:mode] != "null"
if (config[:term][:terminal] ∈ term_text) || (config[:mode] == "ijulia")
write(io, x.svg)
end
end
return nothing
end
function Base.show(io::IO, ::MIME"image/svg+xml", x::Figure)
llplot(x)
write(io,x.svg)
return nothing
end
# return configuration string for a single plot
function linestr_single(conf::CurveConf)
s = ""
conf.legend != "" && (s *= " title '"*conf.legend*"' ")
conf.plotstyle != "" && (s *= " with "*conf.plotstyle*" ")
conf.linecolor != "" && (s *= "lc rgb '"*conf.linecolor*"' ")
conf.linewidth != "" && (s *= "lw "*conf.linewidth*" ")
conf.linestyle != "" && (s *= "dt '"*conf.linestyle*"' ")
conf.fillstyle != "" && (s *= "fs "*conf.fillstyle*" ")
conf.fillcolor != "" && (s *= "fc \""*conf.fillcolor*"\" ")
# some plotstyles don't allow point specifiers
if conf.plotstyle ∈ ps_sup_points
if conf.pointtype != ""
if conf.pointtype ∈ supported_pointtypes
s = s*"pt "*pointtype(conf.pointtype)*" "
else
s = s*"pt \""*conf.pointtype*"\" "
end
conf.pointsize != "" && (s = s*"ps "*conf.pointsize*" ")
end
end
return s
end
# build a string with plot commands according to configuration
function linestr(curves::Vector{Curve}, cmd, file)
# We have to insert "," between plot commands. One easy way to do this
# is create the first plot command, then the rest
# We also need to keep track of the current index (starts at zero)
index = 0
s = cmd*" '"*file*"' "*" i 0 "*linestr_single(curves[1].conf)
if length(curves) > 1
for i in curves[2:end]
index += 1
s = s*", '"*file*"' "*" i "*string(index)*" "*linestr_single(i.conf)
end
end
return s
end
# Build a "set term" string appropriate for the terminal type
function termstring(f::Figure,print=false)
global gnuplot_state
ac = f.axes
tc = f.term
pc = f.print
term = print ? pc.print_term : config[:term][:terminal]
if term != ""
# determine font, size, and background
font = print ? pc.print_font : tc.font
size = print ? pc.print_size : tc.size
background = print ? pc.print_background : tc.background
# build term string
ts = "set term $term "
term ∈ term_window && (ts = ts*string(gnuplot_state.current)*" ")
isempty(font) ? s = "" : s = " font \""*font*"\" "
term ∈ term_sup_font && (ts *= s)
isempty(size) ? s = "" : s = " size "*size*" "
term ∈ term_sup_size && (ts *= s)
isempty(background) ? s = "" : s = " background \""*background*"\" "
term ∈ term_sup_bkgnd && (ts *= s)
# terminal options
print || (ts *= config[:term][:termopts]*" ")
print && (ts *= config[:print][:print_termopts]*" ")
# set output file
if term ∈ term_file
s = ""
isempty(ac.output) || (s = "\nset output \"$(ac.output)\" ")
ts = ts*s
end
end
return ts
end
# send gnuplot the current figure's configuration
function gnuplot_send_fig_config(config)
config.title != "" && gnuplot_send("set title '"*config.title*"' ")
config.fillstyle != "" && gnuplot_send("set style fill "*config.fillstyle)
if config.grid != ""
if config.grid == "on"
gnuplot_send("set grid")
else
gnuplot_send("set grid "*config.grid)
end
end
config.keyoptions != "" && gnuplot_send("set key "*config.keyoptions)
config.boxwidth != "" && gnuplot_send("set boxwidth "*config.boxwidth)
if config.axis != ""
config.axis == "semilogx" && gnuplot_send("set logscale x")
config.axis == "semilogy" && gnuplot_send("set logscale y")
config.axis == "semilogz" && gnuplot_send("set logscale z")
config.axis == "loglog" && gnuplot_send("set logscale xyz")
end
config.xlabel != "" && gnuplot_send("set xlabel '"*config.xlabel*"' ")
config.ylabel != "" && gnuplot_send("set ylabel '"*config.ylabel*"' ")
config.zlabel != "" && gnuplot_send("set zlabel '"*config.zlabel*"' ")
config.xrange != "" && gnuplot_send("set xrange "*config.xrange)
config.yrange != "" && gnuplot_send("set yrange "*config.yrange)
config.zrange != "" && gnuplot_send("set zrange "*config.zrange)
if config.xzeroaxis != ""
if config.xzeroaxis == "on"
gnuplot_send("set xzeroaxis")
else
gnuplot_send("set xzeroaxis "*config.xzeroaxis)
end
end
if config.yzeroaxis != ""
if config.yzeroaxis == "on"
gnuplot_send("set yzeroaxis")
else
gnuplot_send("set yzeroaxis "*config.yzeroaxis)
end
end
if config.zzeroaxis != ""
if config.zzeroaxis == "on"
gnuplot_send("set zzeroaxis")
else
gnuplot_send("set zzeroaxis "*config.zzeroaxis)
end
end
config.palette != "" && gnuplot_send("set palette "*config.palette)
end
# write commands to gnuplot's pipe
function gnuplot_send(s)
config[:debug] && println(s) # print gnuplot commands if debug enabled
w = write(P.gstdin, string(s,"\n"))
# check that data was accepted by the pipe
if !(w > 0)
println("Something went wrong writing to gnuplot STDIN.")
return
end
flush(P.gstdin)
end
| [
2235,
15069,
357,
66,
8,
2211,
1279,
20608,
29,
198,
2235,
198,
2235,
770,
2393,
318,
9387,
739,
262,
362,
12,
565,
682,
347,
10305,
13789,
13,
198,
198,
2,
47105,
28129,
11,
1729,
12,
1069,
9213,
5499,
389,
6875,
994,
13,
198,
198,
2,
10385,
18364,
4731,
6764,
284,
19967,
84,
29487,
338,
2938,
1271,
198,
8818,
966,
4906,
7,
87,
3712,
10100,
8,
198,
220,
220,
220,
2124,
6624,
43825,
1,
11405,
1441,
366,
16,
1,
198,
220,
220,
220,
2124,
6624,
366,
87,
1,
11405,
1441,
366,
17,
1,
198,
220,
220,
220,
2124,
6624,
366,
9,
1,
11405,
1441,
366,
18,
1,
198,
220,
220,
220,
2124,
6624,
366,
274,
421,
533,
1,
11405,
1441,
366,
19,
1,
198,
220,
220,
220,
2124,
6624,
366,
9501,
421,
533,
1,
11405,
1441,
366,
20,
1,
198,
220,
220,
220,
2124,
6624,
366,
721,
1980,
293,
1,
11405,
1441,
366,
21,
1,
198,
220,
220,
220,
2124,
6624,
366,
16072,
1980,
293,
1,
11405,
1441,
366,
22,
1,
198,
220,
220,
220,
2124,
6624,
366,
316,
4484,
929,
1,
11405,
1441,
366,
23,
1,
198,
220,
220,
220,
2124,
6624,
366,
701,
4484,
929,
1,
11405,
1441,
366,
24,
1,
198,
220,
220,
220,
2124,
6624,
366,
316,
380,
392,
77,
1,
11405,
1441,
366,
940,
1,
198,
220,
220,
220,
2124,
6624,
366,
701,
380,
392,
77,
1,
11405,
1441,
366,
1157,
1,
198,
220,
220,
220,
2124,
6624,
366,
276,
9132,
1,
11405,
1441,
366,
1065,
1,
198,
220,
220,
220,
2124,
6624,
366,
16344,
9132,
1,
11405,
1441,
366,
1485,
1,
198,
220,
220,
220,
1441,
366,
16,
1,
198,
437,
198,
198,
2,
2251,
257,
1168,
12,
37652,
4559,
17593,
422,
2124,
11,
331,
22715,
290,
257,
2163,
198,
8818,
19609,
25928,
7,
87,
11,
88,
11,
69,
8,
198,
220,
220,
220,
1168,
796,
1976,
27498,
7,
13664,
7,
87,
828,
13664,
7,
88,
4008,
198,
220,
220,
220,
329,
479,
796,
352,
25,
13664,
7,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1168,
58,
74,
11,
47715,
796,
685,
277,
7,
72,
11,
73,
8,
329,
1312,
28,
87,
58,
74,
4357,
474,
28,
88,
2361,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
1168,
198,
437,
198,
198,
2,
2251,
2124,
11,
88,
22715,
329,
257,
1554,
21857,
11,
422,
257,
6291,
15879,
11,
1262,
257,
1271,
198,
2,
286,
41701,
198,
8818,
1554,
7,
82,
11,
65,
1040,
8,
198,
220,
220,
220,
1303,
1649,
4375,
281,
5002,
264,
284,
257,
9874,
11,
356,
779,
281,
37941,
13237,
285,
1279,
264,
19841,
337,
13,
198,
220,
220,
220,
1303,
554,
1502,
284,
1848,
329,
4847,
264,
855,
76,
11,
356,
761,
284,
2041,
12,
7442,
198,
220,
220,
220,
1303,
262,
29964,
329,
262,
717,
9874,
198,
220,
220,
220,
13845,
796,
5288,
7,
82,
8,
198,
220,
220,
220,
6997,
796,
5415,
7,
82,
8,
198,
220,
220,
220,
41701,
796,
3509,
7,
65,
1040,
11,
352,
8,
198,
220,
220,
220,
611,
6997,
6624,
13845,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
24061,
257,
366,
11802,
1,
5046,
198,
220,
220,
220,
220,
220,
220,
220,
308,
796,
357,
940,
13,
15,
61,
28300,
7,
6404,
940,
7,
8937,
7,
907,
47762,
25386,
3419,
22305,
1220,
362,
198,
220,
220,
220,
220,
220,
220,
220,
13845,
11,
6997,
796,
13845,
532,
308,
11,
13845,
1343,
308,
198,
220,
220,
220,
886,
198,
220,
220,
220,
25979,
796,
357,
10128,
12,
907,
20679,
65,
1040,
198,
220,
220,
220,
2124,
796,
13845,
25,
67,
12514,
25,
10128,
198,
220,
220,
220,
331,
796,
1976,
27498,
7,
65,
1040,
8,
198,
220,
220,
220,
1303,
428,
318,
2041,
12,
66,
839,
780,
356,
765,
284,
2291,
262,
5288,
287,
262,
198,
220,
220,
220,
1303,
717,
9874,
198,
220,
220,
220,
331,
58,
16,
60,
796,
2160,
7,
907,
764,
27,
28,
264,
764,
27,
28,
2124,
58,
17,
12962,
198,
220,
220,
220,
329,
1312,
287,
362,
25,
13664,
7,
87,
13219,
17,
198,
220,
220,
220,
220,
220,
220,
220,
331,
58,
72,
60,
796,
2160,
7,
87,
58,
72,
60,
764,
27,
264,
764,
27,
28,
2124,
58,
72,
10,
16,
12962,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1303,
428,
318,
2041,
12,
66,
839,
780,
612,
318,
645,
9149,
326,
2124,
58,
437,
60,
6624,
6997,
198,
220,
220,
220,
1303,
357,
13893,
286,
703,
16069,
670,
8,
198,
220,
220,
220,
611,
4129,
7,
88,
8,
1875,
352,
331,
58,
437,
60,
796,
2160,
7,
87,
58,
437,
12,
16,
60,
764,
27,
264,
764,
27,
28,
6997,
8,
886,
628,
220,
220,
220,
611,
41701,
14512,
352,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
775,
765,
262,
1364,
9874,
284,
923,
379,
13845,
290,
262,
826,
9874,
284,
886,
379,
6997,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
796,
357,
907,
10,
67,
12514,
14,
17,
2599,
67,
12514,
25,
10128,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
751,
734,
6565,
41701,
319,
262,
5389,
284,
2148,
257,
5046,
284,
19967,
84,
29487,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
796,
357,
907,
12,
67,
12514,
14,
17,
2599,
67,
12514,
37498,
907,
10,
67,
12514,
14,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
331,
796,
685,
15,
13,
15,
11,
331,
58,
16,
4357,
657,
13,
15,
60,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
2124,
11,
88,
198,
437,
198,
198,
8818,
7308,
13,
12860,
7,
952,
3712,
9399,
11,
7904,
44,
12789,
1,
5239,
14,
25638,
1600,
2124,
3712,
11337,
8,
198,
220,
220,
220,
318,
28920,
7,
87,
8,
11405,
1441,
2147,
198,
220,
220,
220,
1148,
41,
929,
88,
353,
5574,
22396,
78,
11405,
1441,
2147,
198,
220,
220,
220,
32660,
29487,
7,
87,
8,
198,
220,
220,
220,
611,
4566,
58,
25,
14171,
60,
14512,
366,
8423,
1,
198,
220,
220,
220,
220,
220,
220,
220,
611,
357,
11250,
58,
25,
4354,
7131,
25,
23705,
282,
60,
18872,
230,
3381,
62,
5239,
8,
8614,
357,
11250,
58,
25,
14171,
60,
6624,
366,
2926,
43640,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3551,
7,
952,
11,
2124,
13,
21370,
70,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
8818,
7308,
13,
12860,
7,
952,
3712,
9399,
11,
7904,
44,
12789,
1,
9060,
14,
21370,
70,
10,
19875,
1600,
2124,
3712,
11337,
8,
198,
220,
220,
220,
32660,
29487,
7,
87,
8,
198,
220,
220,
220,
3551,
7,
952,
11,
87,
13,
21370,
70,
8,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
2,
1441,
8398,
4731,
329,
257,
2060,
7110,
198,
8818,
9493,
395,
81,
62,
29762,
7,
10414,
3712,
26628,
303,
18546,
8,
198,
220,
220,
220,
264,
796,
13538,
198,
220,
220,
220,
1013,
13,
1455,
437,
14512,
13538,
11405,
357,
82,
1635,
28,
366,
3670,
705,
1,
9,
10414,
13,
1455,
437,
9,
30543,
366,
8,
198,
220,
220,
220,
1013,
13,
29487,
7635,
14512,
13538,
11405,
357,
82,
1635,
28,
366,
351,
366,
9,
10414,
13,
29487,
7635,
9,
1,
366,
8,
198,
220,
220,
220,
1013,
13,
1370,
8043,
14512,
13538,
11405,
357,
82,
1635,
28,
366,
44601,
46140,
705,
1,
9,
10414,
13,
1370,
8043,
9,
30543,
366,
8,
198,
220,
220,
220,
1013,
13,
2815,
413,
5649,
14512,
13538,
11405,
357,
82,
1635,
28,
366,
75,
86,
366,
9,
10414,
13,
2815,
413,
5649,
9,
1,
366,
8,
198,
220,
220,
220,
1013,
13,
2815,
10992,
14512,
13538,
11405,
357,
82,
1635,
28,
366,
28664,
705,
1,
9,
10414,
13,
2815,
10992,
9,
30543,
366,
8,
198,
220,
220,
220,
1013,
13,
20797,
7635,
14512,
13538,
11405,
357,
82,
1635,
28,
366,
9501,
366,
9,
10414,
13,
20797,
7635,
9,
1,
366,
8,
198,
220,
220,
220,
1013,
13,
20797,
8043,
14512,
13538,
11405,
357,
82,
1635,
28,
366,
16072,
3467,
15931,
9,
10414,
13,
20797,
8043,
9,
1,
7879,
366,
8,
198,
220,
220,
220,
1303,
617,
7110,
47720,
836,
470,
1249,
966,
1020,
13350,
198,
220,
220,
220,
611,
1013,
13,
29487,
7635,
18872,
230,
26692,
62,
37330,
62,
13033,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1013,
13,
4122,
4906,
14512,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
1013,
13,
4122,
4906,
18872,
230,
4855,
62,
4122,
19199,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
796,
264,
9,
1,
457,
366,
9,
4122,
4906,
7,
10414,
13,
4122,
4906,
27493,
1,
366,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
796,
264,
9,
1,
457,
3467,
15931,
9,
10414,
13,
4122,
4906,
9,
1,
7879,
366,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1013,
13,
4122,
7857,
14512,
13538,
11405,
357,
82,
796,
264,
9,
1,
862,
366,
9,
10414,
13,
4122,
7857,
9,
1,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
264,
198,
437,
198,
198,
2,
1382,
257,
4731,
351,
7110,
9729,
1864,
284,
8398,
198,
8818,
9493,
395,
81,
7,
22019,
1158,
3712,
38469,
90,
26628,
303,
5512,
23991,
11,
2393,
8,
198,
220,
220,
220,
1303,
775,
423,
284,
7550,
366,
553,
1022,
7110,
9729,
13,
1881,
2562,
835,
284,
466,
428,
198,
220,
220,
220,
1303,
318,
2251,
262,
717,
7110,
3141,
11,
788,
262,
1334,
198,
220,
220,
220,
1303,
775,
635,
761,
284,
1394,
2610,
286,
262,
1459,
6376,
357,
301,
5889,
379,
6632,
8,
198,
220,
220,
220,
6376,
796,
657,
198,
220,
220,
220,
264,
796,
23991,
9,
1,
705,
1,
9,
7753,
9,
30543,
366,
9,
1,
1312,
657,
366,
9,
2815,
395,
81,
62,
29762,
7,
22019,
1158,
58,
16,
4083,
10414,
8,
198,
220,
220,
220,
611,
4129,
7,
22019,
1158,
8,
1875,
352,
198,
220,
220,
220,
220,
220,
220,
220,
329,
1312,
287,
23759,
58,
17,
25,
437,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6376,
15853,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
796,
264,
9,
1600,
705,
1,
9,
7753,
9,
30543,
366,
9,
1,
1312,
366,
9,
8841,
7,
9630,
27493,
1,
366,
9,
2815,
395,
81,
62,
29762,
7,
72,
13,
10414,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
264,
198,
437,
198,
198,
2,
10934,
257,
366,
2617,
3381,
1,
4731,
5035,
329,
262,
12094,
2099,
198,
8818,
3381,
8841,
7,
69,
3712,
11337,
11,
4798,
28,
9562,
8,
198,
220,
220,
220,
3298,
19967,
84,
29487,
62,
5219,
628,
220,
220,
220,
936,
796,
277,
13,
897,
274,
198,
220,
220,
220,
37096,
796,
277,
13,
4354,
198,
220,
220,
220,
40653,
796,
277,
13,
4798,
628,
220,
220,
220,
3381,
796,
3601,
5633,
40653,
13,
4798,
62,
4354,
1058,
4566,
58,
25,
4354,
7131,
25,
23705,
282,
60,
628,
220,
220,
220,
611,
3381,
14512,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
5004,
10369,
11,
2546,
11,
290,
4469,
198,
220,
220,
220,
220,
220,
220,
220,
10369,
796,
3601,
5633,
40653,
13,
4798,
62,
10331,
1058,
37096,
13,
10331,
198,
220,
220,
220,
220,
220,
220,
220,
2546,
796,
3601,
5633,
40653,
13,
4798,
62,
7857,
1058,
37096,
13,
7857,
198,
220,
220,
220,
220,
220,
220,
220,
4469,
796,
3601,
5633,
40653,
13,
4798,
62,
25249,
1058,
37096,
13,
25249,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
1382,
3381,
4731,
198,
220,
220,
220,
220,
220,
220,
220,
40379,
796,
366,
2617,
3381,
720,
4354,
366,
198,
220,
220,
220,
220,
220,
220,
220,
3381,
18872,
230,
3381,
62,
17497,
11405,
357,
912,
796,
40379,
9,
8841,
7,
41791,
29487,
62,
5219,
13,
14421,
27493,
1,
366,
8,
628,
220,
220,
220,
220,
220,
220,
220,
318,
28920,
7,
10331,
8,
5633,
264,
796,
13538,
1058,
264,
796,
366,
10369,
3467,
15931,
9,
10331,
9,
1,
7879,
366,
198,
220,
220,
220,
220,
220,
220,
220,
3381,
18872,
230,
3381,
62,
37330,
62,
10331,
11405,
357,
912,
1635,
28,
264,
8,
628,
220,
220,
220,
220,
220,
220,
220,
318,
28920,
7,
7857,
8,
5633,
264,
796,
13538,
1058,
264,
796,
366,
2546,
366,
9,
7857,
9,
1,
366,
198,
220,
220,
220,
220,
220,
220,
220,
3381,
18872,
230,
3381,
62,
37330,
62,
7857,
11405,
357,
912,
1635,
28,
264,
8,
628,
220,
220,
220,
220,
220,
220,
220,
318,
28920,
7,
25249,
8,
5633,
264,
796,
13538,
1058,
264,
796,
366,
4469,
3467,
15931,
9,
25249,
9,
1,
7879,
366,
198,
220,
220,
220,
220,
220,
220,
220,
3381,
18872,
230,
3381,
62,
37330,
62,
65,
10025,
358,
11405,
357,
912,
1635,
28,
264,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
12094,
3689,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
8614,
357,
912,
1635,
28,
4566,
58,
25,
4354,
7131,
25,
4354,
404,
912,
60,
9,
1,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
11405,
357,
912,
1635,
28,
4566,
58,
25,
4798,
7131,
25,
4798,
62,
4354,
404,
912,
60,
9,
1,
366,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
900,
5072,
2393,
198,
220,
220,
220,
220,
220,
220,
220,
611,
3381,
18872,
230,
3381,
62,
7753,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
796,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
28920,
7,
330,
13,
22915,
8,
8614,
357,
82,
796,
37082,
77,
2617,
5072,
19990,
3,
7,
330,
13,
22915,
8,
7879,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
40379,
796,
40379,
9,
82,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
40379,
198,
437,
198,
198,
2,
3758,
19967,
84,
29487,
262,
1459,
3785,
338,
8398,
198,
8818,
19967,
84,
29487,
62,
21280,
62,
5647,
62,
11250,
7,
11250,
8,
198,
220,
220,
220,
4566,
13,
7839,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
3670,
705,
1,
9,
11250,
13,
7839,
9,
30543,
366,
8,
198,
220,
220,
220,
4566,
13,
20797,
7635,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
3918,
6070,
366,
9,
11250,
13,
20797,
7635,
8,
198,
220,
220,
220,
611,
4566,
13,
25928,
14512,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4566,
13,
25928,
6624,
366,
261,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19967,
84,
29487,
62,
21280,
7203,
2617,
10706,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19967,
84,
29487,
62,
21280,
7203,
2617,
10706,
366,
9,
11250,
13,
25928,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4566,
13,
2539,
25811,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
1994,
366,
9,
11250,
13,
2539,
25811,
8,
198,
220,
220,
220,
4566,
13,
3524,
10394,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
3091,
10394,
366,
9,
11250,
13,
3524,
10394,
8,
198,
220,
220,
220,
611,
4566,
13,
22704,
14512,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
4566,
13,
22704,
6624,
366,
325,
25433,
519,
87,
1,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
2604,
9888,
2124,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
4566,
13,
22704,
6624,
366,
43616,
19202,
1,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
2604,
9888,
331,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
4566,
13,
22704,
6624,
366,
325,
25433,
519,
89,
1,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
2604,
9888,
1976,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
4566,
13,
22704,
6624,
366,
6404,
6404,
1,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
2604,
9888,
2124,
45579,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4566,
13,
87,
18242,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
2124,
18242,
705,
1,
9,
11250,
13,
87,
18242,
9,
30543,
366,
8,
198,
220,
220,
220,
4566,
13,
2645,
9608,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
331,
18242,
705,
1,
9,
11250,
13,
2645,
9608,
9,
30543,
366,
8,
198,
220,
220,
220,
4566,
13,
89,
18242,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
1976,
18242,
705,
1,
9,
11250,
13,
89,
18242,
9,
30543,
366,
8,
198,
220,
220,
220,
4566,
13,
87,
9521,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
2124,
9521,
366,
9,
11250,
13,
87,
9521,
8,
198,
220,
220,
220,
4566,
13,
2417,
858,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
331,
9521,
366,
9,
11250,
13,
2417,
858,
8,
198,
220,
220,
220,
4566,
13,
89,
9521,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
1976,
9521,
366,
9,
11250,
13,
89,
9521,
8,
198,
220,
220,
220,
611,
4566,
13,
87,
22570,
22704,
14512,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4566,
13,
87,
22570,
22704,
6624,
366,
261,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19967,
84,
29487,
62,
21280,
7203,
2617,
2124,
22570,
22704,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19967,
84,
29487,
62,
21280,
7203,
2617,
2124,
22570,
22704,
366,
9,
11250,
13,
87,
22570,
22704,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
4566,
13,
88,
22570,
22704,
14512,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4566,
13,
88,
22570,
22704,
6624,
366,
261,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19967,
84,
29487,
62,
21280,
7203,
2617,
331,
22570,
22704,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19967,
84,
29487,
62,
21280,
7203,
2617,
331,
22570,
22704,
366,
9,
11250,
13,
88,
22570,
22704,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
4566,
13,
3019,
3529,
22704,
14512,
13538,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4566,
13,
3019,
3529,
22704,
6624,
366,
261,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19967,
84,
29487,
62,
21280,
7203,
2617,
1976,
22570,
22704,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19967,
84,
29487,
62,
21280,
7203,
2617,
1976,
22570,
22704,
366,
9,
11250,
13,
3019,
3529,
22704,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4566,
13,
18596,
5857,
14512,
13538,
11405,
19967,
84,
29487,
62,
21280,
7203,
2617,
27043,
366,
9,
11250,
13,
18596,
5857,
8,
198,
437,
198,
198,
2,
3551,
9729,
284,
19967,
84,
29487,
338,
12656,
198,
8818,
19967,
84,
29487,
62,
21280,
7,
82,
8,
198,
220,
220,
220,
4566,
58,
25,
24442,
60,
11405,
44872,
7,
82,
8,
220,
1303,
3601,
19967,
84,
29487,
9729,
611,
14257,
9343,
198,
220,
220,
220,
266,
796,
3551,
7,
47,
13,
70,
19282,
259,
11,
4731,
7,
82,
553,
59,
77,
48774,
198,
220,
220,
220,
1303,
2198,
326,
1366,
373,
6292,
416,
262,
12656,
198,
220,
220,
220,
611,
5145,
7,
86,
1875,
657,
8,
198,
220,
220,
220,
220,
220,
220,
220,
44872,
7203,
22210,
1816,
2642,
3597,
284,
19967,
84,
29487,
48571,
1268,
19570,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
198,
220,
220,
220,
24773,
7,
47,
13,
70,
19282,
259,
8,
198,
437,
198
] | 2.254799 | 3,438 |
<gh_stars>0
using Statistics
medium = Medium(:acou_homo1);
ageom = AGeom(medium.mgrid,:xwell);
tgrid = range(0.0,stop=2.0,length=1000)
wav = ricker(10.0, tgrid, tpeak=0.25, );
srcwav = SrcWav(tgrid, ageom, [:P])
update!(srcwav, [:P], wav)
vp0=mean(medium[:vp])
rho0=mean(medium[:rho])
rec1 = GeoPhyInv.Born.mod(vp0=vp0,
medium_pert=medium,
rho0=rho0,
ageom=ageom, srcwav=srcwav, tgridmod=tgrid, src_flag=2)
pa=SeisForwExpt(Fdtd(),npw=1,medium=medium,
ageom=[ageom], srcwav=[srcwav],
sflags=[2], rflags=[1],
tgrid=tgrid, verbose=true );
@time update!(pa);
# least-squares misfit
paerr=GeoPhyInv.VNamedD_misfit(rec1, pa.c.data[1])
err=GeoPhyInv.func_grad!(paerr)
# normalize error
error = err[1]/paerr.ynorm
# desired accuracy?
@test error<1e-2
| [
27,
456,
62,
30783,
29,
15,
198,
198,
3500,
14370,
198,
198,
24132,
796,
13398,
7,
25,
330,
280,
62,
71,
17902,
16,
1776,
198,
496,
296,
796,
317,
10082,
296,
7,
24132,
13,
76,
25928,
11,
25,
87,
4053,
1776,
198,
83,
25928,
796,
2837,
7,
15,
13,
15,
11,
11338,
28,
17,
13,
15,
11,
13664,
28,
12825,
8,
198,
45137,
796,
374,
15799,
7,
940,
13,
15,
11,
256,
25928,
11,
256,
36729,
28,
15,
13,
1495,
11,
5619,
198,
10677,
45137,
796,
311,
6015,
54,
615,
7,
83,
25928,
11,
2479,
296,
11,
685,
25,
47,
12962,
198,
19119,
0,
7,
10677,
45137,
11,
685,
25,
47,
4357,
266,
615,
8,
628,
198,
36133,
15,
28,
32604,
7,
24132,
58,
25,
36133,
12962,
198,
81,
8873,
15,
28,
32604,
7,
24132,
58,
25,
81,
8873,
12962,
198,
8344,
16,
796,
32960,
2725,
88,
19904,
13,
28524,
13,
4666,
7,
36133,
15,
28,
36133,
15,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7090,
62,
11766,
28,
24132,
11,
198,
197,
197,
220,
220,
220,
220,
374,
8873,
15,
28,
81,
8873,
15,
11,
198,
197,
197,
197,
2479,
296,
28,
496,
296,
11,
12351,
45137,
28,
10677,
45137,
11,
256,
25928,
4666,
28,
83,
25928,
11,
12351,
62,
32109,
28,
17,
8,
628,
198,
198,
8957,
28,
4653,
271,
1890,
86,
3109,
457,
7,
37,
67,
8671,
22784,
37659,
86,
28,
16,
11,
24132,
28,
24132,
11,
198,
220,
220,
220,
2479,
296,
41888,
496,
296,
4357,
12351,
45137,
41888,
10677,
45137,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
264,
33152,
41888,
17,
4357,
374,
33152,
41888,
16,
4357,
198,
197,
220,
220,
220,
256,
25928,
28,
83,
25928,
11,
15942,
577,
28,
7942,
5619,
198,
198,
31,
2435,
4296,
0,
7,
8957,
1776,
628,
198,
2,
1551,
12,
16485,
3565,
2984,
11147,
198,
8957,
8056,
28,
10082,
78,
2725,
88,
19904,
13,
53,
45,
2434,
35,
62,
76,
4468,
270,
7,
8344,
16,
11,
14187,
13,
66,
13,
7890,
58,
16,
12962,
198,
8056,
28,
10082,
78,
2725,
88,
19904,
13,
20786,
62,
9744,
0,
7,
8957,
8056,
8,
198,
198,
2,
3487,
1096,
4049,
198,
18224,
796,
11454,
58,
16,
60,
14,
8957,
8056,
13,
2047,
579,
198,
198,
2,
10348,
9922,
30,
198,
31,
9288,
4049,
27,
16,
68,
12,
17,
198
] | 2.007576 | 396 |
# --------------------------------------------------------------------------
# ACE.jl and SHIPs.jl: Julia implementation of the Atomic Cluster Expansion
# Copyright (c) 2019 <NAME> <<EMAIL>>
# All rights reserved.
# --------------------------------------------------------------------------
using ACE, JuLIP, Test
using ACE: evaluate
using JuLIP.Testing: print_tf
#---
@info("Construct basic and parameterised basis")
r0 = 2.3
rcut = 5.5
rin = 0.0
maxn = 5
species = [:X ]
D = SparsePSHDegree(wL = 1.0)
trans = ACE.PolyTransform(1, r0)
J = ACE.OrthPolys.transformed_jacobi(10, trans, rcut, rin)
P1 = ACE.RPI.PSH1pBasis(J, maxn, D=D, species = species)
basis = RPIBasis(P1, 3, D, maxn)
J5 = ACE.OrthPolys.transformed_jacobi(5, trans, rcut, rin)
P1basic = ACE.RPI.BasicPSH1pBasis(J5)
basic = RPIBasis(P1basic, 3, D, maxn)
#--- first test: make sure the bases are equivalent
@info("Test bases with and without parameters match")
for ntest = 1:30
local R, Z, z0 = ACE.Random.rand_nhd(12, J, species)
print_tf(@test ACE.evaluate(basis, R, Z, z0) ≈ ACE.evaluate(basic, R, Z, z0))
end
println()
#--- second test: perturb parameters
@info("Test basis with perturbed parameters doesn't match (duh...)")
params = basis.pibasis.basis1p.C[1]
basis.pibasis.basis1p.C[1] .+= 0.1 * (rand(size(params)...) .- 0.5)
for ntest = 1:30
local R, Z, z0 = ACE.Random.rand_nhd(12, J, species)
print_tf(@test !(ACE.evaluate(basis, R, Z, z0) ≈ ACE.evaluate(basic, R, Z, z0)))
end
println()
| [
198,
2,
16529,
35937,
198,
2,
40488,
13,
20362,
290,
6006,
4061,
82,
13,
20362,
25,
22300,
7822,
286,
262,
28976,
38279,
25042,
198,
2,
15069,
357,
66,
8,
13130,
1279,
20608,
29,
9959,
27630,
4146,
4211,
198,
2,
1439,
2489,
10395,
13,
198,
2,
16529,
35937,
628,
198,
198,
3500,
40488,
11,
12585,
43,
4061,
11,
6208,
198,
3500,
40488,
25,
13446,
198,
3500,
12585,
43,
4061,
13,
44154,
25,
3601,
62,
27110,
628,
198,
2,
6329,
198,
198,
31,
10951,
7203,
42316,
4096,
290,
11507,
1417,
4308,
4943,
198,
198,
81,
15,
796,
362,
13,
18,
198,
6015,
315,
796,
642,
13,
20,
198,
12769,
796,
657,
13,
15,
198,
9806,
77,
796,
642,
198,
35448,
796,
685,
25,
55,
2361,
198,
35,
796,
1338,
17208,
3705,
10227,
1533,
631,
7,
86,
43,
796,
352,
13,
15,
8,
198,
198,
7645,
796,
40488,
13,
34220,
41762,
7,
16,
11,
374,
15,
8,
198,
41,
796,
40488,
13,
5574,
400,
34220,
82,
13,
7645,
12214,
62,
30482,
13411,
7,
940,
11,
1007,
11,
374,
8968,
11,
374,
259,
8,
198,
47,
16,
796,
40488,
13,
49,
11901,
13,
3705,
39,
16,
79,
15522,
271,
7,
41,
11,
3509,
77,
11,
360,
28,
35,
11,
4693,
796,
4693,
8,
198,
198,
12093,
271,
796,
25812,
9865,
17765,
7,
47,
16,
11,
513,
11,
360,
11,
3509,
77,
8,
198,
198,
41,
20,
796,
40488,
13,
5574,
400,
34220,
82,
13,
7645,
12214,
62,
30482,
13411,
7,
20,
11,
1007,
11,
374,
8968,
11,
374,
259,
8,
198,
47,
16,
35487,
796,
40488,
13,
49,
11901,
13,
26416,
3705,
39,
16,
79,
15522,
271,
7,
41,
20,
8,
198,
35487,
796,
25812,
9865,
17765,
7,
47,
16,
35487,
11,
513,
11,
360,
11,
3509,
77,
8,
198,
198,
2,
6329,
717,
1332,
25,
787,
1654,
262,
12536,
389,
7548,
198,
198,
31,
10951,
7203,
14402,
12536,
351,
290,
1231,
10007,
2872,
4943,
198,
1640,
299,
9288,
796,
352,
25,
1270,
198,
220,
220,
1957,
371,
11,
1168,
11,
1976,
15,
796,
40488,
13,
29531,
13,
25192,
62,
77,
31298,
7,
1065,
11,
449,
11,
4693,
8,
198,
220,
220,
3601,
62,
27110,
7,
31,
9288,
40488,
13,
49786,
7,
12093,
271,
11,
371,
11,
1168,
11,
1976,
15,
8,
15139,
230,
40488,
13,
49786,
7,
35487,
11,
371,
11,
1168,
11,
1976,
15,
4008,
198,
437,
198,
35235,
3419,
198,
198,
2,
6329,
1218,
1332,
25,
22146,
5945,
10007,
198,
198,
31,
10951,
7203,
14402,
4308,
351,
22146,
37694,
10007,
1595,
470,
2872,
357,
646,
71,
23029,
4943,
198,
37266,
796,
4308,
13,
79,
571,
17765,
13,
12093,
271,
16,
79,
13,
34,
58,
16,
60,
198,
12093,
271,
13,
79,
571,
17765,
13,
12093,
271,
16,
79,
13,
34,
58,
16,
60,
764,
47932,
657,
13,
16,
1635,
357,
25192,
7,
7857,
7,
37266,
8,
23029,
764,
12,
657,
13,
20,
8,
198,
1640,
299,
9288,
796,
352,
25,
1270,
198,
220,
220,
1957,
371,
11,
1168,
11,
1976,
15,
796,
40488,
13,
29531,
13,
25192,
62,
77,
31298,
7,
1065,
11,
449,
11,
4693,
8,
198,
220,
220,
3601,
62,
27110,
7,
31,
9288,
5145,
7,
11598,
13,
49786,
7,
12093,
271,
11,
371,
11,
1168,
11,
1976,
15,
8,
15139,
230,
40488,
13,
49786,
7,
35487,
11,
371,
11,
1168,
11,
1976,
15,
22305,
198,
437,
198,
35235,
3419,
198
] | 2.651246 | 562 |
<filename>test/perf/shootout/meteor_contest.jl
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
#
# Contributed by <NAME>
# based on Python version by <NAME>
const width = 5
const height = 10
# directions
const E = 0
const NE = 1
const NW = 2
const W = 3
const SW = 4
const SE = 5
const rotate = {E => NE, NE => NW, NW => W, W => SW, SW => SE, SE => E}
const flip = {E => W, NE => NW, NW => NE, W => E, SW => SE, SE => SW}
const move = {
E => (x, y) -> (x + 1, y),
W => (x, y) -> (x - 1, y),
NE => (x, y) -> (x + y%2, y - 1),
NW => (x, y) -> (x + y%2 - 1, y - 1),
SE => (x, y) -> (x + y%2, y + 1),
SW => (x, y) -> (x + y%2 - 1, y + 1)
}
const pieces = (
(E, E, E, SE),
(SE, SW, W, SW),
(W, W, SW, SE),
(E, E, SW, SE),
(NW, W, NW, SE, SW),
(E, E, NE, W),
(NW, NE, NE, W),
(NE, SE, E, NE),
(SE, SE, E, SE),
(E, NW, NW, NW)
)
const solutions = Any[]
const masks = zeros(Uint64, 10)
const masksAtCell = Array(Any, width*height, height)
valid(x, y) = (0 <= x < width) && (0 <= y < height)
legal(mask::Uint64, board::Uint64) = (mask & board) == 0
zerocount(mask::Uint64) = 50 - count_ones(mask)
function findFreeCell(board::Uint64)
for y in 0:height-1
for x in 0:width-1
if board & (uint64(1) << (x + width*y)) == 0
return x, y
end
end
end
end
function floodFill(board::Uint64, fixme)
x, y = fixme
if !valid(x,y)
return board
end
if board & (uint64(1) << (x + width*y)) != 0
return board
end
board |= uint64(1) << (x + width*y)
for f in values(move)
board |= floodFill(board, f(x, y))
end
return board
end
function noIslands(mask::Uint64)
zeroes_ = zerocount(mask)
if zeroes_ < 5
return false
end
while mask != 0x3FFFFFFFFFFFF
mask = floodFill(mask, findFreeCell(mask))
new_zeroes = zerocount(mask)
if zeroes_ - new_zeroes < 5
return false
end
zeroes_ = new_zeroes
end
return true
end
function getBitmask(x, y, piece)
mask = (uint64(1) << (x + width*y))
for cell_ in piece
x, y = move[cell_](x,y)
if valid(x, y)
mask |= uint64(1) << (x + width*y)
else
return false, uint64(0)
end
end
return true, uint64(mask)
end
function allBitmasks(piece, color)
bitmasks = Uint64[]
for orientations in 0:1
for rotations in 0:(6 - 3*(color == 4))-1
for y in 0:height-1
for x in 0:width-1
isValid, mask = getBitmask(x, y, piece)
if isValid && noIslands(uint64(mask))
push!(bitmasks, mask)
end
end
end
piece = [rotate[cell_] for cell_ in piece]
end
piece = [flip[cell_] for cell_ in piece]
end
return bitmasks
end
function generateBitmasks()
for i = 1:length(masksAtCell)
masksAtCell[i] = Uint64[]
end
color = 0
for piece in pieces
masks = allBitmasks(piece, color)
sort!(masks)
cellMask = uint64(1) << (width*height - 1)
cellCounter = width*height - 1
j = length(masks) - 1
while j >= 0
if (masks[j + 1] & cellMask) == cellMask
push!(masksAtCell[cellCounter + 1, color + 1], masks[j + 1])
j -= 1
else
cellMask >>= 1
cellCounter -= 1
end
end
color += 1
end
end
function solveCell(cell_, board::Uint64, n)
if length(solutions) >= n
return
end
if board == 0x0003FFFFFFFFFFFF
# Solved
s = stringOfMasks(masks)
push!(solutions, s)
push!(solutions, reverse(s))
return
end
if board & (uint64(1) << cell_) != 0
# Cell full
solveCell(cell_ - 1, uint64(board), n)
return
end
if cell_ < 0
# Out of board
return
end
for color in 0:9
if masks[color + 1] == 0
for mask in masksAtCell[cell_ + 1, color + 1]
if legal(mask, board)
masks[color + 1] = mask
solveCell(cell_ - 1, uint64(board | mask), n)
masks[color + 1] = 0
end
end
end
end
end
function solve(n)
generateBitmasks()
solveCell(width*height-1, uint64(0), n)
end
function stringOfMasks(masks)
s = ""
mask::Uint64 = 1
for y in 0:height-1
for x in 0:width-1
for color in 0:9
if (masks[color+1] & mask) != 0
s = string(s, color)
break
elseif color == 9
s *= "."
end
end
mask <<= 1
end
end
return s
end
function printSolution(s)
for y in 0:height-1
if y%2 == 1
print(" ")
end
for x in 0:width-1
print("$(s[x + y*width + 1]) ")
end
println()
end
end
function meteor_contest(n::Int=2098)
empty!(solutions)
fill!(masks, 0)
solve(n)
# println("$(length(solutions)) solutions found")
# println()
# printSolution(minimum(solutions))
# println()
# printSolution(maximum(solutions))
# println()
end
| [
27,
34345,
29,
9288,
14,
525,
69,
14,
30408,
448,
14,
4164,
13492,
62,
3642,
395,
13,
20362,
198,
2,
383,
13851,
15417,
25187,
14306,
3776,
198,
2,
2638,
1378,
30408,
448,
13,
7344,
849,
13,
24689,
13,
2398,
14,
198,
2,
198,
2,
2345,
6169,
416,
1279,
20608,
29,
198,
2,
1912,
319,
11361,
2196,
416,
1279,
20608,
29,
198,
198,
9979,
9647,
220,
796,
220,
642,
198,
9979,
6001,
796,
838,
198,
198,
2,
11678,
198,
9979,
412,
220,
796,
657,
198,
9979,
10635,
796,
352,
198,
9979,
21966,
796,
362,
198,
9979,
370,
220,
796,
513,
198,
9979,
12672,
796,
604,
198,
9979,
7946,
796,
642,
198,
198,
9979,
23064,
796,
1391,
36,
5218,
10635,
11,
10635,
5218,
21966,
11,
21966,
5218,
370,
11,
370,
5218,
12672,
11,
12672,
5218,
7946,
11,
7946,
5218,
412,
92,
198,
9979,
14283,
220,
220,
796,
1391,
36,
5218,
370,
11,
10635,
5218,
21966,
11,
21966,
5218,
10635,
11,
370,
5218,
412,
11,
12672,
5218,
7946,
11,
7946,
5218,
12672,
92,
198,
198,
9979,
1445,
796,
1391,
198,
220,
220,
220,
412,
220,
5218,
357,
87,
11,
331,
8,
4613,
357,
87,
1343,
220,
220,
352,
11,
220,
220,
220,
220,
331,
828,
198,
220,
220,
220,
370,
220,
5218,
357,
87,
11,
331,
8,
4613,
357,
87,
532,
220,
220,
352,
11,
220,
220,
220,
220,
331,
828,
198,
220,
220,
220,
10635,
5218,
357,
87,
11,
331,
8,
4613,
357,
87,
1343,
331,
4,
17,
11,
220,
220,
220,
220,
331,
532,
352,
828,
198,
220,
220,
220,
21966,
5218,
357,
87,
11,
331,
8,
4613,
357,
87,
1343,
331,
4,
17,
532,
352,
11,
331,
532,
352,
828,
198,
220,
220,
220,
7946,
5218,
357,
87,
11,
331,
8,
4613,
357,
87,
1343,
331,
4,
17,
11,
220,
220,
220,
220,
331,
1343,
352,
828,
198,
220,
220,
220,
12672,
5218,
357,
87,
11,
331,
8,
4613,
357,
87,
1343,
331,
4,
17,
532,
352,
11,
331,
1343,
352,
8,
198,
92,
198,
198,
9979,
5207,
796,
357,
198,
220,
220,
220,
357,
36,
11,
220,
412,
11,
220,
412,
11,
220,
7946,
828,
198,
220,
220,
220,
357,
5188,
11,
12672,
11,
370,
11,
220,
12672,
828,
198,
220,
220,
220,
357,
54,
11,
220,
370,
11,
220,
12672,
11,
7946,
828,
198,
220,
220,
220,
357,
36,
11,
220,
412,
11,
220,
12672,
11,
7946,
828,
198,
220,
220,
220,
357,
27605,
11,
370,
11,
220,
21966,
11,
7946,
11,
12672,
828,
198,
220,
220,
220,
357,
36,
11,
220,
412,
11,
220,
10635,
11,
370,
828,
198,
220,
220,
220,
357,
27605,
11,
10635,
11,
10635,
11,
370,
828,
198,
220,
220,
220,
357,
12161,
11,
7946,
11,
412,
11,
220,
10635,
828,
198,
220,
220,
220,
357,
5188,
11,
7946,
11,
412,
11,
220,
7946,
828,
198,
220,
220,
220,
357,
36,
11,
220,
21966,
11,
21966,
11,
21966,
8,
198,
8,
198,
198,
9979,
8136,
796,
4377,
21737,
198,
9979,
20680,
796,
1976,
27498,
7,
52,
600,
2414,
11,
838,
8,
198,
9979,
20680,
2953,
28780,
796,
15690,
7,
7149,
11,
9647,
9,
17015,
11,
6001,
8,
198,
198,
12102,
7,
87,
11,
331,
8,
796,
357,
15,
19841,
2124,
1279,
9647,
8,
11405,
357,
15,
19841,
331,
1279,
6001,
8,
198,
18011,
7,
27932,
3712,
52,
600,
2414,
11,
3096,
3712,
52,
600,
2414,
8,
796,
357,
27932,
1222,
3096,
8,
6624,
657,
198,
9107,
420,
608,
7,
27932,
3712,
52,
600,
2414,
8,
796,
2026,
532,
954,
62,
1952,
7,
27932,
8,
198,
198,
8818,
1064,
11146,
28780,
7,
3526,
3712,
52,
600,
2414,
8,
198,
220,
220,
220,
329,
331,
287,
657,
25,
17015,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
329,
2124,
287,
657,
25,
10394,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
3096,
1222,
357,
28611,
2414,
7,
16,
8,
9959,
357,
87,
1343,
9647,
9,
88,
4008,
6624,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
2124,
11,
331,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
6947,
33762,
7,
3526,
3712,
52,
600,
2414,
11,
45199,
8,
198,
220,
220,
220,
2124,
11,
331,
796,
45199,
198,
220,
220,
220,
611,
5145,
12102,
7,
87,
11,
88,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
3096,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
3096,
1222,
357,
28611,
2414,
7,
16,
8,
9959,
357,
87,
1343,
9647,
9,
88,
4008,
14512,
657,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
3096,
198,
220,
220,
220,
886,
628,
220,
220,
220,
3096,
930,
28,
20398,
2414,
7,
16,
8,
9959,
357,
87,
1343,
9647,
9,
88,
8,
198,
220,
220,
220,
329,
277,
287,
3815,
7,
21084,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3096,
930,
28,
6947,
33762,
7,
3526,
11,
277,
7,
87,
11,
331,
4008,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
3096,
198,
437,
198,
198,
8818,
645,
3792,
4447,
7,
27932,
3712,
52,
600,
2414,
8,
198,
220,
220,
220,
1976,
263,
3028,
62,
796,
1976,
263,
420,
608,
7,
27932,
8,
628,
220,
220,
220,
611,
1976,
263,
3028,
62,
1279,
642,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
886,
628,
220,
220,
220,
981,
9335,
14512,
657,
87,
18,
29312,
29312,
29312,
198,
220,
220,
220,
220,
220,
220,
220,
9335,
796,
6947,
33762,
7,
27932,
11,
1064,
11146,
28780,
7,
27932,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
649,
62,
9107,
3028,
796,
1976,
263,
420,
608,
7,
27932,
8,
628,
220,
220,
220,
220,
220,
220,
220,
611,
1976,
263,
3028,
62,
532,
649,
62,
9107,
3028,
1279,
642,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
1976,
263,
3028,
62,
796,
649,
62,
9107,
3028,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
2081,
198,
437,
198,
198,
8818,
651,
13128,
27932,
7,
87,
11,
331,
11,
3704,
8,
198,
220,
220,
220,
9335,
796,
357,
28611,
2414,
7,
16,
8,
9959,
357,
87,
1343,
9647,
9,
88,
4008,
628,
220,
220,
220,
329,
2685,
62,
287,
3704,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
11,
331,
796,
1445,
58,
3846,
62,
16151,
87,
11,
88,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
4938,
7,
87,
11,
331,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9335,
930,
28,
20398,
2414,
7,
16,
8,
9959,
357,
87,
1343,
9647,
9,
88,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
11,
20398,
2414,
7,
15,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
2081,
11,
20398,
2414,
7,
27932,
8,
198,
437,
198,
198,
8818,
477,
13128,
5356,
591,
7,
12239,
11,
3124,
8,
198,
220,
220,
220,
1643,
5356,
591,
796,
471,
600,
2414,
21737,
198,
220,
220,
220,
329,
11367,
602,
287,
657,
25,
16,
198,
220,
220,
220,
220,
220,
220,
220,
329,
5724,
602,
287,
657,
37498,
21,
532,
513,
9,
7,
8043,
6624,
604,
4008,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
331,
287,
657,
25,
17015,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
2124,
287,
657,
25,
10394,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
318,
47139,
11,
9335,
796,
651,
13128,
27932,
7,
87,
11,
331,
11,
3704,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
318,
47139,
11405,
645,
3792,
4447,
7,
28611,
2414,
7,
27932,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
2545,
5356,
591,
11,
9335,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3704,
796,
685,
10599,
378,
58,
3846,
62,
60,
329,
2685,
62,
287,
3704,
60,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
3704,
796,
685,
2704,
541,
58,
3846,
62,
60,
329,
2685,
62,
287,
3704,
60,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
1643,
5356,
591,
198,
437,
198,
198,
8818,
7716,
13128,
5356,
591,
3419,
198,
220,
220,
220,
329,
1312,
796,
352,
25,
13664,
7,
5356,
591,
2953,
28780,
8,
198,
220,
220,
220,
220,
220,
220,
220,
20680,
2953,
28780,
58,
72,
60,
796,
471,
600,
2414,
21737,
198,
220,
220,
220,
886,
628,
220,
220,
220,
3124,
796,
657,
198,
220,
220,
220,
329,
3704,
287,
5207,
198,
220,
220,
220,
220,
220,
220,
220,
20680,
796,
477,
13128,
5356,
591,
7,
12239,
11,
3124,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3297,
0,
7,
5356,
591,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2685,
45195,
796,
20398,
2414,
7,
16,
8,
9959,
357,
10394,
9,
17015,
532,
352,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2685,
31694,
796,
9647,
9,
17015,
532,
352,
628,
220,
220,
220,
220,
220,
220,
220,
474,
796,
4129,
7,
5356,
591,
8,
532,
352,
628,
220,
220,
220,
220,
220,
220,
220,
981,
474,
18189,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
357,
5356,
591,
58,
73,
1343,
352,
60,
1222,
2685,
45195,
8,
6624,
2685,
45195,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
5356,
591,
2953,
28780,
58,
3846,
31694,
1343,
352,
11,
3124,
1343,
352,
4357,
20680,
58,
73,
1343,
352,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
474,
48185,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2685,
45195,
9609,
28,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2685,
31694,
48185,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
3124,
15853,
352,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
8494,
28780,
7,
3846,
62,
11,
3096,
3712,
52,
600,
2414,
11,
299,
8,
198,
220,
220,
220,
611,
4129,
7,
82,
14191,
8,
18189,
299,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
3096,
6624,
657,
87,
830,
18,
29312,
29312,
29312,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
4294,
1079,
198,
220,
220,
220,
220,
220,
220,
220,
264,
796,
4731,
5189,
44,
6791,
7,
5356,
591,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
82,
14191,
11,
264,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
82,
14191,
11,
9575,
7,
82,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
3096,
1222,
357,
28611,
2414,
7,
16,
8,
9959,
2685,
62,
8,
14512,
657,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
12440,
1336,
198,
220,
220,
220,
220,
220,
220,
220,
8494,
28780,
7,
3846,
62,
532,
352,
11,
20398,
2414,
7,
3526,
828,
299,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
2685,
62,
1279,
657,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
3806,
286,
3096,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
329,
3124,
287,
657,
25,
24,
198,
220,
220,
220,
220,
220,
220,
220,
611,
20680,
58,
8043,
1343,
352,
60,
6624,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
9335,
287,
20680,
2953,
28780,
58,
3846,
62,
1343,
352,
11,
3124,
1343,
352,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
2742,
7,
27932,
11,
3096,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
20680,
58,
8043,
1343,
352,
60,
796,
9335,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8494,
28780,
7,
3846,
62,
532,
352,
11,
20398,
2414,
7,
3526,
930,
9335,
828,
299,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
20680,
58,
8043,
1343,
352,
60,
796,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
8494,
7,
77,
8,
198,
220,
220,
220,
7716,
13128,
5356,
591,
3419,
198,
220,
220,
220,
8494,
28780,
7,
10394,
9,
17015,
12,
16,
11,
20398,
2414,
7,
15,
828,
299,
8,
198,
437,
198,
198,
8818,
4731,
5189,
44,
6791,
7,
5356,
591,
8,
198,
220,
220,
220,
264,
796,
13538,
198,
220,
220,
220,
9335,
3712,
52,
600,
2414,
796,
352,
198,
220,
220,
220,
329,
331,
287,
657,
25,
17015,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
329,
2124,
287,
657,
25,
10394,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
3124,
287,
657,
25,
24,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
357,
5356,
591,
58,
8043,
10,
16,
60,
1222,
9335,
8,
14512,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
796,
4731,
7,
82,
11,
3124,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
3124,
6624,
860,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
1635,
28,
366,
526,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9335,
9959,
28,
352,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
264,
198,
437,
198,
198,
8818,
3601,
46344,
7,
82,
8,
198,
220,
220,
220,
329,
331,
287,
657,
25,
17015,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
611,
331,
4,
17,
6624,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
329,
2124,
287,
657,
25,
10394,
12,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
3,
7,
82,
58,
87,
1343,
331,
9,
10394,
1343,
352,
12962,
366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
44872,
3419,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
19999,
62,
3642,
395,
7,
77,
3712,
5317,
28,
1238,
4089,
8,
198,
220,
220,
220,
6565,
0,
7,
82,
14191,
8,
198,
220,
220,
220,
6070,
0,
7,
5356,
591,
11,
657,
8,
198,
220,
220,
220,
8494,
7,
77,
8,
198,
2,
220,
220,
220,
44872,
7203,
3,
7,
13664,
7,
82,
14191,
4008,
8136,
1043,
4943,
198,
2,
220,
220,
220,
44872,
3419,
198,
2,
220,
220,
220,
3601,
46344,
7,
39504,
7,
82,
14191,
4008,
198,
2,
220,
220,
220,
44872,
3419,
198,
2,
220,
220,
220,
3601,
46344,
7,
47033,
7,
82,
14191,
4008,
198,
2,
220,
220,
220,
44872,
3419,
198,
437,
198
] | 1.90298 | 2,886 |
export SimpleObservable, stddev
type SimpleObservable <: ScalarObservable
bins :: Vector{Float64}
num :: Int64
sum :: Float64
sum2 :: Float64
end
SimpleObservable() = SimpleObservable(zeros(0), 0, 0.0, 0.0)
function reset!(obs :: SimpleObservable)
obs.bins = zeros(0)
obs.num = 0
obs.sum = 0.0
obs.sum2 = 0.0
return obs
end
count(obs::SimpleObservable) = obs.num
function push!(obs :: SimpleObservable, value)
push!(obs.bins, value)
obs.num += 1
obs.sum += value
obs.sum2 += value^2
return obs
end
function mean(obs::SimpleObservable)
if obs.num > 0
return obs.sum / obs.num
else
return NaN
end
end
function var(obs::SimpleObservable)
if obs.num > 1
v = (obs.sum2 - obs.sum*obs.sum/obs.num)/(obs.num-1)
return maxzero(v)
elseif obs.num == 1
return Inf
else
return NaN
end
end
stddev(obs::SimpleObservable) = sqrt(var(obs))
stderror(obs::SimpleObservable) = sqrt(var(obs)/count(obs))
function confidence_interval(obs::SimpleObservable, confidence_rate :: Real)
if count(obs) < 2
return Inf
end
q = 0.5 + 0.5confidence_rate
correction = quantile( TDist(obs.num - 1), q)
serr = stderror(obs)
return correction * serr
end
function confidence_interval(obs::SimpleObservable, confidence_rate_symbol::Symbol = :sigma1)
n = parsesigma(confidence_rate_symbol)
return confidence_interval(obs, erf(0.5n*sqrt(2.0)))
end
function merge!(obs::SimpleObservable, other::SimpleObservable)
append!(obs.bins, other.bins)
obs.num += other.num
obs.sum += other.sum
obs.sum2 += other.sum2
return obs
end
merge(lhs::SimpleObservable, rhs::SimpleObservable) = merge!(deepcopy(lhs), rhs)
export SimpleObservableSet
typealias SimpleObservableSet MCObservableSet{SimpleObservable}
function merge!(obs::SimpleObservableSet, other::SimpleObservableSet)
obs_names = Set(keys(obs))
union!(obs_names, Set(keys(other)))
for name in obs_names
if !haskey(obs, name)
# in other only
obs[name] = deepcopy(other[name])
elseif haskey(other, name)
# in both
merge!(obs[name], other[name])
# else
# in obs only
# NOTHING to do
end
end
return obs
end
merge(lhs::SimpleObservableSet, rhs::SimpleObservableSet) = merge!(deepcopy(lhs), rhs)
| [
39344,
17427,
31310,
712,
540,
11,
336,
1860,
1990,
198,
198,
4906,
17427,
31310,
712,
540,
1279,
25,
34529,
283,
31310,
712,
540,
198,
220,
41701,
7904,
20650,
90,
43879,
2414,
92,
198,
220,
997,
7904,
2558,
2414,
198,
220,
2160,
7904,
48436,
2414,
198,
220,
2160,
17,
7904,
48436,
2414,
198,
437,
198,
198,
26437,
31310,
712,
540,
3419,
796,
17427,
31310,
712,
540,
7,
9107,
418,
7,
15,
828,
657,
11,
657,
13,
15,
11,
657,
13,
15,
8,
198,
198,
8818,
13259,
0,
7,
8158,
7904,
17427,
31310,
712,
540,
8,
198,
220,
10201,
13,
65,
1040,
796,
1976,
27498,
7,
15,
8,
198,
220,
10201,
13,
22510,
796,
657,
198,
220,
10201,
13,
16345,
796,
657,
13,
15,
198,
220,
10201,
13,
16345,
17,
796,
657,
13,
15,
198,
220,
1441,
10201,
198,
437,
198,
198,
9127,
7,
8158,
3712,
26437,
31310,
712,
540,
8,
796,
10201,
13,
22510,
198,
198,
8818,
4574,
0,
7,
8158,
7904,
17427,
31310,
712,
540,
11,
1988,
8,
220,
198,
220,
4574,
0,
7,
8158,
13,
65,
1040,
11,
1988,
8,
198,
220,
10201,
13,
22510,
15853,
352,
198,
220,
10201,
13,
16345,
15853,
1988,
198,
220,
10201,
13,
16345,
17,
15853,
1988,
61,
17,
198,
220,
1441,
10201,
198,
437,
198,
198,
8818,
1612,
7,
8158,
3712,
26437,
31310,
712,
540,
8,
198,
220,
611,
10201,
13,
22510,
1875,
657,
198,
220,
220,
220,
1441,
10201,
13,
16345,
1220,
10201,
13,
22510,
198,
220,
2073,
198,
220,
220,
220,
1441,
11013,
45,
198,
220,
886,
198,
437,
198,
198,
8818,
1401,
7,
8158,
3712,
26437,
31310,
712,
540,
8,
198,
220,
611,
10201,
13,
22510,
220,
1875,
352,
198,
220,
220,
220,
410,
796,
357,
8158,
13,
16345,
17,
532,
10201,
13,
16345,
9,
8158,
13,
16345,
14,
8158,
13,
22510,
20679,
7,
8158,
13,
22510,
12,
16,
8,
198,
220,
220,
220,
1441,
3509,
22570,
7,
85,
8,
198,
220,
2073,
361,
10201,
13,
22510,
6624,
352,
198,
220,
220,
220,
1441,
4806,
198,
220,
2073,
198,
220,
220,
220,
1441,
11013,
45,
198,
220,
886,
198,
437,
198,
301,
1860,
1990,
7,
8158,
3712,
26437,
31310,
712,
540,
8,
796,
19862,
17034,
7,
7785,
7,
8158,
4008,
198,
301,
1082,
1472,
7,
8158,
3712,
26437,
31310,
712,
540,
8,
796,
19862,
17034,
7,
7785,
7,
8158,
20679,
9127,
7,
8158,
4008,
198,
8818,
6628,
62,
3849,
2100,
7,
8158,
3712,
26437,
31310,
712,
540,
11,
6628,
62,
4873,
7904,
6416,
8,
198,
220,
611,
954,
7,
8158,
8,
1279,
362,
198,
220,
220,
220,
1441,
4806,
198,
220,
886,
198,
220,
10662,
796,
657,
13,
20,
1343,
657,
13,
20,
39745,
62,
4873,
198,
220,
17137,
796,
5554,
576,
7,
13320,
396,
7,
8158,
13,
22510,
532,
352,
828,
10662,
8,
198,
220,
1055,
81,
796,
336,
1082,
1472,
7,
8158,
8,
198,
220,
1441,
17137,
1635,
1055,
81,
198,
437,
198,
198,
8818,
6628,
62,
3849,
2100,
7,
8158,
3712,
26437,
31310,
712,
540,
11,
6628,
62,
4873,
62,
1837,
23650,
3712,
13940,
23650,
796,
1058,
82,
13495,
16,
8,
198,
220,
299,
796,
13544,
274,
13495,
7,
39745,
62,
4873,
62,
1837,
23650,
8,
198,
220,
1441,
6628,
62,
3849,
2100,
7,
8158,
11,
1931,
69,
7,
15,
13,
20,
77,
9,
31166,
17034,
7,
17,
13,
15,
22305,
198,
437,
198,
198,
8818,
20121,
0,
7,
8158,
3712,
26437,
31310,
712,
540,
11,
584,
3712,
26437,
31310,
712,
540,
8,
198,
220,
24443,
0,
7,
8158,
13,
65,
1040,
11,
584,
13,
65,
1040,
8,
198,
220,
10201,
13,
22510,
15853,
584,
13,
22510,
198,
220,
10201,
13,
16345,
15853,
584,
13,
16345,
198,
220,
10201,
13,
16345,
17,
15853,
584,
13,
16345,
17,
198,
220,
1441,
10201,
198,
437,
198,
647,
469,
7,
75,
11994,
3712,
26437,
31310,
712,
540,
11,
9529,
82,
3712,
26437,
31310,
712,
540,
8,
796,
20121,
0,
7,
22089,
30073,
7,
75,
11994,
828,
9529,
82,
8,
198,
198,
39344,
17427,
31310,
712,
540,
7248,
198,
4906,
26011,
17427,
31310,
712,
540,
7248,
337,
8220,
1443,
712,
540,
7248,
90,
26437,
31310,
712,
540,
92,
198,
198,
8818,
20121,
0,
7,
8158,
3712,
26437,
31310,
712,
540,
7248,
11,
584,
3712,
26437,
31310,
712,
540,
7248,
8,
198,
220,
10201,
62,
14933,
796,
5345,
7,
13083,
7,
8158,
4008,
198,
220,
6441,
0,
7,
8158,
62,
14933,
11,
5345,
7,
13083,
7,
847,
22305,
198,
220,
329,
1438,
287,
10201,
62,
14933,
198,
220,
220,
220,
611,
5145,
10134,
2539,
7,
8158,
11,
1438,
8,
198,
220,
220,
220,
220,
220,
1303,
287,
584,
691,
198,
220,
220,
220,
220,
220,
10201,
58,
3672,
60,
796,
2769,
30073,
7,
847,
58,
3672,
12962,
198,
220,
220,
220,
2073,
361,
468,
2539,
7,
847,
11,
1438,
8,
198,
220,
220,
220,
220,
220,
1303,
287,
1111,
198,
220,
220,
220,
220,
220,
20121,
0,
7,
8158,
58,
3672,
4357,
584,
58,
3672,
12962,
628,
220,
220,
220,
1303,
2073,
198,
220,
220,
220,
1303,
287,
10201,
691,
198,
220,
220,
220,
1303,
5626,
39,
2751,
284,
466,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
1441,
10201,
198,
437,
198,
647,
469,
7,
75,
11994,
3712,
26437,
31310,
712,
540,
7248,
11,
9529,
82,
3712,
26437,
31310,
712,
540,
7248,
8,
796,
20121,
0,
7,
22089,
30073,
7,
75,
11994,
828,
9529,
82,
8,
198
] | 2.521158 | 898 |
<filename>examples/recording_an_interaction.jl
# Use this simple script to record an interaction happening on `figure`
framerate = 10
total_time = 30 # in seconds
framen = framerate*total_time
record(figure, "name.mp4"; framerate = framerate) do io
for i = 1:framen
sleep(1/framerate)
recordframe!(io)
end
end
| [
27,
34345,
29,
1069,
12629,
14,
8344,
1284,
62,
272,
62,
3849,
2673,
13,
20362,
198,
2,
5765,
428,
2829,
4226,
284,
1700,
281,
10375,
5836,
319,
4600,
26875,
63,
198,
198,
19298,
21620,
796,
838,
198,
23350,
62,
2435,
796,
1542,
1303,
287,
4201,
198,
19298,
268,
796,
5346,
21620,
9,
23350,
62,
2435,
198,
198,
22105,
7,
26875,
11,
366,
3672,
13,
3149,
19,
8172,
5346,
21620,
796,
5346,
21620,
8,
466,
33245,
198,
220,
220,
220,
329,
1312,
796,
352,
25,
19298,
268,
198,
220,
220,
220,
220,
220,
220,
220,
3993,
7,
16,
14,
19298,
21620,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1700,
14535,
0,
7,
952,
8,
198,
220,
220,
220,
886,
198,
437,
198
] | 2.731707 | 123 |
<filename>base/grisu/float.jl<gh_stars>0
# This file is a part of Julia, but is derived from
# https://github.com/google/double-conversion which has the following license
#
# Copyright 2006-2014, the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct Float
s::UInt64
e::Int32
de::Int32
end
Float() = Float(0,0,0)
Float(x,y) = Float(x,y,Int32(0))
Float(d::AbstractFloat) = Float(_significand(d), _exponent(d))
# Consts
const Float10MSBits = 0xFFC0000000000000 # used normalize(Float)
const FloatSignMask = 0x8000000000000000 # used in normalize(Float)
const FloatSignificandSize = Int32(64)
function normalize(v::Float)
f = v.s
e::Int32 = v.e
while (f & Float10MSBits) == 0
f <<= 10
e -= 10
end
while (f & FloatSignMask) == 0
f <<= 1
e -= 1
end
return Float(f,e)
end
function normalize(v::Float64)
s = _significand(v); e = _exponent(v)
while (s & HiddenBit(Float64)) == 0
s <<= UInt64(1)
e -= Int32(1)
end
s <<= UInt64(FloatSignificandSize - SignificandSize(Float64))
e -= Int32( FloatSignificandSize - SignificandSize(Float64))
return Float(s, e)
end
# Float128
#DenormalExponent(::Type{Float128}) = Int32(-ExponentBias(Float128) + 1)
#ExponentMask(::Type{Float128}) = 0x7fff0000000000000000000000000000
#PhysicalSignificandSize(::Type{Float128}) = Int32(112)
#SignificandSize(::Type{Float128}) = Int32(113)
#ExponentBias(::Type{Float128}) = Int32(0x00003fff + PhysicalSignificandSize(Float128))
#SignificandMask(::Type{Float128}) = 0x0000ffffffffffffffffffffffffffff
#HiddenBit(::Type{Float128}) = 0x00010000000000000000000000000000
#uint_t(d::Float128) = reinterpret(UInt128,d)
# Float64
DenormalExponent(::Type{Float64}) = Int32(-ExponentBias(Float64) + 1)
ExponentMask(::Type{Float64}) = 0x7FF0000000000000
PhysicalSignificandSize(::Type{Float64}) = Int32(52)
SignificandSize(::Type{Float64}) = Int32(53)
ExponentBias(::Type{Float64}) = Int32(0x3FF + PhysicalSignificandSize(Float64))
SignificandMask(::Type{Float64}) = 0x000FFFFFFFFFFFFF
HiddenBit(::Type{Float64}) = 0x0010000000000000
uint_t(d::Float64) = reinterpret(UInt64,d)
# Float32
DenormalExponent(::Type{Float32}) = Int32(-ExponentBias(Float32) + 1)
ExponentMask(::Type{Float32}) = 0x7F800000
PhysicalSignificandSize(::Type{Float32}) = Int32(23)
SignificandSize(::Type{Float32}) = Int32(24)
ExponentBias(::Type{Float32}) = Int32(0x7F + PhysicalSignificandSize(Float32))
SignificandMask(::Type{Float32}) = 0x007FFFFF
HiddenBit(::Type{Float32}) = 0x00800000
uint_t(d::Float32) = reinterpret(UInt32,d)
# Float16
DenormalExponent(::Type{Float16}) = Int32(-ExponentBias(Float16) + 1)
ExponentMask(::Type{Float16}) = 0x7c00
PhysicalSignificandSize(::Type{Float16}) = Int32(10)
SignificandSize(::Type{Float16}) = Int32(11)
ExponentBias(::Type{Float16}) = Int32(0x000f + PhysicalSignificandSize(Float16))
SignificandMask(::Type{Float16}) = 0x03ff
HiddenBit(::Type{Float16}) = 0x0400
uint_t(d::Float16) = reinterpret(UInt16,d)
function _exponent(d::T) where T<:AbstractFloat
isdenormal(d) && return DenormalExponent(T)
biased_e::Int32 = Int32((uint_t(d) & ExponentMask(T)) >> PhysicalSignificandSize(T))
return Int32(biased_e - ExponentBias(T))
end
function _significand(d::T) where T<:AbstractFloat
s = uint_t(d) & SignificandMask(T)
return !isdenormal(d) ? s + HiddenBit(T) : s
end
isdenormal{T<:AbstractFloat}(d::T) = (uint_t(d) & ExponentMask(T)) == 0
function normalizedbound(f::AbstractFloat)
v = Float(_significand(f),_exponent(f))
m_plus = normalize(Float((v.s << 1) + 1, v.e - 1))
if lowerboundaryiscloser(f)
m_minus = Float((v.s << 2) - 1, v.e - 2)
else
m_minus = Float((v.s << 1) - 1, v.e - 1)
end
return Float(m_minus.s << (m_minus.e - m_plus.e), m_plus.e), m_plus
end
function lowerboundaryiscloser(f::T) where T<:AbstractFloat
physical_significand_is_zero = (uint_t(f) & SignificandMask(T)) == 0
return physical_significand_is_zero && (_exponent(f) != DenormalExponent(T))
end
(-)(a::Float,b::Float) = Float(a.s - b.s,a.e,a.de)
const FloatM32 = 0xFFFFFFFF
function (*)(this::Float,other::Float)
a::UInt64 = this.s >> 32
b::UInt64 = this.s & FloatM32
c::UInt64 = other.s >> 32
d::UInt64 = other.s & FloatM32
ac::UInt64 = a * c
bc::UInt64 = b * c
ad::UInt64 = a * d
bd::UInt64 = b * d
tmp::UInt64 = (bd >> 32) + (ad & FloatM32) + (bc & FloatM32)
# By adding 1U << 31 to tmp we round the final result.
# Halfway cases will be round up.
tmp += UInt64(1) << 31
result_f::UInt64 = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32)
return Float(result_f,this.e + other.e + 64,this.de)
end
const CachedPowers = Float[
Float(0xfa8fd5a0081c0288, -1220, -348),
Float(0xbaaee17fa23ebf76, -1193, -340),
Float(0x8b16fb203055ac76, -1166, -332),
Float(0xcf42894a5dce35ea, -1140, -324),
Float(0x9a6bb0aa55653b2d, -1113, -316),
Float(0xe61acf033d1a45df, -1087, -308),
Float(0xab70fe17c79ac6ca, -1060, -300),
Float(0xff77b1fcbebcdc4f, -1034, -292),
Float(0xbe5691ef416bd60c, -1007, -284),
Float(0x8dd01fad907ffc3c, -980, -276),
Float(0xd3515c2831559a83, -954, -268),
Float(0x9d71ac8fada6c9b5, -927, -260),
Float(0xea9c227723ee8bcb, -901, -252),
Float(0xaecc49914078536d, -874, -244),
Float(0x823c12795db6ce57, -847, -236),
Float(0xc21094364dfb5637, -821, -228),
Float(0x9096ea6f3848984f, -794, -220),
Float(0xd77485cb25823ac7, -768, -212),
Float(0xa086cfcd97bf97f4, -741, -204),
Float(0xef340a98172aace5, -715, -196),
Float(0xb23867fb2a35b28e, -688, -188),
Float(0x84c8d4dfd2c63f3b, -661, -180),
Float(0xc5dd44271ad3cdba, -635, -172),
Float(0x936b9fcebb25c996, -608, -164),
Float(0xdbac6c247d62a584, -582, -156),
Float(0xa3ab66580d5fdaf6, -555, -148),
Float(0xf3e2f893dec3f126, -529, -140),
Float(0xb5b5ada8aaff80b8, -502, -132),
Float(0x87625f056c7c4a8b, -475, -124),
Float(0xc9bcff6034c13053, -449, -116),
Float(0x964e858c91ba2655, -422, -108),
Float(0xdff9772470297ebd, -396, -100),
Float(0xa6dfbd9fb8e5b88f, -369, -92),
Float(0xf8a95fcf88747d94, -343, -84),
Float(0xb94470938fa89bcf, -316, -76),
Float(0x8a08f0f8bf0f156b, -289, -68),
Float(0xcdb02555653131b6, -263, -60),
Float(0x993fe2c6d07b7fac, -236, -52),
Float(0xe45c10c42a2b3b06, -210, -44),
Float(0xaa242499697392d3, -183, -36),
Float(0xfd87b5f28300ca0e, -157, -28),
Float(0xbce5086492111aeb, -130, -20),
Float(0x8cbccc096f5088cc, -103, -12),
Float(0xd1b71758e219652c, -77, -4),
Float(0x9c40000000000000, -50, 4),
Float(0xe8d4a51000000000, -24, 12),
Float(0xad78ebc5ac620000, 3, 20),
Float(0x813f3978f8940984, 30, 28),
Float(0xc097ce7bc90715b3, 56, 36),
Float(0x8f7e32ce7bea5c70, 83, 44),
Float(0xd5d238a4abe98068, 109, 52),
Float(0x9f4f2726179a2245, 136, 60),
Float(0xed63a231d4c4fb27, 162, 68),
Float(0xb0de65388cc8ada8, 189, 76),
Float(0x83c7088e1aab65db, 216, 84),
Float(0xc45d1df942711d9a, 242, 92),
Float(0x924d692ca61be758, 269, 100),
Float(0xda01ee641a708dea, 295, 108),
Float(0xa26da3999aef774a, 322, 116),
Float(0xf209787bb47d6b85, 348, 124),
Float(0xb454e4a179dd1877, 375, 132),
Float(0x865b86925b9bc5c2, 402, 140),
Float(0xc83553c5c8965d3d, 428, 148),
Float(0x952ab45cfa97a0b3, 455, 156),
Float(0xde469fbd99a05fe3, 481, 164),
Float(0xa59bc234db398c25, 508, 172),
Float(0xf6c69a72a3989f5c, 534, 180),
Float(0xb7dcbf5354e9bece, 561, 188),
Float(0x88fcf317f22241e2, 588, 196),
Float(0xcc20ce9bd35c78a5, 614, 204),
Float(0x98165af37b2153df, 641, 212),
Float(0xe2a0b5dc971f303a, 667, 220),
Float(0xa8d9d1535ce3b396, 694, 228),
Float(0xfb9b7cd9a4a7443c, 720, 236),
Float(0xbb764c4ca7a44410, 747, 244),
Float(0x8bab8eefb6409c1a, 774, 252),
Float(0xd01fef10a657842c, 800, 260),
Float(0x9b10a4e5e9913129, 827, 268),
Float(0xe7109bfba19c0c9d, 853, 276),
Float(0xac2820d9623bf429, 880, 284),
Float(0x80444b5e7aa7cf85, 907, 292),
Float(0xbf21e44003acdd2d, 933, 300),
Float(0x8e679c2f5e44ff8f, 960, 308),
Float(0xd433179d9c8cb841, 986, 316),
Float(0x9e19db92b4e31ba9, 1013, 324),
Float(0xeb96bf6ebadf77d9, 1039, 332),
Float(0xaf87023b9bf0ee6b, 1066, 340)]
const CachedPowersLength = length(CachedPowers)
const CachedPowersOffset = 348 # -1 * the first decimal_exponent.
const D_1_LOG2_10 = 0.30102999566398114 # 1 / lg(10)
# Difference between the decimal exponents in the table above.
const DecimalExponentDistance = 8
const MinDecimalExponent = -348
const MaxDecimalExponent = 340
function binexp_cache(min_exponent,max_exponent)
k = ceil(Integer,(min_exponent+63)*D_1_LOG2_10)
index = div(CachedPowersOffset+k-1,DecimalExponentDistance) + 1
cp = CachedPowers[index+1]
return cp
end
| [
27,
34345,
29,
8692,
14,
2164,
46313,
14,
22468,
13,
20362,
27,
456,
62,
30783,
29,
15,
198,
2,
770,
2393,
318,
257,
636,
286,
22300,
11,
475,
318,
10944,
422,
198,
2,
3740,
1378,
12567,
13,
785,
14,
13297,
14,
23352,
12,
1102,
9641,
543,
468,
262,
1708,
5964,
198,
2,
198,
2,
15069,
4793,
12,
4967,
11,
262,
569,
23,
1628,
7035,
13,
1439,
2489,
10395,
13,
198,
2,
2297,
396,
3890,
290,
779,
287,
2723,
290,
13934,
5107,
11,
351,
393,
1231,
198,
2,
17613,
11,
389,
10431,
2810,
326,
262,
1708,
3403,
389,
198,
2,
1138,
25,
198,
2,
198,
2,
220,
220,
220,
220,
1635,
2297,
396,
2455,
507,
286,
2723,
2438,
1276,
12377,
262,
2029,
6634,
198,
2,
220,
220,
220,
220,
220,
220,
4003,
11,
428,
1351,
286,
3403,
290,
262,
1708,
37592,
13,
198,
2,
220,
220,
220,
220,
1635,
2297,
396,
2455,
507,
287,
13934,
1296,
1276,
22919,
262,
2029,
198,
2,
220,
220,
220,
220,
220,
220,
6634,
4003,
11,
428,
1351,
286,
3403,
290,
262,
1708,
198,
2,
220,
220,
220,
220,
220,
220,
37592,
287,
262,
10314,
290,
14,
273,
584,
5696,
2810,
198,
2,
220,
220,
220,
220,
220,
220,
351,
262,
6082,
13,
198,
2,
220,
220,
220,
220,
1635,
16126,
262,
1438,
286,
3012,
3457,
13,
4249,
262,
3891,
286,
663,
198,
2,
220,
220,
220,
220,
220,
220,
20420,
743,
307,
973,
284,
11438,
393,
7719,
3186,
10944,
198,
2,
220,
220,
220,
220,
220,
220,
422,
428,
3788,
1231,
2176,
3161,
3194,
7170,
13,
198,
2,
198,
2,
12680,
47466,
3180,
36592,
2389,
1961,
11050,
3336,
27975,
38162,
9947,
367,
15173,
4877,
5357,
27342,
9865,
3843,
20673,
198,
2,
366,
1921,
3180,
1,
5357,
15529,
7788,
32761,
6375,
8959,
49094,
34764,
11015,
11,
47783,
2751,
11,
21728,
5626,
198,
2,
40880,
5390,
11,
3336,
8959,
49094,
34764,
11015,
3963,
34482,
3398,
1565,
5603,
25382,
5357,
376,
46144,
7473,
198,
2,
317,
16652,
2149,
37232,
33079,
48933,
15986,
13954,
48778,
1961,
13,
3268,
8005,
49261,
50163,
3336,
27975,
38162,
9947,
198,
2,
47210,
21479,
6375,
27342,
9865,
3843,
20673,
9348,
43031,
19146,
7473,
15529,
42242,
11,
3268,
17931,
23988,
11,
19387,
25256,
1847,
11,
198,
2,
38846,
11,
7788,
3620,
6489,
13153,
11,
6375,
7102,
5188,
10917,
3525,
12576,
29506,
25552,
357,
1268,
39149,
2751,
11,
21728,
5626,
198,
2,
40880,
5390,
11,
41755,
11335,
10979,
3963,
28932,
2257,
2043,
37780,
21090,
50,
6375,
49254,
26,
406,
18420,
3963,
23210,
11,
198,
2,
42865,
11,
6375,
4810,
19238,
29722,
26,
6375,
43949,
44180,
23255,
49,
8577,
24131,
8,
29630,
36,
5959,
7257,
2937,
1961,
5357,
6177,
15529,
198,
2,
3336,
15513,
3963,
43031,
25382,
11,
7655,
2767,
16879,
3268,
27342,
10659,
11,
19269,
18379,
43031,
25382,
11,
6375,
309,
9863,
198,
2,
357,
1268,
39149,
2751,
399,
7156,
43,
3528,
18310,
6375,
25401,
54,
24352,
8,
5923,
1797,
2751,
3268,
15529,
34882,
16289,
3963,
3336,
23210,
198,
2,
3963,
12680,
47466,
11,
45886,
16876,
5984,
29817,
1961,
3963,
3336,
28069,
11584,
25382,
3963,
13558,
3398,
29506,
11879,
13,
198,
198,
7249,
48436,
198,
220,
220,
220,
264,
3712,
52,
5317,
2414,
198,
220,
220,
220,
304,
3712,
5317,
2624,
198,
220,
220,
220,
390,
3712,
5317,
2624,
198,
437,
198,
198,
43879,
3419,
796,
48436,
7,
15,
11,
15,
11,
15,
8,
198,
43879,
7,
87,
11,
88,
8,
796,
48436,
7,
87,
11,
88,
11,
5317,
2624,
7,
15,
4008,
198,
43879,
7,
67,
3712,
23839,
43879,
8,
796,
48436,
28264,
12683,
811,
392,
7,
67,
828,
4808,
11201,
3471,
7,
67,
4008,
198,
198,
2,
4757,
82,
198,
9979,
48436,
940,
5653,
33,
896,
796,
657,
87,
37,
4851,
8269,
20483,
1303,
973,
3487,
1096,
7,
43879,
8,
198,
9979,
48436,
11712,
45195,
796,
657,
87,
23,
8269,
24598,
1303,
973,
287,
3487,
1096,
7,
43879,
8,
198,
9979,
48436,
11712,
811,
392,
10699,
796,
2558,
2624,
7,
2414,
8,
198,
198,
8818,
3487,
1096,
7,
85,
3712,
43879,
8,
198,
220,
220,
220,
277,
796,
410,
13,
82,
198,
220,
220,
220,
304,
3712,
5317,
2624,
796,
410,
13,
68,
198,
220,
220,
220,
981,
357,
69,
1222,
48436,
940,
5653,
33,
896,
8,
6624,
657,
198,
220,
220,
220,
220,
220,
220,
220,
277,
9959,
28,
838,
198,
220,
220,
220,
220,
220,
220,
220,
304,
48185,
838,
198,
220,
220,
220,
886,
198,
220,
220,
220,
981,
357,
69,
1222,
48436,
11712,
45195,
8,
6624,
657,
198,
220,
220,
220,
220,
220,
220,
220,
277,
9959,
28,
352,
198,
220,
220,
220,
220,
220,
220,
220,
304,
48185,
352,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
48436,
7,
69,
11,
68,
8,
198,
437,
198,
8818,
3487,
1096,
7,
85,
3712,
43879,
2414,
8,
198,
220,
220,
220,
264,
796,
4808,
12683,
811,
392,
7,
85,
1776,
304,
796,
4808,
11201,
3471,
7,
85,
8,
198,
220,
220,
220,
981,
357,
82,
1222,
20458,
13128,
7,
43879,
2414,
4008,
6624,
657,
198,
220,
220,
220,
220,
220,
220,
220,
264,
9959,
28,
471,
5317,
2414,
7,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
304,
48185,
2558,
2624,
7,
16,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
264,
9959,
28,
471,
5317,
2414,
7,
43879,
11712,
811,
392,
10699,
532,
5865,
811,
392,
10699,
7,
43879,
2414,
4008,
198,
220,
220,
220,
304,
48185,
220,
2558,
2624,
7,
48436,
11712,
811,
392,
10699,
532,
5865,
811,
392,
10699,
7,
43879,
2414,
4008,
198,
220,
220,
220,
1441,
48436,
7,
82,
11,
304,
8,
198,
437,
198,
198,
2,
48436,
12762,
198,
2,
21306,
6636,
16870,
3471,
7,
3712,
6030,
90,
43879,
12762,
30072,
796,
2558,
2624,
32590,
16870,
3471,
33,
4448,
7,
43879,
12762,
8,
1343,
352,
8,
198,
2,
16870,
3471,
45195,
7,
3712,
6030,
90,
43879,
12762,
30072,
796,
657,
87,
22,
20972,
25645,
8269,
2388,
198,
2,
31611,
11712,
811,
392,
10699,
7,
3712,
6030,
90,
43879,
12762,
30072,
796,
2558,
2624,
7,
14686,
8,
198,
2,
11712,
811,
392,
10699,
7,
3712,
6030,
90,
43879,
12762,
30072,
796,
2558,
2624,
7,
16616,
8,
198,
2,
16870,
3471,
33,
4448,
7,
3712,
6030,
90,
43879,
12762,
30072,
796,
2558,
2624,
7,
15,
87,
2388,
18,
20972,
1343,
16331,
11712,
811,
392,
10699,
7,
43879,
12762,
4008,
198,
2,
11712,
811,
392,
45195,
7,
3712,
6030,
90,
43879,
12762,
30072,
796,
657,
87,
2388,
12927,
12927,
12927,
12927,
12927,
12927,
12927,
198,
2,
41691,
13128,
7,
3712,
6030,
90,
43879,
12762,
30072,
796,
657,
87,
18005,
25645,
8269,
2388,
198,
2,
28611,
62,
83,
7,
67,
3712,
43879,
12762,
8,
796,
302,
27381,
7,
52,
5317,
12762,
11,
67,
8,
198,
2,
48436,
2414,
198,
21306,
6636,
16870,
3471,
7,
3712,
6030,
90,
43879,
2414,
30072,
796,
2558,
2624,
32590,
16870,
3471,
33,
4448,
7,
43879,
2414,
8,
1343,
352,
8,
198,
16870,
3471,
45195,
7,
3712,
6030,
90,
43879,
2414,
30072,
796,
657,
87,
22,
5777,
8269,
20483,
198,
31611,
11712,
811,
392,
10699,
7,
3712,
6030,
90,
43879,
2414,
30072,
796,
2558,
2624,
7,
4309,
8,
198,
11712,
811,
392,
10699,
7,
3712,
6030,
90,
43879,
2414,
30072,
796,
2558,
2624,
7,
4310,
8,
198,
16870,
3471,
33,
4448,
7,
3712,
6030,
90,
43879,
2414,
30072,
796,
2558,
2624,
7,
15,
87,
18,
5777,
1343,
16331,
11712,
811,
392,
10699,
7,
43879,
2414,
4008,
198,
11712,
811,
392,
45195,
7,
3712,
6030,
90,
43879,
2414,
30072,
796,
657,
87,
830,
29312,
29312,
29312,
37,
198,
41691,
13128,
7,
3712,
6030,
90,
43879,
2414,
30072,
796,
657,
87,
8298,
8269,
20483,
198,
28611,
62,
83,
7,
67,
3712,
43879,
2414,
8,
796,
302,
27381,
7,
52,
5317,
2414,
11,
67,
8,
198,
2,
48436,
2624,
198,
21306,
6636,
16870,
3471,
7,
3712,
6030,
90,
43879,
2624,
30072,
796,
2558,
2624,
32590,
16870,
3471,
33,
4448,
7,
43879,
2624,
8,
1343,
352,
8,
198,
16870,
3471,
45195,
7,
3712,
6030,
90,
43879,
2624,
30072,
796,
657,
87,
22,
37,
7410,
830,
198,
31611,
11712,
811,
392,
10699,
7,
3712,
6030,
90,
43879,
2624,
30072,
796,
2558,
2624,
7,
1954,
8,
198,
11712,
811,
392,
10699,
7,
3712,
6030,
90,
43879,
2624,
30072,
796,
2558,
2624,
7,
1731,
8,
198,
16870,
3471,
33,
4448,
7,
3712,
6030,
90,
43879,
2624,
30072,
796,
2558,
2624,
7,
15,
87,
22,
37,
1343,
16331,
11712,
811,
392,
10699,
7,
43879,
2624,
4008,
198,
11712,
811,
392,
45195,
7,
3712,
6030,
90,
43879,
2624,
30072,
796,
657,
87,
25816,
29312,
37,
198,
41691,
13128,
7,
3712,
6030,
90,
43879,
2624,
30072,
796,
657,
87,
405,
7410,
830,
198,
28611,
62,
83,
7,
67,
3712,
43879,
2624,
8,
796,
302,
27381,
7,
52,
5317,
2624,
11,
67,
8,
198,
2,
48436,
1433,
198,
21306,
6636,
16870,
3471,
7,
3712,
6030,
90,
43879,
1433,
30072,
796,
2558,
2624,
32590,
16870,
3471,
33,
4448,
7,
43879,
1433,
8,
1343,
352,
8,
198,
16870,
3471,
45195,
7,
3712,
6030,
90,
43879,
1433,
30072,
796,
657,
87,
22,
66,
405,
198,
31611,
11712,
811,
392,
10699,
7,
3712,
6030,
90,
43879,
1433,
30072,
796,
2558,
2624,
7,
940,
8,
198,
11712,
811,
392,
10699,
7,
3712,
6030,
90,
43879,
1433,
30072,
796,
2558,
2624,
7,
1157,
8,
198,
16870,
3471,
33,
4448,
7,
3712,
6030,
90,
43879,
1433,
30072,
796,
2558,
2624,
7,
15,
87,
830,
69,
1343,
16331,
11712,
811,
392,
10699,
7,
43879,
1433,
4008,
198,
11712,
811,
392,
45195,
7,
3712,
6030,
90,
43879,
1433,
30072,
796,
657,
87,
3070,
487,
198,
41691,
13128,
7,
3712,
6030,
90,
43879,
1433,
30072,
796,
657,
87,
3023,
405,
198,
28611,
62,
83,
7,
67,
3712,
43879,
1433,
8,
796,
302,
27381,
7,
52,
5317,
1433,
11,
67,
8,
198,
198,
8818,
4808,
11201,
3471,
7,
67,
3712,
51,
8,
810,
309,
27,
25,
23839,
43879,
198,
220,
318,
6559,
6636,
7,
67,
8,
11405,
1441,
5601,
6636,
16870,
3471,
7,
51,
8,
198,
220,
21925,
62,
68,
3712,
5317,
2624,
796,
2558,
2624,
19510,
28611,
62,
83,
7,
67,
8,
1222,
5518,
3471,
45195,
7,
51,
4008,
9609,
16331,
11712,
811,
392,
10699,
7,
51,
4008,
198,
220,
1441,
2558,
2624,
7,
38002,
62,
68,
532,
5518,
3471,
33,
4448,
7,
51,
4008,
198,
437,
198,
8818,
4808,
12683,
811,
392,
7,
67,
3712,
51,
8,
810,
309,
27,
25,
23839,
43879,
198,
220,
264,
796,
20398,
62,
83,
7,
67,
8,
1222,
5865,
811,
392,
45195,
7,
51,
8,
198,
220,
1441,
5145,
271,
6559,
6636,
7,
67,
8,
5633,
264,
1343,
20458,
13128,
7,
51,
8,
1058,
264,
198,
437,
198,
271,
6559,
6636,
90,
51,
27,
25,
23839,
43879,
92,
7,
67,
3712,
51,
8,
796,
357,
28611,
62,
83,
7,
67,
8,
1222,
5518,
3471,
45195,
7,
51,
4008,
6624,
657,
198,
198,
8818,
39279,
7784,
7,
69,
3712,
23839,
43879,
8,
198,
220,
220,
220,
410,
796,
48436,
28264,
12683,
811,
392,
7,
69,
828,
62,
11201,
3471,
7,
69,
4008,
198,
220,
220,
220,
285,
62,
9541,
796,
3487,
1096,
7,
43879,
19510,
85,
13,
82,
9959,
352,
8,
1343,
352,
11,
410,
13,
68,
532,
352,
4008,
198,
220,
220,
220,
611,
2793,
7784,
560,
271,
565,
13416,
7,
69,
8,
198,
220,
220,
220,
220,
220,
220,
220,
285,
62,
40191,
796,
48436,
19510,
85,
13,
82,
9959,
362,
8,
532,
352,
11,
410,
13,
68,
532,
362,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
285,
62,
40191,
796,
48436,
19510,
85,
13,
82,
9959,
352,
8,
532,
352,
11,
410,
13,
68,
532,
352,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
48436,
7,
76,
62,
40191,
13,
82,
9959,
357,
76,
62,
40191,
13,
68,
532,
285,
62,
9541,
13,
68,
828,
285,
62,
9541,
13,
68,
828,
285,
62,
9541,
198,
437,
198,
8818,
2793,
7784,
560,
271,
565,
13416,
7,
69,
3712,
51,
8,
810,
309,
27,
25,
23839,
43879,
198,
220,
220,
220,
3518,
62,
12683,
811,
392,
62,
271,
62,
22570,
796,
357,
28611,
62,
83,
7,
69,
8,
1222,
5865,
811,
392,
45195,
7,
51,
4008,
6624,
657,
198,
220,
220,
220,
1441,
3518,
62,
12683,
811,
392,
62,
271,
62,
22570,
11405,
44104,
11201,
3471,
7,
69,
8,
14512,
5601,
6636,
16870,
3471,
7,
51,
4008,
198,
437,
198,
198,
32590,
5769,
64,
3712,
43879,
11,
65,
3712,
43879,
8,
796,
48436,
7,
64,
13,
82,
532,
275,
13,
82,
11,
64,
13,
68,
11,
64,
13,
2934,
8,
198,
198,
9979,
48436,
44,
2624,
796,
657,
87,
29312,
29312,
198,
198,
8818,
20789,
5769,
5661,
3712,
43879,
11,
847,
3712,
43879,
8,
198,
220,
220,
220,
257,
3712,
52,
5317,
2414,
796,
428,
13,
82,
9609,
3933,
198,
220,
220,
220,
275,
3712,
52,
5317,
2414,
796,
428,
13,
82,
1222,
48436,
44,
2624,
198,
220,
220,
220,
269,
3712,
52,
5317,
2414,
796,
584,
13,
82,
9609,
3933,
198,
220,
220,
220,
288,
3712,
52,
5317,
2414,
796,
584,
13,
82,
1222,
48436,
44,
2624,
198,
220,
220,
220,
936,
3712,
52,
5317,
2414,
796,
257,
1635,
269,
198,
220,
220,
220,
47125,
3712,
52,
5317,
2414,
796,
275,
1635,
269,
198,
220,
220,
220,
512,
3712,
52,
5317,
2414,
796,
257,
1635,
288,
198,
220,
220,
220,
275,
67,
3712,
52,
5317,
2414,
796,
275,
1635,
288,
198,
220,
220,
220,
45218,
3712,
52,
5317,
2414,
796,
357,
17457,
9609,
3933,
8,
1343,
357,
324,
1222,
48436,
44,
2624,
8,
1343,
357,
15630,
1222,
48436,
44,
2624,
8,
198,
220,
220,
220,
1303,
2750,
4375,
352,
52,
9959,
3261,
284,
45218,
356,
2835,
262,
2457,
1255,
13,
198,
220,
220,
220,
1303,
13139,
1014,
2663,
481,
307,
2835,
510,
13,
198,
220,
220,
220,
45218,
15853,
471,
5317,
2414,
7,
16,
8,
9959,
3261,
198,
220,
220,
220,
1255,
62,
69,
3712,
52,
5317,
2414,
796,
936,
1343,
357,
324,
9609,
3933,
8,
1343,
357,
15630,
9609,
3933,
8,
1343,
357,
22065,
9609,
3933,
8,
198,
220,
220,
220,
1441,
48436,
7,
20274,
62,
69,
11,
5661,
13,
68,
1343,
584,
13,
68,
1343,
5598,
11,
5661,
13,
2934,
8,
198,
437,
198,
198,
9979,
327,
2317,
47,
3618,
796,
48436,
58,
198,
220,
48436,
7,
15,
87,
13331,
23,
16344,
20,
64,
405,
6659,
66,
15,
25270,
11,
532,
1065,
1238,
11,
532,
28978,
828,
198,
220,
48436,
7,
15,
87,
7012,
64,
1453,
1558,
13331,
1954,
1765,
69,
4304,
11,
532,
16315,
18,
11,
532,
23601,
828,
198,
220,
48436,
7,
15,
87,
23,
65,
1433,
21855,
1238,
1270,
2816,
330,
4304,
11,
532,
1157,
2791,
11,
532,
32148,
828,
198,
220,
48436,
7,
15,
87,
12993,
40173,
5824,
64,
20,
67,
344,
2327,
18213,
11,
532,
1157,
1821,
11,
532,
33916,
828,
198,
220,
48436,
7,
15,
87,
24,
64,
21,
11848,
15,
7252,
2816,
46435,
65,
17,
67,
11,
532,
1157,
1485,
11,
532,
33400,
828,
198,
220,
48436,
7,
15,
27705,
5333,
330,
69,
44427,
67,
16,
64,
2231,
7568,
11,
532,
940,
5774,
11,
532,
21495,
828,
198,
220,
48436,
7,
15,
87,
397,
2154,
5036,
1558,
66,
3720,
330,
21,
6888,
11,
532,
940,
1899,
11,
532,
6200,
828,
198,
220,
48436,
7,
15,
47596,
3324,
65,
16,
16072,
1350,
65,
10210,
66,
19,
69,
11,
532,
940,
2682,
11,
532,
32759,
828,
198,
220,
48436,
7,
15,
87,
1350,
20,
49541,
891,
35218,
17457,
1899,
66,
11,
532,
44318,
11,
532,
30336,
828,
198,
220,
48436,
7,
15,
87,
23,
1860,
486,
69,
324,
24,
2998,
487,
66,
18,
66,
11,
532,
40022,
11,
532,
27988,
828,
198,
220,
48436,
7,
15,
24954,
2327,
1314,
66,
2078,
27936,
3270,
64,
5999,
11,
532,
48372,
11,
532,
25022,
828,
198,
220,
48436,
7,
15,
87,
24,
67,
4869,
330,
23,
69,
4763,
21,
66,
24,
65,
20,
11,
532,
24,
1983,
11,
532,
21719,
828,
198,
220,
48436,
7,
15,
87,
18213,
24,
66,
1828,
3324,
1954,
1453,
23,
15630,
65,
11,
532,
46815,
11,
532,
22800,
828,
198,
220,
48436,
7,
15,
87,
3609,
535,
28324,
1415,
2998,
5332,
2623,
67,
11,
532,
23,
4524,
11,
532,
25707,
828,
198,
220,
48436,
7,
15,
87,
23,
1954,
66,
1065,
41544,
9945,
21,
344,
3553,
11,
532,
23,
2857,
11,
532,
24940,
828,
198,
220,
48436,
7,
15,
25306,
17,
14454,
3559,
2414,
7568,
65,
3980,
2718,
11,
532,
23,
2481,
11,
532,
23815,
828,
198,
220,
48436,
7,
15,
87,
44675,
21,
18213,
21,
69,
2548,
2780,
4089,
19,
69,
11,
532,
50242,
11,
532,
17572,
828,
198,
220,
48436,
7,
15,
24954,
3324,
32642,
21101,
25600,
1954,
330,
22,
11,
532,
30610,
11,
532,
21777,
828,
198,
220,
48436,
7,
15,
27865,
2919,
21,
12993,
10210,
5607,
19881,
5607,
69,
19,
11,
532,
22,
3901,
11,
532,
18638,
828,
198,
220,
48436,
7,
15,
87,
891,
23601,
64,
4089,
23628,
64,
558,
20,
11,
532,
22,
1314,
11,
532,
25272,
828,
198,
220,
48436,
7,
15,
30894,
23721,
3134,
21855,
17,
64,
2327,
65,
2078,
68,
11,
532,
34427,
11,
532,
20356,
828,
198,
220,
48436,
7,
15,
87,
5705,
66,
23,
67,
19,
7568,
67,
17,
66,
5066,
69,
18,
65,
11,
532,
47159,
11,
532,
15259,
828,
198,
220,
48436,
7,
15,
25306,
20,
1860,
2598,
28977,
324,
18,
10210,
7012,
11,
532,
48250,
11,
532,
23628,
828,
198,
220,
48436,
7,
15,
87,
24,
2623,
65,
24,
69,
344,
11848,
1495,
66,
38565,
11,
532,
28688,
11,
532,
23237,
828,
198,
220,
48436,
7,
15,
87,
9945,
330,
21,
66,
23753,
67,
5237,
64,
46352,
11,
532,
46044,
11,
532,
21599,
828,
198,
220,
48436,
7,
15,
27865,
18,
397,
36879,
1795,
67,
20,
16344,
1878,
21,
11,
532,
31046,
11,
532,
18294,
828,
198,
220,
48436,
7,
15,
26152,
18,
68,
17,
69,
49682,
12501,
18,
69,
19420,
11,
532,
49721,
11,
532,
15187,
828,
198,
220,
48436,
7,
15,
30894,
20,
65,
20,
4763,
23,
64,
2001,
1795,
65,
23,
11,
532,
35126,
11,
532,
19924,
828,
198,
220,
48436,
7,
15,
87,
23,
4304,
1495,
69,
2713,
21,
66,
22,
66,
19,
64,
23,
65,
11,
532,
32576,
11,
532,
17464,
828,
198,
220,
48436,
7,
15,
25306,
24,
15630,
487,
1899,
2682,
66,
12952,
4310,
11,
532,
31911,
11,
532,
18298,
828,
198,
220,
48436,
7,
15,
87,
24,
2414,
68,
23,
3365,
66,
6420,
7012,
2075,
2816,
11,
532,
44361,
11,
532,
15711,
828,
198,
220,
48436,
7,
15,
24954,
487,
24,
3324,
1731,
2154,
26561,
1765,
67,
11,
532,
34107,
11,
532,
3064,
828,
198,
220,
48436,
7,
15,
27865,
21,
7568,
17457,
24,
21855,
23,
68,
20,
65,
3459,
69,
11,
532,
30803,
11,
532,
5892,
828,
198,
220,
48436,
7,
15,
26152,
23,
64,
3865,
69,
12993,
46660,
2857,
67,
5824,
11,
532,
32118,
11,
532,
5705,
828,
198,
220,
48436,
7,
15,
30894,
24,
2598,
31495,
2548,
13331,
4531,
65,
12993,
11,
532,
33400,
11,
532,
4304,
828,
198,
220,
48436,
7,
15,
87,
23,
64,
2919,
69,
15,
69,
23,
19881,
15,
69,
21599,
65,
11,
532,
27693,
11,
532,
3104,
828,
198,
220,
48436,
7,
15,
25306,
9945,
36629,
2816,
46435,
22042,
65,
21,
11,
532,
29558,
11,
532,
1899,
828,
198,
220,
48436,
7,
15,
87,
44821,
5036,
17,
66,
21,
67,
2998,
65,
22,
38942,
11,
532,
24940,
11,
532,
4309,
828,
198,
220,
48436,
7,
15,
27705,
2231,
66,
940,
66,
3682,
64,
17,
65,
18,
65,
3312,
11,
532,
21536,
11,
532,
2598,
828,
198,
220,
48436,
7,
15,
87,
7252,
1731,
1731,
2079,
40035,
32321,
67,
18,
11,
532,
24839,
11,
532,
2623,
828,
198,
220,
48436,
7,
15,
87,
16344,
5774,
65,
20,
69,
2078,
6200,
6888,
15,
68,
11,
532,
18458,
11,
532,
2078,
828,
198,
220,
48436,
7,
15,
30894,
344,
33042,
2414,
5892,
16243,
64,
1765,
11,
532,
12952,
11,
532,
1238,
828,
198,
220,
48436,
7,
15,
87,
23,
21101,
535,
66,
2931,
21,
69,
1120,
3459,
535,
11,
532,
15197,
11,
532,
1065,
828,
198,
220,
48436,
7,
15,
24954,
16,
65,
22,
1558,
3365,
68,
28896,
43193,
66,
11,
532,
3324,
11,
532,
19,
828,
198,
220,
48436,
7,
15,
87,
24,
66,
19,
8269,
20483,
11,
532,
1120,
11,
604,
828,
198,
220,
48436,
7,
15,
27705,
23,
67,
19,
64,
4349,
10535,
830,
11,
532,
1731,
11,
1105,
828,
198,
220,
48436,
7,
15,
87,
324,
3695,
1765,
66,
20,
330,
21,
2167,
405,
11,
513,
11,
1160,
828,
198,
220,
48436,
7,
15,
87,
23,
1485,
69,
2670,
3695,
69,
4531,
1821,
4089,
19,
11,
1542,
11,
2579,
828,
198,
220,
48436,
7,
15,
25306,
2931,
22,
344,
22,
15630,
24,
2998,
1314,
65,
18,
11,
7265,
11,
4570,
828,
198,
220,
48436,
7,
15,
87,
23,
69,
22,
68,
2624,
344,
22,
1350,
64,
20,
66,
2154,
11,
9698,
11,
5846,
828,
198,
220,
48436,
7,
15,
24954,
20,
67,
23721,
64,
19,
11231,
40022,
3104,
11,
16003,
11,
6740,
828,
198,
220,
48436,
7,
15,
87,
24,
69,
19,
69,
1983,
2075,
21738,
64,
17,
22995,
11,
21056,
11,
3126,
828,
198,
220,
48436,
7,
15,
87,
276,
5066,
64,
25667,
67,
19,
66,
19,
21855,
1983,
11,
25090,
11,
8257,
828,
198,
220,
48436,
7,
15,
30894,
15,
2934,
2996,
30460,
535,
23,
4763,
23,
11,
27230,
11,
8684,
828,
198,
220,
48436,
7,
15,
87,
5999,
66,
2154,
3459,
68,
16,
64,
397,
2996,
9945,
11,
26881,
11,
9508,
828,
198,
220,
48436,
7,
15,
25306,
2231,
67,
16,
7568,
5824,
1983,
1157,
67,
24,
64,
11,
34353,
11,
10190,
828,
198,
220,
48436,
7,
15,
87,
24,
1731,
67,
46589,
6888,
5333,
1350,
38569,
11,
38249,
11,
1802,
828,
198,
220,
48436,
7,
15,
87,
6814,
486,
1453,
42759,
64,
32583,
2934,
64,
11,
34772,
11,
15495,
828,
198,
220,
48436,
7,
15,
27865,
2075,
6814,
18,
17032,
64,
891,
47582,
64,
11,
38831,
11,
18693,
828,
198,
220,
48436,
7,
15,
26152,
22567,
41019,
11848,
2857,
67,
21,
65,
5332,
11,
44084,
11,
19755,
828,
198,
220,
48436,
7,
15,
30894,
34229,
68,
19,
64,
21738,
1860,
1507,
3324,
11,
29414,
11,
21761,
828,
198,
220,
48436,
7,
15,
87,
23,
2996,
65,
23,
3388,
1495,
65,
24,
15630,
20,
66,
17,
11,
42622,
11,
12713,
828,
198,
220,
48436,
7,
15,
25306,
23,
2327,
4310,
66,
20,
66,
4531,
2996,
67,
18,
67,
11,
45063,
11,
22613,
828,
198,
220,
48436,
7,
15,
87,
49234,
397,
2231,
12993,
64,
5607,
64,
15,
65,
18,
11,
46839,
11,
23871,
828,
198,
220,
48436,
7,
15,
87,
2934,
42947,
69,
17457,
2079,
64,
2713,
5036,
18,
11,
4764,
16,
11,
25307,
828,
198,
220,
48436,
7,
15,
27865,
3270,
15630,
24409,
9945,
31952,
66,
1495,
11,
2026,
23,
11,
23120,
828,
198,
220,
48436,
7,
15,
26152,
21,
66,
3388,
64,
4761,
64,
2670,
4531,
69,
20,
66,
11,
642,
2682,
11,
11546,
828,
198,
220,
48436,
7,
15,
30894,
22,
17896,
19881,
20,
32182,
68,
24,
1350,
344,
11,
642,
5333,
11,
27778,
828,
198,
220,
48436,
7,
15,
87,
3459,
69,
12993,
34125,
69,
1828,
28872,
68,
17,
11,
642,
3459,
11,
28817,
828,
198,
220,
48436,
7,
15,
87,
535,
1238,
344,
24,
17457,
2327,
66,
3695,
64,
20,
11,
718,
1415,
11,
26956,
828,
198,
220,
48436,
7,
15,
87,
4089,
20986,
1878,
2718,
65,
17,
21395,
7568,
11,
718,
3901,
11,
23679,
828,
198,
220,
48436,
7,
15,
27705,
17,
64,
15,
65,
20,
17896,
24,
4869,
69,
22572,
64,
11,
718,
3134,
11,
15629,
828,
198,
220,
48436,
7,
15,
27865,
23,
67,
24,
67,
1314,
2327,
344,
18,
65,
34107,
11,
718,
5824,
11,
29041,
828,
198,
220,
48436,
7,
15,
87,
21855,
24,
65,
22,
10210,
24,
64,
19,
64,
22,
34938,
66,
11,
26250,
11,
34044,
828,
198,
220,
48436,
7,
15,
87,
11848,
22,
2414,
66,
19,
6888,
22,
64,
30272,
940,
11,
45600,
11,
35264,
828,
198,
220,
48436,
7,
15,
87,
23,
65,
397,
23,
68,
891,
65,
21,
29416,
66,
16,
64,
11,
767,
4524,
11,
25264,
828,
198,
220,
48436,
7,
15,
24954,
486,
69,
891,
940,
64,
2996,
3695,
3682,
66,
11,
10460,
11,
21148,
828,
198,
220,
48436,
7,
15,
87,
24,
65,
940,
64,
19,
68,
20,
68,
2079,
1485,
18741,
11,
807,
1983,
11,
36678,
828,
198,
220,
48436,
7,
15,
27705,
22,
14454,
19881,
7012,
1129,
66,
15,
66,
24,
67,
11,
807,
4310,
11,
38147,
828,
198,
220,
48436,
7,
15,
87,
330,
2078,
1238,
67,
4846,
1954,
19881,
11785,
11,
807,
1795,
11,
40654,
828,
198,
220,
48436,
7,
15,
87,
1795,
30272,
65,
20,
68,
22,
7252,
22,
12993,
5332,
11,
860,
2998,
11,
41569,
828,
198,
220,
48436,
7,
15,
87,
19881,
2481,
68,
2598,
11245,
330,
1860,
17,
67,
11,
860,
2091,
11,
5867,
828,
198,
220,
48436,
7,
15,
87,
23,
68,
37601,
66,
17,
69,
20,
68,
2598,
487,
23,
69,
11,
41263,
11,
35617,
828,
198,
220,
48436,
7,
15,
24954,
42117,
21738,
67,
24,
66,
23,
21101,
23,
3901,
11,
860,
4521,
11,
34131,
828,
198,
220,
48436,
7,
15,
87,
24,
68,
1129,
9945,
5892,
65,
19,
68,
3132,
7012,
24,
11,
8949,
18,
11,
38595,
828,
198,
220,
48436,
7,
15,
87,
1765,
4846,
19881,
21,
1765,
324,
69,
3324,
67,
24,
11,
838,
2670,
11,
41423,
828,
198,
220,
48436,
7,
15,
87,
1878,
46951,
1954,
65,
24,
19881,
15,
1453,
21,
65,
11,
838,
2791,
11,
28560,
15437,
198,
198,
9979,
327,
2317,
47,
3618,
24539,
796,
4129,
7,
34,
2317,
47,
3618,
8,
198,
9979,
327,
2317,
47,
3618,
34519,
796,
44084,
220,
1303,
532,
16,
1635,
262,
717,
32465,
62,
11201,
3471,
13,
198,
9979,
360,
62,
16,
62,
25294,
17,
62,
940,
796,
657,
13,
18938,
48891,
33438,
2791,
31952,
16562,
220,
1303,
220,
352,
1220,
300,
70,
7,
940,
8,
198,
2,
43795,
1022,
262,
32465,
1033,
3906,
287,
262,
3084,
2029,
13,
198,
9979,
4280,
4402,
16870,
3471,
45767,
796,
807,
198,
9979,
1855,
10707,
4402,
16870,
3471,
796,
532,
28978,
198,
9979,
5436,
10707,
4402,
16870,
3471,
796,
28560,
198,
198,
8818,
275,
500,
42372,
62,
23870,
7,
1084,
62,
11201,
3471,
11,
9806,
62,
11201,
3471,
8,
198,
220,
220,
220,
479,
796,
2906,
346,
7,
46541,
11,
7,
1084,
62,
11201,
3471,
10,
5066,
27493,
35,
62,
16,
62,
25294,
17,
62,
940,
8,
198,
220,
220,
220,
6376,
796,
2659,
7,
34,
2317,
47,
3618,
34519,
10,
74,
12,
16,
11,
10707,
4402,
16870,
3471,
45767,
8,
1343,
352,
198,
220,
220,
220,
31396,
796,
327,
2317,
47,
3618,
58,
9630,
10,
16,
60,
198,
220,
220,
220,
1441,
31396,
198,
437,
198
] | 2.278743 | 4,488 |
<filename>test/immerse.jl
# These tests are designed to ensure that Immerse.jl works. If you
# need to edit these tests to make them pass, that's fine, but please
# submit the corresponding fix to Immerse.
using Compose, Base.Test
import Cairo
### The Immerse backend
srf = Cairo.CairoImageSurface(10, 10, Cairo.FORMAT_RGB24)
ctx = compose(compose(context(), rectangle(0.0w, 0.0h, 0.8w, 0.7h, :rect)), fill("tomato"))
be = Compose.ImmerseBackend(srf)
draw(be, ctx)
@test be.coords[:rect][2] == Compose.UnitBox()
### Finding tagged objects
const ContainersWithChildren = Union{Context,Compose.Table}
const Iterables = Union{ContainersWithChildren, AbstractArray}
iterable(ctx::ContainersWithChildren) = ctx.children
iterable(a::AbstractArray) = a
function find_tagged(root)
handles = Dict{Symbol,Context}()
find_tagged!(handles, root)
end
function find_tagged!(handles, obj::Iterables)
for item in iterable(obj)
if has_tag(item)
handles[item.tag] = obj
else
find_tagged!(handles, item)
end
end
handles
end
function find_tagged!(handles, obj::Context)
for item in obj.form_children
if has_tag(item)
handles[item.tag] = obj
end
end
for item in obj.container_children
find_tagged!(handles, item)
end
handles
end
find_tagged!(handles, obj) = obj
has_tag(form::Compose.Form, tag) = form.tag == tag
has_tag(form::Compose.Form) = form.tag != Compose.empty_tag
has_tag(obj, tag) = false
has_tag(obj) = false
@test find_tagged(ctx)[:rect] == ctx
### Coordinate computations
function absolute_to_data(x, y, transform, unit_box, parent_box)
xt, yt = invert_transform(transform, x, y)
(unit_box.x0 + unit_box.width *(xt-parent_box.x0[1])/Measures.width(parent_box),
unit_box.y0 + unit_box.height*(yt-parent_box.x0[2])/Measures.height(parent_box))
end
invert_transform(::Compose.IdentityTransform, x, y) = x, y
function invert_transform(t::Compose.MatrixTransform, x, y)
@assert t.M[3,1] == t.M[3,2] == 0
xyt = t.M\[x, y, 1.0]
xyt[1], xyt[2]
end
box, units, transform = be.coords[:rect]
xd, yd = absolute_to_data(0.5mm, 0.5mm, transform, units, box)
@test isapprox(xd,0.1417; atol=0.0001)
| [
27,
34345,
29,
9288,
14,
10957,
325,
13,
20362,
198,
2,
2312,
5254,
389,
3562,
284,
4155,
326,
1846,
647,
325,
13,
20362,
2499,
13,
1002,
345,
198,
2,
761,
284,
4370,
777,
5254,
284,
787,
606,
1208,
11,
326,
338,
3734,
11,
475,
3387,
198,
2,
9199,
262,
11188,
4259,
284,
1846,
647,
325,
13,
198,
198,
3500,
3082,
577,
11,
7308,
13,
14402,
198,
11748,
23732,
198,
198,
21017,
383,
1846,
647,
325,
30203,
198,
27891,
69,
796,
23732,
13,
34,
18131,
5159,
14214,
2550,
7,
940,
11,
838,
11,
23732,
13,
21389,
1404,
62,
36982,
1731,
8,
198,
49464,
796,
36664,
7,
785,
3455,
7,
22866,
22784,
35991,
7,
15,
13,
15,
86,
11,
657,
13,
15,
71,
11,
657,
13,
23,
86,
11,
657,
13,
22,
71,
11,
1058,
2554,
36911,
6070,
7203,
39532,
5549,
48774,
198,
1350,
796,
3082,
577,
13,
3546,
647,
325,
7282,
437,
7,
27891,
69,
8,
198,
19334,
7,
1350,
11,
269,
17602,
8,
198,
31,
9288,
307,
13,
1073,
3669,
58,
25,
2554,
7131,
17,
60,
6624,
3082,
577,
13,
26453,
14253,
3419,
198,
198,
21017,
27063,
30509,
5563,
198,
9979,
2345,
50221,
3152,
26829,
796,
4479,
90,
21947,
11,
7293,
577,
13,
10962,
92,
198,
9979,
40806,
2977,
796,
4479,
90,
4264,
50221,
3152,
26829,
11,
27741,
19182,
92,
198,
198,
2676,
540,
7,
49464,
3712,
4264,
50221,
3152,
26829,
8,
796,
269,
17602,
13,
17197,
198,
2676,
540,
7,
64,
3712,
23839,
19182,
8,
796,
257,
198,
198,
8818,
1064,
62,
12985,
2004,
7,
15763,
8,
198,
220,
220,
220,
17105,
796,
360,
713,
90,
13940,
23650,
11,
21947,
92,
3419,
198,
220,
220,
220,
1064,
62,
12985,
2004,
0,
7,
4993,
829,
11,
6808,
8,
198,
437,
198,
198,
8818,
1064,
62,
12985,
2004,
0,
7,
4993,
829,
11,
26181,
3712,
29993,
2977,
8,
198,
220,
220,
220,
329,
2378,
287,
11629,
540,
7,
26801,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
468,
62,
12985,
7,
9186,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17105,
58,
9186,
13,
12985,
60,
796,
26181,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1064,
62,
12985,
2004,
0,
7,
4993,
829,
11,
2378,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
17105,
198,
437,
198,
198,
8818,
1064,
62,
12985,
2004,
0,
7,
4993,
829,
11,
26181,
3712,
21947,
8,
198,
220,
220,
220,
329,
2378,
287,
26181,
13,
687,
62,
17197,
198,
220,
220,
220,
220,
220,
220,
220,
611,
468,
62,
12985,
7,
9186,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17105,
58,
9186,
13,
12985,
60,
796,
26181,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
329,
2378,
287,
26181,
13,
34924,
62,
17197,
198,
220,
220,
220,
220,
220,
220,
220,
1064,
62,
12985,
2004,
0,
7,
4993,
829,
11,
2378,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
17105,
198,
437,
198,
198,
19796,
62,
12985,
2004,
0,
7,
4993,
829,
11,
26181,
8,
796,
26181,
198,
198,
10134,
62,
12985,
7,
687,
3712,
7293,
577,
13,
8479,
11,
7621,
8,
796,
1296,
13,
12985,
6624,
7621,
198,
10134,
62,
12985,
7,
687,
3712,
7293,
577,
13,
8479,
8,
220,
220,
220,
220,
220,
796,
1296,
13,
12985,
14512,
3082,
577,
13,
28920,
62,
12985,
198,
198,
10134,
62,
12985,
7,
26801,
11,
7621,
8,
796,
3991,
198,
10134,
62,
12985,
7,
26801,
8,
220,
220,
220,
220,
220,
796,
3991,
198,
198,
31,
9288,
1064,
62,
12985,
2004,
7,
49464,
38381,
25,
2554,
60,
6624,
269,
17602,
198,
198,
21017,
22819,
4559,
2653,
602,
198,
8818,
4112,
62,
1462,
62,
7890,
7,
87,
11,
331,
11,
6121,
11,
4326,
62,
3524,
11,
2560,
62,
3524,
8,
198,
220,
220,
220,
220,
742,
11,
331,
83,
796,
287,
1851,
62,
35636,
7,
35636,
11,
2124,
11,
331,
8,
198,
220,
220,
220,
357,
20850,
62,
3524,
13,
87,
15,
1343,
4326,
62,
3524,
13,
10394,
1635,
7,
742,
12,
8000,
62,
3524,
13,
87,
15,
58,
16,
12962,
14,
5308,
13846,
13,
10394,
7,
8000,
62,
3524,
828,
198,
220,
220,
220,
220,
4326,
62,
3524,
13,
88,
15,
1343,
4326,
62,
3524,
13,
17015,
9,
7,
20760,
12,
8000,
62,
3524,
13,
87,
15,
58,
17,
12962,
14,
5308,
13846,
13,
17015,
7,
8000,
62,
3524,
4008,
198,
437,
198,
198,
259,
1851,
62,
35636,
7,
3712,
7293,
577,
13,
7390,
26858,
41762,
11,
2124,
11,
331,
8,
796,
2124,
11,
331,
198,
198,
8818,
287,
1851,
62,
35636,
7,
83,
3712,
7293,
577,
13,
46912,
41762,
11,
2124,
11,
331,
8,
198,
220,
220,
220,
2488,
30493,
256,
13,
44,
58,
18,
11,
16,
60,
6624,
256,
13,
44,
58,
18,
11,
17,
60,
6624,
657,
198,
220,
220,
220,
2124,
20760,
796,
256,
13,
44,
59,
58,
87,
11,
331,
11,
352,
13,
15,
60,
198,
220,
220,
220,
2124,
20760,
58,
16,
4357,
2124,
20760,
58,
17,
60,
198,
437,
198,
198,
3524,
11,
4991,
11,
6121,
796,
307,
13,
1073,
3669,
58,
25,
2554,
60,
198,
24954,
11,
331,
67,
796,
4112,
62,
1462,
62,
7890,
7,
15,
13,
20,
3020,
11,
657,
13,
20,
3020,
11,
6121,
11,
4991,
11,
3091,
8,
198,
31,
9288,
318,
1324,
13907,
7,
24954,
11,
15,
13,
1415,
1558,
26,
379,
349,
28,
15,
13,
18005,
8,
198
] | 2.402778 | 936 |
<filename>src/ImageIO.jl
module ImageIO
using UUIDs
using FileIO: File, DataFormat, Stream, stream, Formatted
const idNetpbm = Base.PkgId(UUID("f09324ee-3d7c-5217-9330-fc30815ba969"), "Netpbm")
const idPNGFiles = Base.PkgId(UUID("f57f5aa1-a3ce-4bc8-8ab9-96f992907883"), "PNGFiles")
const idTiffImages = Base.PkgId(UUID("731e570b-9d59-4bfa-96dc-6df516fadf69"), "TiffImages")
# Enforce a type conversion to be backend independent (issue #25)
# Note: If the backend does not provide efficient `convert` implementation,
# there will be an extra memeory allocation and thus hurt the performance.
for FMT in (
:PBMBinary, :PGMBinary, :PPMBinary, :PBMText, :PGMText, :PPMText,
:TIFF,
:PNG,
)
@eval canonical_type(::DataFormat{$(Expr(:quote, FMT))}, ::AbstractArray{T, N}) where {T,N} =
Array{T,N}
end
@inline canonical_type(::Formatted{T}, data) where T = canonical_type(T(), data)
## PNGs
const load_locker = Threads.ReentrantLock()
function checked_import(pkgid)
Base.root_module_exists(pkgid) && return Base.root_module(pkgid)
# If not available, lock and load the library in a sequential order
lock(load_locker) do
Base.require(pkgid)
end
end
function load(f::File{DataFormat{:PNG}}; kwargs...)
data = Base.invokelatest(checked_import(idPNGFiles).load, f.filename, kwargs...)
return convert(canonical_type(f, data), data)
end
function load(s::Stream{DataFormat{:PNG}}; kwargs...)
data = Base.invokelatest(checked_import(idPNGFiles).load, stream(s), kwargs...)
return convert(canonical_type(s, data), data)
end
function save(f::File{DataFormat{:PNG}}, image::S; kwargs...) where {T, S<:Union{AbstractMatrix, AbstractArray{T,3}}}
return Base.invokelatest(checked_import(idPNGFiles).save, f.filename, image, kwargs...)
end
function save(s::Stream{DataFormat{:PNG}}, image::S; permute_horizontal=false, mapi=identity, kwargs...) where {T, S<:Union{AbstractMatrix, AbstractArray{T,3}}}
imgout = map(mapi, image)
if permute_horizontal
perm = ndims(imgout) == 2 ? (2, 1) : ndims(imgout) == 3 ? (2, 1, 3) : error("$(ndims(imgout)) dims array is not supported")
return Base.invokelatest(checked_import(idPNGFiles).save, stream(s), PermutedDimsArray(imgout, perm), kwargs...)
else
return Base.invokelatest(checked_import(idPNGFiles).save, stream(s), imgout, kwargs...)
end
end
# Netpbm types
for NETPBMFORMAT in (:PBMBinary, :PGMBinary, :PPMBinary, :PBMText, :PGMText, :PPMText)
@eval begin
function load(f::File{DataFormat{$(Expr(:quote,NETPBMFORMAT))}})
data = Base.invokelatest(checked_import(idNetpbm).load, f)
return convert(canonical_type(f, data), data)
end
function load(s::Stream{DataFormat{$(Expr(:quote,NETPBMFORMAT))}})
data = Base.invokelatest(checked_import(idNetpbm).load, s)
return convert(canonical_type(s, data), data)
end
function save(f::File{DataFormat{$(Expr(:quote,NETPBMFORMAT))}}, image::S; kwargs...) where {S<:AbstractMatrix}
return Base.invokelatest(checked_import(idNetpbm).save, f, image; kwargs...)
end
function save(s::Stream{DataFormat{$(Expr(:quote,NETPBMFORMAT))}}, image::S; kwargs...) where {S<:AbstractMatrix}
return Base.invokelatest(checked_import(idNetpbm).save, s, image; kwargs...)
end
end
end
## TIFFs
function load(f::File{DataFormat{:TIFF}}; kwargs...)
data = Base.invokelatest(checked_import(idTiffImages).load, f.filename, kwargs...)
return convert(canonical_type(f, data), data)
end
function load(s::Stream{DataFormat{:TIFF}}; kwargs...)
data = Base.invokelatest(checked_import(idTiffImages).load, stream(s), kwargs...)
return convert(canonical_type(s, data), data)
end
function save(f::File{DataFormat{:TIFF}}, image::S) where {T, S<:Union{AbstractMatrix, AbstractArray{T,3}}}
Base.invokelatest(checked_import(idTiffImages).save, f.filename, image)
end
function save(s::Stream{DataFormat{:TIFF}}, image::S; permute_horizontal=false, mapi=identity) where {T, S<:Union{AbstractMatrix, AbstractArray{T,3}}}
imgout = map(mapi, image)
if permute_horizontal
perm = ndims(imgout) == 2 ? (2, 1) : ndims(imgout) == 3 ? (2, 1, 3) : error("$(ndims(imgout)) dims array is not supported")
Base.invokelatest(checked_import(idTiffImages).save, stream(s), PermutedDimsArray(imgout, perm))
else
Base.invokelatest(checked_import(idTiffImages).save, stream(s), imgout)
end
end
## Function names labelled for FileIO. Makes FileIO lookup quicker
const fileio_save = save
const fileio_load = load
end # module
| [
27,
34345,
29,
10677,
14,
5159,
9399,
13,
20362,
198,
21412,
7412,
9399,
198,
198,
3500,
471,
27586,
82,
198,
3500,
9220,
9399,
25,
9220,
11,
6060,
26227,
11,
13860,
11,
4269,
11,
5178,
16898,
198,
198,
9979,
4686,
7934,
79,
20475,
796,
7308,
13,
47,
10025,
7390,
7,
52,
27586,
7203,
69,
2931,
33916,
1453,
12,
18,
67,
22,
66,
12,
4309,
1558,
12,
6052,
1270,
12,
16072,
21495,
1314,
7012,
38819,
12340,
366,
7934,
79,
20475,
4943,
198,
9979,
4686,
47,
10503,
25876,
796,
7308,
13,
47,
10025,
7390,
7,
52,
27586,
7203,
69,
3553,
69,
20,
7252,
16,
12,
64,
18,
344,
12,
19,
15630,
23,
12,
23,
397,
24,
12,
4846,
69,
2079,
1959,
2998,
49287,
12340,
366,
47,
10503,
25876,
4943,
198,
9979,
4686,
51,
733,
29398,
796,
7308,
13,
47,
10025,
7390,
7,
52,
27586,
7203,
22,
3132,
68,
39254,
65,
12,
24,
67,
3270,
12,
19,
65,
13331,
12,
4846,
17896,
12,
21,
7568,
47493,
69,
324,
69,
3388,
12340,
366,
51,
733,
29398,
4943,
198,
198,
2,
2039,
3174,
257,
2099,
11315,
284,
307,
30203,
4795,
357,
21949,
1303,
1495,
8,
198,
2,
5740,
25,
1002,
262,
30203,
857,
407,
2148,
6942,
4600,
1102,
1851,
63,
7822,
11,
198,
2,
220,
220,
220,
220,
220,
220,
612,
481,
307,
281,
3131,
25336,
652,
20157,
290,
4145,
5938,
262,
2854,
13,
198,
1640,
376,
13752,
287,
357,
198,
220,
220,
220,
1058,
49079,
10744,
3219,
11,
1058,
6968,
10744,
3219,
11,
1058,
47,
5868,
33,
3219,
11,
1058,
47,
12261,
8206,
11,
1058,
6968,
44,
8206,
11,
1058,
47,
5868,
8206,
11,
198,
220,
220,
220,
1058,
51,
29267,
11,
198,
220,
220,
220,
1058,
47,
10503,
11,
198,
8,
198,
220,
220,
220,
2488,
18206,
40091,
62,
4906,
7,
3712,
6601,
26227,
90,
3,
7,
3109,
1050,
7,
25,
22708,
11,
376,
13752,
4008,
5512,
7904,
23839,
19182,
90,
51,
11,
399,
30072,
810,
1391,
51,
11,
45,
92,
796,
198,
220,
220,
220,
220,
220,
220,
220,
15690,
90,
51,
11,
45,
92,
198,
437,
198,
31,
45145,
40091,
62,
4906,
7,
3712,
8479,
16898,
90,
51,
5512,
1366,
8,
810,
309,
796,
40091,
62,
4906,
7,
51,
22784,
1366,
8,
198,
198,
2235,
36182,
82,
198,
198,
9979,
3440,
62,
5354,
263,
796,
14122,
82,
13,
3041,
298,
5250,
25392,
3419,
198,
8818,
10667,
62,
11748,
7,
35339,
312,
8,
198,
220,
220,
220,
7308,
13,
15763,
62,
21412,
62,
1069,
1023,
7,
35339,
312,
8,
11405,
1441,
7308,
13,
15763,
62,
21412,
7,
35339,
312,
8,
198,
220,
220,
220,
1303,
1002,
407,
1695,
11,
5793,
290,
3440,
262,
5888,
287,
257,
35582,
1502,
198,
220,
220,
220,
5793,
7,
2220,
62,
5354,
263,
8,
466,
198,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
46115,
7,
35339,
312,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
3440,
7,
69,
3712,
8979,
90,
6601,
26227,
90,
25,
47,
10503,
11709,
26,
479,
86,
22046,
23029,
198,
220,
220,
220,
1366,
796,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
47,
10503,
25876,
737,
2220,
11,
277,
13,
34345,
11,
479,
86,
22046,
23029,
198,
220,
220,
220,
1441,
10385,
7,
49883,
605,
62,
4906,
7,
69,
11,
1366,
828,
1366,
8,
198,
437,
198,
8818,
3440,
7,
82,
3712,
12124,
90,
6601,
26227,
90,
25,
47,
10503,
11709,
26,
479,
86,
22046,
23029,
198,
220,
220,
220,
1366,
796,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
47,
10503,
25876,
737,
2220,
11,
4269,
7,
82,
828,
479,
86,
22046,
23029,
198,
220,
220,
220,
1441,
10385,
7,
49883,
605,
62,
4906,
7,
82,
11,
1366,
828,
1366,
8,
198,
437,
198,
198,
8818,
3613,
7,
69,
3712,
8979,
90,
6601,
26227,
90,
25,
47,
10503,
92,
5512,
2939,
3712,
50,
26,
479,
86,
22046,
23029,
810,
1391,
51,
11,
311,
27,
25,
38176,
90,
23839,
46912,
11,
27741,
19182,
90,
51,
11,
18,
42535,
198,
220,
220,
220,
1441,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
47,
10503,
25876,
737,
21928,
11,
277,
13,
34345,
11,
2939,
11,
479,
86,
22046,
23029,
198,
437,
198,
198,
8818,
3613,
7,
82,
3712,
12124,
90,
6601,
26227,
90,
25,
47,
10503,
92,
5512,
2939,
3712,
50,
26,
9943,
1133,
62,
17899,
38342,
28,
9562,
11,
3975,
72,
28,
738,
414,
11,
479,
86,
22046,
23029,
810,
1391,
51,
11,
311,
27,
25,
38176,
90,
23839,
46912,
11,
27741,
19182,
90,
51,
11,
18,
42535,
198,
220,
220,
220,
33705,
448,
796,
3975,
7,
8899,
72,
11,
2939,
8,
198,
220,
220,
220,
611,
9943,
1133,
62,
17899,
38342,
198,
220,
220,
220,
220,
220,
220,
220,
9943,
796,
299,
67,
12078,
7,
9600,
448,
8,
6624,
362,
5633,
357,
17,
11,
352,
8,
1058,
299,
67,
12078,
7,
9600,
448,
8,
6624,
513,
5633,
357,
17,
11,
352,
11,
513,
8,
1058,
4049,
7203,
3,
7,
358,
12078,
7,
9600,
448,
4008,
5391,
82,
7177,
318,
407,
4855,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
47,
10503,
25876,
737,
21928,
11,
4269,
7,
82,
828,
2448,
76,
7241,
35,
12078,
19182,
7,
9600,
448,
11,
9943,
828,
479,
86,
22046,
23029,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
47,
10503,
25876,
737,
21928,
11,
4269,
7,
82,
828,
33705,
448,
11,
479,
86,
22046,
23029,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2,
3433,
79,
20475,
3858,
198,
198,
1640,
30502,
47,
12261,
21389,
1404,
287,
357,
25,
49079,
10744,
3219,
11,
1058,
6968,
10744,
3219,
11,
1058,
47,
5868,
33,
3219,
11,
1058,
47,
12261,
8206,
11,
1058,
6968,
44,
8206,
11,
1058,
47,
5868,
8206,
8,
198,
220,
220,
220,
2488,
18206,
2221,
198,
220,
220,
220,
220,
220,
220,
220,
2163,
3440,
7,
69,
3712,
8979,
90,
6601,
26227,
90,
3,
7,
3109,
1050,
7,
25,
22708,
11,
12884,
47,
12261,
21389,
1404,
4008,
11709,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
7934,
79,
20475,
737,
2220,
11,
277,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10385,
7,
49883,
605,
62,
4906,
7,
69,
11,
1366,
828,
1366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
2163,
3440,
7,
82,
3712,
12124,
90,
6601,
26227,
90,
3,
7,
3109,
1050,
7,
25,
22708,
11,
12884,
47,
12261,
21389,
1404,
4008,
11709,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
7934,
79,
20475,
737,
2220,
11,
264,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
10385,
7,
49883,
605,
62,
4906,
7,
82,
11,
1366,
828,
1366,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
2163,
3613,
7,
69,
3712,
8979,
90,
6601,
26227,
90,
3,
7,
3109,
1050,
7,
25,
22708,
11,
12884,
47,
12261,
21389,
1404,
4008,
92,
5512,
2939,
3712,
50,
26,
479,
86,
22046,
23029,
810,
1391,
50,
27,
25,
23839,
46912,
92,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
7934,
79,
20475,
737,
21928,
11,
277,
11,
2939,
26,
479,
86,
22046,
23029,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
2163,
3613,
7,
82,
3712,
12124,
90,
6601,
26227,
90,
3,
7,
3109,
1050,
7,
25,
22708,
11,
12884,
47,
12261,
21389,
1404,
4008,
92,
5512,
2939,
3712,
50,
26,
479,
86,
22046,
23029,
810,
1391,
50,
27,
25,
23839,
46912,
92,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
7934,
79,
20475,
737,
21928,
11,
264,
11,
2939,
26,
479,
86,
22046,
23029,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2235,
309,
29267,
82,
198,
198,
8818,
3440,
7,
69,
3712,
8979,
90,
6601,
26227,
90,
25,
51,
29267,
11709,
26,
479,
86,
22046,
23029,
198,
220,
220,
220,
1366,
796,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
51,
733,
29398,
737,
2220,
11,
277,
13,
34345,
11,
479,
86,
22046,
23029,
198,
220,
220,
220,
1441,
10385,
7,
49883,
605,
62,
4906,
7,
69,
11,
1366,
828,
1366,
8,
198,
437,
198,
8818,
3440,
7,
82,
3712,
12124,
90,
6601,
26227,
90,
25,
51,
29267,
11709,
26,
479,
86,
22046,
23029,
198,
220,
220,
220,
1366,
796,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
51,
733,
29398,
737,
2220,
11,
4269,
7,
82,
828,
479,
86,
22046,
23029,
198,
220,
220,
220,
1441,
10385,
7,
49883,
605,
62,
4906,
7,
82,
11,
1366,
828,
1366,
8,
198,
437,
198,
198,
8818,
3613,
7,
69,
3712,
8979,
90,
6601,
26227,
90,
25,
51,
29267,
92,
5512,
2939,
3712,
50,
8,
810,
1391,
51,
11,
311,
27,
25,
38176,
90,
23839,
46912,
11,
27741,
19182,
90,
51,
11,
18,
42535,
198,
220,
220,
220,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
51,
733,
29398,
737,
21928,
11,
277,
13,
34345,
11,
2939,
8,
198,
437,
198,
198,
8818,
3613,
7,
82,
3712,
12124,
90,
6601,
26227,
90,
25,
51,
29267,
92,
5512,
2939,
3712,
50,
26,
9943,
1133,
62,
17899,
38342,
28,
9562,
11,
3975,
72,
28,
738,
414,
8,
810,
1391,
51,
11,
311,
27,
25,
38176,
90,
23839,
46912,
11,
27741,
19182,
90,
51,
11,
18,
42535,
198,
220,
220,
220,
33705,
448,
796,
3975,
7,
8899,
72,
11,
2939,
8,
198,
220,
220,
220,
611,
9943,
1133,
62,
17899,
38342,
198,
220,
220,
220,
220,
220,
220,
220,
9943,
796,
299,
67,
12078,
7,
9600,
448,
8,
6624,
362,
5633,
357,
17,
11,
352,
8,
1058,
299,
67,
12078,
7,
9600,
448,
8,
6624,
513,
5633,
357,
17,
11,
352,
11,
513,
8,
1058,
4049,
7203,
3,
7,
358,
12078,
7,
9600,
448,
4008,
5391,
82,
7177,
318,
407,
4855,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
51,
733,
29398,
737,
21928,
11,
4269,
7,
82,
828,
2448,
76,
7241,
35,
12078,
19182,
7,
9600,
448,
11,
9943,
4008,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
37669,
42861,
7,
26752,
62,
11748,
7,
312,
51,
733,
29398,
737,
21928,
11,
4269,
7,
82,
828,
33705,
448,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2235,
15553,
3891,
30538,
329,
9220,
9399,
13,
27433,
9220,
9399,
35847,
20061,
198,
9979,
2393,
952,
62,
21928,
796,
3613,
198,
9979,
2393,
952,
62,
2220,
796,
3440,
198,
198,
437,
1303,
8265,
198
] | 2.502415 | 1,863 |
<gh_stars>0
mutable struct childSupportIncome:>
nonfixedIncome
end | [
27,
456,
62,
30783,
29,
15,
198,
198,
76,
18187,
2878,
1200,
15514,
818,
2958,
25,
29,
198,
220,
220,
220,
1729,
34021,
818,
2958,
198,
437
] | 2.62963 | 27 |
"""
CenteredAxis(origin=0, indices)
A `CenteredAxis` takes `indices` and provides a user facing set of keys centered around zero.
The `CenteredAxis` is a subtype of `AbstractOffsetAxis` and its keys are treated as the predominant indexing style.
Note that the element type of a `CenteredAxis` cannot be unsigned because any instance with a length greater than 1 will begin at a negative value.
## Examples
A `CenteredAxis` sends all indexing arguments to the keys and only maps to the indices when `to_index` is called.
```jldoctest
julia> using AxisIndices
julia> axis = AxisIndices.CenteredAxis(1:10)
center(0)(SimpleAxis(1:10))
julia> axis[10] # the indexing goes straight to keys and is centered around zero
ERROR: BoundsError: attempt to access center(0)(SimpleAxis(1:10)) at index [10]
[...]
julia> axis[-4]
-4
```
"""
struct CenteredAxis{I,Inds,F} <: AbstractOffsetAxis{I,Inds,F}
origin::F
parent::Inds
function CenteredAxis{I,Inds,F}(origin::Integer, inds::AbstractAxis) where {I,Inds,F}
if inds isa Inds && origin isa F
return new{I,Inds,F}(origin, inds)
else
return CenteredAxis(origin, convert(Inds, inds))
end
end
function CenteredAxis{I,Inds,F}(inds::AbstractRange) where {I,Inds,F<:StaticInt}
return new{I,Inds,F}(F(), inds)
end
function CenteredAxis{I,Inds,F}(inds::AbstractRange) where {I,Inds,F}
return new{I,Inds,F}(F(0), inds)
end
function CenteredAxis{I,Inds,F}(origin::Integer, inds::AbstractRange) where {I,Inds,F}
return CenteredAxis{I,Inds}(origin, inds)
end
function CenteredAxis{I,Inds}(inds::AbstractRange) where {I,Inds}
return CenteredAxis{I,Inds}(Zero(), inds)
end
function CenteredAxis{I,Inds}(origin::Integer, inds::AbstractArray) where {I,Inds}
return CenteredAxis{I,Inds}(origin, compose_axis(inds))
end
function CenteredAxis{I,Inds}(origin::Integer, inds::AbstractAxis) where {I,Inds}
if inds isa Inds
return CenteredAxis{I,Inds,typeof(origin)}(origin, inds)
else
return CenteredAxis{I}(origin, convert(Inds, inds))
end
end
function CenteredAxis{I}(origin::Integer, inds::AbstractArray) where {I}
return CenteredAxis{I}(origin, compose_axis(inds))
end
function CenteredAxis{I}(origin::Integer, inds::AbstractOffsetAxis) where {I}
return CenteredAxis{I}(origin, parent(inds))
end
function CenteredAxis{I}(origin::Integer, inds::AbstractAxis) where {I}
if eltype(inds) <: I
return CenteredAxis{I,typeof(inds)}(origin, inds)
else
return CenteredAxis{I}(origin, convert(AbstractUnitRange{I}, inds))
end
end
CenteredAxis{I}(inds::AbstractRange) where {I} = CenteredAxis{I}(Zero(), inds)
CenteredAxis(inds::AbstractRange) = CenteredAxis(Zero(), inds)
function CenteredAxis(origin::Integer, inds::AbstractOffsetAxis)
return CenteredAxis(origin, parent(inds))
end
function CenteredAxis(origin::Integer, inds::AbstractArray)
return CenteredAxis(origin, compose_axis(inds))
end
function CenteredAxis(origin::Integer, inds::AbstractAxis)
return CenteredAxis{eltype(inds)}(origin, inds)
end
end
@inline Base.getproperty(axis::CenteredAxis, k::Symbol) = getproperty(parent(axis), k)
function ArrayInterface.unsafe_reconstruct(axis::CenteredAxis, inds; kwargs...)
return CenteredAxis(origin(axis), unsafe_reconstruct(parent(axis), inds; kwargs...))
end
ArrayInterface.known_first(::Type{T}) where {T<:CenteredAxis{<:Any,<:Any,<:Any}} = nothing
function ArrayInterface.known_first(::Type{T}) where {Inds,F,T<:CenteredAxis{<:Any,Inds,StaticInt{F}}}
if known_length(Inds) === nothing
return nothing
else
return F - div(known_length(Inds), 2)
end
end
Base.first(axis::CenteredAxis) = origin(axis) - div(length(parent(axis)), 2)
ArrayInterface.known_last(::Type{T}) where {T<:CenteredAxis{<:Any,<:Any,<:Any}} = nothing
function ArrayInterface.known_last(::Type{T}) where {Inds,F,T<:CenteredAxis{<:Any,Inds,StaticInt{F}}}
if known_length(Inds) === nothing
return nothing
else
return F - div(known_length(Inds), 2) + known_length(Inds)
end
end
Base.last(axis::CenteredAxis) = last(parent(axis)) + _origin_to_offset(axis)
function _origin_to_offset(axis::CenteredAxis)
p = parent(axis)
return _origin_to_offset(first(p), length(p), origin(axis))
end
_origin_to_offset(start, len, origin) = (origin - div(len, 2one(start))) - start
origin(axis::CenteredAxis) = getfield(axis, :origin)
@inline function ArrayInterface.offsets(axis::CenteredAxis)
inds = parent(axis)
return (_origin_to_offset(static_first(inds), static_length(inds), origin(axis)),)
end
"""
center(collection, origin)
center(collection, origin)
Shortcut for creating [`CenteredAxis`](@ref).
## Examples
```jldoctest
julia> using AxisIndices
julia> AxisArray(ones(3), center(0))
3-element AxisArray(::Vector{Float64}
• axes:
1 = -1:1
)
1
-1 1.0
0 1.0
1 1.0
```
"""
struct Center <: AxisInitializer end
const center = Center()
axis_method(::Center, x, inds) = CenteredAxis(x, inds)
center(collection::AbstractArray) = center(collection, Zero())
"""
CenteredArray(A::AbstractArray)
Provides centered axes for indexing `A`.
## Examples
```jldoctest
julia> using AxisIndices
julia> AxisIndices.CenteredArray(ones(3,3))
3×3 AxisArray(::Matrix{Float64}
• axes:
1 = -1:1
2 = -1:1
)
-1 0 1
-1 1.0 1.0 1.0
0 1.0 1.0 1.0
1 1.0 1.0 1.0
```
"""
const CenteredArray{T,N,P,A<:Tuple{Vararg{<:CenteredAxis}}} = AxisArray{T,N,P,A}
CenteredArray(A::AbstractArray{T,N}) where {T,N} = CenteredArray{T,N}(A)
CenteredArray(A::AbstractArray{T,0}) where {T} = AxisArray(A)
CenteredArray{T}(A::AbstractArray) where {T} = CenteredArray{T,ndims(A)}(A)
CenteredArray{T,N}(A::AbstractArray) where {T,N} = CenteredArray{T,N,typeof(A)}(A)
CenteredArray{T,N,P}(A::CenteredArray{T,N,P}) where {T,N,P} = A
function CenteredArray{T,N,P}(A::CenteredArray) where {T,N,P}
return CenteredArray{T,N,P}(parent(A))
end
function CenteredArray{T,N,P}(A::AbstractArray) where {T,N,P<:AbstractArray{T,N}}
return CenteredArray{T,N,P}(convert(P, A))
end
function CenteredArray{T,N,P}(A::P) where {T,N,P<:AbstractArray{T,N}}
axs = map(center, axes(A))
return CenteredArray{T,N,P,typeof(axs)}(A, axs)
end
function CenteredArray{T}(init::ArrayInitializer, sz::Tuple=()) where {T}
return CenteredArray{T,length(inds)}(init, sz)
end
function CenteredArray{T,N}(init::ArrayInitializer, sz::Tuple=()) where {T,N}
return CenteredArray{T,N}(Array{T,N}(init, sz))
end
"""
CenteredVector(v::AbstractVector)
Provides a centered axis for indexing `v`.
## Examples
```jldoctest
julia> using AxisIndices
julia> AxisIndices.CenteredVector(ones(3))
3-element AxisArray(::Vector{Float64}
• axes:
1 = -1:1
)
1
-1 1.0
0 1.0
1 1.0
```
"""
const CenteredVector{T,P<:AbstractVector{T},Ax1<:CenteredAxis} = CenteredArray{T,1,P,Tuple{Ax1}}
CenteredVector(A::AbstractVector) = CenteredArray{eltype(A)}(A)
CenteredVector{T}(A::AbstractVector) where {T} = CenteredArray{T,1}(A)
"""
CenteredVector{T}(init::ArrayInitializer, sz::Integer)
Creates a vector with elements of type `T` of size `sz` and a centered axis.
## Examples
```jldoctest
julia> using AxisIndices
julia> AxisIndices.CenteredVector{Union{Missing, Int}}(missing, 3)
3-element AxisArray(::Vector{Union{Missing, Int64}}
• axes:
1 = -1:1
)
1
-1 missing
0 missing
1 missing
```
"""
function CenteredVector{T}(init::ArrayInitializer, arg) where {T}
return CenteredVector{T}(Vector{T}(init, arg))
end
function print_axis(io::IO, axis::CenteredAxis)
print(io, "center($(Int(origin(axis))))($(parent(axis)))")
end
| [
198,
37811,
198,
220,
220,
220,
1979,
1068,
31554,
271,
7,
47103,
28,
15,
11,
36525,
8,
198,
198,
32,
4600,
19085,
1068,
31554,
271,
63,
2753,
4600,
521,
1063,
63,
290,
3769,
257,
2836,
6476,
900,
286,
8251,
19254,
1088,
6632,
13,
198,
464,
4600,
19085,
1068,
31554,
271,
63,
318,
257,
850,
4906,
286,
4600,
23839,
34519,
31554,
271,
63,
290,
663,
8251,
389,
5716,
355,
262,
45718,
6376,
278,
3918,
13,
198,
6425,
326,
262,
5002,
2099,
286,
257,
4600,
19085,
1068,
31554,
271,
63,
2314,
307,
22165,
780,
597,
4554,
351,
257,
4129,
3744,
621,
352,
481,
2221,
379,
257,
4633,
1988,
13,
198,
198,
2235,
21066,
198,
198,
32,
4600,
19085,
1068,
31554,
271,
63,
12800,
477,
6376,
278,
7159,
284,
262,
8251,
290,
691,
8739,
284,
262,
36525,
618,
4600,
1462,
62,
9630,
63,
318,
1444,
13,
198,
15506,
63,
73,
335,
38441,
395,
198,
73,
43640,
29,
1262,
38349,
5497,
1063,
198,
198,
73,
43640,
29,
16488,
796,
38349,
5497,
1063,
13,
19085,
1068,
31554,
271,
7,
16,
25,
940,
8,
198,
16159,
7,
15,
5769,
26437,
31554,
271,
7,
16,
25,
940,
4008,
198,
198,
73,
43640,
29,
16488,
58,
940,
60,
220,
1303,
262,
6376,
278,
2925,
3892,
284,
8251,
290,
318,
19254,
1088,
6632,
198,
24908,
25,
347,
3733,
12331,
25,
2230,
284,
1895,
3641,
7,
15,
5769,
26437,
31554,
271,
7,
16,
25,
940,
4008,
379,
6376,
685,
940,
60,
198,
58,
22345,
198,
198,
73,
43640,
29,
16488,
58,
12,
19,
60,
198,
12,
19,
198,
198,
15506,
63,
198,
37811,
198,
7249,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
11,
37,
92,
1279,
25,
27741,
34519,
31554,
271,
90,
40,
11,
5497,
82,
11,
37,
92,
198,
220,
220,
220,
8159,
3712,
37,
198,
220,
220,
220,
2560,
3712,
5497,
82,
628,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
11,
37,
92,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
31554,
271,
8,
810,
1391,
40,
11,
5497,
82,
11,
37,
92,
198,
220,
220,
220,
220,
220,
220,
220,
611,
773,
82,
318,
64,
1423,
82,
11405,
8159,
318,
64,
376,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
649,
90,
40,
11,
5497,
82,
11,
37,
92,
7,
47103,
11,
773,
82,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
7,
47103,
11,
10385,
7,
5497,
82,
11,
773,
82,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
11,
37,
92,
7,
521,
82,
3712,
23839,
17257,
8,
810,
1391,
40,
11,
5497,
82,
11,
37,
27,
25,
45442,
5317,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
649,
90,
40,
11,
5497,
82,
11,
37,
92,
7,
37,
22784,
773,
82,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
11,
37,
92,
7,
521,
82,
3712,
23839,
17257,
8,
810,
1391,
40,
11,
5497,
82,
11,
37,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
649,
90,
40,
11,
5497,
82,
11,
37,
92,
7,
37,
7,
15,
828,
773,
82,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
11,
37,
92,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
17257,
8,
810,
1391,
40,
11,
5497,
82,
11,
37,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
92,
7,
47103,
11,
773,
82,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
92,
7,
521,
82,
3712,
23839,
17257,
8,
810,
1391,
40,
11,
5497,
82,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
92,
7,
28667,
22784,
773,
82,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
92,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
19182,
8,
810,
1391,
40,
11,
5497,
82,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
92,
7,
47103,
11,
36664,
62,
22704,
7,
521,
82,
4008,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
92,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
31554,
271,
8,
810,
1391,
40,
11,
5497,
82,
92,
198,
220,
220,
220,
220,
220,
220,
220,
611,
773,
82,
318,
64,
1423,
82,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
11,
5497,
82,
11,
4906,
1659,
7,
47103,
38165,
7,
47103,
11,
773,
82,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
92,
7,
47103,
11,
10385,
7,
5497,
82,
11,
773,
82,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
92,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
19182,
8,
810,
1391,
40,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
92,
7,
47103,
11,
36664,
62,
22704,
7,
521,
82,
4008,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
92,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
34519,
31554,
271,
8,
810,
1391,
40,
92,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
92,
7,
47103,
11,
2560,
7,
521,
82,
4008,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
90,
40,
92,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
31554,
271,
8,
810,
1391,
40,
92,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1288,
4906,
7,
521,
82,
8,
1279,
25,
314,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
11,
4906,
1659,
7,
521,
82,
38165,
7,
47103,
11,
773,
82,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
40,
92,
7,
47103,
11,
10385,
7,
23839,
26453,
17257,
90,
40,
5512,
773,
82,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1979,
1068,
31554,
271,
90,
40,
92,
7,
521,
82,
3712,
23839,
17257,
8,
810,
1391,
40,
92,
796,
1979,
1068,
31554,
271,
90,
40,
92,
7,
28667,
22784,
773,
82,
8,
628,
220,
220,
220,
1979,
1068,
31554,
271,
7,
521,
82,
3712,
23839,
17257,
8,
796,
1979,
1068,
31554,
271,
7,
28667,
22784,
773,
82,
8,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
34519,
31554,
271,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
7,
47103,
11,
2560,
7,
521,
82,
4008,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
19182,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
7,
47103,
11,
36664,
62,
22704,
7,
521,
82,
4008,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2163,
1979,
1068,
31554,
271,
7,
47103,
3712,
46541,
11,
773,
82,
3712,
23839,
31554,
271,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
90,
417,
4906,
7,
521,
82,
38165,
7,
47103,
11,
773,
82,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
31,
45145,
7308,
13,
1136,
26745,
7,
22704,
3712,
19085,
1068,
31554,
271,
11,
479,
3712,
13940,
23650,
8,
796,
651,
26745,
7,
8000,
7,
22704,
828,
479,
8,
198,
198,
8818,
15690,
39317,
13,
13271,
8635,
62,
260,
41571,
7,
22704,
3712,
19085,
1068,
31554,
271,
11,
773,
82,
26,
479,
86,
22046,
23029,
198,
220,
220,
220,
1441,
1979,
1068,
31554,
271,
7,
47103,
7,
22704,
828,
21596,
62,
260,
41571,
7,
8000,
7,
22704,
828,
773,
82,
26,
479,
86,
22046,
986,
4008,
198,
437,
198,
198,
19182,
39317,
13,
4002,
62,
11085,
7,
3712,
6030,
90,
51,
30072,
810,
1391,
51,
27,
25,
19085,
1068,
31554,
271,
90,
27,
25,
7149,
11,
27,
25,
7149,
11,
27,
25,
7149,
11709,
796,
2147,
198,
8818,
15690,
39317,
13,
4002,
62,
11085,
7,
3712,
6030,
90,
51,
30072,
810,
1391,
5497,
82,
11,
37,
11,
51,
27,
25,
19085,
1068,
31554,
271,
90,
27,
25,
7149,
11,
5497,
82,
11,
45442,
5317,
90,
37,
42535,
198,
220,
220,
220,
611,
1900,
62,
13664,
7,
5497,
82,
8,
24844,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
376,
532,
2659,
7,
4002,
62,
13664,
7,
5497,
82,
828,
362,
8,
198,
220,
220,
220,
886,
198,
437,
198,
14881,
13,
11085,
7,
22704,
3712,
19085,
1068,
31554,
271,
8,
796,
8159,
7,
22704,
8,
532,
2659,
7,
13664,
7,
8000,
7,
22704,
36911,
362,
8,
198,
198,
19182,
39317,
13,
4002,
62,
12957,
7,
3712,
6030,
90,
51,
30072,
810,
1391,
51,
27,
25,
19085,
1068,
31554,
271,
90,
27,
25,
7149,
11,
27,
25,
7149,
11,
27,
25,
7149,
11709,
796,
2147,
198,
8818,
15690,
39317,
13,
4002,
62,
12957,
7,
3712,
6030,
90,
51,
30072,
810,
1391,
5497,
82,
11,
37,
11,
51,
27,
25,
19085,
1068,
31554,
271,
90,
27,
25,
7149,
11,
5497,
82,
11,
45442,
5317,
90,
37,
42535,
198,
220,
220,
220,
611,
1900,
62,
13664,
7,
5497,
82,
8,
24844,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
376,
532,
2659,
7,
4002,
62,
13664,
7,
5497,
82,
828,
362,
8,
1343,
1900,
62,
13664,
7,
5497,
82,
8,
198,
220,
220,
220,
886,
198,
437,
198,
14881,
13,
12957,
7,
22704,
3712,
19085,
1068,
31554,
271,
8,
796,
938,
7,
8000,
7,
22704,
4008,
1343,
4808,
47103,
62,
1462,
62,
28968,
7,
22704,
8,
198,
198,
8818,
4808,
47103,
62,
1462,
62,
28968,
7,
22704,
3712,
19085,
1068,
31554,
271,
8,
198,
220,
220,
220,
279,
796,
2560,
7,
22704,
8,
198,
220,
220,
220,
1441,
4808,
47103,
62,
1462,
62,
28968,
7,
11085,
7,
79,
828,
4129,
7,
79,
828,
8159,
7,
22704,
4008,
198,
437,
198,
62,
47103,
62,
1462,
62,
28968,
7,
9688,
11,
18896,
11,
8159,
8,
796,
357,
47103,
532,
2659,
7,
11925,
11,
362,
505,
7,
9688,
22305,
532,
923,
198,
198,
47103,
7,
22704,
3712,
19085,
1068,
31554,
271,
8,
796,
651,
3245,
7,
22704,
11,
1058,
47103,
8,
198,
31,
45145,
2163,
15690,
39317,
13,
8210,
1039,
7,
22704,
3712,
19085,
1068,
31554,
271,
8,
198,
220,
220,
220,
773,
82,
796,
2560,
7,
22704,
8,
198,
220,
220,
220,
1441,
44104,
47103,
62,
1462,
62,
28968,
7,
12708,
62,
11085,
7,
521,
82,
828,
9037,
62,
13664,
7,
521,
82,
828,
8159,
7,
22704,
36911,
8,
198,
437,
628,
198,
37811,
198,
220,
220,
220,
3641,
7,
43681,
11,
8159,
8,
198,
220,
220,
220,
3641,
7,
43681,
11,
8159,
8,
198,
198,
16438,
8968,
329,
4441,
685,
63,
19085,
1068,
31554,
271,
63,
16151,
31,
5420,
737,
198,
198,
2235,
21066,
198,
15506,
63,
73,
335,
38441,
395,
198,
73,
43640,
29,
1262,
38349,
5497,
1063,
198,
198,
73,
43640,
29,
38349,
19182,
7,
1952,
7,
18,
828,
3641,
7,
15,
4008,
198,
18,
12,
30854,
38349,
19182,
7,
3712,
38469,
90,
43879,
2414,
92,
198,
220,
5595,
34197,
25,
198,
220,
220,
220,
220,
352,
796,
532,
16,
25,
16,
198,
8,
198,
220,
220,
220,
220,
220,
352,
198,
220,
532,
16,
220,
352,
13,
15,
198,
220,
657,
220,
220,
352,
13,
15,
198,
220,
352,
220,
220,
352,
13,
15,
198,
198,
15506,
63,
198,
37811,
198,
7249,
3337,
1279,
25,
38349,
24243,
7509,
886,
198,
9979,
3641,
796,
3337,
3419,
198,
22704,
62,
24396,
7,
3712,
23656,
11,
2124,
11,
773,
82,
8,
796,
1979,
1068,
31554,
271,
7,
87,
11,
773,
82,
8,
198,
16159,
7,
43681,
3712,
23839,
19182,
8,
796,
3641,
7,
43681,
11,
12169,
28955,
198,
198,
37811,
198,
220,
220,
220,
1979,
1068,
19182,
7,
32,
3712,
23839,
19182,
8,
198,
198,
15946,
1460,
19254,
34197,
329,
6376,
278,
4600,
32,
44646,
198,
198,
2235,
21066,
198,
15506,
63,
73,
335,
38441,
395,
198,
73,
43640,
29,
1262,
38349,
5497,
1063,
198,
198,
73,
43640,
29,
38349,
5497,
1063,
13,
19085,
1068,
19182,
7,
1952,
7,
18,
11,
18,
4008,
198,
18,
12906,
18,
38349,
19182,
7,
3712,
46912,
90,
43879,
2414,
92,
198,
220,
5595,
34197,
25,
198,
220,
220,
220,
220,
352,
796,
532,
16,
25,
16,
198,
220,
220,
220,
220,
362,
796,
532,
16,
25,
16,
198,
8,
198,
220,
220,
220,
220,
220,
532,
16,
220,
220,
220,
657,
220,
220,
220,
352,
198,
220,
532,
16,
220,
220,
352,
13,
15,
220,
352,
13,
15,
220,
352,
13,
15,
198,
220,
657,
220,
220,
220,
352,
13,
15,
220,
352,
13,
15,
220,
352,
13,
15,
198,
220,
352,
220,
220,
220,
352,
13,
15,
220,
352,
13,
15,
220,
352,
13,
15,
198,
198,
15506,
63,
198,
37811,
198,
9979,
1979,
1068,
19182,
90,
51,
11,
45,
11,
47,
11,
32,
27,
25,
51,
29291,
90,
19852,
853,
90,
27,
25,
19085,
1068,
31554,
271,
42535,
796,
38349,
19182,
90,
51,
11,
45,
11,
47,
11,
32,
92,
198,
198,
19085,
1068,
19182,
7,
32,
3712,
23839,
19182,
90,
51,
11,
45,
30072,
810,
1391,
51,
11,
45,
92,
796,
1979,
1068,
19182,
90,
51,
11,
45,
92,
7,
32,
8,
198,
198,
19085,
1068,
19182,
7,
32,
3712,
23839,
19182,
90,
51,
11,
15,
30072,
810,
1391,
51,
92,
796,
38349,
19182,
7,
32,
8,
628,
198,
19085,
1068,
19182,
90,
51,
92,
7,
32,
3712,
23839,
19182,
8,
810,
1391,
51,
92,
796,
1979,
1068,
19182,
90,
51,
11,
358,
12078,
7,
32,
38165,
7,
32,
8,
198,
198,
19085,
1068,
19182,
90,
51,
11,
45,
92,
7,
32,
3712,
23839,
19182,
8,
810,
1391,
51,
11,
45,
92,
796,
1979,
1068,
19182,
90,
51,
11,
45,
11,
4906,
1659,
7,
32,
38165,
7,
32,
8,
198,
198,
19085,
1068,
19182,
90,
51,
11,
45,
11,
47,
92,
7,
32,
3712,
19085,
1068,
19182,
90,
51,
11,
45,
11,
47,
30072,
810,
1391,
51,
11,
45,
11,
47,
92,
796,
317,
198,
8818,
1979,
1068,
19182,
90,
51,
11,
45,
11,
47,
92,
7,
32,
3712,
19085,
1068,
19182,
8,
810,
1391,
51,
11,
45,
11,
47,
92,
198,
220,
220,
220,
1441,
1979,
1068,
19182,
90,
51,
11,
45,
11,
47,
92,
7,
8000,
7,
32,
4008,
198,
437,
628,
198,
8818,
1979,
1068,
19182,
90,
51,
11,
45,
11,
47,
92,
7,
32,
3712,
23839,
19182,
8,
810,
1391,
51,
11,
45,
11,
47,
27,
25,
23839,
19182,
90,
51,
11,
45,
11709,
198,
220,
220,
220,
1441,
1979,
1068,
19182,
90,
51,
11,
45,
11,
47,
92,
7,
1102,
1851,
7,
47,
11,
317,
4008,
198,
437,
198,
198,
8818,
1979,
1068,
19182,
90,
51,
11,
45,
11,
47,
92,
7,
32,
3712,
47,
8,
810,
1391,
51,
11,
45,
11,
47,
27,
25,
23839,
19182,
90,
51,
11,
45,
11709,
198,
220,
220,
220,
7877,
82,
796,
3975,
7,
16159,
11,
34197,
7,
32,
4008,
198,
220,
220,
220,
1441,
1979,
1068,
19182,
90,
51,
11,
45,
11,
47,
11,
4906,
1659,
7,
897,
82,
38165,
7,
32,
11,
7877,
82,
8,
198,
437,
198,
198,
8818,
1979,
1068,
19182,
90,
51,
92,
7,
15003,
3712,
19182,
24243,
7509,
11,
264,
89,
3712,
51,
29291,
28,
28955,
810,
1391,
51,
92,
198,
220,
220,
220,
1441,
1979,
1068,
19182,
90,
51,
11,
13664,
7,
521,
82,
38165,
7,
15003,
11,
264,
89,
8,
198,
437,
198,
198,
8818,
1979,
1068,
19182,
90,
51,
11,
45,
92,
7,
15003,
3712,
19182,
24243,
7509,
11,
264,
89,
3712,
51,
29291,
28,
28955,
810,
1391,
51,
11,
45,
92,
198,
220,
220,
220,
1441,
1979,
1068,
19182,
90,
51,
11,
45,
92,
7,
19182,
90,
51,
11,
45,
92,
7,
15003,
11,
264,
89,
4008,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
1979,
1068,
38469,
7,
85,
3712,
23839,
38469,
8,
198,
198,
15946,
1460,
257,
19254,
16488,
329,
6376,
278,
4600,
85,
44646,
198,
198,
2235,
21066,
198,
15506,
63,
73,
335,
38441,
395,
198,
73,
43640,
29,
1262,
38349,
5497,
1063,
198,
198,
73,
43640,
29,
38349,
5497,
1063,
13,
19085,
1068,
38469,
7,
1952,
7,
18,
4008,
198,
18,
12,
30854,
38349,
19182,
7,
3712,
38469,
90,
43879,
2414,
92,
198,
220,
5595,
34197,
25,
198,
220,
220,
220,
220,
352,
796,
532,
16,
25,
16,
198,
8,
198,
220,
220,
220,
220,
220,
352,
198,
220,
532,
16,
220,
352,
13,
15,
198,
220,
657,
220,
220,
352,
13,
15,
198,
220,
352,
220,
220,
352,
13,
15,
198,
198,
15506,
63,
198,
37811,
198,
9979,
1979,
1068,
38469,
90,
51,
11,
47,
27,
25,
23839,
38469,
90,
51,
5512,
31554,
16,
27,
25,
19085,
1068,
31554,
271,
92,
796,
1979,
1068,
19182,
90,
51,
11,
16,
11,
47,
11,
51,
29291,
90,
31554,
16,
11709,
198,
198,
19085,
1068,
38469,
7,
32,
3712,
23839,
38469,
8,
796,
1979,
1068,
19182,
90,
417,
4906,
7,
32,
38165,
7,
32,
8,
198,
19085,
1068,
38469,
90,
51,
92,
7,
32,
3712,
23839,
38469,
8,
810,
1391,
51,
92,
796,
1979,
1068,
19182,
90,
51,
11,
16,
92,
7,
32,
8,
198,
198,
37811,
198,
220,
220,
220,
1979,
1068,
38469,
90,
51,
92,
7,
15003,
3712,
19182,
24243,
7509,
11,
264,
89,
3712,
46541,
8,
198,
198,
16719,
274,
257,
15879,
351,
4847,
286,
2099,
4600,
51,
63,
286,
2546,
4600,
82,
89,
63,
290,
257,
19254,
16488,
13,
198,
198,
2235,
21066,
198,
15506,
63,
73,
335,
38441,
395,
198,
73,
43640,
29,
1262,
38349,
5497,
1063,
198,
198,
73,
43640,
29,
38349,
5497,
1063,
13,
19085,
1068,
38469,
90,
38176,
90,
43730,
11,
2558,
11709,
7,
45688,
11,
513,
8,
198,
18,
12,
30854,
38349,
19182,
7,
3712,
38469,
90,
38176,
90,
43730,
11,
2558,
2414,
11709,
198,
220,
5595,
34197,
25,
198,
220,
220,
220,
220,
352,
796,
532,
16,
25,
16,
198,
8,
198,
220,
220,
220,
220,
220,
352,
198,
220,
532,
16,
220,
220,
4814,
198,
220,
657,
220,
220,
220,
4814,
198,
220,
352,
220,
220,
220,
4814,
198,
198,
15506,
63,
198,
37811,
198,
8818,
1979,
1068,
38469,
90,
51,
92,
7,
15003,
3712,
19182,
24243,
7509,
11,
1822,
8,
810,
1391,
51,
92,
198,
220,
220,
220,
1441,
1979,
1068,
38469,
90,
51,
92,
7,
38469,
90,
51,
92,
7,
15003,
11,
1822,
4008,
198,
437,
198,
198,
8818,
3601,
62,
22704,
7,
952,
3712,
9399,
11,
16488,
3712,
19085,
1068,
31554,
271,
8,
198,
220,
220,
220,
3601,
7,
952,
11,
366,
16159,
16763,
7,
5317,
7,
47103,
7,
22704,
35514,
16763,
7,
8000,
7,
22704,
22305,
4943,
198,
437,
628
] | 2.388001 | 3,317 |
<reponame>racinmat/Mill.jl<filename>test/lazynode.jl
using Mill, Flux, Test, LearnBase
using Mill: LazyNode
@testset "LazyNode" begin
ss = ["Hello world.", "Make peace.", "Make food.", "Eat penam."]
function Mill.unpack2mill(ds::LazyNode{:Sentence})
s = ds.data
ss = map(x -> split(x, " "),s)
x = NGramMatrix(reduce(vcat, ss), 3, 256, 2053)
BagNode(ArrayNode(x), Mill.length2bags(length.(ss)))
end
@test LazyNode{:Sentence,Vector{String}}(ss).data == ss
@test LazyNode(:Sentence, ss).data == ss
@test LazyNode{:Sentence}(ss).data == ss
@test nobs(LazyNode{:Sentence}(ss)) == 4
@test (LazyNode{:Sentence}(ss))[[1,3]].data == ss[[1,3]]
@test (LazyNode{:Sentence}(ss))[2].data == [ss[2]]
@test reduce(catobs, [LazyNode{:Sentence}(ss)[i] for i in [1:2,3:4]]).data == ss
@test reduce(catobs, [LazyNode{:Sentence}(ss)[i] for i in [1,2,3,4]]).data == ss
ds = LazyNode{:Sentence}(ss)
m = Mill.reflectinmodel(ds, d -> Dense(d,2), s -> SegmentedMeanMax(s))
@test m(ds).data ≈ m.m(Mill.unpack2mill(ds)).data
end
| [
27,
7856,
261,
480,
29,
11510,
259,
6759,
14,
22603,
13,
20362,
27,
34345,
29,
9288,
14,
75,
1031,
2047,
1098,
13,
20362,
198,
3500,
9212,
11,
1610,
2821,
11,
6208,
11,
14365,
14881,
198,
3500,
9212,
25,
406,
12582,
19667,
198,
198,
31,
9288,
2617,
366,
43,
12582,
19667,
1,
2221,
198,
197,
824,
796,
14631,
15496,
995,
33283,
366,
12050,
4167,
33283,
366,
12050,
2057,
33283,
366,
47659,
3112,
321,
526,
60,
628,
197,
8818,
9212,
13,
403,
8002,
17,
17805,
7,
9310,
3712,
43,
12582,
19667,
90,
25,
31837,
594,
30072,
198,
197,
197,
82,
796,
288,
82,
13,
7890,
198,
197,
197,
824,
796,
3975,
7,
87,
4613,
6626,
7,
87,
11,
366,
366,
828,
82,
8,
198,
197,
197,
87,
796,
39058,
859,
46912,
7,
445,
7234,
7,
85,
9246,
11,
37786,
828,
513,
11,
17759,
11,
1160,
4310,
8,
198,
197,
197,
33,
363,
19667,
7,
19182,
19667,
7,
87,
828,
9212,
13,
13664,
17,
34005,
7,
13664,
12195,
824,
22305,
198,
197,
437,
628,
197,
31,
9288,
406,
12582,
19667,
90,
25,
31837,
594,
11,
38469,
90,
10100,
11709,
7,
824,
737,
7890,
6624,
37786,
198,
197,
31,
9288,
406,
12582,
19667,
7,
25,
31837,
594,
11,
37786,
737,
7890,
6624,
37786,
198,
197,
31,
9288,
406,
12582,
19667,
90,
25,
31837,
594,
92,
7,
824,
737,
7890,
6624,
37786,
198,
197,
31,
9288,
645,
1443,
7,
43,
12582,
19667,
90,
25,
31837,
594,
92,
7,
824,
4008,
6624,
604,
198,
197,
31,
9288,
357,
43,
12582,
19667,
90,
25,
31837,
594,
92,
7,
824,
4008,
30109,
16,
11,
18,
60,
4083,
7890,
6624,
37786,
30109,
16,
11,
18,
11907,
198,
197,
31,
9288,
357,
43,
12582,
19667,
90,
25,
31837,
594,
92,
7,
824,
4008,
58,
17,
4083,
7890,
6624,
685,
824,
58,
17,
11907,
198,
197,
31,
9288,
4646,
7,
9246,
8158,
11,
685,
43,
12582,
19667,
90,
25,
31837,
594,
92,
7,
824,
38381,
72,
60,
329,
1312,
287,
685,
16,
25,
17,
11,
18,
25,
19,
11907,
737,
7890,
6624,
37786,
198,
197,
31,
9288,
4646,
7,
9246,
8158,
11,
685,
43,
12582,
19667,
90,
25,
31837,
594,
92,
7,
824,
38381,
72,
60,
329,
1312,
287,
685,
16,
11,
17,
11,
18,
11,
19,
11907,
737,
7890,
6624,
37786,
628,
197,
9310,
796,
406,
12582,
19667,
90,
25,
31837,
594,
92,
7,
824,
8,
198,
197,
76,
796,
9212,
13,
35051,
259,
19849,
7,
9310,
11,
288,
4613,
360,
1072,
7,
67,
11,
17,
828,
264,
4613,
1001,
5154,
276,
5308,
272,
11518,
7,
82,
4008,
198,
197,
31,
9288,
285,
7,
9310,
737,
7890,
15139,
230,
285,
13,
76,
7,
22603,
13,
403,
8002,
17,
17805,
7,
9310,
29720,
7890,
198,
437,
198
] | 2.252193 | 456 |
<reponame>noob-data-analaysis/LeetCode.jl<gh_stars>0
# ---
# title: 461. Hamming Distance
# id: problem461
# author: <NAME>
# date: 2020-10-31
# difficulty: Easy
# categories: Bit Manipulation
# link: <https://leetcode.com/problems/hamming-distance/description/>
# hidden: true
# ---
#
# The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between
# two integers is the number of positions at which the corresponding bits are
# different.
#
# Given two integers `x` and `y`, calculate the Hamming distance.
#
# **Note:**
# 0 ≤ `x`, `y` < 231.
#
# **Example:**
#
#
#
# Input: x = 1, y = 4
#
# Output: 2
#
# Explanation:
# 1 (0 0 0 1)
# 4 (0 1 0 0)
# ↑ ↑
#
# The above arrows point to positions where the corresponding bits are different.
#
#
#
## @lc code=start
using LeetCode
## add your code here:
## @lc code=end
| [
27,
7856,
261,
480,
29,
3919,
672,
12,
7890,
12,
272,
282,
592,
271,
14,
3123,
316,
10669,
13,
20362,
27,
456,
62,
30783,
29,
15,
198,
2,
11420,
198,
2,
3670,
25,
604,
5333,
13,
4345,
2229,
34600,
198,
2,
4686,
25,
1917,
40652,
198,
2,
1772,
25,
1279,
20608,
29,
198,
2,
3128,
25,
12131,
12,
940,
12,
3132,
198,
2,
8722,
25,
16789,
198,
2,
9376,
25,
4722,
35045,
1741,
198,
2,
2792,
25,
1279,
5450,
1378,
293,
316,
8189,
13,
785,
14,
1676,
22143,
14,
2763,
2229,
12,
30246,
14,
11213,
15913,
198,
2,
7104,
25,
2081,
198,
2,
11420,
198,
2,
220,
198,
2,
383,
685,
21281,
2229,
5253,
16151,
5450,
1378,
268,
13,
31266,
13,
2398,
14,
15466,
14,
21281,
2229,
62,
30246,
8,
1022,
198,
2,
734,
37014,
318,
262,
1271,
286,
6116,
379,
543,
262,
11188,
10340,
389,
198,
2,
1180,
13,
198,
2,
220,
198,
2,
11259,
734,
37014,
4600,
87,
63,
290,
4600,
88,
47671,
15284,
262,
4345,
2229,
5253,
13,
198,
2,
220,
198,
2,
12429,
6425,
25,
1174,
220,
220,
198,
2,
657,
41305,
4600,
87,
47671,
4600,
88,
63,
1279,
34598,
13,
198,
2,
220,
198,
2,
12429,
16281,
25,
1174,
198,
2,
220,
198,
2,
220,
220,
220,
220,
220,
198,
2,
220,
220,
220,
220,
220,
198,
2,
220,
220,
220,
220,
23412,
25,
2124,
796,
352,
11,
331,
796,
604,
198,
2,
220,
220,
220,
220,
220,
198,
2,
220,
220,
220,
220,
25235,
25,
362,
198,
2,
220,
220,
220,
220,
220,
198,
2,
220,
220,
220,
220,
50125,
341,
25,
198,
2,
220,
220,
220,
220,
352,
220,
220,
357,
15,
657,
657,
352,
8,
198,
2,
220,
220,
220,
220,
604,
220,
220,
357,
15,
352,
657,
657,
8,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
24935,
220,
220,
24935,
198,
2,
220,
220,
220,
220,
220,
198,
2,
220,
220,
220,
220,
383,
2029,
20507,
966,
284,
6116,
810,
262,
11188,
10340,
389,
1180,
13,
198,
2,
220,
220,
220,
220,
220,
198,
2,
220,
198,
2,
220,
198,
2235,
2488,
44601,
2438,
28,
9688,
198,
3500,
1004,
316,
10669,
198,
198,
2235,
751,
534,
2438,
994,
25,
198,
2235,
2488,
44601,
2438,
28,
437,
198
] | 2.395288 | 382 |
using Pkg; Pkg.activate("../")
using WebAssemblyText
function translate(infile, outfile)
wat = jl2wat(infile)
open(outfile, "w") do io
write(io, wat)
end
end
translate(ARGS[1], ARGS[2]) | [
3500,
350,
10025,
26,
350,
10025,
13,
39022,
7203,
40720,
4943,
198,
3500,
5313,
49670,
8206,
198,
198,
8818,
15772,
7,
259,
7753,
11,
503,
7753,
8,
198,
220,
220,
220,
4383,
796,
474,
75,
17,
47261,
7,
259,
7753,
8,
198,
220,
220,
220,
1280,
7,
448,
7753,
11,
366,
86,
4943,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
3551,
7,
952,
11,
4383,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
7645,
17660,
7,
1503,
14313,
58,
16,
4357,
5923,
14313,
58,
17,
12962
] | 2.274725 | 91 |
<reponame>danielwe/LoopVectorization.jl<gh_stars>100-1000
using LoopVectorization, Test#, OffsetArrays
@testset "Array Wrappers" begin
@show @__LINE__
function addone!(y, x)
@turbo for i ∈ eachindex(x,y)
y[i] = x[i] + 1
end
y
end
x5 = PermutedDimsArray(rand(10,10), (2,1));
y5 = PermutedDimsArray(rand(10,10), (2,1));
y5t = x5 .+ 1;
@test LoopVectorization.check_args(x5)
@test y5t == addone!(y5, x5)
x6 = view(x5, 1:3, 1:3);
y6 = view(y5, 1:3, 1:3);
fill!(y6, NaN);
@test LoopVectorization.check_args(x6)
addone!(y6, x6); # also
@test y5t == y5 # Test that `NaN`s replaced with correct answers, and that other values were untouched.
A = rand(12,13,14,15);
pA = PermutedDimsArray(A, (3,1,4,2));
@test addone!(similar(pA), pA) == pA .+ 1
ppA = PermutedDimsArray(pA, (4,2,3,1));
@test LoopVectorization.check_args(ppA)
@test addone!(similar(ppA), ppA) == ppA .+ 1
x = rand(10,10); xc = copy(x);
xv = view(x, 1:2:10, 1:3);
xcv = view(xc, 1:2:10, 1:3);
@test LoopVectorization.check_args(xv)
addone!(xv, xv);
xcv .+= 1;
@test x == xc
end
| [
27,
7856,
261,
480,
29,
67,
6321,
732,
14,
39516,
38469,
1634,
13,
20362,
27,
456,
62,
30783,
29,
3064,
12,
12825,
198,
3500,
26304,
38469,
1634,
11,
6208,
2,
11,
3242,
2617,
3163,
20477,
198,
198,
31,
9288,
2617,
366,
19182,
27323,
11799,
1,
2221,
198,
197,
31,
12860,
2488,
834,
24027,
834,
628,
220,
220,
220,
2163,
751,
505,
0,
7,
88,
11,
2124,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
36590,
2127,
329,
1312,
18872,
230,
1123,
9630,
7,
87,
11,
88,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
331,
58,
72,
60,
796,
2124,
58,
72,
60,
1343,
352,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
331,
198,
220,
220,
220,
886,
628,
220,
220,
220,
2124,
20,
796,
2448,
76,
7241,
35,
12078,
19182,
7,
25192,
7,
940,
11,
940,
828,
357,
17,
11,
16,
18125,
198,
220,
220,
220,
331,
20,
796,
2448,
76,
7241,
35,
12078,
19182,
7,
25192,
7,
940,
11,
940,
828,
357,
17,
11,
16,
18125,
198,
220,
220,
220,
331,
20,
83,
796,
2124,
20,
764,
10,
352,
26,
198,
220,
220,
220,
2488,
9288,
26304,
38469,
1634,
13,
9122,
62,
22046,
7,
87,
20,
8,
198,
220,
220,
220,
2488,
9288,
331,
20,
83,
6624,
751,
505,
0,
7,
88,
20,
11,
2124,
20,
8,
628,
220,
220,
220,
2124,
21,
796,
1570,
7,
87,
20,
11,
352,
25,
18,
11,
352,
25,
18,
1776,
198,
220,
220,
220,
331,
21,
796,
1570,
7,
88,
20,
11,
352,
25,
18,
11,
352,
25,
18,
1776,
198,
220,
220,
220,
6070,
0,
7,
88,
21,
11,
11013,
45,
1776,
198,
220,
220,
220,
2488,
9288,
26304,
38469,
1634,
13,
9122,
62,
22046,
7,
87,
21,
8,
220,
198,
220,
220,
220,
751,
505,
0,
7,
88,
21,
11,
2124,
21,
1776,
1303,
635,
220,
198,
220,
220,
220,
2488,
9288,
331,
20,
83,
6624,
331,
20,
1303,
6208,
326,
4600,
26705,
45,
63,
82,
6928,
351,
3376,
7429,
11,
290,
326,
584,
3815,
547,
36519,
13,
628,
220,
220,
220,
317,
796,
43720,
7,
1065,
11,
1485,
11,
1415,
11,
1314,
1776,
198,
220,
220,
220,
279,
32,
796,
2448,
76,
7241,
35,
12078,
19182,
7,
32,
11,
357,
18,
11,
16,
11,
19,
11,
17,
18125,
198,
220,
220,
220,
2488,
9288,
751,
505,
0,
7,
38610,
7,
79,
32,
828,
279,
32,
8,
6624,
279,
32,
764,
10,
352,
198,
220,
220,
220,
9788,
32,
796,
2448,
76,
7241,
35,
12078,
19182,
7,
79,
32,
11,
357,
19,
11,
17,
11,
18,
11,
16,
18125,
198,
220,
220,
220,
2488,
9288,
26304,
38469,
1634,
13,
9122,
62,
22046,
7,
381,
32,
8,
198,
220,
220,
220,
2488,
9288,
751,
505,
0,
7,
38610,
7,
381,
32,
828,
9788,
32,
8,
6624,
9788,
32,
764,
10,
352,
628,
220,
220,
220,
2124,
796,
43720,
7,
940,
11,
940,
1776,
2124,
66,
796,
4866,
7,
87,
1776,
198,
220,
220,
220,
2124,
85,
796,
1570,
7,
87,
11,
352,
25,
17,
25,
940,
11,
352,
25,
18,
1776,
198,
220,
220,
220,
2124,
33967,
796,
1570,
7,
25306,
11,
352,
25,
17,
25,
940,
11,
352,
25,
18,
1776,
198,
220,
220,
220,
2488,
9288,
26304,
38469,
1634,
13,
9122,
62,
22046,
7,
87,
85,
8,
198,
220,
220,
220,
751,
505,
0,
7,
87,
85,
11,
2124,
85,
1776,
198,
220,
220,
220,
2124,
33967,
764,
47932,
352,
26,
198,
220,
220,
220,
2488,
9288,
2124,
6624,
2124,
66,
198,
437,
628,
198
] | 1.961921 | 604 |
#=* ДАНО: Робот находится в произвольной клетке ограниченного прямоугольного поля без внутренних перегородок и маркеров.
+учитываются внутренние прямоугольные перегородки,которые изолированы друг от друга и от внешней перегородки
РЕЗУЛЬТАТ: Робот — в исходном положении в центре прямого креста из маркеров, расставленных вплоть до внешней рамки.=#
function cross_but_harder(r::Robot)
for side in (Nord,West,Sud,Ost)
count=1
while count!=0
count=workaround_wall(r,side)
putmarker!(r)
end
while ismarker(r)==true
workaround_wall(r,inverse(side))
end
side=inverse(next(side))
end
putmarker!(r)
end
function workaround_wall(r::Robot, side::HorizonSide) #функция для обхода внутренних перегородок
num_steps=0
while isborder(r,side)==true && isborder(r,next(side))==false #уходим от линии маркеров чтобы обойти перегородки
move!(r,next(side))
num_steps+=1
end
count=0
if isborder(r,side)==false
move!(r,side)
count+=1 #считаем шаги при движении по линии
end
if num_steps !=0
while isborder(r,inverse(next(side)))==true #проходим перегородку на другой линии
move!(r,side)
count+=1
end
for t in 1:num_steps
move!(r,inverse(next(side))) #возвращаемся на линию
end
end
return count #Возвращение значения счётчика(сколько будет маркеров в линии)
end
next(side::HorizonSide)= HorizonSide(mod(Int(side)+1,4))
inverse(side::HorizonSide)=HorizonSide(mod(Int(side)+2,4))
| [
2,
28,
9,
12466,
242,
140,
238,
140,
251,
140,
252,
25,
12466,
254,
25443,
109,
15166,
20375,
12466,
121,
16142,
141,
227,
25443,
112,
18849,
20375,
21727,
40623,
12466,
110,
12466,
123,
21169,
15166,
18849,
140,
115,
38857,
25443,
119,
45367,
22177,
25443,
117,
12466,
118,
30143,
16843,
20375,
31583,
16843,
12466,
122,
140,
111,
21169,
16142,
22177,
18849,
141,
229,
16843,
22177,
22177,
25443,
111,
15166,
12466,
123,
21169,
40623,
43108,
15166,
35072,
140,
111,
25443,
119,
45367,
22177,
25443,
111,
15166,
12466,
123,
25443,
119,
40623,
12466,
109,
16843,
140,
115,
12466,
110,
22177,
35072,
20375,
21169,
16843,
22177,
22177,
18849,
141,
227,
12466,
123,
16843,
21169,
16843,
140,
111,
15166,
21169,
25443,
112,
25443,
118,
12466,
116,
12466,
120,
16142,
21169,
31583,
16843,
21169,
25443,
110,
13,
201,
198,
220,
220,
220,
1343,
35072,
141,
229,
18849,
20375,
45035,
38857,
16142,
141,
236,
20375,
21727,
40623,
12466,
110,
22177,
35072,
20375,
21169,
16843,
22177,
22177,
18849,
16843,
12466,
123,
21169,
40623,
43108,
15166,
35072,
140,
111,
25443,
119,
45367,
22177,
45035,
16843,
12466,
123,
16843,
21169,
16843,
140,
111,
15166,
21169,
25443,
112,
31583,
18849,
11,
31583,
15166,
20375,
15166,
21169,
45035,
16843,
12466,
116,
140,
115,
25443,
119,
18849,
21169,
25443,
110,
16142,
22177,
45035,
12466,
112,
21169,
35072,
140,
111,
12466,
122,
20375,
12466,
112,
21169,
35072,
140,
111,
16142,
12466,
116,
12466,
122,
20375,
12466,
110,
22177,
16843,
141,
230,
22177,
16843,
140,
117,
12466,
123,
16843,
21169,
16843,
140,
111,
15166,
21169,
25443,
112,
31583,
18849,
201,
198,
201,
198,
220,
220,
220,
12466,
254,
140,
243,
140,
245,
140,
96,
140,
249,
140,
105,
140,
95,
140,
238,
140,
95,
25,
12466,
254,
25443,
109,
15166,
20375,
851,
12466,
110,
12466,
116,
21727,
141,
227,
25443,
112,
22177,
25443,
120,
12466,
123,
25443,
119,
25443,
114,
16843,
22177,
18849,
18849,
12466,
110,
220,
141,
228,
16843,
22177,
20375,
21169,
16843,
12466,
123,
21169,
40623,
43108,
25443,
111,
15166,
12466,
118,
21169,
16843,
21727,
20375,
16142,
12466,
116,
140,
115,
12466,
120,
16142,
21169,
31583,
16843,
21169,
25443,
110,
11,
220,
21169,
16142,
21727,
21727,
20375,
16142,
38857,
30143,
16843,
22177,
22177,
45035,
141,
227,
12466,
110,
140,
123,
30143,
15166,
20375,
45367,
12466,
112,
15166,
12466,
110,
22177,
16843,
141,
230,
22177,
16843,
140,
117,
220,
21169,
16142,
43108,
31583,
18849,
13,
46249,
201,
198,
201,
198,
8818,
3272,
62,
4360,
62,
10424,
263,
7,
81,
3712,
14350,
313,
8,
201,
198,
1640,
1735,
287,
357,
45,
585,
11,
15045,
11,
50,
463,
11,
46,
301,
8,
201,
198,
220,
220,
220,
954,
28,
16,
201,
198,
220,
220,
220,
981,
954,
0,
28,
15,
201,
198,
220,
220,
220,
220,
220,
220,
220,
954,
28,
1818,
14145,
62,
11930,
7,
81,
11,
1589,
8,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1234,
4102,
263,
0,
7,
81,
8,
201,
198,
220,
220,
220,
886,
201,
198,
220,
220,
220,
981,
318,
4102,
263,
7,
81,
8,
855,
7942,
201,
198,
220,
220,
220,
220,
220,
220,
220,
46513,
62,
11930,
7,
81,
11,
259,
4399,
7,
1589,
4008,
201,
198,
220,
220,
220,
886,
201,
198,
220,
220,
220,
1735,
28,
259,
4399,
7,
19545,
7,
1589,
4008,
201,
198,
220,
220,
220,
886,
201,
198,
1996,
4102,
263,
0,
7,
81,
8,
201,
198,
437,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
201,
198,
8818,
46513,
62,
11930,
7,
81,
3712,
14350,
313,
11,
1735,
3712,
27991,
8637,
24819,
8,
1303,
141,
226,
35072,
22177,
31583,
141,
228,
18849,
40623,
12466,
112,
30143,
40623,
12466,
122,
140,
109,
141,
227,
25443,
112,
16142,
12466,
110,
22177,
35072,
20375,
21169,
16843,
22177,
22177,
18849,
141,
227,
12466,
123,
16843,
21169,
16843,
140,
111,
15166,
21169,
25443,
112,
25443,
118,
201,
198,
22510,
62,
20214,
28,
15,
201,
198,
4514,
318,
20192,
7,
81,
11,
1589,
8,
855,
7942,
11405,
318,
20192,
7,
81,
11,
19545,
7,
1589,
4008,
855,
9562,
220,
1303,
35072,
141,
227,
25443,
112,
18849,
43108,
12466,
122,
20375,
12466,
119,
18849,
22177,
18849,
18849,
12466,
120,
16142,
21169,
31583,
16843,
21169,
25443,
110,
220,
141,
229,
20375,
25443,
109,
45035,
12466,
122,
140,
109,
25443,
117,
20375,
18849,
12466,
123,
16843,
21169,
16843,
140,
111,
15166,
21169,
25443,
112,
31583,
18849,
201,
198,
220,
220,
220,
1445,
0,
7,
81,
11,
19545,
7,
1589,
4008,
201,
198,
220,
220,
220,
997,
62,
20214,
47932,
16,
201,
198,
437,
201,
198,
9127,
28,
15,
220,
201,
198,
361,
318,
20192,
7,
81,
11,
1589,
8,
855,
9562,
201,
198,
220,
220,
220,
1445,
0,
7,
81,
11,
1589,
8,
201,
198,
220,
220,
220,
954,
47932,
16,
1303,
21727,
141,
229,
18849,
20375,
16142,
16843,
43108,
220,
141,
230,
16142,
140,
111,
18849,
12466,
123,
21169,
18849,
12466,
112,
38857,
18849,
140,
114,
16843,
22177,
18849,
18849,
12466,
123,
15166,
12466,
119,
18849,
22177,
18849,
18849,
201,
198,
437,
201,
198,
361,
997,
62,
20214,
14512,
15,
201,
198,
220,
220,
220,
981,
318,
20192,
7,
81,
11,
259,
4399,
7,
19545,
7,
1589,
22305,
855,
7942,
1303,
140,
123,
21169,
15166,
141,
227,
25443,
112,
18849,
43108,
12466,
123,
16843,
21169,
16843,
140,
111,
15166,
21169,
25443,
112,
31583,
35072,
12466,
121,
16142,
12466,
112,
21169,
35072,
140,
111,
25443,
117,
12466,
119,
18849,
22177,
18849,
18849,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1445,
0,
7,
81,
11,
1589,
8,
201,
198,
220,
220,
220,
220,
220,
220,
220,
954,
47932,
16,
201,
198,
220,
220,
220,
886,
201,
198,
220,
220,
220,
329,
256,
287,
352,
25,
22510,
62,
20214,
201,
198,
220,
220,
220,
1445,
0,
7,
81,
11,
259,
4399,
7,
19545,
7,
1589,
22305,
1303,
38857,
25443,
115,
38857,
21169,
16142,
141,
231,
16142,
16843,
43108,
21727,
40623,
12466,
121,
16142,
12466,
119,
18849,
22177,
18849,
141,
236,
201,
198,
220,
220,
220,
886,
201,
198,
437,
201,
198,
7783,
954,
1303,
140,
240,
25443,
115,
38857,
21169,
16142,
141,
231,
16843,
22177,
18849,
16843,
12466,
115,
22177,
16142,
141,
229,
16843,
22177,
18849,
40623,
220,
21727,
141,
229,
141,
239,
20375,
141,
229,
18849,
31583,
16142,
7,
21727,
31583,
25443,
119,
45367,
31583,
15166,
12466,
109,
35072,
43666,
16843,
20375,
12466,
120,
16142,
21169,
31583,
16843,
21169,
25443,
110,
12466,
110,
12466,
119,
18849,
22177,
18849,
18849,
8,
201,
198,
437,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
201,
198,
19545,
7,
1589,
3712,
27991,
8637,
24819,
47505,
22776,
24819,
7,
4666,
7,
5317,
7,
1589,
47762,
16,
11,
19,
4008,
201,
198,
201,
198,
259,
4399,
7,
1589,
3712,
27991,
8637,
24819,
47505,
27991,
8637,
24819,
7,
4666,
7,
5317,
7,
1589,
47762,
17,
11,
19,
4008,
201,
198
] | 1.359292 | 1,130 |
# Many derivative free methods of different orders
##################################################
## Helpers for the various methods
## issue with approx derivative
isissue(x) = (x == 0.0) || isnan(x) || isinf(x)
"""
heuristic to get a decent first step with Steffensen steps
"""
function steff_step(x::T, fx) where {T}
thresh = max(1, norm(x)) * sqrt(eps(T)) # max(1, sqrt(abs(x/fx))) * 1e-6
norm(fx) <= thresh ? fx : sign(fx) * thresh
end
function guarded_secant_step(alpha::T, beta::T, falpha, fbeta) where {T <: AbstractFloat}
fp = (fbeta - falpha) / (beta - alpha)
Δ::T = fbeta / fp
## odd, we get allocations if we define Delta, then beta - Delta
## Δ = beta - fbeta * (beta - alpha) / (fbeta - falpha)
if isissue(Δ)
Δ = one(T)/1000
elseif norm(Δ) >= 100 * norm(alpha - beta) # guard runaway
Δ = sign(Δ) * 100 * min(one(T), norm(alpha - beta))
end
if isissue(Δ)
return (alpha + (beta - alpha)*(0.5), true) # midpoint
else
return (beta - Δ, false)
end
end
## Different functions for approximating f'(xn)
## return fpxn and whether it is an issue
## use f[a,b] to approximate f'(x)
function _fbracket(a, b, fa, fb)
num, den = fb - fa, b - a
num == 0 && den == 0 && return Inf, true
out = num / den
out, isissue(out)
end
## use f[y,z] - f[x,y] + f[x,z] to approximate
function _fbracket_diff(a,b,c, fa, fb, fc)
x1, _ = _fbracket(b, c, fb, fc)
x2, _ = _fbracket(a, b, fa, fb)
x3, _ = _fbracket(a, c, fa, fc)
out = x1 - x2 + x3
out, isissue(out)
end
## use f[a,b] * f[a,c] / f[b,c]
function _fbracket_ratio(a, b, c, fa, fb, fc)
x1, _ = _fbracket(a, b, fa, fb)
x2, _ = _fbracket(a, c, fa, fc)
x3, _ = _fbracket(b, c, fb, fc)
out = (x2 * x3) / x3
out, isissue(out)
end
##################################################
## Order0 and Secant are related
"""
Order0()
The `Order0` method is engineered to be a more robust, though possibly
slower, alternative to to the other derivative-free root-finding
methods. The implementation roughly follows the algorithm described in
*Personal Calculator Has Key to Solve Any Equation f(x) = 0*, the
SOLVE button from the
[HP-34C](http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1979-12.pdf).
The basic idea is to use a secant step. If along the way a bracket is
found, switch to bisection, using `Bisection` if possible, else
`A42`. If the secant step fails to decrease the function value, a
quadratic step is used up to 3 times.
"""
mutable struct Order0 <: AbstractSecant end
"""
Order1()
The `Order1()` method is an alias for `Secant` and performs a secant
step. This method keeps two values in its state, `x_n` and `x_n1`. The
updated point is the intersection point of x axis with the secant line
formed from the two points. The secant method uses 1 function
evaluation and has order `(1+sqrt(5))/2`.
"""
mutable struct Secant <: AbstractSecant end
const Order1 = Secant
function init_state(method::AbstractSecant, fs, x::Union{T, Vector{T}}, bracket) where {T <: AbstractFloat}
if isa(x, Vector)
x0, x1 = x[1:2]
# fx0, fx1 = fs.f(x0), fs.f(x1)
fx0, fx1 = fs(x0), fs(x1)
else
x0 = float(x)
# fx0 = fs.f(x0)
fx0 = fs(x0)
stepsize = max(1/100, min(abs(fx0), abs(x0/100)))
x1 = x0 + stepsize
# x0, x1, fx0, fx1 = x1, x0, fs.f(x1), fx0 # switch
x0, x1, fx0, fx1 = x1, x0, fs(x1), fx0 # switch
end
state = UnivariateZeroStateBase(
promote(float(x1), float(x0))...,
promote(fx1, fx0)...,
bracket,
0, 2,
false, false, false, false,
"")
state
end
##################################################
## in Order0, we run bisection if a bracketing interval is found
function _run_bisection(fs, o, options)
verbose = options.verbose; options.verbose=false # turn off verbose
find_zero(Bisection(), fs, o, options)
options.verbose = verbose
o.message = "Used bisection for last step"
end
## order 0
# goal: more robust to initial guess than higher order methods
# follows roughly algorithm described http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1979-12.pdf, the SOLVE button from the HP-34C
# though some modifications were made.
# * use secant step
# * if along the way a bracket is found, switch to bisection. (We use float64 bisection not a42 if available)
# * if secant step fails to decrease, we use quadratic step up to 3 times
#
# Goal is to return a value `x` with either:
# * `f(x) == 0.0` or
# * `f(prevfloat(x)) * f(nextfloat(x)) < 0`.
# if a bracket is found that can be done, otherwise secant step is used
function update_state(method::Order0, fs, o::UnivariateZeroState{T}, options::UnivariateZeroOptions) where {T}
f = fs.f
alpha, beta = o.xn0, o.xn1
falpha, fbeta = o.fxn0, o.fxn1
incsteps(o)
if sign(falpha) * sign(fbeta) < 0.0
_run_bisection(fs, o, options)
return nothing
end
gamma, issue = guarded_secant_step(alpha, beta, falpha, fbeta)
fgamma = f(gamma); incfn(o)
if sign(fgamma)*sign(fbeta) < 0.0
o.xn0, o.xn1 = gamma, beta
o.fxn0, o.fxn1 = fgamma, fbeta
_run_bisection(fs, o, options)
return nothing
end
if norm(fgamma) <= norm(fbeta)
o.xn0, o.xn1 = beta, gamma
o.fxn0, o.fxn1 = fbeta, fgamma
return nothing
end
ctr = 0
while true
## quadratic step
ctr += 1
if ctr >= 3
o.stopped = true
o.message = "dithering, algorithm failed to improve using quadratic steps"
return nothing
end
# quadratic_step. Put new gamma at vertex of parabola through alpha, beta, (old) gamma
denom = (beta - alpha) * (fbeta - fgamma) - (beta - fgamma) * (fbeta - falpha)
if isissue(denom)
o.stopped
o.message = "dithering, algorithm failed to improve using quadratic steps"
return nothing
end
gamma = beta - ((beta - alpha)^2 * (fbeta - fgamma) - (beta - gamma)^2 * (fbeta - falpha))/denom/2
fgamma = f(gamma); incfn(o)
incfn(o)
if norm(fgamma) < norm(fbeta)
o.xn0, o.xn1 = beta, gamma
o.fxn0, o.fxn1 = fbeta, fgamma
return nothing
end
theta, issue = guarded_secant_step(beta, gamma, fbeta, fgamma)
ftheta = f(theta); incfn(o)
if sign(ftheta) * sign(fbeta) < 0
o.xn0, o.xn1 = beta, theta
o.fxn0, o.fxn1 = fbeta, ftheta
_run_bisection(fs, o, options)
return nothing
end
end
# failed to improve
o.stopped = true
o.message = "failure to improve"
return nothing
end
##################################################
## Secant
## https://en.wikipedia.org/wiki/Secant_method
function update_state(method::Secant, fs, o::UnivariateZeroState{T}, options::UnivariateZeroOptions{T}) where {T <: AbstractFloat}
incsteps(o)
fp, issue = _fbracket(o.xn0, o.xn1, o.fxn0, o.fxn1)
if issue
o.stopped = true
o.message = "Derivative approximation had issues"
return
end
o.xn0 = o.xn1
o.fxn0 = o.fxn1
o.xn1 = o.xn1 - o.fxn1 / fp
# o.fxn1 = fs.f(o.xn1)
o.fxn1 = fs(o.xn1)
incfn(o)
nothing
end
"""
secant_method(f, x0, x1; [kwargs...])
Solve for zero of `f(x) = 0` using the secant method.
Not exported. Use `find_zero` with `Order1()`.
"""
secant_method(f, x0::Real, x1::Real; kwargs...) = find_zero(f, map(float, [x0,x1]), Order1(); kwargs...)
##################################################
### Steffensen
## https://en.wikipedia.org/wiki/Steffensen's_method#Simple_description
mutable struct Steffensen <: UnivariateZeroMethod
end
"""
Order2()
The quadratically converging
[Steffensen](https://en.wikipedia.org/wiki/Steffensen's_method#Simple_description)
method is used for the derivative free `Order2()` algorithm. Unlike
the quadratically converging Newton's method, no derivative is
necessary, though like Newton's method, two function calls per step
are. This algorithm is more sensitive than Newton's method to poor
initial guesses.
"""
const Order2 = Steffensen
function update_state(method::Steffensen, fs, o::UnivariateZeroState{T}, options::UnivariateZeroOptions{T}) where {T <: AbstractFloat}
S = eltype(o.fxn1)
incsteps(o)
wn = o.xn1 + steff_step(o.xn1, o.fxn1)::T
fwn = fs(wn)::S
incfn(o)
fp, issue = _fbracket(o.xn1, wn, o.fxn1, fwn)
if issue
o.stopped = true
o.message = "Derivative approximation had issues"
return
end
o.xn0 = o.xn1
o.fxn0 = o.fxn1
o.xn1 = o.xn1 - o.fxn1 / fp #xn1
o.fxn1 = fs(o.xn1)
incfn(o)
nothing
end
steffenson(f, x0; kwargs...) = find_zero(f, x0, Steffensen(); kwargs...)
##################################################
"""
Order5()
Implements an algorithm
from *A New Fifth Order Derivative Free Newton-Type Method for Solving Nonlinear Equations*
by <NAME>, <NAME>, and Akanksha,
Appl. Math. Inf. Sci. 9, No. 3, 1507-1513 (2015). Four function calls per step are needed.
"""
mutable struct Order5 <: UnivariateZeroMethod end
function update_state(method::Order5, fs, o::UnivariateZeroState{T}, options::UnivariateZeroOptions) where {T}
xn = o.xn1
fxn = o.fxn1
S = eltype(o.fxn1)
incsteps(o)
wn::T = o.xn1 + steff_step(o.xn1, o.fxn1)
fwn = fs(wn)::S
incfn(o)
fp, issue = _fbracket(o.xn1, wn, o.fxn1, fwn)
if issue
o.xn0, o.xn1 = o.xn1, wn
o.fxn0, o.fxn1 = o.fxn1, fwn
o.message = "Issue with divided difference f[xn, wn]"
o.stopped = true
return
end
yn::T = o.xn1 - o.fxn1 / fp
fyn = fs(yn)::S
incfn(o)
zn::T = xn - (fxn + fyn) / fp
fzn = fs(zn)::S
incfn(o)
fp, issue = _fbracket_ratio(yn, o.xn1, wn, fyn, o.fxn1, fwn)
if issue
o.xn0, o.xn1 = o.xn1, yn
o.fxn0, o.fxn1 = o.fxn1, fyn
o.message = "Issue with f[xn,yn]*f[yn,wn] / f[xn, wn]"
o.stopped = true
return
end
o.xn0 = o.xn1
o.fxn0 = o.fxn1
o.xn1 = zn - fzn / fp
o.fxn1 = fs(o.xn1)
incfn(o)
nothing
end
## If we have a derivative
function update_state(method::Order5, fs::FirstDerivative, o::UnivariateZeroState{T}, options::UnivariateZeroOptions) where {T}
xn, fxn = o.xn1, o.fxn1
S = eltype(fxn)
incsteps(o)
fpxn = fs.fp(xn)
incfn(o)
if isissue(fpxn)
o.stopped = true
return
end
yn = xn - fxn / fpxn
fyn, fpyn = fs.f(yn), fs.fp(yn)
incfn(o, 2)
if isissue(fpyn)
o.xn0, o.xn1 = xn, yn
o.fxn0, o.fxn1 = fxn, fyn
o.stopped = true
return
end
zn = xn - (fxn + fyn) / fpxn
fzn = fs.f(zn)
incfn(o, 1)
xn1 = zn - fzn / fpyn
fxn1 = fs.f(xn1)
incfn(o, 1)
o.xn0, o.xn1 = xn, xn1
o.fxn0, o.fxn1 = fxn, fxn1
nothing
end
##################################################
"""
Order8()
Implements an algorithm from
*New Eighth-Order Derivative-Free Methods for Solving Nonlinear Equations*
by <NAME>,
International Journal of Mathematics and Mathematical Sciences
Volume 2012 (2012), Article ID 493456, 12 pages. Four function calls per step are required.
"""
mutable struct Order8 <: UnivariateZeroMethod
end
function update_state(method::Order8, fs, o::UnivariateZeroState{T}, options::UnivariateZeroOptions) where {T}
xn = o.xn1
fxn = o.fxn1
S = eltype(fxn)
incsteps(o)
wn::T = xn + steff_step(xn, fxn)
fwn::S = fs(wn)
incfn(o)
if isissue(fwn)
o.xn0,o.xn1 = xn, wn
o.fxn0,o.fxn1 = fxn, fwn
o.stopped = true
o.message = "issue with Steffensen step fwn"
return
end
fp, issue = _fbracket(xn, wn, fxn, fwn)
issue && return (xn, true)
if issue
o.stopped = true
o.message = "issue with divided difference f[xn, wn]"
return
end
yn::T = xn - fxn / fp
fyn::S = fs(yn)
incfn(o)
fp, issue = _fbracket(yn, xn, fyn, fxn)
if issue #fp
o.xn0,o.xn1 = xn, yn
o.fxn0,o.fxn1 = fxn, fyn
o.stopped = true
o.message = "issue with divided difference f[xn, yn]"
return
end
phi = (1 + fyn / fwn) # pick one of options
zn = yn - phi * fyn / fp
fzn::S = fs(zn)
incfn(o)
fp, issue = _fbracket_diff(xn, yn, zn, fxn, fyn, fzn)
if issue
o.xn0,o.xn1 = xn, zn
o.fxn0,o.fxn1 = fxn, fzn
o.message = "issue with divided difference f[y,z] - f[x,y] + f[x,z]"
o.stopped = true
return
end
w::T = 1 / (1 - fzn/fwn)
xi::T = (1 - 2fyn*fyn*fyn / (fwn * fwn * fxn))
xn1::T = zn - w * xi * fzn / fp
fxn1::S = fs(xn1)
incfn(o)
o.xn0,o.xn1 = xn, xn1
o.fxn0,o.fxn1 = fxn, fxn1
nothing
end
##################################################
"""
Order16()
Implement the algorithm from
*New Sixteenth-Order Derivative-Free Methods for Solving Nonlinear Equations*
by <NAME>,
American Journal of Computational and Applied Mathematics
p-ISSN: 2165-8935; e-ISSN: 2165-8943; 2012; 2(3): 112-118
doi: 10.5923/j.ajcam.20120203.08.
Five function calls per step are required. Though rapidly converging, this method generally isn't faster (fewer
function calls/steps) over other methods when using `Float64` values,
but may be useful for solving over `BigFloat`.
"""
mutable struct Order16 <: UnivariateZeroMethod
end
function update_state(method::Order16, fs, o::UnivariateZeroState{T}, options::UnivariateZeroOptions) where {T}
xn = o.xn1
fxn = o.fxn1
S = eltype(fxn)
incsteps(o)
wn::T = xn + steff_step(xn, fxn)
fwn::S = fs(wn)
incfn(o)
fp, issue = _fbracket(xn, wn, fxn, fwn)
if issue
o.xn0, o.xn1 = xn, wn
o.fxn0, o.fxn1 = fxn, fwn
o.message = "issue with f[xn,wn]"
o.stopped = true
return
end
yn::T = xn - fxn / fp
fyn::S = fs(yn)
incfn(o)
fp, issue = _fbracket_ratio(yn, xn, wn, fyn, fxn, fwn)
if issue
o.xn0, o.xn1 = xn, yn
o.fxn0, o.fxn1 = fxn, fyn
o.message = "issue with f[xn,yn]*f[yn,wn]/f[xn,wn]"
o.stopped = true
return
end
zn::T = yn - fyn / fp
fzn::S = fs(zn)
incfn(o)
fp, issue = _fbracket_diff(xn, yn, zn, fxn, fyn, fzn)
u2, u3, u4 = fzn/fwn, fyn/fxn, fyn/fwn
eta = 1 / (1 + 2*u3*u4^2) / (1 - u2)
if issue
o.xn0, o.xn1 = xn, zn
o.fxn0, o.fxn1 = fxn, fzn
o.stopped = true
o.message = "Approximate derivative failed"
return
end
an = zn - eta * fzn / fp
fan = fs(an)
incfn(o)
fp, issue = _fbracket_ratio(an, yn, zn, fan, fyn, fzn)
if issue
o.xn0, o.xn1 = xn, an
o.fxn0, o.fxn1 = fxn, fan
o.stopped = true
o.message = "Approximate derivative failed"
return
end
u1, u5, u6 = fzn/fxn, fan/fxn, fan/fwn
sigma = 1 + u1*u2 - u1*u3*u4^2 + u5 + u6 + u1^2*u4 +
u2^2*u3 + 3*u1*u4^2*(u3^2 - u4^2)/_fbracket(xn,yn, fxn, fyn)[1]
xn1 = an - sigma * fan / fp
fxn1 = fs(xn1)
incfn(o)
o.xn0, o.xn1 = xn, xn1
o.fxn0, o.fxn1 = fxn, fxn1
nothing
end
| [
2,
4650,
27255,
1479,
5050,
286,
1180,
6266,
198,
198,
29113,
14468,
2235,
198,
2235,
10478,
364,
329,
262,
2972,
5050,
198,
2235,
2071,
351,
5561,
27255,
198,
271,
21949,
7,
87,
8,
796,
357,
87,
6624,
657,
13,
15,
8,
8614,
2125,
272,
7,
87,
8,
8614,
318,
10745,
7,
87,
8,
628,
198,
37811,
198,
258,
27915,
284,
651,
257,
7709,
717,
2239,
351,
2441,
487,
18756,
4831,
198,
37811,
198,
8818,
2876,
487,
62,
9662,
7,
87,
3712,
51,
11,
277,
87,
8,
810,
1391,
51,
92,
198,
220,
220,
220,
294,
3447,
796,
220,
3509,
7,
16,
11,
2593,
7,
87,
4008,
1635,
19862,
17034,
7,
25386,
7,
51,
4008,
1303,
3509,
7,
16,
11,
19862,
17034,
7,
8937,
7,
87,
14,
21373,
22305,
1635,
352,
68,
12,
21,
198,
220,
220,
220,
2593,
7,
21373,
8,
19841,
294,
3447,
5633,
277,
87,
1058,
1051,
7,
21373,
8,
1635,
294,
3447,
198,
437,
198,
198,
8818,
28178,
62,
2363,
415,
62,
9662,
7,
26591,
3712,
51,
11,
12159,
3712,
51,
11,
24215,
7566,
11,
277,
31361,
8,
810,
1391,
51,
1279,
25,
27741,
43879,
92,
628,
220,
220,
220,
277,
79,
796,
357,
69,
31361,
532,
24215,
7566,
8,
1220,
220,
357,
31361,
532,
17130,
8,
198,
220,
220,
220,
37455,
3712,
51,
796,
277,
31361,
1220,
277,
79,
198,
220,
220,
220,
22492,
5629,
11,
356,
651,
49157,
611,
356,
8160,
16978,
11,
788,
12159,
532,
16978,
198,
220,
220,
220,
22492,
37455,
796,
12159,
532,
277,
31361,
1635,
357,
31361,
532,
17130,
8,
1220,
357,
69,
31361,
532,
24215,
7566,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
611,
318,
21949,
7,
138,
242,
8,
198,
220,
220,
220,
220,
220,
220,
220,
37455,
796,
530,
7,
51,
20679,
12825,
198,
220,
220,
220,
2073,
361,
2593,
7,
138,
242,
8,
18189,
1802,
1635,
2593,
7,
26591,
532,
12159,
8,
1303,
4860,
39732,
198,
220,
220,
220,
220,
220,
220,
220,
37455,
796,
1051,
7,
138,
242,
8,
1635,
1802,
1635,
949,
7,
505,
7,
51,
828,
2593,
7,
26591,
532,
12159,
4008,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
318,
21949,
7,
138,
242,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
26591,
1343,
357,
31361,
532,
17130,
27493,
7,
15,
13,
20,
828,
2081,
8,
1303,
3095,
4122,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
31361,
532,
37455,
11,
3991,
8,
198,
220,
220,
220,
886,
198,
437,
628,
198,
2235,
20615,
5499,
329,
5561,
39204,
277,
6,
7,
87,
77,
8,
198,
2235,
1441,
277,
8416,
77,
290,
1771,
340,
318,
281,
2071,
198,
198,
2235,
779,
277,
58,
64,
11,
65,
60,
284,
27665,
277,
6,
7,
87,
8,
198,
8818,
4808,
69,
1671,
8317,
7,
64,
11,
275,
11,
24685,
11,
277,
65,
8,
198,
220,
220,
220,
997,
11,
2853,
796,
277,
65,
532,
24685,
11,
275,
532,
257,
198,
220,
220,
220,
997,
6624,
657,
11405,
2853,
6624,
657,
11405,
1441,
4806,
11,
2081,
198,
220,
220,
220,
503,
796,
997,
1220,
2853,
198,
220,
220,
220,
503,
11,
318,
21949,
7,
448,
8,
198,
437,
198,
198,
2235,
779,
277,
58,
88,
11,
89,
60,
532,
277,
58,
87,
11,
88,
60,
1343,
277,
58,
87,
11,
89,
60,
284,
27665,
198,
8818,
4808,
69,
1671,
8317,
62,
26069,
7,
64,
11,
65,
11,
66,
11,
24685,
11,
277,
65,
11,
277,
66,
8,
198,
220,
220,
220,
2124,
16,
11,
4808,
796,
4808,
69,
1671,
8317,
7,
65,
11,
269,
11,
277,
65,
11,
220,
277,
66,
8,
198,
220,
220,
220,
2124,
17,
11,
4808,
796,
4808,
69,
1671,
8317,
7,
64,
11,
275,
11,
24685,
11,
220,
277,
65,
8,
198,
220,
220,
220,
2124,
18,
11,
4808,
796,
4808,
69,
1671,
8317,
7,
64,
11,
269,
11,
24685,
11,
220,
277,
66,
8,
198,
220,
220,
220,
503,
796,
2124,
16,
532,
2124,
17,
1343,
2124,
18,
198,
220,
220,
220,
503,
11,
318,
21949,
7,
448,
8,
198,
437,
628,
198,
2235,
779,
277,
58,
64,
11,
65,
60,
1635,
277,
58,
64,
11,
66,
60,
1220,
277,
58,
65,
11,
66,
60,
198,
8818,
4808,
69,
1671,
8317,
62,
10366,
952,
7,
64,
11,
275,
11,
269,
11,
24685,
11,
277,
65,
11,
277,
66,
8,
198,
220,
220,
220,
2124,
16,
11,
4808,
796,
4808,
69,
1671,
8317,
7,
64,
11,
275,
11,
24685,
11,
277,
65,
8,
198,
220,
220,
220,
2124,
17,
11,
4808,
796,
4808,
69,
1671,
8317,
7,
64,
11,
269,
11,
24685,
11,
277,
66,
8,
198,
220,
220,
220,
2124,
18,
11,
4808,
796,
4808,
69,
1671,
8317,
7,
65,
11,
269,
11,
277,
65,
11,
277,
66,
8,
198,
220,
220,
220,
503,
796,
357,
87,
17,
1635,
2124,
18,
8,
1220,
2124,
18,
198,
220,
220,
220,
503,
11,
318,
21949,
7,
448,
8,
198,
437,
628,
198,
29113,
14468,
2235,
198,
198,
2235,
8284,
15,
290,
1882,
415,
389,
3519,
198,
37811,
198,
220,
220,
220,
8284,
15,
3419,
628,
198,
464,
4600,
18743,
15,
63,
2446,
318,
23371,
284,
307,
257,
517,
12373,
11,
996,
5457,
198,
6649,
789,
11,
5559,
284,
284,
262,
584,
27255,
12,
5787,
6808,
12,
41070,
198,
24396,
82,
13,
383,
7822,
7323,
5679,
262,
11862,
3417,
287,
198,
9,
30228,
43597,
7875,
7383,
284,
4294,
303,
4377,
7889,
341,
277,
7,
87,
8,
796,
657,
25666,
262,
198,
50,
3535,
6089,
4936,
422,
262,
198,
58,
14082,
12,
2682,
34,
16151,
4023,
1378,
2503,
13,
71,
489,
13,
24831,
13,
785,
14,
24831,
24891,
14,
12315,
82,
14,
45147,
20456,
82,
14,
33581,
12,
1065,
13,
12315,
737,
198,
464,
4096,
2126,
318,
284,
779,
257,
792,
415,
2239,
13,
1002,
1863,
262,
835,
257,
19096,
318,
198,
9275,
11,
5078,
284,
47457,
3213,
11,
1262,
4600,
33,
271,
3213,
63,
611,
1744,
11,
2073,
198,
63,
32,
3682,
44646,
220,
1002,
262,
792,
415,
2239,
10143,
284,
10070,
262,
2163,
1988,
11,
257,
198,
421,
41909,
1512,
2239,
318,
973,
510,
284,
513,
1661,
13,
198,
220,
220,
220,
220,
198,
37811,
198,
76,
18187,
2878,
8284,
15,
1279,
25,
27741,
6558,
415,
886,
198,
198,
37811,
198,
220,
220,
220,
8284,
16,
3419,
198,
198,
464,
4600,
18743,
16,
3419,
63,
2446,
318,
281,
16144,
329,
4600,
6558,
415,
63,
290,
17706,
257,
792,
415,
198,
9662,
13,
770,
2446,
7622,
734,
3815,
287,
663,
1181,
11,
4600,
87,
62,
77,
63,
290,
4600,
87,
62,
77,
16,
44646,
383,
198,
43162,
966,
318,
262,
16246,
966,
286,
2124,
16488,
351,
262,
792,
415,
1627,
198,
12214,
422,
262,
734,
2173,
13,
383,
792,
415,
2446,
3544,
352,
2163,
198,
18206,
2288,
290,
468,
1502,
4600,
7,
16,
10,
31166,
17034,
7,
20,
4008,
14,
17,
44646,
198,
198,
37811,
198,
76,
18187,
2878,
1882,
415,
1279,
25,
27741,
6558,
415,
886,
198,
9979,
8284,
16,
796,
1882,
415,
198,
198,
8818,
2315,
62,
5219,
7,
24396,
3712,
23839,
6558,
415,
11,
43458,
11,
2124,
3712,
38176,
90,
51,
11,
20650,
90,
51,
92,
5512,
19096,
8,
810,
1391,
51,
1279,
25,
27741,
43879,
92,
628,
220,
220,
220,
611,
318,
64,
7,
87,
11,
20650,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
15,
11,
2124,
16,
796,
2124,
58,
16,
25,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
220,
220,
220,
220,
220,
277,
87,
15,
11,
277,
87,
16,
796,
43458,
13,
69,
7,
87,
15,
828,
43458,
13,
69,
7,
87,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
277,
87,
15,
11,
277,
87,
16,
796,
43458,
7,
87,
15,
828,
43458,
7,
87,
16,
8,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
15,
796,
12178,
7,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
220,
220,
220,
220,
220,
277,
87,
15,
796,
43458,
13,
69,
7,
87,
15,
8,
198,
220,
220,
220,
220,
220,
220,
220,
277,
87,
15,
796,
43458,
7,
87,
15,
8,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
4831,
1096,
796,
3509,
7,
16,
14,
3064,
11,
949,
7,
8937,
7,
21373,
15,
828,
2352,
7,
87,
15,
14,
3064,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
16,
796,
2124,
15,
1343,
4831,
1096,
198,
2,
220,
220,
220,
220,
220,
220,
220,
2124,
15,
11,
2124,
16,
11,
277,
87,
15,
11,
277,
87,
16,
220,
796,
2124,
16,
11,
2124,
15,
11,
43458,
13,
69,
7,
87,
16,
828,
277,
87,
15,
1303,
5078,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
15,
11,
2124,
16,
11,
277,
87,
15,
11,
277,
87,
16,
220,
796,
2124,
16,
11,
2124,
15,
11,
43458,
7,
87,
16,
828,
277,
87,
15,
1303,
5078,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1181,
796,
791,
42524,
28667,
9012,
14881,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7719,
7,
22468,
7,
87,
16,
828,
12178,
7,
87,
15,
4008,
986,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7719,
7,
21373,
16,
11,
277,
87,
15,
26513,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19096,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
657,
11,
362,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3991,
11,
3991,
11,
3991,
11,
3991,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
4943,
198,
220,
220,
220,
1181,
198,
437,
198,
198,
29113,
14468,
2235,
198,
198,
2235,
287,
8284,
15,
11,
356,
1057,
47457,
3213,
611,
257,
19096,
278,
16654,
318,
1043,
198,
8818,
4808,
5143,
62,
41907,
3213,
7,
9501,
11,
267,
11,
3689,
8,
198,
220,
220,
220,
15942,
577,
796,
3689,
13,
19011,
577,
26,
3689,
13,
19011,
577,
28,
9562,
1303,
1210,
572,
15942,
577,
198,
220,
220,
220,
1064,
62,
22570,
7,
33,
271,
3213,
22784,
43458,
11,
267,
11,
3689,
8,
198,
220,
220,
220,
3689,
13,
19011,
577,
796,
15942,
577,
198,
220,
220,
220,
267,
13,
20500,
796,
366,
38052,
47457,
3213,
329,
938,
2239,
1,
198,
437,
628,
198,
2235,
1502,
657,
198,
2,
3061,
25,
517,
12373,
284,
4238,
4724,
621,
2440,
1502,
5050,
198,
2,
5679,
7323,
11862,
3417,
2638,
1378,
2503,
13,
71,
489,
13,
24831,
13,
785,
14,
24831,
24891,
14,
12315,
82,
14,
45147,
20456,
82,
14,
33581,
12,
1065,
13,
12315,
11,
262,
36817,
6089,
4936,
422,
262,
6574,
12,
2682,
34,
198,
2,
996,
617,
19008,
547,
925,
13,
198,
2,
1635,
779,
792,
415,
2239,
198,
2,
1635,
611,
1863,
262,
835,
257,
19096,
318,
1043,
11,
5078,
284,
47457,
3213,
13,
357,
1135,
779,
12178,
2414,
47457,
3213,
407,
257,
3682,
611,
1695,
8,
198,
2,
1635,
611,
792,
415,
2239,
10143,
284,
10070,
11,
356,
779,
15094,
81,
1512,
2239,
510,
284,
513,
1661,
198,
2,
198,
2,
25376,
318,
284,
1441,
257,
1988,
4600,
87,
63,
351,
2035,
25,
198,
2,
1635,
4600,
69,
7,
87,
8,
6624,
657,
13,
15,
63,
393,
198,
2,
1635,
4600,
69,
7,
47050,
22468,
7,
87,
4008,
1635,
277,
7,
19545,
22468,
7,
87,
4008,
1279,
657,
44646,
198,
2,
611,
257,
19096,
318,
1043,
326,
460,
307,
1760,
11,
4306,
792,
415,
2239,
318,
973,
198,
8818,
4296,
62,
5219,
7,
24396,
3712,
18743,
15,
11,
43458,
11,
267,
3712,
3118,
42524,
28667,
9012,
90,
51,
5512,
3689,
3712,
3118,
42524,
28667,
29046,
8,
810,
1391,
51,
92,
628,
220,
220,
220,
277,
796,
43458,
13,
69,
198,
220,
220,
220,
17130,
11,
12159,
796,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
198,
220,
220,
220,
24215,
7566,
11,
277,
31361,
796,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
628,
220,
220,
220,
753,
20214,
7,
78,
8,
628,
220,
220,
220,
611,
1051,
7,
69,
26591,
8,
1635,
1051,
7,
69,
31361,
8,
1279,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
5143,
62,
41907,
3213,
7,
9501,
11,
267,
11,
3689,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
886,
628,
220,
220,
220,
34236,
11,
2071,
796,
28178,
62,
2363,
415,
62,
9662,
7,
26591,
11,
12159,
11,
24215,
7566,
11,
277,
31361,
8,
628,
220,
220,
220,
277,
28483,
2611,
796,
277,
7,
28483,
2611,
1776,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
611,
1051,
7,
69,
28483,
2611,
27493,
12683,
7,
69,
31361,
8,
1279,
657,
13,
15,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
34236,
11,
12159,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
28483,
2611,
11,
277,
31361,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
5143,
62,
41907,
3213,
7,
9501,
11,
267,
11,
3689,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
2593,
7,
69,
28483,
2611,
8,
19841,
2593,
7,
69,
31361,
8,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
12159,
11,
34236,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
31361,
11,
277,
28483,
2611,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
886,
628,
220,
220,
220,
269,
2213,
796,
657,
198,
220,
220,
220,
981,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
22492,
15094,
81,
1512,
2239,
198,
220,
220,
220,
220,
220,
220,
220,
269,
2213,
15853,
352,
198,
220,
220,
220,
220,
220,
220,
220,
611,
269,
2213,
18189,
513,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
67,
40861,
11,
11862,
4054,
284,
2987,
1262,
15094,
81,
1512,
4831,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
15094,
81,
1512,
62,
9662,
13,
5930,
649,
34236,
379,
37423,
286,
1582,
397,
5708,
832,
17130,
11,
12159,
11,
357,
727,
8,
34236,
198,
220,
220,
220,
220,
220,
220,
220,
2853,
296,
796,
357,
31361,
532,
17130,
8,
1635,
357,
69,
31361,
532,
277,
28483,
2611,
8,
220,
532,
357,
31361,
532,
277,
28483,
2611,
8,
1635,
357,
69,
31361,
532,
24215,
7566,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
318,
21949,
7,
6559,
296,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
67,
40861,
11,
11862,
4054,
284,
2987,
1262,
15094,
81,
1512,
4831,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
34236,
796,
12159,
532,
220,
14808,
31361,
532,
17130,
8,
61,
17,
1635,
357,
69,
31361,
532,
277,
28483,
2611,
8,
532,
357,
31361,
532,
34236,
8,
61,
17,
1635,
357,
69,
31361,
532,
24215,
7566,
4008,
14,
6559,
296,
14,
17,
628,
198,
220,
220,
220,
220,
220,
220,
220,
277,
28483,
2611,
796,
277,
7,
28483,
2611,
1776,
753,
22184,
7,
78,
8,
198,
220,
220,
220,
220,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
220,
220,
220,
220,
611,
2593,
7,
69,
28483,
2611,
8,
1279,
2593,
7,
69,
31361,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
12159,
11,
34236,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
31361,
11,
277,
28483,
2611,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
262,
8326,
11,
2071,
796,
28178,
62,
2363,
415,
62,
9662,
7,
31361,
11,
34236,
11,
277,
31361,
11,
277,
28483,
2611,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
277,
1169,
8326,
796,
277,
7,
1169,
8326,
1776,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
220,
220,
220,
220,
611,
1051,
7,
701,
3202,
64,
8,
1635,
1051,
7,
69,
31361,
8,
1279,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
12159,
11,
262,
8326,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
31361,
11,
277,
1169,
8326,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4808,
5143,
62,
41907,
3213,
7,
9501,
11,
267,
11,
3689,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1303,
4054,
284,
2987,
198,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
267,
13,
20500,
796,
366,
32165,
495,
284,
2987,
1,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
29113,
14468,
2235,
198,
198,
2235,
1882,
415,
198,
2235,
3740,
1378,
268,
13,
31266,
13,
2398,
14,
15466,
14,
6558,
415,
62,
24396,
198,
8818,
4296,
62,
5219,
7,
24396,
3712,
6558,
415,
11,
43458,
11,
267,
3712,
3118,
42524,
28667,
9012,
90,
51,
5512,
3689,
3712,
3118,
42524,
28667,
29046,
90,
51,
30072,
810,
1391,
51,
1279,
25,
27741,
43879,
92,
628,
220,
220,
220,
753,
20214,
7,
78,
8,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
7,
78,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
11,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
8,
198,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
28532,
452,
876,
40874,
550,
2428,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
267,
13,
87,
77,
15,
796,
267,
13,
87,
77,
16,
198,
220,
220,
220,
267,
13,
21373,
77,
15,
796,
267,
13,
21373,
77,
16,
628,
220,
220,
220,
267,
13,
87,
77,
16,
796,
267,
13,
87,
77,
16,
532,
220,
267,
13,
21373,
77,
16,
1220,
277,
79,
198,
220,
220,
220,
1303,
220,
220,
220,
267,
13,
21373,
77,
16,
796,
43458,
13,
69,
7,
78,
13,
87,
77,
16,
8,
198,
220,
220,
220,
267,
13,
21373,
77,
16,
796,
43458,
7,
78,
13,
87,
77,
16,
8,
220,
220,
220,
220,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
2147,
198,
437,
198,
198,
37811,
628,
220,
220,
220,
792,
415,
62,
24396,
7,
69,
11,
2124,
15,
11,
2124,
16,
26,
685,
46265,
22046,
986,
12962,
198,
220,
220,
220,
220,
198,
50,
6442,
329,
6632,
286,
4600,
69,
7,
87,
8,
796,
657,
63,
1262,
262,
792,
415,
2446,
13,
198,
198,
3673,
29050,
13,
220,
5765,
4600,
19796,
62,
22570,
63,
351,
4600,
18743,
16,
3419,
44646,
220,
220,
220,
220,
198,
37811,
198,
2363,
415,
62,
24396,
7,
69,
11,
2124,
15,
3712,
15633,
11,
2124,
16,
3712,
15633,
26,
479,
86,
22046,
23029,
796,
1064,
62,
22570,
7,
69,
11,
3975,
7,
22468,
11,
685,
87,
15,
11,
87,
16,
46570,
8284,
16,
9783,
479,
86,
22046,
23029,
628,
198,
29113,
14468,
2235,
198,
198,
21017,
2441,
487,
18756,
198,
2235,
3740,
1378,
268,
13,
31266,
13,
2398,
14,
15466,
14,
7447,
487,
18756,
338,
62,
24396,
2,
26437,
62,
11213,
198,
76,
18187,
2878,
2441,
487,
18756,
1279,
25,
791,
42524,
28667,
17410,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
8284,
17,
3419,
198,
198,
464,
15094,
81,
4142,
6718,
2667,
198,
58,
7447,
487,
18756,
16151,
5450,
1378,
268,
13,
31266,
13,
2398,
14,
15466,
14,
7447,
487,
18756,
338,
62,
24396,
2,
26437,
62,
11213,
8,
198,
24396,
318,
973,
329,
262,
27255,
1479,
4600,
18743,
17,
3419,
63,
11862,
13,
12101,
198,
1169,
15094,
81,
4142,
6718,
2667,
17321,
338,
2446,
11,
645,
27255,
318,
198,
49986,
11,
996,
588,
17321,
338,
2446,
11,
734,
2163,
3848,
583,
2239,
198,
533,
13,
770,
11862,
318,
517,
8564,
621,
17321,
338,
2446,
284,
3595,
198,
36733,
44774,
13,
198,
198,
37811,
220,
220,
220,
220,
198,
9979,
8284,
17,
796,
2441,
487,
18756,
198,
198,
8818,
4296,
62,
5219,
7,
24396,
3712,
7447,
487,
18756,
11,
43458,
11,
267,
3712,
3118,
42524,
28667,
9012,
90,
51,
5512,
3689,
3712,
3118,
42524,
28667,
29046,
90,
51,
30072,
810,
1391,
51,
1279,
25,
27741,
43879,
92,
628,
220,
220,
220,
311,
796,
1288,
4906,
7,
78,
13,
21373,
77,
16,
8,
628,
220,
220,
220,
753,
20214,
7,
78,
8,
628,
220,
220,
220,
266,
77,
796,
267,
13,
87,
77,
16,
1343,
2876,
487,
62,
9662,
7,
78,
13,
87,
77,
16,
11,
267,
13,
21373,
77,
16,
2599,
25,
51,
198,
220,
220,
220,
277,
675,
796,
43458,
7,
675,
2599,
25,
50,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
7,
78,
13,
87,
77,
16,
11,
266,
77,
11,
267,
13,
21373,
77,
16,
11,
277,
675,
8,
628,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
28532,
452,
876,
40874,
550,
2428,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
267,
13,
87,
77,
15,
796,
267,
13,
87,
77,
16,
198,
220,
220,
220,
267,
13,
21373,
77,
15,
796,
267,
13,
21373,
77,
16,
198,
220,
220,
220,
267,
13,
87,
77,
16,
796,
267,
13,
87,
77,
16,
532,
267,
13,
21373,
77,
16,
1220,
277,
79,
1303,
87,
77,
16,
198,
220,
220,
220,
267,
13,
21373,
77,
16,
796,
43458,
7,
78,
13,
87,
77,
16,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
198,
220,
220,
220,
2147,
198,
437,
198,
198,
4169,
487,
19069,
7,
69,
11,
2124,
15,
26,
479,
86,
22046,
23029,
796,
1064,
62,
22570,
7,
69,
11,
2124,
15,
11,
2441,
487,
18756,
9783,
479,
86,
22046,
23029,
198,
198,
29113,
14468,
2235,
628,
198,
37811,
198,
220,
220,
220,
8284,
20,
3419,
198,
198,
3546,
1154,
902,
281,
11862,
198,
6738,
1635,
32,
968,
19383,
8284,
9626,
452,
876,
3232,
17321,
12,
6030,
11789,
329,
4294,
1075,
8504,
29127,
7889,
602,
9,
198,
1525,
1279,
20608,
22330,
1279,
20608,
22330,
290,
9084,
2283,
3099,
11,
198,
4677,
75,
13,
16320,
13,
4806,
13,
10286,
13,
860,
11,
1400,
13,
513,
11,
6640,
22,
12,
1314,
1485,
357,
4626,
737,
6675,
2163,
3848,
583,
2239,
389,
2622,
13,
198,
198,
37811,
220,
220,
220,
220,
198,
76,
18187,
2878,
8284,
20,
1279,
25,
791,
42524,
28667,
17410,
886,
198,
198,
8818,
4296,
62,
5219,
7,
24396,
3712,
18743,
20,
11,
43458,
11,
267,
3712,
3118,
42524,
28667,
9012,
90,
51,
5512,
3689,
3712,
3118,
42524,
28667,
29046,
8,
810,
1391,
51,
92,
628,
220,
220,
220,
2124,
77,
796,
267,
13,
87,
77,
16,
198,
220,
220,
220,
277,
87,
77,
796,
267,
13,
21373,
77,
16,
198,
220,
220,
220,
311,
796,
1288,
4906,
7,
78,
13,
21373,
77,
16,
8,
628,
220,
220,
220,
753,
20214,
7,
78,
8,
628,
220,
220,
220,
266,
77,
3712,
51,
796,
267,
13,
87,
77,
16,
1343,
2876,
487,
62,
9662,
7,
78,
13,
87,
77,
16,
11,
267,
13,
21373,
77,
16,
8,
198,
220,
220,
220,
277,
675,
796,
43458,
7,
675,
2599,
25,
50,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
7,
78,
13,
87,
77,
16,
11,
266,
77,
11,
267,
13,
21373,
77,
16,
11,
277,
675,
8,
198,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
267,
13,
87,
77,
16,
11,
266,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
267,
13,
21373,
77,
16,
11,
277,
675,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
45147,
351,
9086,
3580,
277,
58,
87,
77,
11,
266,
77,
30866,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
220,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
331,
77,
3712,
51,
796,
267,
13,
87,
77,
16,
532,
267,
13,
21373,
77,
16,
1220,
277,
79,
198,
220,
220,
220,
277,
2047,
796,
43458,
7,
2047,
2599,
25,
50,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
198,
220,
220,
220,
1976,
77,
3712,
51,
796,
2124,
77,
532,
357,
21373,
77,
1343,
277,
2047,
8,
1220,
277,
79,
198,
220,
220,
220,
277,
47347,
796,
43458,
7,
47347,
2599,
25,
50,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
62,
10366,
952,
7,
2047,
11,
267,
13,
87,
77,
16,
11,
266,
77,
11,
277,
2047,
11,
267,
13,
21373,
77,
16,
11,
277,
675,
8,
198,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
267,
13,
87,
77,
16,
11,
331,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
267,
13,
21373,
77,
16,
11,
277,
2047,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
45147,
351,
277,
58,
87,
77,
11,
2047,
60,
9,
69,
58,
2047,
11,
675,
60,
1220,
277,
58,
87,
77,
11,
266,
77,
30866,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
267,
13,
87,
77,
15,
796,
267,
13,
87,
77,
16,
198,
220,
220,
220,
267,
13,
21373,
77,
15,
796,
267,
13,
21373,
77,
16,
198,
220,
220,
220,
267,
13,
87,
77,
16,
796,
1976,
77,
220,
532,
277,
47347,
220,
1220,
277,
79,
198,
220,
220,
220,
267,
13,
21373,
77,
16,
796,
43458,
7,
78,
13,
87,
77,
16,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
2147,
198,
437,
198,
198,
2235,
1002,
356,
423,
257,
27255,
198,
8818,
4296,
62,
5219,
7,
24396,
3712,
18743,
20,
11,
43458,
3712,
5962,
28532,
452,
876,
11,
267,
3712,
3118,
42524,
28667,
9012,
90,
51,
5512,
3689,
3712,
3118,
42524,
28667,
29046,
8,
810,
1391,
51,
92,
628,
198,
220,
220,
220,
2124,
77,
11,
277,
87,
77,
796,
267,
13,
87,
77,
16,
11,
267,
13,
21373,
77,
16,
198,
220,
220,
220,
311,
796,
1288,
4906,
7,
21373,
77,
8,
628,
220,
220,
220,
753,
20214,
7,
78,
8,
628,
220,
220,
220,
277,
8416,
77,
796,
43458,
13,
46428,
7,
87,
77,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
611,
318,
21949,
7,
69,
8416,
77,
8,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
220,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
331,
77,
796,
2124,
77,
532,
277,
87,
77,
1220,
277,
8416,
77,
198,
220,
220,
220,
277,
2047,
11,
277,
79,
2047,
796,
43458,
13,
69,
7,
2047,
828,
43458,
13,
46428,
7,
2047,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
11,
362,
8,
628,
220,
220,
220,
611,
318,
21949,
7,
46428,
2047,
8,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
2124,
77,
11,
331,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
2047,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
220,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
198,
220,
220,
220,
1976,
77,
796,
2124,
77,
220,
532,
357,
21373,
77,
1343,
277,
2047,
8,
1220,
277,
8416,
77,
198,
220,
220,
220,
277,
47347,
796,
43458,
13,
69,
7,
47347,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
11,
352,
8,
628,
220,
220,
220,
2124,
77,
16,
796,
1976,
77,
532,
277,
47347,
1220,
277,
79,
2047,
198,
220,
220,
220,
277,
87,
77,
16,
796,
43458,
13,
69,
7,
87,
77,
16,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
11,
352,
8,
628,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
2124,
77,
11,
2124,
77,
16,
198,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
87,
77,
16,
628,
220,
220,
220,
2147,
198,
437,
628,
198,
29113,
14468,
2235,
628,
198,
198,
37811,
198,
220,
220,
220,
8284,
23,
3419,
198,
198,
3546,
1154,
902,
281,
11862,
422,
220,
198,
9,
3791,
41040,
12,
18743,
9626,
452,
876,
12,
11146,
25458,
329,
4294,
1075,
8504,
29127,
7889,
602,
9,
198,
1525,
1279,
20608,
22330,
198,
24274,
4913,
286,
39448,
290,
30535,
605,
13473,
198,
31715,
2321,
357,
6999,
828,
10172,
4522,
5125,
27712,
21,
11,
1105,
5468,
13,
6675,
2163,
3848,
583,
2239,
389,
2672,
13,
198,
37811,
198,
76,
18187,
2878,
8284,
23,
1279,
25,
791,
42524,
28667,
17410,
198,
437,
198,
198,
8818,
4296,
62,
5219,
7,
24396,
3712,
18743,
23,
11,
43458,
11,
267,
3712,
3118,
42524,
28667,
9012,
90,
51,
5512,
3689,
3712,
3118,
42524,
28667,
29046,
8,
810,
1391,
51,
92,
198,
220,
220,
220,
2124,
77,
796,
267,
13,
87,
77,
16,
198,
220,
220,
220,
277,
87,
77,
796,
267,
13,
21373,
77,
16,
198,
220,
220,
220,
311,
796,
1288,
4906,
7,
21373,
77,
8,
628,
220,
220,
220,
753,
20214,
7,
78,
8,
628,
220,
220,
220,
266,
77,
3712,
51,
796,
2124,
77,
1343,
2876,
487,
62,
9662,
7,
87,
77,
11,
277,
87,
77,
8,
198,
220,
220,
220,
277,
675,
3712,
50,
796,
43458,
7,
675,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
611,
318,
21949,
7,
69,
675,
8,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
78,
13,
87,
77,
16,
796,
2124,
77,
11,
266,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
78,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
675,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
21949,
351,
2441,
487,
18756,
2239,
277,
675,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
7,
87,
77,
11,
266,
77,
11,
277,
87,
77,
11,
277,
675,
8,
198,
220,
220,
220,
2071,
11405,
1441,
357,
87,
77,
11,
2081,
8,
628,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
21949,
351,
9086,
3580,
277,
58,
87,
77,
11,
266,
77,
30866,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
331,
77,
3712,
51,
796,
2124,
77,
532,
277,
87,
77,
1220,
277,
79,
198,
220,
220,
220,
277,
2047,
3712,
50,
796,
43458,
7,
2047,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
7,
2047,
11,
2124,
77,
11,
277,
2047,
11,
277,
87,
77,
8,
198,
220,
220,
220,
611,
2071,
1303,
46428,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
78,
13,
87,
77,
16,
796,
2124,
77,
11,
331,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
78,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
2047,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
21949,
351,
9086,
3580,
277,
58,
87,
77,
11,
331,
77,
30866,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
198,
220,
220,
220,
872,
72,
796,
357,
16,
1343,
277,
2047,
1220,
277,
675,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2298,
530,
286,
3689,
198,
220,
220,
220,
1976,
77,
796,
220,
331,
77,
532,
872,
72,
1635,
277,
2047,
1220,
277,
79,
198,
220,
220,
220,
277,
47347,
3712,
50,
796,
43458,
7,
47347,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
220,
4808,
69,
1671,
8317,
62,
26069,
7,
87,
77,
11,
331,
77,
11,
1976,
77,
11,
277,
87,
77,
11,
277,
2047,
11,
277,
47347,
8,
198,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
78,
13,
87,
77,
16,
796,
2124,
77,
11,
1976,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
78,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
47347,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
21949,
351,
9086,
3580,
220,
277,
58,
88,
11,
89,
60,
532,
277,
58,
87,
11,
88,
60,
1343,
277,
58,
87,
11,
89,
30866,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
266,
3712,
51,
796,
352,
1220,
357,
16,
532,
277,
47347,
14,
69,
675,
8,
628,
220,
220,
220,
2124,
72,
3712,
51,
796,
357,
16,
532,
362,
69,
2047,
9,
69,
2047,
9,
69,
2047,
1220,
357,
69,
675,
1635,
277,
675,
1635,
277,
87,
77,
4008,
628,
220,
220,
220,
2124,
77,
16,
3712,
51,
796,
1976,
77,
532,
266,
1635,
2124,
72,
1635,
277,
47347,
1220,
277,
79,
198,
220,
220,
220,
277,
87,
77,
16,
3712,
50,
796,
43458,
7,
87,
77,
16,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
267,
13,
87,
77,
15,
11,
78,
13,
87,
77,
16,
796,
2124,
77,
11,
2124,
77,
16,
198,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
78,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
87,
77,
16,
628,
220,
220,
220,
2147,
198,
437,
198,
198,
29113,
14468,
2235,
198,
198,
37811,
198,
220,
220,
220,
8284,
1433,
3419,
198,
198,
3546,
26908,
262,
11862,
422,
198,
9,
3791,
9699,
20283,
12,
18743,
9626,
452,
876,
12,
11146,
25458,
329,
4294,
1075,
8504,
29127,
7889,
602,
9,
198,
1525,
1279,
20608,
22330,
220,
198,
7437,
4913,
286,
22476,
864,
290,
27684,
39448,
198,
79,
12,
1797,
15571,
25,
362,
20986,
12,
4531,
2327,
26,
220,
220,
220,
304,
12,
1797,
15571,
25,
362,
20986,
12,
4531,
3559,
26,
2321,
26,
220,
362,
7,
18,
2599,
13539,
12,
16817,
198,
34023,
25,
838,
13,
3270,
1954,
14,
73,
13,
1228,
20991,
13,
1264,
1238,
22416,
13,
2919,
13,
198,
198,
20029,
2163,
3848,
583,
2239,
389,
2672,
13,
7486,
8902,
6718,
2667,
11,
428,
2446,
4143,
2125,
470,
5443,
357,
32146,
263,
198,
8818,
3848,
14,
20214,
8,
625,
584,
5050,
618,
1262,
4600,
43879,
2414,
63,
3815,
11,
198,
4360,
743,
307,
4465,
329,
18120,
625,
4600,
12804,
43879,
44646,
198,
37811,
198,
76,
18187,
2878,
8284,
1433,
1279,
25,
791,
42524,
28667,
17410,
198,
437,
198,
198,
8818,
4296,
62,
5219,
7,
24396,
3712,
18743,
1433,
11,
43458,
11,
267,
3712,
3118,
42524,
28667,
9012,
90,
51,
5512,
3689,
3712,
3118,
42524,
28667,
29046,
8,
810,
1391,
51,
92,
198,
220,
220,
220,
2124,
77,
796,
267,
13,
87,
77,
16,
198,
220,
220,
220,
277,
87,
77,
796,
267,
13,
21373,
77,
16,
198,
220,
220,
220,
311,
796,
1288,
4906,
7,
21373,
77,
8,
628,
220,
220,
220,
753,
20214,
7,
78,
8,
628,
220,
220,
220,
266,
77,
3712,
51,
796,
2124,
77,
1343,
2876,
487,
62,
9662,
7,
87,
77,
11,
277,
87,
77,
8,
198,
220,
220,
220,
277,
675,
3712,
50,
796,
43458,
7,
675,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
7,
87,
77,
11,
266,
77,
11,
277,
87,
77,
11,
277,
675,
8,
628,
220,
220,
198,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
2124,
77,
11,
266,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
675,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
21949,
351,
277,
58,
87,
77,
11,
675,
30866,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
331,
77,
3712,
51,
796,
2124,
77,
532,
277,
87,
77,
1220,
277,
79,
198,
220,
220,
220,
277,
2047,
3712,
50,
796,
43458,
7,
2047,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
62,
10366,
952,
7,
2047,
11,
2124,
77,
11,
266,
77,
11,
277,
2047,
11,
277,
87,
77,
11,
277,
675,
8,
198,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
2124,
77,
11,
331,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
2047,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
21949,
351,
277,
58,
87,
77,
11,
2047,
60,
9,
69,
58,
2047,
11,
675,
60,
14,
69,
58,
87,
77,
11,
675,
30866,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
628,
220,
220,
220,
1976,
77,
3712,
51,
796,
331,
77,
532,
277,
2047,
1220,
277,
79,
198,
220,
220,
220,
277,
47347,
3712,
50,
796,
43458,
7,
47347,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
62,
26069,
7,
87,
77,
11,
331,
77,
11,
1976,
77,
11,
277,
87,
77,
11,
277,
2047,
11,
277,
47347,
8,
198,
220,
220,
220,
334,
17,
11,
334,
18,
11,
334,
19,
796,
277,
47347,
14,
69,
675,
11,
277,
2047,
14,
21373,
77,
11,
277,
2047,
14,
69,
675,
198,
220,
220,
220,
2123,
64,
796,
352,
1220,
357,
16,
1343,
362,
9,
84,
18,
9,
84,
19,
61,
17,
8,
1220,
357,
16,
532,
334,
17,
8,
198,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
2124,
77,
11,
1976,
77,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
47347,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
4677,
13907,
1920,
27255,
4054,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
281,
796,
1976,
77,
532,
2123,
64,
1635,
277,
47347,
1220,
277,
79,
198,
220,
220,
220,
4336,
796,
43458,
7,
272,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
277,
79,
11,
2071,
796,
4808,
69,
1671,
8317,
62,
10366,
952,
7,
272,
11,
331,
77,
11,
1976,
77,
11,
4336,
11,
277,
2047,
11,
277,
47347,
8,
198,
220,
220,
220,
611,
2071,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
2124,
77,
11,
281,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
4336,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
301,
38333,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
267,
13,
20500,
796,
366,
4677,
13907,
1920,
27255,
4054,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
886,
628,
220,
220,
220,
334,
16,
11,
334,
20,
11,
334,
21,
796,
277,
47347,
14,
21373,
77,
11,
4336,
14,
21373,
77,
11,
4336,
14,
69,
675,
198,
220,
220,
220,
264,
13495,
796,
220,
352,
1343,
334,
16,
9,
84,
17,
532,
334,
16,
9,
84,
18,
9,
84,
19,
61,
17,
1343,
334,
20,
1343,
334,
21,
1343,
334,
16,
61,
17,
9,
84,
19,
1343,
198,
220,
220,
220,
334,
17,
61,
17,
9,
84,
18,
1343,
513,
9,
84,
16,
9,
84,
19,
61,
17,
9,
7,
84,
18,
61,
17,
532,
334,
19,
61,
17,
20679,
62,
69,
1671,
8317,
7,
87,
77,
11,
2047,
11,
277,
87,
77,
11,
277,
2047,
38381,
16,
60,
628,
628,
220,
220,
220,
220,
628,
220,
220,
220,
2124,
77,
16,
796,
281,
532,
264,
13495,
1635,
4336,
1220,
277,
79,
198,
220,
220,
220,
277,
87,
77,
16,
796,
43458,
7,
87,
77,
16,
8,
198,
220,
220,
220,
753,
22184,
7,
78,
8,
628,
220,
220,
220,
267,
13,
87,
77,
15,
11,
267,
13,
87,
77,
16,
796,
2124,
77,
11,
2124,
77,
16,
198,
220,
220,
220,
267,
13,
21373,
77,
15,
11,
267,
13,
21373,
77,
16,
796,
277,
87,
77,
11,
277,
87,
77,
16,
628,
220,
220,
220,
2147,
198,
437,
628,
198
] | 2.073545 | 7,560 |
<filename>Experiment 07/partical_reflux.jl
## 调包
using CurveFit
using CSV
using Interpolations
using PyCall
using PyPlot
using DataFrames
## 调 python 包
@pyimport numpy as np
pygui(true)
## 原始数据
"""
原始数据输入
(进料组成, 塔顶产品组成, 塔釜组成) 的质量分数 (ω_f, ω_d, ω_w)
进料温度 t_f
回流流量 L
产品流量 D
"""
# (进料组成, 塔顶产品组成, 塔釜组成) 的质量分数
ω_f = 16.2419e-2
ω_d = 89.8466e-2
ω_w = 6.0228e-2
# 进料温度 / C
t_f = 33.9
# 回流流量 / (L * h ^ -1)
L = 3.6
# 产品流量 / (L * h ^ -1)
D = 1.5
# 质量分数 -> 摩尔分数 换算函数
f(ω_i) = (ω_i / 46.07) / (ω_i / 46.07 + (1 - ω_i) / 18.02)
# (进料组成, 塔顶产品组成, 塔釜组成) 摩尔分数
x_f = f(ω_f)
x_d = f(ω_d)
x_w = f(ω_w)
## 对角线
x = y = np.linspace(0, 1)
## 平衡线
# EtOH-H2O 相平衡数据
EtOH = CSV.read("EtOH-H2O.csv", DataFrame)
# EtOH-H2O 相平衡组成插值
interp_y = Interpolations.LinearInterpolation(EtOH.x, EtOH.y)
# 相平衡线
yy = interp_y(x)
## 精馏段操作线
R = L / D
f_r(x) = (R * x + x_d) / (R + 1)
## q 线
# 泡点温度插值
interp_t = Interpolations.LinearInterpolation(EtOH.x, EtOH.t)
# 泡点温度
t_s = interp_t(x_f)
# 乙醇摩尔热容
c_pm_EtOH(t) = (1.56 * 10e-2 * t + 2.012) * 46.07
# 水摩尔热容
c_pm_H2O(t) = (2.143 * 10e-4 * t + 4.198) * 18.02
# 溶液热容 / (kJ * kmol ^ -1 * C ^ -1)
t_m = (t_f + t_s) / 2
c_pm = x_f * c_pm_EtOH(t_m) + (1 - x_f) * c_pm_H2O(t_m)
# 乙醇摩尔气化潜热
r_m_EtOH(t) = 113 * (243 - t) ^ 0.4218 * 46.07
# 水的摩尔气化潜热
r_m_H2O(t) = 445.6 * (374 - t) ^ 0.3003 * 18.02
# 溶液气化潜热 / (kJ * kmol ^ -1)
r_m = x_f * r_m_EtOH(t_f) + (1 - x_f) * r_m_EtOH(t_f)
# q 值
q = 1 + c_pm * (t_s - t_f) / r_m
# q 线方程
f_q(x) = (q * x - x_f) / (q - 1)
## 交点
# 精馏段操作线和对角线交点
point_a = [x_d, x_d]
# 提馏段操作线和对角线的交点
point_b = [x_w, x_w]
# 精馏段操作线和 y 轴的交点
point_c = [0, f_r(0)]
# q 线和精馏段操作线的交点
point_d = [((R + 1) * x_f + (q - 1) * x_d) / (R + q), (R * x_f + q * x_d) / (R + q)]
# q 线和对角线的交点
point_f = [x_f, x_f]
## 提馏段操作线方程
p_d = CurveFit.linear_fit([point_b[1], point_d[1]], [point_b[2], point_d[2]])
f_d(x) = p_d[1] + p_d[2] * x
## 绘图
# 对角线
PyPlot.plot(x, y, "-")
# 相平衡线
PyPlot.plot(x, yy, "-")
# 精馏段操作线 a-c
PyPlot.plot([point_a[1], point_c[1]], [point_a[2], point_c[2]], "-")
# q 线 d-f
PyPlot.plot([point_d[1], point_f[1]], [point_d[2], point_f[2]], "-")
# 提馏段操作线 b-d
PyPlot.plot([point_b[1], point_d[1]], [point_b[2], point_d[2]], "-")
# x_w 垂直线
PyPlot.plot([x_w, x_w], [0, x_w], "b-")
# x_d 垂直线
PyPlot.plot([x_d, x_d], [0, x_d], "b-")
# x_f 垂直线
PyPlot.plot([x_f, x_f], [0, x_f], "b-")
# 绘图设置
PyPlot.xlabel("\$ x \$")
PyPlot.ylabel("\$ y \$")
PyPlot.xlim([0, 1])
PyPlot.ylim([0, 1])
## 塔板数计算
# 迭代点
point_1 = [x_d, x_d]
point_2 = zeros(2)
# 塔板数
num = 0
# 迭代记数
n = 1
# 迭代计算 & 绘图
println("开始迭代")
while true
global point_1, point_2, num, n
if point_1[1] < x_w
break
end
println("迭代第 $(n) 次")
n += 1
for x_i in np.linspace(0, 1, 10000000)
if abs(interp_y(x_i) - point_1[2]) < 0.00001 * point_1[2]
point_temp = [x_i, point_1[2]]
point_2 = zeros(2)
if point_d[1] < x_i
# 在精馏段操作线上
point_2 = [x_i, f_r(x_i)]
elseif point_b[1] < x_i < point_d[1]
# 在提馏段操作线上
point_2 = [x_i, f_d(x_i)]
elseif x_i < point_b[1]
# 在对角线上
point_2 = [x_i, x_i]
end
num += 1
PyPlot.plot([point_1[1], point_temp[1]], [point_1[2], point_temp[2]], "b-")
PyPlot.plot([point_2[1], point_temp[1]], [point_2[2], point_temp[2]], "b-")
# 迭代后新点
point_1 = point_2
point_2 = zeros(2)
break
end
end
end
# 理论塔板数结果
println("理论塔板数 = $(num)")
| [
27,
34345,
29,
20468,
3681,
8753,
14,
3911,
605,
62,
5420,
22564,
13,
20362,
198,
2235,
5525,
108,
225,
44293,
227,
198,
3500,
46300,
31805,
198,
3500,
44189,
198,
3500,
4225,
16104,
602,
198,
3500,
9485,
14134,
198,
3500,
9485,
43328,
198,
3500,
6060,
35439,
198,
198,
2235,
5525,
108,
225,
21015,
10263,
234,
227,
198,
31,
9078,
11748,
299,
32152,
355,
45941,
198,
9078,
48317,
7,
7942,
8,
198,
198,
2235,
10263,
236,
253,
34650,
233,
46763,
108,
162,
235,
106,
198,
37811,
198,
43889,
253,
34650,
233,
46763,
108,
162,
235,
106,
164,
122,
241,
17739,
98,
198,
7,
32573,
249,
23877,
247,
163,
119,
226,
22755,
238,
11,
10263,
94,
242,
165,
94,
114,
12859,
100,
161,
241,
223,
163,
119,
226,
22755,
238,
11,
10263,
94,
242,
34932,
250,
163,
119,
226,
22755,
238,
8,
13328,
248,
226,
164,
112,
101,
34932,
237,
26344,
228,
46763,
108,
357,
49535,
62,
69,
11,
18074,
231,
62,
67,
11,
18074,
231,
62,
86,
8,
198,
32573,
249,
23877,
247,
162,
116,
102,
41753,
99,
256,
62,
69,
198,
32368,
252,
38184,
223,
38184,
223,
34932,
237,
406,
198,
12859,
100,
161,
241,
223,
38184,
223,
34932,
237,
360,
198,
37811,
198,
198,
2,
357,
32573,
249,
23877,
247,
163,
119,
226,
22755,
238,
11,
10263,
94,
242,
165,
94,
114,
12859,
100,
161,
241,
223,
163,
119,
226,
22755,
238,
11,
10263,
94,
242,
34932,
250,
163,
119,
226,
22755,
238,
8,
13328,
248,
226,
164,
112,
101,
34932,
237,
26344,
228,
46763,
108,
198,
49535,
62,
69,
796,
1467,
13,
1731,
1129,
68,
12,
17,
198,
49535,
62,
67,
796,
9919,
13,
5705,
2791,
68,
12,
17,
198,
49535,
62,
86,
796,
718,
13,
15,
23815,
68,
12,
17,
198,
198,
2,
5525,
123,
249,
23877,
247,
162,
116,
102,
41753,
99,
1220,
327,
198,
83,
62,
69,
796,
4747,
13,
24,
198,
198,
2,
10263,
249,
252,
38184,
223,
38184,
223,
34932,
237,
1220,
357,
43,
1635,
289,
10563,
532,
16,
8,
198,
43,
796,
513,
13,
21,
198,
2,
220,
12859,
100,
161,
241,
223,
38184,
223,
34932,
237,
1220,
357,
43,
1635,
289,
10563,
532,
16,
8,
198,
35,
796,
352,
13,
20,
198,
198,
2,
5525,
112,
101,
34932,
237,
26344,
228,
46763,
108,
4613,
10545,
239,
102,
22887,
242,
26344,
228,
46763,
108,
10545,
235,
95,
163,
106,
245,
49035,
121,
46763,
108,
198,
69,
7,
49535,
62,
72,
8,
796,
357,
49535,
62,
72,
1220,
6337,
13,
2998,
8,
1220,
357,
49535,
62,
72,
1220,
6337,
13,
2998,
1343,
357,
16,
532,
18074,
231,
62,
72,
8,
1220,
1248,
13,
2999,
8,
198,
198,
2,
357,
32573,
249,
23877,
247,
163,
119,
226,
22755,
238,
11,
10263,
94,
242,
165,
94,
114,
12859,
100,
161,
241,
223,
163,
119,
226,
22755,
238,
11,
10263,
94,
242,
34932,
250,
163,
119,
226,
22755,
238,
8,
10545,
239,
102,
22887,
242,
26344,
228,
46763,
108,
198,
87,
62,
69,
796,
277,
7,
49535,
62,
69,
8,
198,
87,
62,
67,
796,
277,
7,
49535,
62,
67,
8,
198,
87,
62,
86,
796,
277,
7,
49535,
62,
86,
8,
198,
198,
2235,
10263,
107,
117,
164,
100,
240,
163,
118,
123,
198,
87,
796,
331,
796,
45941,
13,
21602,
10223,
7,
15,
11,
352,
8,
198,
198,
2235,
10263,
117,
111,
26193,
94,
163,
118,
123,
198,
2,
17906,
12096,
12,
39,
17,
46,
13328,
249,
116,
33176,
111,
26193,
94,
46763,
108,
162,
235,
106,
198,
36,
83,
12096,
796,
44189,
13,
961,
7203,
36,
83,
12096,
12,
39,
17,
46,
13,
40664,
1600,
6060,
19778,
8,
198,
2,
17906,
12096,
12,
39,
17,
46,
13328,
249,
116,
33176,
111,
26193,
94,
163,
119,
226,
22755,
238,
162,
237,
240,
161,
222,
120,
198,
3849,
79,
62,
88,
796,
4225,
16104,
602,
13,
14993,
451,
9492,
16104,
341,
7,
36,
83,
12096,
13,
87,
11,
17906,
12096,
13,
88,
8,
198,
2,
13328,
249,
116,
33176,
111,
26193,
94,
163,
118,
123,
198,
22556,
796,
987,
79,
62,
88,
7,
87,
8,
198,
198,
2235,
13328,
39333,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
198,
49,
796,
406,
1220,
360,
198,
69,
62,
81,
7,
87,
8,
796,
357,
49,
1635,
2124,
1343,
2124,
62,
67,
8,
1220,
357,
49,
1343,
352,
8,
198,
198,
2235,
10662,
13328,
118,
123,
198,
2,
10545,
111,
94,
163,
224,
117,
162,
116,
102,
41753,
99,
162,
237,
240,
161,
222,
120,
198,
3849,
79,
62,
83,
796,
4225,
16104,
602,
13,
14993,
451,
9492,
16104,
341,
7,
36,
83,
12096,
13,
87,
11,
17906,
12096,
13,
83,
8,
198,
2,
10545,
111,
94,
163,
224,
117,
162,
116,
102,
41753,
99,
198,
83,
62,
82,
796,
987,
79,
62,
83,
7,
87,
62,
69,
8,
198,
198,
2,
220,
20046,
247,
165,
228,
229,
162,
239,
102,
22887,
242,
163,
225,
255,
22522,
117,
198,
66,
62,
4426,
62,
36,
83,
12096,
7,
83,
8,
796,
357,
16,
13,
3980,
1635,
838,
68,
12,
17,
1635,
256,
1343,
362,
13,
30206,
8,
1635,
6337,
13,
2998,
198,
2,
10545,
108,
112,
162,
239,
102,
22887,
242,
163,
225,
255,
22522,
117,
198,
66,
62,
4426,
62,
39,
17,
46,
7,
83,
8,
796,
357,
17,
13,
21139,
1635,
838,
68,
12,
19,
1635,
256,
1343,
604,
13,
22337,
8,
1635,
1248,
13,
2999,
198,
2,
10545,
118,
35050,
114,
110,
163,
225,
255,
22522,
117,
1220,
357,
74,
41,
1635,
10571,
349,
10563,
532,
16,
1635,
327,
10563,
532,
16,
8,
198,
83,
62,
76,
796,
357,
83,
62,
69,
1343,
256,
62,
82,
8,
1220,
362,
198,
66,
62,
4426,
796,
2124,
62,
69,
1635,
269,
62,
4426,
62,
36,
83,
12096,
7,
83,
62,
76,
8,
1343,
357,
16,
532,
2124,
62,
69,
8,
1635,
269,
62,
4426,
62,
39,
17,
46,
7,
83,
62,
76,
8,
198,
198,
2,
220,
20046,
247,
165,
228,
229,
162,
239,
102,
22887,
242,
36365,
242,
44293,
244,
162,
121,
250,
163,
225,
255,
198,
81,
62,
76,
62,
36,
83,
12096,
7,
83,
8,
796,
17318,
1635,
357,
26660,
532,
256,
8,
10563,
657,
13,
3682,
1507,
1635,
6337,
13,
2998,
198,
2,
10545,
108,
112,
21410,
162,
239,
102,
22887,
242,
36365,
242,
44293,
244,
162,
121,
250,
163,
225,
255,
198,
81,
62,
76,
62,
39,
17,
46,
7,
83,
8,
796,
48655,
13,
21,
1635,
357,
31020,
532,
256,
8,
10563,
657,
13,
6200,
18,
1635,
1248,
13,
2999,
198,
2,
10545,
118,
35050,
114,
110,
36365,
242,
44293,
244,
162,
121,
250,
163,
225,
255,
1220,
357,
74,
41,
1635,
10571,
349,
10563,
532,
16,
8,
198,
81,
62,
76,
796,
2124,
62,
69,
1635,
374,
62,
76,
62,
36,
83,
12096,
7,
83,
62,
69,
8,
1343,
357,
16,
532,
2124,
62,
69,
8,
1635,
374,
62,
76,
62,
36,
83,
12096,
7,
83,
62,
69,
8,
198,
198,
2,
10662,
10263,
222,
120,
198,
80,
796,
352,
1343,
269,
62,
4426,
1635,
357,
83,
62,
82,
532,
256,
62,
69,
8,
1220,
374,
62,
76,
198,
198,
2,
10662,
13328,
118,
123,
43095,
163,
101,
233,
198,
69,
62,
80,
7,
87,
8,
796,
357,
80,
1635,
2124,
532,
2124,
62,
69,
8,
1220,
357,
80,
532,
352,
8,
198,
198,
2235,
220,
12859,
97,
163,
224,
117,
198,
2,
13328,
39333,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
161,
240,
234,
43380,
117,
164,
100,
240,
163,
118,
123,
12859,
97,
163,
224,
117,
198,
4122,
62,
64,
796,
685,
87,
62,
67,
11,
2124,
62,
67,
60,
198,
2,
10545,
237,
238,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
161,
240,
234,
43380,
117,
164,
100,
240,
163,
118,
123,
21410,
12859,
97,
163,
224,
117,
198,
4122,
62,
65,
796,
685,
87,
62,
86,
11,
2124,
62,
86,
60,
198,
2,
13328,
39333,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
161,
240,
234,
331,
5525,
121,
112,
21410,
12859,
97,
163,
224,
117,
198,
4122,
62,
66,
796,
685,
15,
11,
277,
62,
81,
7,
15,
15437,
198,
2,
10662,
13328,
118,
123,
161,
240,
234,
163,
39333,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
21410,
12859,
97,
163,
224,
117,
198,
4122,
62,
67,
796,
685,
19510,
49,
1343,
352,
8,
1635,
2124,
62,
69,
1343,
357,
80,
532,
352,
8,
1635,
2124,
62,
67,
8,
1220,
357,
49,
1343,
10662,
828,
357,
49,
1635,
2124,
62,
69,
1343,
10662,
1635,
2124,
62,
67,
8,
1220,
357,
49,
1343,
10662,
15437,
198,
2,
10662,
13328,
118,
123,
161,
240,
234,
43380,
117,
164,
100,
240,
163,
118,
123,
21410,
12859,
97,
163,
224,
117,
198,
4122,
62,
69,
796,
685,
87,
62,
69,
11,
2124,
62,
69,
60,
198,
198,
2235,
10545,
237,
238,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
43095,
163,
101,
233,
198,
79,
62,
67,
796,
46300,
31805,
13,
29127,
62,
11147,
26933,
4122,
62,
65,
58,
16,
4357,
966,
62,
67,
58,
16,
60,
4357,
685,
4122,
62,
65,
58,
17,
4357,
966,
62,
67,
58,
17,
11907,
8,
198,
69,
62,
67,
7,
87,
8,
796,
279,
62,
67,
58,
16,
60,
1343,
279,
62,
67,
58,
17,
60,
1635,
2124,
198,
198,
2235,
13328,
119,
246,
32368,
122,
198,
2,
10263,
107,
117,
164,
100,
240,
163,
118,
123,
198,
20519,
43328,
13,
29487,
7,
87,
11,
331,
11,
27444,
4943,
198,
2,
13328,
249,
116,
33176,
111,
26193,
94,
163,
118,
123,
198,
20519,
43328,
13,
29487,
7,
87,
11,
331,
88,
11,
27444,
4943,
198,
2,
13328,
39333,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
257,
12,
66,
198,
20519,
43328,
13,
29487,
26933,
4122,
62,
64,
58,
16,
4357,
966,
62,
66,
58,
16,
60,
4357,
685,
4122,
62,
64,
58,
17,
4357,
966,
62,
66,
58,
17,
60,
4357,
27444,
4943,
198,
2,
10662,
13328,
118,
123,
288,
12,
69,
198,
20519,
43328,
13,
29487,
26933,
4122,
62,
67,
58,
16,
4357,
966,
62,
69,
58,
16,
60,
4357,
685,
4122,
62,
67,
58,
17,
4357,
966,
62,
69,
58,
17,
60,
4357,
27444,
4943,
198,
2,
10545,
237,
238,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
275,
12,
67,
198,
20519,
43328,
13,
29487,
26933,
4122,
62,
65,
58,
16,
4357,
966,
62,
67,
58,
16,
60,
4357,
685,
4122,
62,
65,
58,
17,
4357,
966,
62,
67,
58,
17,
60,
4357,
27444,
4943,
198,
2,
2124,
62,
86,
10263,
252,
224,
33566,
112,
163,
118,
123,
198,
20519,
43328,
13,
29487,
26933,
87,
62,
86,
11,
2124,
62,
86,
4357,
685,
15,
11,
2124,
62,
86,
4357,
366,
65,
12,
4943,
198,
2,
2124,
62,
67,
10263,
252,
224,
33566,
112,
163,
118,
123,
198,
20519,
43328,
13,
29487,
26933,
87,
62,
67,
11,
2124,
62,
67,
4357,
685,
15,
11,
2124,
62,
67,
4357,
366,
65,
12,
4943,
198,
2,
2124,
62,
69,
10263,
252,
224,
33566,
112,
163,
118,
123,
198,
20519,
43328,
13,
29487,
26933,
87,
62,
69,
11,
2124,
62,
69,
4357,
685,
15,
11,
2124,
62,
69,
4357,
366,
65,
12,
4943,
198,
198,
2,
13328,
119,
246,
32368,
122,
164,
106,
122,
163,
121,
106,
198,
20519,
43328,
13,
87,
18242,
7203,
59,
3,
2124,
3467,
3,
4943,
198,
20519,
43328,
13,
2645,
9608,
7203,
59,
3,
331,
3467,
3,
4943,
198,
20519,
43328,
13,
87,
2475,
26933,
15,
11,
352,
12962,
198,
20519,
43328,
13,
88,
2475,
26933,
15,
11,
352,
12962,
198,
198,
2235,
10263,
94,
242,
30266,
123,
46763,
108,
164,
106,
94,
163,
106,
245,
198,
2,
5525,
123,
255,
47987,
163,
224,
117,
198,
4122,
62,
16,
796,
685,
87,
62,
67,
11,
2124,
62,
67,
60,
198,
4122,
62,
17,
796,
1976,
27498,
7,
17,
8,
198,
2,
10263,
94,
242,
30266,
123,
46763,
108,
198,
22510,
796,
657,
198,
2,
5525,
123,
255,
47987,
164,
106,
108,
46763,
108,
198,
77,
796,
352,
198,
2,
5525,
123,
255,
47987,
164,
106,
94,
163,
106,
245,
1222,
13328,
119,
246,
32368,
122,
198,
35235,
7203,
28156,
222,
34650,
233,
32573,
255,
47987,
4943,
198,
4514,
2081,
198,
220,
220,
220,
3298,
966,
62,
16,
11,
966,
62,
17,
11,
997,
11,
299,
198,
220,
220,
220,
611,
966,
62,
16,
58,
16,
60,
1279,
2124,
62,
86,
198,
220,
220,
220,
220,
220,
220,
220,
2270,
198,
220,
220,
220,
886,
198,
220,
220,
220,
44872,
7203,
32573,
255,
47987,
163,
105,
105,
29568,
77,
8,
10545,
105,
94,
4943,
198,
220,
220,
220,
299,
15853,
352,
198,
220,
220,
220,
329,
2124,
62,
72,
287,
45941,
13,
21602,
10223,
7,
15,
11,
352,
11,
1802,
20483,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
2352,
7,
3849,
79,
62,
88,
7,
87,
62,
72,
8,
532,
966,
62,
16,
58,
17,
12962,
1279,
657,
13,
2388,
16,
1635,
966,
62,
16,
58,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
966,
62,
29510,
796,
685,
87,
62,
72,
11,
966,
62,
16,
58,
17,
11907,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
966,
62,
17,
796,
1976,
27498,
7,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
966,
62,
67,
58,
16,
60,
1279,
2124,
62,
72,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
10263,
250,
101,
163,
39333,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
41468,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
966,
62,
17,
796,
685,
87,
62,
72,
11,
277,
62,
81,
7,
87,
62,
72,
15437,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
966,
62,
65,
58,
16,
60,
1279,
2124,
62,
72,
1279,
966,
62,
67,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
10263,
250,
101,
162,
237,
238,
165,
99,
237,
162,
106,
113,
162,
241,
235,
43291,
163,
118,
123,
41468,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
966,
62,
17,
796,
685,
87,
62,
72,
11,
277,
62,
67,
7,
87,
62,
72,
15437,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
361,
2124,
62,
72,
1279,
966,
62,
65,
58,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
10263,
250,
101,
43380,
117,
164,
100,
240,
163,
118,
123,
41468,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
966,
62,
17,
796,
685,
87,
62,
72,
11,
2124,
62,
72,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
997,
15853,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9485,
43328,
13,
29487,
26933,
4122,
62,
16,
58,
16,
4357,
966,
62,
29510,
58,
16,
60,
4357,
685,
4122,
62,
16,
58,
17,
4357,
966,
62,
29510,
58,
17,
60,
4357,
366,
65,
12,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9485,
43328,
13,
29487,
26933,
4122,
62,
17,
58,
16,
4357,
966,
62,
29510,
58,
16,
60,
4357,
685,
4122,
62,
17,
58,
17,
4357,
966,
62,
29510,
58,
17,
60,
4357,
366,
65,
12,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
5525,
123,
255,
47987,
28938,
236,
23877,
108,
163,
224,
117,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
966,
62,
16,
796,
966,
62,
17,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
966,
62,
17,
796,
1976,
27498,
7,
17,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2,
13328,
238,
228,
164,
106,
118,
161,
94,
242,
30266,
123,
46763,
108,
163,
119,
241,
162,
252,
250,
198,
35235,
7203,
49426,
228,
164,
106,
118,
161,
94,
242,
30266,
123,
46763,
108,
796,
29568,
22510,
8,
4943,
198
] | 1.260402 | 2,788 |
<gh_stars>0
mutable struct Preferences
benchmark_output::String
benchmark_histogram::String
end
const PREFS = Preferences("classical", "classical")
const PREFS_FILE_NAME = "benchmarkext.toml"
const ALLOWED = Dict(:benchmark_output => ["classical", "fancy"],
:benchmark_histogram => ["classical", "fancy"])
function update!(prefs::Preferences, data)
for k in fieldnames(Preferences)
ks = string(k)
haskey(data, ks) || continue
setfield!(prefs, k, data[ks])
end
return
end
default_prefs_path(default) = joinpath(first(DEPOT_PATH), "prefs", default)
function get_prefs_path(default)
haskey(ENV, "JULIA_BENCHMARKEXT_CONFIG") && return ENV["JULIA_BENCHMARKEXT_CONFIG"]
path = default_prefs_path(default)
isfile(path) && return path
return ""
end
initialize_prefs(prefs = PREFS, default = PREFS_FILE_NAME) = load_preferences!("", prefs, default)
########################################
# Exported
########################################
"""
set_preferences!(; kwargs...)
Set preferences for current session. Subset of allowed keywords and their values
can be found in BenchmarkExt.ALLOWED
"""
function set_preferences!(prefs = PREFS; kwargs...)
for (k, v) in kwargs
haskey(ALLOWED, k) || (@warn "Unknown settings \"$k\""; continue)
v in ALLOWED[k] || (@warn "Unsupported value \"$v\" for \"$k\""; continue)
setfield!(prefs, k, v)
end
return nothing
end
"""
save_preferences!()
Store current preferences so they can to be reused between sessions. Saved
preferences automatically loaded during `using BenchmarkExt`. Preferences
saved either in path defined in `JULIA_BENCHMARKEXT_CONFIG` environment
variable or `~/.julia/prefs/benchmarkext.toml`
"""
function save_preferences!(prefs = PREFS, default = PREFS_FILE_NAME)
path = get_prefs_path(default)
if isempty(path)
path = default_prefs_path(default)
mkpath(dirname(path))
end
data = Dict{Symbol, String}()
for k in fieldnames(Preferences)
data[k] = getfield(prefs, k)
end
open(path, "w") do io
TOML.print(io, data)
end
return
end
"""
load_preferences!(path)
Load preferences from the path. If path is an empty string, then default
path location is used, i.e. path defined in `JULIA_BENCHMARKEXT_CONFIG`
environment variable or `~/.julia/prefs/benchmarkext.toml`
"""
function load_preferences!(path, prefs = PREFS, default = PREFS_FILE_NAME)
path = isempty(path) ? get_prefs_path(default) : path
isempty(path) && return
try
update!(prefs, TOML.parsefile(path))
catch err
@warn "Unable to load BenchmarkExt configuration file in $path " err
end
return
end
| [
27,
456,
62,
30783,
29,
15,
198,
76,
18187,
2878,
49780,
198,
220,
220,
220,
18335,
62,
22915,
3712,
10100,
198,
220,
220,
220,
18335,
62,
10034,
21857,
3712,
10100,
198,
437,
198,
198,
9979,
22814,
10652,
796,
49780,
7203,
4871,
605,
1600,
366,
4871,
605,
4943,
198,
9979,
22814,
10652,
62,
25664,
62,
20608,
796,
366,
26968,
3876,
365,
742,
13,
39532,
75,
1,
198,
9979,
11096,
3913,
1961,
796,
360,
713,
7,
25,
26968,
4102,
62,
22915,
5218,
14631,
4871,
605,
1600,
366,
69,
3883,
33116,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1058,
26968,
4102,
62,
10034,
21857,
5218,
14631,
4871,
605,
1600,
366,
69,
3883,
8973,
8,
198,
198,
8818,
4296,
0,
7,
3866,
9501,
3712,
36698,
4972,
11,
1366,
8,
198,
220,
220,
220,
329,
479,
287,
2214,
14933,
7,
36698,
4972,
8,
198,
220,
220,
220,
220,
220,
220,
220,
479,
82,
796,
4731,
7,
74,
8,
198,
220,
220,
220,
220,
220,
220,
220,
468,
2539,
7,
7890,
11,
479,
82,
8,
8614,
2555,
198,
220,
220,
220,
220,
220,
220,
220,
900,
3245,
0,
7,
3866,
9501,
11,
479,
11,
1366,
58,
591,
12962,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
198,
437,
198,
198,
12286,
62,
3866,
9501,
62,
6978,
7,
12286,
8,
796,
4654,
6978,
7,
11085,
7,
46162,
2394,
62,
34219,
828,
366,
3866,
9501,
1600,
4277,
8,
198,
198,
8818,
651,
62,
3866,
9501,
62,
6978,
7,
12286,
8,
198,
220,
220,
220,
468,
2539,
7,
1677,
53,
11,
366,
41,
6239,
3539,
62,
33,
1677,
3398,
44,
14175,
13918,
62,
10943,
16254,
4943,
11405,
1441,
12964,
53,
14692,
41,
6239,
3539,
62,
33,
1677,
3398,
44,
14175,
13918,
62,
10943,
16254,
8973,
198,
220,
220,
220,
3108,
796,
4277,
62,
3866,
9501,
62,
6978,
7,
12286,
8,
198,
220,
220,
220,
318,
7753,
7,
6978,
8,
11405,
1441,
3108,
628,
220,
220,
220,
1441,
13538,
198,
437,
198,
36733,
1096,
62,
3866,
9501,
7,
3866,
9501,
796,
22814,
10652,
11,
4277,
796,
22814,
10652,
62,
25664,
62,
20608,
8,
796,
3440,
62,
3866,
69,
4972,
0,
7203,
1600,
7694,
82,
11,
4277,
8,
198,
198,
29113,
7804,
198,
2,
1475,
9213,
198,
29113,
7804,
198,
37811,
198,
220,
220,
220,
900,
62,
3866,
69,
4972,
0,
7,
26,
479,
86,
22046,
23029,
198,
198,
7248,
15387,
329,
1459,
6246,
13,
3834,
2617,
286,
3142,
26286,
290,
511,
3815,
198,
5171,
307,
1043,
287,
25187,
4102,
11627,
13,
7036,
3913,
1961,
198,
37811,
198,
8818,
900,
62,
3866,
69,
4972,
0,
7,
3866,
9501,
796,
22814,
10652,
26,
479,
86,
22046,
23029,
198,
220,
220,
220,
329,
357,
74,
11,
410,
8,
287,
479,
86,
22046,
198,
220,
220,
220,
220,
220,
220,
220,
468,
2539,
7,
7036,
3913,
1961,
11,
479,
8,
8614,
4275,
40539,
366,
20035,
6460,
19990,
3,
74,
7879,
8172,
2555,
8,
198,
220,
220,
220,
220,
220,
220,
220,
410,
287,
11096,
3913,
1961,
58,
74,
60,
8614,
4275,
40539,
366,
3118,
15999,
1988,
19990,
3,
85,
7879,
329,
19990,
3,
74,
7879,
8172,
2555,
8,
628,
220,
220,
220,
220,
220,
220,
220,
900,
3245,
0,
7,
3866,
9501,
11,
479,
11,
410,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3613,
62,
3866,
69,
4972,
0,
3419,
198,
198,
22658,
1459,
15387,
523,
484,
460,
284,
307,
46823,
1022,
10991,
13,
8858,
276,
220,
198,
3866,
69,
4972,
6338,
9639,
1141,
4600,
3500,
25187,
4102,
11627,
44646,
49780,
220,
198,
82,
9586,
2035,
287,
3108,
5447,
287,
4600,
41,
6239,
3539,
62,
33,
1677,
3398,
44,
14175,
13918,
62,
10943,
16254,
63,
2858,
220,
198,
45286,
393,
4600,
93,
11757,
73,
43640,
14,
3866,
9501,
14,
26968,
3876,
365,
742,
13,
39532,
75,
63,
198,
37811,
198,
8818,
3613,
62,
3866,
69,
4972,
0,
7,
3866,
9501,
796,
22814,
10652,
11,
4277,
796,
22814,
10652,
62,
25664,
62,
20608,
8,
198,
220,
220,
220,
3108,
796,
651,
62,
3866,
9501,
62,
6978,
7,
12286,
8,
198,
220,
220,
220,
611,
318,
28920,
7,
6978,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3108,
796,
4277,
62,
3866,
9501,
62,
6978,
7,
12286,
8,
198,
220,
220,
220,
220,
220,
220,
220,
33480,
6978,
7,
15908,
3672,
7,
6978,
4008,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1366,
796,
360,
713,
90,
13940,
23650,
11,
10903,
92,
3419,
198,
220,
220,
220,
329,
479,
287,
2214,
14933,
7,
36698,
4972,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
58,
74,
60,
796,
651,
3245,
7,
3866,
9501,
11,
479,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1280,
7,
6978,
11,
366,
86,
4943,
466,
33245,
198,
220,
220,
220,
220,
220,
220,
220,
41526,
43,
13,
4798,
7,
952,
11,
1366,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3440,
62,
3866,
69,
4972,
0,
7,
6978,
8,
198,
198,
8912,
15387,
422,
262,
3108,
13,
1002,
3108,
318,
281,
6565,
4731,
11,
788,
4277,
220,
198,
6978,
4067,
318,
973,
11,
1312,
13,
68,
13,
3108,
5447,
287,
4600,
41,
6239,
3539,
62,
33,
1677,
3398,
44,
14175,
13918,
62,
10943,
16254,
63,
198,
38986,
7885,
393,
4600,
93,
11757,
73,
43640,
14,
3866,
9501,
14,
26968,
3876,
365,
742,
13,
39532,
75,
63,
198,
37811,
198,
8818,
3440,
62,
3866,
69,
4972,
0,
7,
6978,
11,
7694,
82,
796,
22814,
10652,
11,
4277,
796,
22814,
10652,
62,
25664,
62,
20608,
8,
198,
220,
220,
220,
3108,
796,
318,
28920,
7,
6978,
8,
5633,
651,
62,
3866,
9501,
62,
6978,
7,
12286,
8,
1058,
3108,
198,
220,
220,
220,
318,
28920,
7,
6978,
8,
11405,
1441,
198,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
4296,
0,
7,
3866,
9501,
11,
41526,
43,
13,
29572,
7753,
7,
6978,
4008,
198,
220,
220,
220,
4929,
11454,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
40539,
366,
3118,
540,
284,
3440,
25187,
4102,
11627,
8398,
2393,
287,
720,
6978,
366,
11454,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
198,
437,
198
] | 2.612689 | 1,056 |
<reponame>matutenun/projectbinder3
using Plots
x = 1:10
y = rand(10)
plot(x, y)
| [
27,
7856,
261,
480,
29,
6759,
7809,
403,
14,
16302,
65,
5540,
18,
198,
3500,
1345,
1747,
198,
87,
796,
352,
25,
940,
198,
88,
796,
43720,
7,
940,
8,
220,
198,
29487,
7,
87,
11,
331,
8,
628,
628,
198
] | 2.073171 | 41 |
<gh_stars>1-10
# A hacky function to return an empty Int64[] for the first conditioning set.
@inline cond_ixs(j, r) = j == 1 ? Int64[] : collect(max(1,j-r):max(1,j-1))
# number of elements in the lower triangle of an n x n matrix.
ltrisz(n) = div(n*(n+1), 2)
# Update kernel matrix buffer, exploiting redundancy for symmetric case. Not
# necessarily faster unless the kernel is very expensive to evaluate, but not
# slower in any case in my experimentation.
#
# Note that this does _NOT_ use threads, since I am already assuming that the
# nll function itself will be using threads, and in my benchmarking putting
# threaded constructors here slows things down a bit and increases allocations.
function updatebuf!(buf, pts1, pts2, kfun::F, params; skipltri=false) where{F}
(F <: MemoizedKernel) && (@assert hash(params) === kfun.phash "params for memoized kernel don't agree with provided params. This shouldn't happen and is a bug.")
if pts1 == pts2 && skipltri
for k in eachindex(pts2)
ptk = pts2[k]
@inbounds buf[k,k] = kfun(ptk, ptk, params)
@inbounds for j in 1:(k-1)
buf[j,k] = kfun(pts1[j], ptk, params)
end
end
elseif pts1 == pts2 && !skipltri
for k in eachindex(pts2)
ptk = pts2[k]
@inbounds buf[k,k] = kfun(ptk, ptk, params)
@inbounds for j in 1:(k-1)
buf[j,k] = kfun(pts1[j], ptk, params)
buf[k,j] = kfun(pts1[j], ptk, params)
end
end
else
@inbounds for k in eachindex(pts2), j in eachindex(pts1)
buf[j,k] = kfun(pts1[j], pts2[k], params)
end
end
nothing
end
# This function works pretty differently: now we assume that the points have all
# been catted together and that the kernel function takes entirely scalar
# inputs. With this formatting, we can then actually use the SIMD tools of
# LoopVectorization.jl and get some serious speedup.
#
# Very grateful to <NAME> (@elrod on discourse, @chriselrod on Github) for
# the help in making this work.
@generated function updatebuf_avx!(buf, ::Val{D}, pts1, pts2,
kfun, params; skipltri=false) where{D}
quote
if pts1 == pts2 && skipltri
for _k in 0:div(length(pts2)-1,$D)
@turbo for _j in 0:_k # @turbo
#@inbounds for _j in 0:_k
val = kfun($([:(pts1[_j*$D+$d]) for d in 1:D]...),
$([:(pts2[_k*$D+$d]) for d in 1:D]...),
params)
buf[_j+1,_k+1] = val
end
end
elseif pts1 == pts2 && !skipltri
for _k in 0:div(length(pts2)-1,$D)
@turbo for _j in 0:_k # @turbo
#@inbounds for _j in 0:_k
val = kfun($([:(pts1[_j*$D+$d]) for d in 1:D]...),
$([:(pts2[_k*$D+$d]) for d in 1:D]...),
params)
buf[_j+1,_k+1] = val
buf[_k+1,_j+1] = val
end
end
else
@turbo for _k in 0:div(length(pts2)-1,$D), _j in 0:div(length(pts1)-1,$D) # @turbo
#@inbounds for _k in 0:div(length(pts2)-1,$D), _j in 0:div(length(pts1)-1,$D)
val = kfun($([:(pts1[_j*$D+$d]) for d in 1:D]...),
$([:(pts2[_k*$D+$d]) for d in 1:D]...),
params)
buf[_j+1,_k+1] = val
end
end
nothing
end
end
# Primarily kept because it's readable and helps to transition from math
# notation in a paper to code.
function sunsteinchunk_naive(T, n, cpbuf, solve, fccov,
pts_ixs::AbstractVector{Int64},
cnd_ixs::AbstractVector{Int64})
# allocate the sparse matrix for b_j^T. Eventually, a possible
# micro-optimization would be to avoid this entirely and just build the final
# one from the nzindices. But for now let's just do this.
bt = spzeros(T, length(pts_ixs), n)
# fill in the identity matrix part, doing the solves along the way.
# about 50% of the time.
for (j, ptixj) in enumerate(pts_ixs)
ej = zeros(T, length(pts_ixs))
ej[j] = one(T)
ldiv!(fccov.U', ej)
bt[:,ptixj] .= ej
end
# solve the linear system, overwriting input "solve", and update the
# corresponding columns of bt:
ldiv!(fccov.U', Adjoint(solve))
for (j, rowj) in enumerate(eachrow(solve))
bt[:,cnd_ixs[j]] .= -rowj
end
# return the conjugation.
return bt'bt # almost _all_ the allocs.
end
function sparseIJvecs_ltri(ixs)
len = ltrisz(length(ixs))
(Iv, Jv) = (Vector{Int64}(undef, len), Vector{Int64}(undef, len))
current = 1
for j in eachindex(ixs)
view(Iv, current:(current+j-1)) .= ixs[j]
view(Jv, current:(current+j-1)) .= view(ixs, 1:j)
current += j
end
(Iv, Jv)
end
function sparseIJvecs_full(ixs)
ilen = length(ixs)
len = ilen^2
(Iv, Jv) = (Vector{Int64}(undef, len), Vector{Int64}(undef, len))
# fill in the I vector. Slightly more involved this time.
current = 1
for j in eachindex(ixs)
view(Iv, current:(current+ilen-1)) .= ixs[j]
current += ilen
end
# fill in the J vector. Again, slightly more involved.
current = 1
for j in eachindex(ixs)
view(Jv, current:(current+ilen-1)) .= ixs
current += ilen
end
(Iv, Jv)
end
function update_IJ!(ixs, I, J)
@inbounds for l in eachindex(I,J)
I[l] = ixs[I[l]]
J[l] = ixs[J[l]]
end
nothing
end
function prepare_columns(T, solve, fccov)
sz = size(solve, 1) + size(fccov,1)
out = Array{T}(undef, size(fccov,1), sz)
for j in 1:size(solve,1)
view(out, :, j) .= -view(solve, j, :)
end
for (row_counter, j) in enumerate((size(solve, 1)+1):sz)
colj = view(out, :, j)
fill!(colj, zero(T))
colj[row_counter] = one(T)
end
lastchunk = view(out, :, (size(solve, 1)+1):sz)
ldiv!(fccov.U', lastchunk)
out
end
# TODO (cg 2021/04/24 18:26): this could always be optimized better.
# I suppose I could get rid of the allocation in combined by making the cross
# buffer slightly larger than it needs to be and updating that object. One of
# the dimensions is right already. But it's hard to imagine that boosting
# performance.
function sunsteinchunk(T, n, solve, fccov, mulbuf,
pts_ixs::AbstractVector{Int64},
cnd_ixs::AbstractVector{Int64})::Tuple{Vector{Int64}, Vector{Int64}, Vector{T}}
# Incredibly, this hcat code seems to be more efficient than prepare_columns
# above. I'm really confused about how it has fewer allocations.
ldiv!(fccov.U', Adjoint(solve))
combined = hcat(-permutedims(solve), inv(fccov.U'))
combined_ixs = vcat(cnd_ixs, pts_ixs)
# index set:
(Iv, Jv) = sparseIJvecs_ltri(1:length(combined_ixs))
# fill in the matrix entries. The extra allocation isn't ideal, but BLAS-3!
# having experimented with dropping the ltri-only approach so that I can just
# return Vv = vec(mulbuf), this approach oddly has slightly more allocations
# but was significantly faster---by about a factor of 2.
mul!(mulbuf, Adjoint(combined), combined)
Vv = Vector{T}(undef, ltrisz(length(combined_ixs)))
@turbo for l in eachindex(Iv, Jv)
#@inbounds for l in eachindex(Iv, Jv)
j = Iv[l]
k = Jv[l]
Vv[l] = mulbuf[j,k]
end
update_IJ!(combined_ixs, Iv, Jv)
return (Iv, Jv, Vv)
end
# Primarily kept because it's readable and helps to transition from math
# notation in a paper to code.
function sunsteinchunk1_naive(T, n, buf)
out = spzeros(T, n, n)
len = size(buf, 1)
out[1:len, 1:len] .= inv(buf)
out
end
# something that instead returns nzindices instead of constructing the matrix.
function sunsteinchunk1(T, n, buf)::Tuple{Vector{Int64}, Vector{Int64}, Vector{T}}
ibuf = inv(buf)
Vv = Vector{T}(undef, ltrisz(size(buf, 1)))
counter = 1
@inbounds for j in 1:size(buf, 1)
@inbounds for k in 1:j
Vv[counter] = ibuf[j,k]
counter += 1
end
end
(Iv, Jv) = sparseIJvecs_ltri(1:size(buf, 1))
return (Iv, Jv, Vv)
end
function globalidxs(datavv)
(out, start) = (Vector{UnitRange{Int64}}(undef, length(datavv)), 1)
for (j, datvj) in enumerate(datavv)
len = size(datvj,1)
out[j] = start:(start+len-1)
start += len
end
out
end
function checksorted(V::VecchiaConfig{D,F}) where{D,F}
all(issorted, V.condix) || throw(error("This function requires that every conditioning vector be sorted."))
nothing
end
# TODO (cg 2022/04/21 16:16): This is totally not good.
function vec_of_vecs_to_matrows(vv)
Matrix(reduce(hcat, vv)')
end
# For debugging. This gives M = U*U'.
function rchol(M)
tmp = cholesky(Symmetric(reverse(Matrix(M), dims=(1,2)))).L
UpperTriangular(reverse(Matrix(tmp), dims=(1,2)))
end
# Again, for debugging. Don't use this.
irchol(M) = inv(cholesky(M).U)
function prepare_v_buf!(buf, v::Matrix, idxv)
_ix = 1
for ixs in idxv
for ix in ixs
view(buf, _ix, :) .= view(v, ix, :)
_ix += 1
end
end
view(buf, 1:(_ix-1), :)
end
function updateptsbuf!(ptbuf, ptvv, idxs)
ix = 1
for idx in idxs
for pt in ptvv[idx]
ptbuf[ix] = pt
ix += 1
end
end
view(ptbuf, 1:(ix-1))
end
# Not a clever function at all,
function rchol_nnz(U::RCholesky{T}) where{T}
# diagonal elements:
out = sum(U.idxs) do ix
n = length(ix)
div(n*(n+1), 2)
end
# off-diagonal elements:
out += sum(enumerate(U.condix)) do (j,ix_c)
isempty(ix_c) && return 0
tmp = 0
len = length(U.idxs[j])
for ix in ix_c
tmp += len*length(U.idxs[ix])
end
tmp
end
out
end
| [
27,
456,
62,
30783,
29,
16,
12,
940,
198,
198,
2,
317,
8156,
88,
2163,
284,
1441,
281,
6565,
2558,
2414,
21737,
329,
262,
717,
21143,
900,
13,
198,
31,
45145,
1779,
62,
844,
82,
7,
73,
11,
374,
8,
796,
474,
6624,
352,
5633,
2558,
2414,
21737,
1058,
2824,
7,
9806,
7,
16,
11,
73,
12,
81,
2599,
9806,
7,
16,
11,
73,
12,
16,
4008,
198,
198,
2,
1271,
286,
4847,
287,
262,
2793,
22950,
286,
281,
299,
2124,
299,
17593,
13,
198,
75,
2213,
271,
89,
7,
77,
8,
796,
2659,
7,
77,
9,
7,
77,
10,
16,
828,
362,
8,
198,
198,
2,
10133,
9720,
17593,
11876,
11,
29440,
49052,
329,
23606,
19482,
1339,
13,
1892,
198,
2,
6646,
5443,
4556,
262,
9720,
318,
845,
5789,
284,
13446,
11,
475,
407,
198,
2,
13611,
287,
597,
1339,
287,
616,
29315,
13,
198,
2,
198,
2,
5740,
326,
428,
857,
4808,
11929,
62,
779,
14390,
11,
1201,
314,
716,
1541,
13148,
326,
262,
198,
2,
299,
297,
2163,
2346,
481,
307,
1262,
14390,
11,
290,
287,
616,
18335,
278,
5137,
198,
2,
40945,
5678,
669,
994,
33019,
1243,
866,
257,
1643,
290,
5732,
49157,
13,
198,
8818,
4296,
29325,
0,
7,
29325,
11,
43344,
16,
11,
43344,
17,
11,
479,
12543,
3712,
37,
11,
42287,
26,
19984,
489,
28461,
28,
9562,
8,
810,
90,
37,
92,
198,
220,
357,
37,
1279,
25,
4942,
78,
1143,
42,
7948,
8,
11405,
4275,
30493,
12234,
7,
37266,
8,
24844,
479,
12543,
13,
746,
1077,
366,
37266,
329,
16155,
1143,
9720,
836,
470,
4236,
351,
2810,
42287,
13,
770,
6584,
470,
1645,
290,
318,
257,
5434,
19570,
198,
220,
611,
43344,
16,
6624,
43344,
17,
11405,
19984,
489,
28461,
198,
220,
220,
220,
329,
479,
287,
1123,
9630,
7,
457,
82,
17,
8,
198,
220,
220,
220,
220,
220,
279,
30488,
796,
43344,
17,
58,
74,
60,
198,
220,
220,
220,
220,
220,
2488,
259,
65,
3733,
42684,
58,
74,
11,
74,
60,
796,
479,
12543,
7,
457,
74,
11,
279,
30488,
11,
42287,
8,
198,
220,
220,
220,
220,
220,
2488,
259,
65,
3733,
329,
474,
287,
352,
37498,
74,
12,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
42684,
58,
73,
11,
74,
60,
796,
479,
12543,
7,
457,
82,
16,
58,
73,
4357,
279,
30488,
11,
42287,
8,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
2073,
361,
43344,
16,
6624,
43344,
17,
11405,
5145,
20545,
489,
28461,
198,
220,
220,
220,
329,
479,
287,
1123,
9630,
7,
457,
82,
17,
8,
198,
220,
220,
220,
220,
220,
279,
30488,
796,
43344,
17,
58,
74,
60,
198,
220,
220,
220,
220,
220,
2488,
259,
65,
3733,
42684,
58,
74,
11,
74,
60,
796,
479,
12543,
7,
457,
74,
11,
279,
30488,
11,
42287,
8,
198,
220,
220,
220,
220,
220,
2488,
259,
65,
3733,
329,
474,
287,
352,
37498,
74,
12,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
42684,
58,
73,
11,
74,
60,
796,
479,
12543,
7,
457,
82,
16,
58,
73,
4357,
279,
30488,
11,
42287,
8,
198,
220,
220,
220,
220,
220,
220,
220,
42684,
58,
74,
11,
73,
60,
796,
479,
12543,
7,
457,
82,
16,
58,
73,
4357,
279,
30488,
11,
42287,
8,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
2073,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
479,
287,
1123,
9630,
7,
457,
82,
17,
828,
474,
287,
1123,
9630,
7,
457,
82,
16,
8,
220,
198,
220,
220,
220,
220,
220,
42684,
58,
73,
11,
74,
60,
796,
479,
12543,
7,
457,
82,
16,
58,
73,
4357,
43344,
17,
58,
74,
4357,
42287,
8,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
2147,
198,
437,
198,
198,
2,
770,
2163,
2499,
2495,
10338,
25,
783,
356,
7048,
326,
262,
2173,
423,
477,
198,
2,
587,
269,
16898,
1978,
290,
326,
262,
9720,
2163,
2753,
5000,
16578,
283,
198,
2,
17311,
13,
2080,
428,
33313,
11,
356,
460,
788,
1682,
779,
262,
23749,
35,
4899,
286,
198,
2,
26304,
38469,
1634,
13,
20362,
290,
651,
617,
2726,
2866,
929,
13,
198,
2,
198,
2,
9576,
14066,
284,
1279,
20608,
29,
4275,
417,
14892,
319,
18129,
11,
2488,
354,
2442,
417,
14892,
319,
38994,
8,
329,
198,
2,
262,
1037,
287,
1642,
428,
670,
13,
198,
31,
27568,
2163,
4296,
29325,
62,
615,
87,
0,
7,
29325,
11,
7904,
7762,
90,
35,
5512,
43344,
16,
11,
43344,
17,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
479,
12543,
11,
42287,
26,
19984,
489,
28461,
28,
9562,
8,
810,
90,
35,
92,
198,
220,
9577,
198,
220,
220,
220,
611,
43344,
16,
6624,
43344,
17,
11405,
19984,
489,
28461,
198,
220,
220,
220,
220,
220,
329,
4808,
74,
287,
657,
25,
7146,
7,
13664,
7,
457,
82,
17,
13219,
16,
11,
3,
35,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
36590,
2127,
329,
4808,
73,
287,
657,
25,
62,
74,
1303,
2488,
36590,
2127,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
31,
259,
65,
3733,
329,
4808,
73,
287,
657,
25,
62,
74,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1188,
796,
479,
12543,
16763,
26933,
37498,
457,
82,
16,
29795,
73,
9,
3,
35,
10,
3,
67,
12962,
329,
288,
287,
352,
25,
35,
60,
986,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
720,
26933,
37498,
457,
82,
17,
29795,
74,
9,
3,
35,
10,
3,
67,
12962,
329,
288,
287,
352,
25,
35,
60,
986,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
42287,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
42684,
29795,
73,
10,
16,
11,
62,
74,
10,
16,
60,
796,
1188,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
2073,
361,
43344,
16,
6624,
43344,
17,
11405,
5145,
20545,
489,
28461,
198,
220,
220,
220,
220,
220,
329,
4808,
74,
287,
657,
25,
7146,
7,
13664,
7,
457,
82,
17,
13219,
16,
11,
3,
35,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
36590,
2127,
329,
4808,
73,
287,
657,
25,
62,
74,
1303,
2488,
36590,
2127,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
31,
259,
65,
3733,
329,
4808,
73,
287,
657,
25,
62,
74,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1188,
796,
479,
12543,
16763,
26933,
37498,
457,
82,
16,
29795,
73,
9,
3,
35,
10,
3,
67,
12962,
329,
288,
287,
352,
25,
35,
60,
986,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
720,
26933,
37498,
457,
82,
17,
29795,
74,
9,
3,
35,
10,
3,
67,
12962,
329,
288,
287,
352,
25,
35,
60,
986,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
42287,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
42684,
29795,
73,
10,
16,
11,
62,
74,
10,
16,
60,
796,
1188,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
42684,
29795,
74,
10,
16,
11,
62,
73,
10,
16,
60,
796,
1188,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
2488,
36590,
2127,
329,
220,
4808,
74,
287,
657,
25,
7146,
7,
13664,
7,
457,
82,
17,
13219,
16,
11,
3,
35,
828,
220,
4808,
73,
287,
657,
25,
7146,
7,
13664,
7,
457,
82,
16,
13219,
16,
11,
3,
35,
8,
1303,
2488,
36590,
2127,
198,
220,
220,
220,
220,
220,
1303,
31,
259,
65,
3733,
329,
220,
4808,
74,
287,
657,
25,
7146,
7,
13664,
7,
457,
82,
17,
13219,
16,
11,
3,
35,
828,
220,
4808,
73,
287,
657,
25,
7146,
7,
13664,
7,
457,
82,
16,
13219,
16,
11,
3,
35,
8,
220,
198,
220,
220,
220,
220,
220,
220,
220,
1188,
796,
479,
12543,
16763,
26933,
37498,
457,
82,
16,
29795,
73,
9,
3,
35,
10,
3,
67,
12962,
329,
288,
287,
352,
25,
35,
60,
986,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
720,
26933,
37498,
457,
82,
17,
29795,
74,
9,
3,
35,
10,
3,
67,
12962,
329,
288,
287,
352,
25,
35,
60,
986,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
42287,
8,
198,
220,
220,
220,
220,
220,
220,
220,
42684,
29795,
73,
10,
16,
11,
62,
74,
10,
16,
60,
796,
1188,
198,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2147,
198,
220,
886,
198,
437,
198,
198,
2,
11460,
3093,
4030,
780,
340,
338,
31744,
290,
5419,
284,
6801,
422,
10688,
198,
2,
33274,
287,
257,
3348,
284,
2438,
13,
198,
8818,
4252,
5714,
354,
2954,
62,
2616,
425,
7,
51,
11,
299,
11,
31396,
29325,
11,
8494,
11,
277,
535,
709,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
43344,
62,
844,
82,
3712,
23839,
38469,
90,
5317,
2414,
5512,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
358,
62,
844,
82,
3712,
23839,
38469,
90,
5317,
2414,
30072,
198,
220,
1303,
31935,
262,
29877,
17593,
329,
275,
62,
73,
61,
51,
13,
16178,
11,
257,
1744,
198,
220,
1303,
4580,
12,
40085,
1634,
561,
307,
284,
3368,
428,
5000,
290,
655,
1382,
262,
2457,
198,
220,
1303,
530,
422,
262,
299,
89,
521,
1063,
13,
887,
329,
783,
1309,
338,
655,
466,
428,
13,
198,
220,
275,
83,
796,
599,
9107,
418,
7,
51,
11,
4129,
7,
457,
82,
62,
844,
82,
828,
299,
8,
198,
220,
1303,
6070,
287,
262,
5369,
17593,
636,
11,
1804,
262,
39107,
1863,
262,
835,
13,
198,
220,
1303,
546,
2026,
4,
286,
262,
640,
13,
198,
220,
329,
357,
73,
11,
42975,
844,
73,
8,
287,
27056,
378,
7,
457,
82,
62,
844,
82,
8,
198,
220,
220,
220,
304,
73,
220,
220,
220,
796,
1976,
27498,
7,
51,
11,
4129,
7,
457,
82,
62,
844,
82,
4008,
198,
220,
220,
220,
304,
73,
58,
73,
60,
796,
530,
7,
51,
8,
198,
220,
220,
220,
300,
7146,
0,
7,
69,
535,
709,
13,
52,
3256,
304,
73,
8,
198,
220,
220,
220,
275,
83,
58,
45299,
457,
844,
73,
60,
764,
28,
304,
73,
198,
220,
886,
198,
220,
1303,
8494,
262,
14174,
1080,
11,
6993,
799,
278,
5128,
366,
82,
6442,
1600,
290,
4296,
262,
198,
220,
1303,
11188,
15180,
286,
275,
83,
25,
198,
220,
300,
7146,
0,
7,
69,
535,
709,
13,
52,
3256,
1215,
73,
1563,
7,
82,
6442,
4008,
198,
220,
329,
357,
73,
11,
5752,
73,
8,
287,
27056,
378,
7,
27379,
808,
7,
82,
6442,
4008,
198,
220,
220,
220,
275,
83,
58,
45299,
66,
358,
62,
844,
82,
58,
73,
11907,
764,
28,
532,
808,
73,
198,
220,
886,
198,
220,
1303,
1441,
262,
11644,
1018,
341,
13,
198,
220,
1441,
275,
83,
6,
18347,
1303,
2048,
4808,
439,
62,
262,
36836,
82,
13,
198,
437,
198,
198,
8818,
29877,
23852,
303,
6359,
62,
2528,
380,
7,
844,
82,
8,
198,
220,
18896,
796,
300,
2213,
271,
89,
7,
13664,
7,
844,
82,
4008,
198,
220,
357,
45766,
11,
449,
85,
8,
796,
357,
38469,
90,
5317,
2414,
92,
7,
917,
891,
11,
18896,
828,
20650,
90,
5317,
2414,
92,
7,
917,
891,
11,
18896,
4008,
198,
220,
1459,
220,
796,
352,
198,
220,
329,
474,
287,
1123,
9630,
7,
844,
82,
8,
198,
220,
220,
220,
1570,
7,
45766,
11,
1459,
37498,
14421,
10,
73,
12,
16,
4008,
764,
28,
220,
844,
82,
58,
73,
60,
198,
220,
220,
220,
1570,
7,
41,
85,
11,
1459,
37498,
14421,
10,
73,
12,
16,
4008,
764,
28,
1570,
7,
844,
82,
11,
352,
25,
73,
8,
198,
220,
220,
220,
1459,
15853,
474,
198,
220,
886,
198,
220,
357,
45766,
11,
449,
85,
8,
198,
437,
198,
198,
8818,
29877,
23852,
303,
6359,
62,
12853,
7,
844,
82,
8,
198,
220,
4229,
268,
796,
4129,
7,
844,
82,
8,
198,
220,
18896,
220,
796,
4229,
268,
61,
17,
198,
220,
357,
45766,
11,
449,
85,
8,
796,
357,
38469,
90,
5317,
2414,
92,
7,
917,
891,
11,
18896,
828,
20650,
90,
5317,
2414,
92,
7,
917,
891,
11,
18896,
4008,
198,
220,
1303,
6070,
287,
262,
314,
15879,
13,
49365,
517,
2950,
428,
640,
13,
198,
220,
1459,
796,
352,
198,
220,
329,
474,
287,
1123,
9630,
7,
844,
82,
8,
198,
220,
220,
220,
1570,
7,
45766,
11,
1459,
37498,
14421,
10,
346,
268,
12,
16,
4008,
764,
28,
220,
844,
82,
58,
73,
60,
198,
220,
220,
220,
1459,
15853,
4229,
268,
198,
220,
886,
198,
220,
1303,
6070,
287,
262,
449,
15879,
13,
6521,
11,
4622,
517,
2950,
13,
198,
220,
1459,
796,
352,
198,
220,
329,
474,
287,
1123,
9630,
7,
844,
82,
8,
198,
220,
220,
220,
1570,
7,
41,
85,
11,
1459,
37498,
14421,
10,
346,
268,
12,
16,
4008,
764,
28,
220,
844,
82,
198,
220,
220,
220,
1459,
15853,
4229,
268,
198,
220,
886,
198,
220,
357,
45766,
11,
449,
85,
8,
198,
437,
198,
198,
8818,
4296,
62,
23852,
0,
7,
844,
82,
11,
314,
11,
449,
8,
198,
220,
2488,
259,
65,
3733,
329,
300,
287,
1123,
9630,
7,
40,
11,
41,
8,
198,
220,
220,
220,
314,
58,
75,
60,
796,
220,
844,
82,
58,
40,
58,
75,
11907,
198,
220,
220,
220,
449,
58,
75,
60,
796,
220,
844,
82,
58,
41,
58,
75,
11907,
198,
220,
886,
198,
220,
2147,
198,
437,
198,
198,
8818,
8335,
62,
28665,
82,
7,
51,
11,
8494,
11,
277,
535,
709,
8,
198,
220,
264,
89,
220,
796,
2546,
7,
82,
6442,
11,
352,
8,
1343,
2546,
7,
69,
535,
709,
11,
16,
8,
198,
220,
503,
796,
15690,
90,
51,
92,
7,
917,
891,
11,
2546,
7,
69,
535,
709,
11,
16,
828,
264,
89,
8,
198,
220,
329,
474,
287,
352,
25,
7857,
7,
82,
6442,
11,
16,
8,
198,
220,
220,
220,
1570,
7,
448,
11,
1058,
11,
474,
8,
764,
28,
532,
1177,
7,
82,
6442,
11,
474,
11,
14373,
198,
220,
886,
198,
220,
329,
357,
808,
62,
24588,
11,
474,
8,
287,
27056,
378,
19510,
7857,
7,
82,
6442,
11,
352,
47762,
16,
2599,
82,
89,
8,
198,
220,
220,
220,
951,
73,
796,
1570,
7,
448,
11,
1058,
11,
474,
8,
198,
220,
220,
220,
6070,
0,
7,
4033,
73,
11,
6632,
7,
51,
4008,
198,
220,
220,
220,
951,
73,
58,
808,
62,
24588,
60,
796,
530,
7,
51,
8,
198,
220,
886,
198,
220,
938,
354,
2954,
796,
1570,
7,
448,
11,
1058,
11,
357,
7857,
7,
82,
6442,
11,
352,
47762,
16,
2599,
82,
89,
8,
198,
220,
300,
7146,
0,
7,
69,
535,
709,
13,
52,
3256,
938,
354,
2954,
8,
198,
220,
503,
198,
437,
198,
198,
2,
16926,
46,
357,
66,
70,
33448,
14,
3023,
14,
1731,
1248,
25,
2075,
2599,
428,
714,
1464,
307,
23392,
1365,
13,
220,
198,
2,
314,
11691,
314,
714,
651,
5755,
286,
262,
20157,
287,
5929,
416,
1642,
262,
3272,
198,
2,
11876,
4622,
4025,
621,
340,
2476,
284,
307,
290,
19698,
326,
2134,
13,
1881,
286,
198,
2,
262,
15225,
318,
826,
1541,
13,
887,
340,
338,
1327,
284,
5967,
326,
27611,
198,
2,
2854,
13,
198,
8818,
4252,
5714,
354,
2954,
7,
51,
11,
299,
11,
8494,
11,
277,
535,
709,
11,
35971,
29325,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
43344,
62,
844,
82,
3712,
23839,
38469,
90,
5317,
2414,
5512,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
358,
62,
844,
82,
3712,
23839,
38469,
90,
5317,
2414,
92,
2599,
25,
51,
29291,
90,
38469,
90,
5317,
2414,
5512,
20650,
90,
5317,
2414,
5512,
20650,
90,
51,
11709,
198,
220,
1303,
3457,
45779,
11,
428,
289,
9246,
2438,
2331,
284,
307,
517,
6942,
621,
8335,
62,
28665,
82,
198,
220,
1303,
2029,
13,
314,
1101,
1107,
10416,
546,
703,
340,
468,
7380,
49157,
13,
220,
198,
220,
300,
7146,
0,
7,
69,
535,
709,
13,
52,
3256,
1215,
73,
1563,
7,
82,
6442,
4008,
198,
220,
5929,
220,
220,
220,
220,
796,
289,
9246,
32590,
16321,
7241,
12078,
7,
82,
6442,
828,
800,
7,
69,
535,
709,
13,
52,
6,
4008,
198,
220,
5929,
62,
844,
82,
796,
410,
9246,
7,
66,
358,
62,
844,
82,
11,
43344,
62,
844,
82,
8,
198,
220,
1303,
6376,
900,
25,
198,
220,
357,
45766,
11,
449,
85,
8,
796,
29877,
23852,
303,
6359,
62,
2528,
380,
7,
16,
25,
13664,
7,
24011,
1389,
62,
844,
82,
4008,
198,
220,
1303,
6070,
287,
262,
17593,
12784,
13,
383,
3131,
20157,
2125,
470,
7306,
11,
475,
9878,
1921,
12,
18,
0,
198,
220,
1303,
1719,
42107,
351,
12047,
262,
300,
28461,
12,
8807,
3164,
523,
326,
314,
460,
655,
198,
220,
1303,
1441,
569,
85,
796,
43030,
7,
76,
377,
29325,
828,
428,
3164,
31414,
468,
4622,
517,
49157,
198,
220,
1303,
475,
373,
5566,
5443,
6329,
1525,
546,
257,
5766,
286,
362,
13,
198,
220,
35971,
0,
7,
76,
377,
29325,
11,
1215,
73,
1563,
7,
24011,
1389,
828,
5929,
8,
198,
220,
569,
85,
220,
796,
20650,
90,
51,
92,
7,
917,
891,
11,
300,
2213,
271,
89,
7,
13664,
7,
24011,
1389,
62,
844,
82,
22305,
198,
220,
2488,
36590,
2127,
329,
300,
287,
1123,
9630,
7,
45766,
11,
449,
85,
8,
198,
220,
1303,
31,
259,
65,
3733,
329,
300,
287,
1123,
9630,
7,
45766,
11,
449,
85,
8,
198,
220,
220,
220,
474,
220,
220,
220,
220,
796,
16975,
58,
75,
60,
198,
220,
220,
220,
479,
220,
220,
220,
220,
796,
449,
85,
58,
75,
60,
198,
220,
220,
220,
569,
85,
58,
75,
60,
796,
35971,
29325,
58,
73,
11,
74,
60,
198,
220,
886,
198,
220,
4296,
62,
23852,
0,
7,
24011,
1389,
62,
844,
82,
11,
16975,
11,
449,
85,
8,
198,
220,
1441,
357,
45766,
11,
449,
85,
11,
569,
85,
8,
198,
437,
198,
198,
2,
11460,
3093,
4030,
780,
340,
338,
31744,
290,
5419,
284,
6801,
422,
10688,
198,
2,
33274,
287,
257,
3348,
284,
2438,
13,
198,
8818,
4252,
5714,
354,
2954,
16,
62,
2616,
425,
7,
51,
11,
299,
11,
42684,
8,
198,
220,
503,
796,
599,
9107,
418,
7,
51,
11,
299,
11,
299,
8,
198,
220,
18896,
796,
2546,
7,
29325,
11,
352,
8,
198,
220,
503,
58,
16,
25,
11925,
11,
352,
25,
11925,
60,
764,
28,
800,
7,
29325,
8,
198,
220,
503,
198,
437,
198,
198,
2,
1223,
326,
2427,
5860,
299,
89,
521,
1063,
2427,
286,
30580,
262,
17593,
13,
198,
8818,
4252,
5714,
354,
2954,
16,
7,
51,
11,
299,
11,
42684,
2599,
25,
51,
29291,
90,
38469,
90,
5317,
2414,
5512,
20650,
90,
5317,
2414,
5512,
20650,
90,
51,
11709,
198,
220,
24283,
3046,
220,
220,
220,
796,
800,
7,
29325,
8,
198,
220,
569,
85,
220,
220,
220,
220,
220,
796,
20650,
90,
51,
92,
7,
917,
891,
11,
300,
2213,
271,
89,
7,
7857,
7,
29325,
11,
352,
22305,
198,
220,
3753,
796,
352,
198,
220,
2488,
259,
65,
3733,
329,
474,
287,
352,
25,
7857,
7,
29325,
11,
352,
8,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
479,
287,
352,
25,
73,
198,
220,
220,
220,
220,
220,
569,
85,
58,
24588,
60,
796,
24283,
3046,
58,
73,
11,
74,
60,
198,
220,
220,
220,
220,
220,
3753,
15853,
352,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
357,
45766,
11,
449,
85,
8,
796,
29877,
23852,
303,
6359,
62,
2528,
380,
7,
16,
25,
7857,
7,
29325,
11,
352,
4008,
198,
220,
1441,
357,
45766,
11,
449,
85,
11,
569,
85,
8,
198,
437,
198,
198,
8818,
3298,
312,
34223,
7,
19608,
615,
85,
8,
198,
220,
357,
448,
11,
923,
8,
796,
357,
38469,
90,
26453,
17257,
90,
5317,
2414,
11709,
7,
917,
891,
11,
4129,
7,
19608,
615,
85,
36911,
352,
8,
198,
220,
329,
357,
73,
11,
4818,
85,
73,
8,
287,
27056,
378,
7,
19608,
615,
85,
8,
198,
220,
220,
220,
18896,
796,
2546,
7,
19608,
85,
73,
11,
16,
8,
198,
220,
220,
220,
503,
58,
73,
60,
796,
923,
37498,
9688,
10,
11925,
12,
16,
8,
198,
220,
220,
220,
923,
15853,
18896,
198,
220,
886,
198,
220,
503,
198,
437,
198,
198,
8818,
8794,
9741,
7,
53,
3712,
53,
721,
354,
544,
16934,
90,
35,
11,
37,
30072,
810,
90,
35,
11,
37,
92,
198,
220,
477,
7,
747,
9741,
11,
569,
13,
17561,
844,
8,
8614,
3714,
7,
18224,
7203,
1212,
2163,
4433,
326,
790,
21143,
15879,
307,
23243,
526,
4008,
198,
220,
2147,
198,
437,
198,
198,
2,
16926,
46,
357,
66,
70,
33160,
14,
3023,
14,
2481,
1467,
25,
1433,
2599,
770,
318,
6635,
407,
922,
13,
198,
8818,
43030,
62,
1659,
62,
303,
6359,
62,
1462,
62,
6759,
8516,
7,
25093,
8,
198,
220,
24936,
7,
445,
7234,
7,
71,
9246,
11,
410,
85,
8,
11537,
198,
437,
198,
198,
2,
1114,
28769,
13,
770,
3607,
337,
796,
471,
9,
52,
4458,
198,
8818,
374,
354,
349,
7,
44,
8,
198,
220,
45218,
796,
442,
4316,
2584,
7,
13940,
3020,
19482,
7,
50188,
7,
46912,
7,
44,
828,
5391,
82,
16193,
16,
11,
17,
22305,
737,
43,
198,
220,
20390,
14824,
21413,
7,
50188,
7,
46912,
7,
22065,
828,
5391,
82,
16193,
16,
11,
17,
22305,
198,
437,
198,
198,
2,
6521,
11,
329,
28769,
13,
2094,
470,
779,
428,
13,
198,
343,
354,
349,
7,
44,
8,
796,
800,
7,
354,
4316,
2584,
7,
44,
737,
52,
8,
198,
198,
8818,
8335,
62,
85,
62,
29325,
0,
7,
29325,
11,
410,
3712,
46912,
11,
4686,
87,
85,
8,
198,
220,
4808,
844,
796,
352,
198,
220,
329,
220,
844,
82,
287,
4686,
87,
85,
198,
220,
220,
220,
329,
220,
844,
287,
220,
844,
82,
198,
220,
220,
220,
220,
220,
1570,
7,
29325,
11,
4808,
844,
11,
14373,
764,
28,
1570,
7,
85,
11,
220,
844,
11,
14373,
198,
220,
220,
220,
220,
220,
4808,
844,
15853,
352,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
1570,
7,
29325,
11,
352,
25,
28264,
844,
12,
16,
828,
14373,
198,
437,
198,
198,
8818,
4296,
457,
82,
29325,
0,
7,
457,
29325,
11,
279,
14981,
85,
11,
4686,
34223,
8,
198,
220,
220,
844,
796,
352,
198,
220,
329,
4686,
87,
287,
4686,
34223,
198,
220,
220,
220,
329,
42975,
287,
279,
14981,
85,
58,
312,
87,
60,
198,
220,
220,
220,
220,
220,
42975,
29325,
58,
844,
60,
796,
42975,
198,
220,
220,
220,
220,
220,
220,
844,
15853,
352,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
1570,
7,
457,
29325,
11,
352,
37498,
844,
12,
16,
4008,
198,
437,
198,
198,
2,
1892,
257,
14169,
2163,
379,
477,
11,
198,
8818,
374,
354,
349,
62,
20471,
89,
7,
52,
3712,
49,
1925,
4316,
2584,
90,
51,
30072,
810,
90,
51,
92,
198,
220,
1303,
40039,
4847,
25,
198,
220,
503,
796,
2160,
7,
52,
13,
312,
34223,
8,
466,
220,
844,
198,
220,
220,
220,
299,
796,
4129,
7,
844,
8,
198,
220,
220,
220,
2659,
7,
77,
9,
7,
77,
10,
16,
828,
362,
8,
198,
220,
886,
198,
220,
1303,
572,
12,
10989,
27923,
4847,
25,
198,
220,
503,
15853,
2160,
7,
268,
6975,
378,
7,
52,
13,
17561,
844,
4008,
466,
357,
73,
11,
844,
62,
66,
8,
198,
220,
220,
220,
318,
28920,
7,
844,
62,
66,
8,
11405,
1441,
657,
198,
220,
220,
220,
45218,
796,
657,
198,
220,
220,
220,
18896,
796,
4129,
7,
52,
13,
312,
34223,
58,
73,
12962,
198,
220,
220,
220,
329,
220,
844,
287,
220,
844,
62,
66,
198,
220,
220,
220,
220,
220,
45218,
15853,
18896,
9,
13664,
7,
52,
13,
312,
34223,
58,
844,
12962,
220,
198,
220,
220,
220,
886,
198,
220,
220,
220,
45218,
198,
220,
886,
198,
220,
503,
198,
437,
628
] | 2.236805 | 4,206 |
# custom extension of CuArray in CUDArt for sparse vectors/matrices
# using CSC format for interop with Julia's native sparse functionality
export CuSparseMatrixCSC, CuSparseMatrixCSR,
CuSparseMatrixHYB, CuSparseMatrixBSR,
CuSparseMatrix, AbstractCuSparseMatrix,
CuSparseVector
import Base: length, size, ndims, eltype, similar, pointer, stride,
copy, convert, reinterpret, show, summary, copyto!, getindex, get!, fill!, collect
using LinearAlgebra
import LinearAlgebra: BlasFloat, Hermitian, HermOrSym, issymmetric, Transpose, Adjoint,
ishermitian, istriu, istril, Symmetric, UpperTriangular, LowerTriangular
using SparseArrays
import SparseArrays: sparse, SparseMatrixCSC, nnz, nonzeros, nonzeroinds,
_spgetindex
abstract type AbstractCuSparseArray{Tv, N} <: AbstractSparseArray{Tv, Cint, N} end
const AbstractCuSparseVector{Tv} = AbstractCuSparseArray{Tv,1}
const AbstractCuSparseMatrix{Tv} = AbstractCuSparseArray{Tv,2}
mutable struct CuSparseVector{Tv} <: AbstractCuSparseVector{Tv}
iPtr::CuVector{Cint}
nzVal::CuVector{Tv}
dims::NTuple{2,Int}
nnz::Cint
function CuSparseVector{Tv}(iPtr::CuVector{Cint}, nzVal::CuVector{Tv}, dims::Int, nnz::Cint) where Tv
new(iPtr,nzVal,(dims,1),nnz)
end
end
function CuArrays.unsafe_free!(xs::CuSparseVector)
unsafe_free!(xs.iPtr)
unsafe_free!(xs.nzVal)
return
end
mutable struct CuSparseMatrixCSC{Tv} <: AbstractCuSparseMatrix{Tv}
colPtr::CuVector{Cint}
rowVal::CuVector{Cint}
nzVal::CuVector{Tv}
dims::NTuple{2,Int}
nnz::Cint
function CuSparseMatrixCSC{Tv}(colPtr::CuVector{Cint}, rowVal::CuVector{Cint}, nzVal::CuVector{Tv}, dims::NTuple{2,Int}, nnz::Cint) where Tv
new(colPtr,rowVal,nzVal,dims,nnz)
end
end
function CuSparseMatrixCSC!(xs::CuSparseVector)
unsafe_free!(xs.colPtr)
unsafe_free!(xs.rowVal)
unsafe_free!(xs.nzVal)
return
end
"""
Container to hold sparse matrices in compressed sparse row (CSR) format on the
GPU.
**Note**: Most CUSPARSE operations work with CSR formatted matrices, rather
than CSC.
"""
mutable struct CuSparseMatrixCSR{Tv} <: AbstractCuSparseMatrix{Tv}
rowPtr::CuVector{Cint}
colVal::CuVector{Cint}
nzVal::CuVector{Tv}
dims::NTuple{2,Int}
nnz::Cint
function CuSparseMatrixCSR{Tv}(rowPtr::CuVector{Cint}, colVal::CuVector{Cint}, nzVal::CuVector{Tv}, dims::NTuple{2,Int}, nnz::Cint) where Tv
new(rowPtr,colVal,nzVal,dims,nnz)
end
end
function CuSparseMatrixCSR!(xs::CuSparseVector)
unsafe_free!(xs.rowPtr)
unsafe_free!(xs.colVal)
unsafe_free!(xs.nzVal)
return
end
"""
Container to hold sparse matrices in block compressed sparse row (BSR) format on
the GPU. BSR format is also used in Intel MKL, and is suited to matrices that are
"block" sparse - rare blocks of non-sparse regions.
"""
mutable struct CuSparseMatrixBSR{Tv} <: AbstractCuSparseMatrix{Tv}
rowPtr::CuVector{Cint}
colVal::CuVector{Cint}
nzVal::CuVector{Tv}
dims::NTuple{2,Int}
blockDim::Cint
dir::SparseChar
nnz::Cint
function CuSparseMatrixBSR{Tv}(rowPtr::CuVector{Cint}, colVal::CuVector{Cint}, nzVal::CuVector{Tv}, dims::NTuple{2,Int},blockDim::Cint, dir::SparseChar, nnz::Cint) where Tv
new(rowPtr,colVal,nzVal,dims,blockDim,dir,nnz)
end
end
function CuSparseMatrixBSR!(xs::CuSparseVector)
unsafe_free!(xs.rowPtr)
unsafe_free!(xs.colVal)
unsafe_free!(xs.nzVal)
return
end
"""
Container to hold sparse matrices in NVIDIA's hybrid (HYB) format on the GPU.
HYB format is an opaque struct, which can be converted to/from using
CUSPARSE routines.
"""
mutable struct CuSparseMatrixHYB{Tv} <: AbstractCuSparseMatrix{Tv}
Mat::cusparseHybMat_t
dims::NTuple{2,Int}
nnz::Cint
function CuSparseMatrixHYB{Tv}(Mat::cusparseHybMat_t, dims::NTuple{2,Int}, nnz::Cint) where Tv
new(Mat,dims,nnz)
end
end
"""
Utility union type of [`CuSparseMatrixCSC`](@ref), [`CuSparseMatrixCSR`](@ref),
and `Hermitian` and `Symmetric` versions of these two containers. A function accepting
this type can make use of performance improvements by only indexing one triangle of the
matrix if it is guaranteed to be hermitian/symmetric.
"""
const CompressedSparse{T} = Union{CuSparseMatrixCSC{T},CuSparseMatrixCSR{T},HermOrSym{T,CuSparseMatrixCSC{T}},HermOrSym{T,CuSparseMatrixCSR{T}}}
"""
Utility union type of [`CuSparseMatrixCSC`](@ref), [`CuSparseMatrixCSR`](@ref),
[`CuSparseMatrixBSR`](@ref), and [`CuSparseMatrixHYB`](@ref).
"""
const CuSparseMatrix{T} = Union{CuSparseMatrixCSC{T},CuSparseMatrixCSR{T}, CuSparseMatrixBSR{T}, CuSparseMatrixHYB{T}}
Hermitian{T}(Mat::CuSparseMatrix{T}) where T = Hermitian{T,typeof(Mat)}(Mat,'U')
length(g::CuSparseVector) = prod(g.dims)
size(g::CuSparseVector) = g.dims
ndims(g::CuSparseVector) = 1
length(g::CuSparseMatrix) = prod(g.dims)
size(g::CuSparseMatrix) = g.dims
ndims(g::CuSparseMatrix) = 2
function size(g::CuSparseVector, d::Integer)
if d == 1
return g.dims[d]
elseif d > 1
return 1
else
throw(ArgumentError("dimension must be ≥ 1, got $d"))
end
end
function size(g::CuSparseMatrix, d::Integer)
if d in [1, 2]
return g.dims[d]
elseif d > 1
return 1
else
throw(ArgumentError("dimension must be ≥ 1, got $d"))
end
end
nnz(g::AbstractCuSparseArray) = g.nnz
nonzeros(g::AbstractCuSparseArray) = g.nzVal
nonzeroinds(g::AbstractCuSparseVector) = g.iPtr
issymmetric(M::Union{CuSparseMatrixCSC,CuSparseMatrixCSR}) = false
ishermitian(M::Union{CuSparseMatrixCSC,CuSparseMatrixCSR}) = false
issymmetric(M::Symmetric{CuSparseMatrixCSC}) = true
ishermitian(M::Hermitian{CuSparseMatrixCSC}) = true
istriu(M::UpperTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = true
istril(M::UpperTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = false
istriu(M::LowerTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = false
istril(M::LowerTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = true
eltype(g::CuSparseMatrix{T}) where T = T
# getindex (mostly adapted from stdlib/SparseArrays)
# Translations
getindex(A::AbstractCuSparseVector, ::Colon) = copy(A)
getindex(A::AbstractCuSparseMatrix, ::Colon, ::Colon) = copy(A)
getindex(A::AbstractCuSparseMatrix, i, ::Colon) = getindex(A, i, 1:size(A, 2))
getindex(A::AbstractCuSparseMatrix, ::Colon, i) = getindex(A, 1:size(A, 1), i)
getindex(A::AbstractCuSparseMatrix, I::Tuple{Integer,Integer}) = getindex(A, I[1], I[2])
# Column slices
function getindex(x::CuSparseMatrixCSC, ::Colon, j::Integer)
checkbounds(x, :, j)
r1 = convert(Int, x.colPtr[j])
r2 = convert(Int, x.colPtr[j+1]) - 1
CuSparseVector(x.rowVal[r1:r2], x.nzVal[r1:r2], size(x, 1))
end
function getindex(x::CuSparseMatrixCSR, i::Integer, ::Colon)
checkbounds(x, :, i)
c1 = convert(Int, x.rowPtr[i])
c2 = convert(Int, x.rowPtr[i+1]) - 1
CuSparseVector(x.colVal[c1:c2], x.nzVal[c1:c2], size(x, 2))
end
# Row slices
# TODO optimize
getindex(A::CuSparseMatrixCSC, i::Integer, ::Colon) = CuSparseVector(sparse(A[i, 1:end]))
# TODO optimize
getindex(A::CuSparseMatrixCSR, ::Colon, j::Integer) = CuSparseVector(sparse(A[1:end, j]))
function getindex(A::CuSparseMatrixCSC{T}, i0::Integer, i1::Integer) where T
m, n = size(A)
if !(1 <= i0 <= m && 1 <= i1 <= n)
throw(BoundsError())
end
r1 = Int(A.colPtr[i1])
r2 = Int(A.colPtr[i1+1]-1)
(r1 > r2) && return zero(T)
r1 = searchsortedfirst(A.rowVal, i0, r1, r2, Base.Order.Forward)
((r1 > r2) || (A.rowVal[r1] != i0)) ? zero(T) : A.nzVal[r1]
end
function getindex(A::CuSparseMatrixCSR{T}, i0::Integer, i1::Integer) where T
m, n = size(A)
if !(1 <= i0 <= m && 1 <= i1 <= n)
throw(BoundsError())
end
c1 = Int(A.rowPtr[i0])
c2 = Int(A.rowPtr[i0+1]-1)
(c1 > c2) && return zero(T)
c1 = searchsortedfirst(A.colVal, i1, c1, c2, Base.Order.Forward)
((c1 > c2) || (A.colVal[c1] != i1)) ? zero(T) : A.nzVal[c1]
end
# Called for indexing into `CuSparseVector`s
function _spgetindex(m::Integer, nzind::CuVector{Ti}, nzval::CuVector{Tv},
i::Integer) where {Tv,Ti}
ii = searchsortedfirst(nzind, convert(Ti, i))
(ii <= m && nzind[ii] == i) ? nzval[ii] : zero(Tv)
end
function collect(Vec::CuSparseVector)
SparseVector(Vec.dims[1], collect(Vec.iPtr), collect(Vec.nzVal))
end
function collect(Mat::CuSparseMatrixCSC)
SparseMatrixCSC(Mat.dims[1], Mat.dims[2], collect(Mat.colPtr), collect(Mat.rowVal), collect(Mat.nzVal))
end
function collect(Mat::CuSparseMatrixCSR)
rowPtr = collect(Mat.rowPtr)
colVal = collect(Mat.colVal)
nzVal = collect(Mat.nzVal)
#construct Is
I = similar(colVal)
counter = 1
for row = 1 : size(Mat)[1], k = rowPtr[row] : (rowPtr[row+1]-1)
I[counter] = row
counter += 1
end
return sparse(I,colVal,nzVal,Mat.dims[1],Mat.dims[2])
end
summary(g::CuSparseMatrix) = string(g)
summary(g::CuSparseVector) = string(g)
CuSparseVector(iPtr::Vector{Ti}, nzVal::Vector{T}, dims::Int) where {T<:BlasFloat, Ti<:Integer} = CuSparseVector{T}(CuArray(convert(Vector{Cint},iPtr)), CuArray(nzVal), dims, convert(Cint,length(nzVal)))
CuSparseVector(iPtr::CuArray{Ti}, nzVal::CuArray{T}, dims::Int) where {T<:BlasFloat, Ti<:Integer} = CuSparseVector{T}(iPtr, nzVal, dims, convert(Cint,length(nzVal)))
CuSparseMatrixCSC(colPtr::Vector{Ti}, rowVal::Vector{Ti}, nzVal::Vector{T}, dims::NTuple{2,Int}) where {T<:BlasFloat,Ti<:Integer} = CuSparseMatrixCSC{T}(CuArray(convert(Vector{Cint},colPtr)), CuArray(convert(Vector{Cint},rowVal)), CuArray(nzVal), dims, convert(Cint,length(nzVal)))
CuSparseMatrixCSC(colPtr::CuArray{Ti}, rowVal::CuArray{Ti}, nzVal::CuArray{T}, dims::NTuple{2,Int}) where {T<:BlasFloat,Ti<:Integer} = CuSparseMatrixCSC{T}(colPtr, rowVal, nzVal, dims, convert(Cint,length(nzVal)))
CuSparseMatrixCSC(colPtr::CuArray{Ti}, rowVal::CuArray{Ti}, nzVal::CuArray{T}, nnz, dims::NTuple{2,Int}) where {T<:BlasFloat,Ti<:Integer} = CuSparseMatrixCSC{T}(colPtr, rowVal, nzVal, dims, nnz)
CuSparseMatrixCSR(rowPtr::CuArray, colVal::CuArray, nzVal::CuArray{T}, dims::NTuple{2,Int}) where T = CuSparseMatrixCSR{T}(rowPtr, colVal, nzVal, dims, convert(Cint,length(nzVal)))
CuSparseMatrixCSR(rowPtr::CuArray, colVal::CuArray, nzVal::CuArray{T}, nnz, dims::NTuple{2,Int}) where T = CuSparseMatrixCSR{T}(rowPtr, colVal, nzVal, dims, nnz)
CuSparseMatrixBSR(rowPtr::CuArray, colVal::CuArray, nzVal::CuArray{T}, blockDim, dir, nnz, dims::NTuple{2,Int}) where T = CuSparseMatrixBSR{T}(rowPtr, colVal, nzVal, dims, blockDim, dir, nnz)
CuSparseVector(Vec::SparseVector) = CuSparseVector(Vec.nzind, Vec.nzval, size(Vec)[1])
CuSparseMatrixCSC(Vec::SparseVector) = CuSparseMatrixCSC([1], Vec.nzind, Vec.nzval, size(Vec))
CuSparseVector(Mat::SparseMatrixCSC) = size(Mat,2) == 1 ? CuSparseVector(Mat.rowval, Mat.nzval, size(Mat)[1]) : throw(ArgumentError("The input argument must have a single column"))
CuSparseMatrixCSC(Mat::SparseMatrixCSC) = CuSparseMatrixCSC(Mat.colptr, Mat.rowval, Mat.nzval, size(Mat))
CuSparseMatrixCSR(Mat::SparseMatrixCSC) = switch2csr(CuSparseMatrixCSC(Mat))
similar(Vec::CuSparseVector) = CuSparseVector(copy(Vec.iPtr), similar(Vec.nzVal), Vec.dims[1])
similar(Mat::CuSparseMatrixCSC) = CuSparseMatrixCSC(copy(Mat.colPtr), copy(Mat.rowVal), similar(Mat.nzVal), Mat.nnz, Mat.dims)
similar(Mat::CuSparseMatrixCSR) = CuSparseMatrixCSR(copy(Mat.rowPtr), copy(Mat.colVal), similar(Mat.nzVal), Mat.nnz, Mat.dims)
similar(Mat::CuSparseMatrixBSR) = CuSparseMatrixBSR(copy(Mat.rowPtr), copy(Mat.colVal), similar(Mat.nzVal), Mat.blockDim, Mat.dir, Mat.nnz, Mat.dims)
function copyto!(dst::CuSparseVector, src::CuSparseVector)
if dst.dims != src.dims
throw(ArgumentError("Inconsistent Sparse Vector size"))
end
copyto!(dst.iPtr, src.iPtr)
copyto!(dst.nzVal, src.nzVal)
dst.nnz = src.nnz
dst
end
function copyto!(dst::CuSparseMatrixCSC, src::CuSparseMatrixCSC)
if dst.dims != src.dims
throw(ArgumentError("Inconsistent Sparse Matrix size"))
end
copyto!(dst.colPtr, src.colPtr)
copyto!(dst.rowVal, src.rowVal)
copyto!(dst.nzVal, src.nzVal)
dst.nnz = src.nnz
dst
end
function copyto!(dst::CuSparseMatrixCSR, src::CuSparseMatrixCSR)
if dst.dims != src.dims
throw(ArgumentError("Inconsistent Sparse Matrix size"))
end
copyto!(dst.rowPtr, src.rowPtr)
copyto!(dst.colVal, src.colVal)
copyto!(dst.nzVal, src.nzVal)
dst.nnz = src.nnz
dst
end
function copyto!(dst::CuSparseMatrixBSR, src::CuSparseMatrixBSR)
if dst.dims != src.dims
throw(ArgumentError("Inconsistent Sparse Matrix size"))
end
copyto!(dst.rowPtr, src.rowPtr)
copyto!(dst.colVal, src.colVal)
copyto!(dst.nzVal, src.nzVal)
dst.dir = src.dir
dst.nnz = src.nnz
dst
end
function copyto!(dst::CuSparseMatrixHYB, src::CuSparseMatrixHYB)
if dst.dims != src.dims
throw(ArgumentError("Inconsistent Sparse Matrix size"))
end
dst.Mat = src.Mat
dst.nnz = src.nnz
dst
end
copy(Vec::CuSparseVector) = copyto!(similar(Vec),Vec)
copy(Mat::CuSparseMatrixCSC) = copyto!(similar(Mat),Mat)
copy(Mat::CuSparseMatrixCSR) = copyto!(similar(Mat),Mat)
copy(Mat::CuSparseMatrixBSR) = copyto!(similar(Mat),Mat)
| [
2,
2183,
7552,
286,
14496,
19182,
287,
327,
8322,
8001,
329,
29877,
30104,
14,
6759,
45977,
198,
2,
1262,
327,
6173,
5794,
329,
987,
404,
351,
22300,
338,
6868,
29877,
11244,
198,
198,
39344,
14496,
50,
29572,
46912,
34,
6173,
11,
14496,
50,
29572,
46912,
7902,
49,
11,
198,
220,
220,
220,
220,
220,
220,
14496,
50,
29572,
46912,
42598,
33,
11,
14496,
50,
29572,
46912,
4462,
49,
11,
198,
220,
220,
220,
220,
220,
220,
14496,
50,
29572,
46912,
11,
27741,
46141,
50,
29572,
46912,
11,
198,
220,
220,
220,
220,
220,
220,
14496,
50,
29572,
38469,
198,
198,
11748,
7308,
25,
4129,
11,
2546,
11,
299,
67,
12078,
11,
1288,
4906,
11,
2092,
11,
17562,
11,
33769,
11,
198,
220,
220,
220,
4866,
11,
10385,
11,
302,
27381,
11,
905,
11,
10638,
11,
4866,
1462,
28265,
651,
9630,
11,
651,
28265,
6070,
28265,
2824,
198,
198,
3500,
44800,
2348,
29230,
198,
11748,
44800,
2348,
29230,
25,
1086,
292,
43879,
11,
2332,
2781,
666,
11,
18113,
5574,
43094,
11,
1189,
26621,
19482,
11,
3602,
3455,
11,
1215,
73,
1563,
11,
198,
220,
220,
220,
318,
372,
2781,
666,
11,
318,
28461,
84,
11,
318,
2213,
346,
11,
1632,
3020,
19482,
11,
20390,
14824,
21413,
11,
16048,
14824,
21413,
198,
198,
3500,
1338,
17208,
3163,
20477,
198,
11748,
1338,
17208,
3163,
20477,
25,
29877,
11,
1338,
17208,
46912,
34,
6173,
11,
299,
27305,
11,
1729,
9107,
418,
11,
1729,
22570,
521,
82,
11,
198,
220,
220,
220,
4808,
2777,
1136,
9630,
198,
198,
397,
8709,
2099,
27741,
46141,
50,
29572,
19182,
90,
51,
85,
11,
399,
92,
1279,
25,
27741,
50,
29572,
19182,
90,
51,
85,
11,
327,
600,
11,
399,
92,
886,
198,
9979,
27741,
46141,
50,
29572,
38469,
90,
51,
85,
92,
796,
27741,
46141,
50,
29572,
19182,
90,
51,
85,
11,
16,
92,
198,
9979,
27741,
46141,
50,
29572,
46912,
90,
51,
85,
92,
796,
27741,
46141,
50,
29572,
19182,
90,
51,
85,
11,
17,
92,
198,
198,
76,
18187,
2878,
14496,
50,
29572,
38469,
90,
51,
85,
92,
1279,
25,
27741,
46141,
50,
29572,
38469,
90,
51,
85,
92,
198,
220,
220,
220,
9736,
2213,
3712,
46141,
38469,
90,
34,
600,
92,
198,
220,
220,
220,
299,
89,
7762,
3712,
46141,
38469,
90,
51,
85,
92,
198,
220,
220,
220,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
92,
198,
220,
220,
220,
299,
27305,
3712,
34,
600,
628,
220,
220,
220,
2163,
14496,
50,
29572,
38469,
90,
51,
85,
92,
7,
72,
46745,
3712,
46141,
38469,
90,
34,
600,
5512,
299,
89,
7762,
3712,
46141,
38469,
90,
51,
85,
5512,
5391,
82,
3712,
5317,
11,
299,
27305,
3712,
34,
600,
8,
810,
309,
85,
198,
220,
220,
220,
220,
220,
220,
220,
649,
7,
72,
46745,
11,
27305,
7762,
11,
7,
67,
12078,
11,
16,
828,
20471,
89,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
14496,
3163,
20477,
13,
13271,
8635,
62,
5787,
0,
7,
34223,
3712,
46141,
50,
29572,
38469,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
72,
46745,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
27305,
7762,
8,
198,
220,
220,
220,
1441,
198,
437,
198,
198,
76,
18187,
2878,
14496,
50,
29572,
46912,
34,
6173,
90,
51,
85,
92,
1279,
25,
27741,
46141,
50,
29572,
46912,
90,
51,
85,
92,
198,
220,
220,
220,
951,
46745,
3712,
46141,
38469,
90,
34,
600,
92,
198,
220,
220,
220,
5752,
7762,
3712,
46141,
38469,
90,
34,
600,
92,
198,
220,
220,
220,
299,
89,
7762,
3712,
46141,
38469,
90,
51,
85,
92,
198,
220,
220,
220,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
92,
198,
220,
220,
220,
299,
27305,
3712,
34,
600,
628,
220,
220,
220,
2163,
14496,
50,
29572,
46912,
34,
6173,
90,
51,
85,
92,
7,
4033,
46745,
3712,
46141,
38469,
90,
34,
600,
5512,
5752,
7762,
3712,
46141,
38469,
90,
34,
600,
5512,
299,
89,
7762,
3712,
46141,
38469,
90,
51,
85,
5512,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
5512,
299,
27305,
3712,
34,
600,
8,
810,
309,
85,
198,
220,
220,
220,
220,
220,
220,
220,
649,
7,
4033,
46745,
11,
808,
7762,
11,
27305,
7762,
11,
67,
12078,
11,
20471,
89,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
14496,
50,
29572,
46912,
34,
6173,
0,
7,
34223,
3712,
46141,
50,
29572,
38469,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
4033,
46745,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
808,
7762,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
27305,
7762,
8,
198,
220,
220,
220,
1441,
198,
437,
198,
198,
37811,
198,
29869,
284,
1745,
29877,
2603,
45977,
287,
25388,
29877,
5752,
357,
7902,
49,
8,
5794,
319,
262,
198,
33346,
13,
198,
198,
1174,
6425,
1174,
25,
4042,
327,
2937,
27082,
5188,
4560,
670,
351,
9429,
49,
39559,
2603,
45977,
11,
2138,
198,
14813,
327,
6173,
13,
198,
37811,
198,
76,
18187,
2878,
14496,
50,
29572,
46912,
7902,
49,
90,
51,
85,
92,
1279,
25,
27741,
46141,
50,
29572,
46912,
90,
51,
85,
92,
198,
220,
220,
220,
5752,
46745,
3712,
46141,
38469,
90,
34,
600,
92,
198,
220,
220,
220,
951,
7762,
3712,
46141,
38469,
90,
34,
600,
92,
198,
220,
220,
220,
299,
89,
7762,
3712,
46141,
38469,
90,
51,
85,
92,
198,
220,
220,
220,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
92,
198,
220,
220,
220,
299,
27305,
3712,
34,
600,
628,
220,
220,
220,
2163,
14496,
50,
29572,
46912,
7902,
49,
90,
51,
85,
92,
7,
808,
46745,
3712,
46141,
38469,
90,
34,
600,
5512,
951,
7762,
3712,
46141,
38469,
90,
34,
600,
5512,
299,
89,
7762,
3712,
46141,
38469,
90,
51,
85,
5512,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
5512,
299,
27305,
3712,
34,
600,
8,
810,
309,
85,
198,
220,
220,
220,
220,
220,
220,
220,
649,
7,
808,
46745,
11,
4033,
7762,
11,
27305,
7762,
11,
67,
12078,
11,
20471,
89,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
14496,
50,
29572,
46912,
7902,
49,
0,
7,
34223,
3712,
46141,
50,
29572,
38469,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
808,
46745,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
4033,
7762,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
27305,
7762,
8,
198,
220,
220,
220,
1441,
198,
437,
198,
198,
37811,
198,
29869,
284,
1745,
29877,
2603,
45977,
287,
2512,
25388,
29877,
5752,
357,
4462,
49,
8,
5794,
319,
198,
1169,
11362,
13,
347,
12562,
5794,
318,
635,
973,
287,
8180,
20553,
43,
11,
290,
318,
16662,
284,
2603,
45977,
326,
389,
198,
1,
9967,
1,
29877,
532,
4071,
7021,
286,
1729,
12,
82,
29572,
7652,
13,
198,
37811,
198,
76,
18187,
2878,
14496,
50,
29572,
46912,
4462,
49,
90,
51,
85,
92,
1279,
25,
27741,
46141,
50,
29572,
46912,
90,
51,
85,
92,
198,
220,
220,
220,
5752,
46745,
3712,
46141,
38469,
90,
34,
600,
92,
198,
220,
220,
220,
951,
7762,
3712,
46141,
38469,
90,
34,
600,
92,
198,
220,
220,
220,
299,
89,
7762,
3712,
46141,
38469,
90,
51,
85,
92,
198,
220,
220,
220,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
92,
198,
220,
220,
220,
2512,
29271,
3712,
34,
600,
198,
220,
220,
220,
26672,
3712,
50,
29572,
12441,
198,
220,
220,
220,
299,
27305,
3712,
34,
600,
628,
220,
220,
220,
2163,
14496,
50,
29572,
46912,
4462,
49,
90,
51,
85,
92,
7,
808,
46745,
3712,
46141,
38469,
90,
34,
600,
5512,
951,
7762,
3712,
46141,
38469,
90,
34,
600,
5512,
299,
89,
7762,
3712,
46141,
38469,
90,
51,
85,
5512,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
5512,
9967,
29271,
3712,
34,
600,
11,
26672,
3712,
50,
29572,
12441,
11,
299,
27305,
3712,
34,
600,
8,
810,
309,
85,
198,
220,
220,
220,
220,
220,
220,
220,
649,
7,
808,
46745,
11,
4033,
7762,
11,
27305,
7762,
11,
67,
12078,
11,
9967,
29271,
11,
15908,
11,
20471,
89,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
14496,
50,
29572,
46912,
4462,
49,
0,
7,
34223,
3712,
46141,
50,
29572,
38469,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
808,
46745,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
4033,
7762,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
7,
34223,
13,
27305,
7762,
8,
198,
220,
220,
220,
1441,
198,
437,
198,
198,
37811,
198,
29869,
284,
1745,
29877,
2603,
45977,
287,
15127,
338,
14554,
357,
42598,
33,
8,
5794,
319,
262,
11362,
13,
198,
42598,
33,
5794,
318,
281,
32191,
2878,
11,
543,
460,
307,
11513,
284,
14,
6738,
1262,
198,
34,
2937,
27082,
5188,
31878,
13,
198,
37811,
198,
76,
18187,
2878,
14496,
50,
29572,
46912,
42598,
33,
90,
51,
85,
92,
1279,
25,
27741,
46141,
50,
29572,
46912,
90,
51,
85,
92,
198,
220,
220,
220,
6550,
3712,
9042,
29572,
21217,
65,
19044,
62,
83,
198,
220,
220,
220,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
92,
198,
220,
220,
220,
299,
27305,
3712,
34,
600,
628,
220,
220,
220,
2163,
14496,
50,
29572,
46912,
42598,
33,
90,
51,
85,
92,
7,
19044,
3712,
9042,
29572,
21217,
65,
19044,
62,
83,
11,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
5512,
299,
27305,
3712,
34,
600,
8,
810,
309,
85,
198,
220,
220,
220,
220,
220,
220,
220,
649,
7,
19044,
11,
67,
12078,
11,
20471,
89,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
37811,
198,
18274,
879,
6441,
2099,
286,
685,
63,
46141,
50,
29572,
46912,
34,
6173,
63,
16151,
31,
5420,
828,
685,
63,
46141,
50,
29572,
46912,
7902,
49,
63,
16151,
31,
5420,
828,
198,
392,
4600,
9360,
2781,
666,
63,
290,
4600,
13940,
3020,
19482,
63,
6300,
286,
777,
734,
16472,
13,
317,
2163,
12598,
198,
5661,
2099,
460,
787,
779,
286,
2854,
8561,
416,
691,
6376,
278,
530,
22950,
286,
262,
198,
6759,
8609,
611,
340,
318,
11462,
284,
307,
607,
2781,
666,
14,
1837,
3020,
19482,
13,
198,
37811,
198,
9979,
3082,
2790,
50,
29572,
90,
51,
92,
796,
4479,
90,
46141,
50,
29572,
46912,
34,
6173,
90,
51,
5512,
46141,
50,
29572,
46912,
7902,
49,
90,
51,
5512,
48523,
5574,
43094,
90,
51,
11,
46141,
50,
29572,
46912,
34,
6173,
90,
51,
92,
5512,
48523,
5574,
43094,
90,
51,
11,
46141,
50,
29572,
46912,
7902,
49,
90,
51,
42535,
198,
198,
37811,
198,
18274,
879,
6441,
2099,
286,
685,
63,
46141,
50,
29572,
46912,
34,
6173,
63,
16151,
31,
5420,
828,
685,
63,
46141,
50,
29572,
46912,
7902,
49,
63,
16151,
31,
5420,
828,
198,
58,
63,
46141,
50,
29572,
46912,
4462,
49,
63,
16151,
31,
5420,
828,
290,
685,
63,
46141,
50,
29572,
46912,
42598,
33,
63,
16151,
31,
5420,
737,
198,
37811,
198,
9979,
14496,
50,
29572,
46912,
90,
51,
92,
796,
4479,
90,
46141,
50,
29572,
46912,
34,
6173,
90,
51,
5512,
46141,
50,
29572,
46912,
7902,
49,
90,
51,
5512,
14496,
50,
29572,
46912,
4462,
49,
90,
51,
5512,
14496,
50,
29572,
46912,
42598,
33,
90,
51,
11709,
198,
198,
9360,
2781,
666,
90,
51,
92,
7,
19044,
3712,
46141,
50,
29572,
46912,
90,
51,
30072,
810,
309,
796,
2332,
2781,
666,
90,
51,
11,
4906,
1659,
7,
19044,
38165,
7,
19044,
4032,
52,
11537,
198,
198,
13664,
7,
70,
3712,
46141,
50,
29572,
38469,
8,
796,
40426,
7,
70,
13,
67,
12078,
8,
198,
7857,
7,
70,
3712,
46141,
50,
29572,
38469,
8,
796,
308,
13,
67,
12078,
198,
358,
12078,
7,
70,
3712,
46141,
50,
29572,
38469,
8,
796,
352,
198,
13664,
7,
70,
3712,
46141,
50,
29572,
46912,
8,
796,
40426,
7,
70,
13,
67,
12078,
8,
198,
7857,
7,
70,
3712,
46141,
50,
29572,
46912,
8,
796,
308,
13,
67,
12078,
198,
358,
12078,
7,
70,
3712,
46141,
50,
29572,
46912,
8,
796,
362,
198,
198,
8818,
2546,
7,
70,
3712,
46141,
50,
29572,
38469,
11,
288,
3712,
46541,
8,
198,
220,
220,
220,
611,
288,
6624,
352,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
308,
13,
67,
12078,
58,
67,
60,
198,
220,
220,
220,
2073,
361,
288,
1875,
352,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
352,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
46156,
1276,
307,
26870,
352,
11,
1392,
720,
67,
48774,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
2546,
7,
70,
3712,
46141,
50,
29572,
46912,
11,
288,
3712,
46541,
8,
198,
220,
220,
220,
611,
288,
287,
685,
16,
11,
362,
60,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
308,
13,
67,
12078,
58,
67,
60,
198,
220,
220,
220,
2073,
361,
288,
1875,
352,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
352,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
46156,
1276,
307,
26870,
352,
11,
1392,
720,
67,
48774,
198,
220,
220,
220,
886,
198,
437,
198,
198,
20471,
89,
7,
70,
3712,
23839,
46141,
50,
29572,
19182,
8,
796,
308,
13,
20471,
89,
198,
13159,
9107,
418,
7,
70,
3712,
23839,
46141,
50,
29572,
19182,
8,
796,
308,
13,
27305,
7762,
198,
198,
13159,
22570,
521,
82,
7,
70,
3712,
23839,
46141,
50,
29572,
38469,
8,
796,
308,
13,
72,
46745,
198,
198,
747,
26621,
19482,
7,
44,
3712,
38176,
90,
46141,
50,
29572,
46912,
34,
6173,
11,
46141,
50,
29572,
46912,
7902,
49,
30072,
796,
3991,
198,
4828,
2781,
666,
7,
44,
3712,
38176,
90,
46141,
50,
29572,
46912,
34,
6173,
11,
46141,
50,
29572,
46912,
7902,
49,
30072,
796,
3991,
198,
747,
26621,
19482,
7,
44,
3712,
13940,
3020,
19482,
90,
46141,
50,
29572,
46912,
34,
6173,
30072,
796,
2081,
198,
4828,
2781,
666,
7,
44,
3712,
9360,
2781,
666,
90,
46141,
50,
29572,
46912,
34,
6173,
30072,
796,
2081,
198,
198,
396,
380,
84,
7,
44,
3712,
52,
2848,
14824,
21413,
90,
51,
11,
50,
30072,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
311,
27,
25,
23839,
46141,
50,
29572,
46912,
92,
796,
2081,
198,
396,
22379,
7,
44,
3712,
52,
2848,
14824,
21413,
90,
51,
11,
50,
30072,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
311,
27,
25,
23839,
46141,
50,
29572,
46912,
92,
796,
3991,
198,
396,
380,
84,
7,
44,
3712,
31426,
14824,
21413,
90,
51,
11,
50,
30072,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
311,
27,
25,
23839,
46141,
50,
29572,
46912,
92,
796,
3991,
198,
396,
22379,
7,
44,
3712,
31426,
14824,
21413,
90,
51,
11,
50,
30072,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
311,
27,
25,
23839,
46141,
50,
29572,
46912,
92,
796,
2081,
198,
417,
4906,
7,
70,
3712,
46141,
50,
29572,
46912,
90,
51,
30072,
810,
309,
796,
309,
198,
198,
2,
651,
9630,
357,
29471,
16573,
422,
14367,
8019,
14,
50,
29572,
3163,
20477,
8,
198,
198,
2,
3602,
49905,
198,
1136,
9630,
7,
32,
3712,
23839,
46141,
50,
29572,
38469,
11,
7904,
5216,
261,
8,
220,
220,
220,
220,
220,
220,
220,
220,
220,
796,
4866,
7,
32,
8,
198,
1136,
9630,
7,
32,
3712,
23839,
46141,
50,
29572,
46912,
11,
7904,
5216,
261,
11,
7904,
5216,
261,
8,
796,
4866,
7,
32,
8,
198,
1136,
9630,
7,
32,
3712,
23839,
46141,
50,
29572,
46912,
11,
1312,
11,
7904,
5216,
261,
8,
220,
220,
220,
220,
220,
220,
796,
651,
9630,
7,
32,
11,
1312,
11,
352,
25,
7857,
7,
32,
11,
362,
4008,
198,
1136,
9630,
7,
32,
3712,
23839,
46141,
50,
29572,
46912,
11,
7904,
5216,
261,
11,
1312,
8,
220,
220,
220,
220,
220,
220,
796,
651,
9630,
7,
32,
11,
352,
25,
7857,
7,
32,
11,
352,
828,
1312,
8,
198,
1136,
9630,
7,
32,
3712,
23839,
46141,
50,
29572,
46912,
11,
314,
3712,
51,
29291,
90,
46541,
11,
46541,
30072,
796,
651,
9630,
7,
32,
11,
314,
58,
16,
4357,
314,
58,
17,
12962,
198,
198,
2,
29201,
24314,
198,
8818,
651,
9630,
7,
87,
3712,
46141,
50,
29572,
46912,
34,
6173,
11,
7904,
5216,
261,
11,
474,
3712,
46541,
8,
198,
220,
220,
220,
2198,
65,
3733,
7,
87,
11,
1058,
11,
474,
8,
198,
220,
220,
220,
374,
16,
796,
10385,
7,
5317,
11,
2124,
13,
4033,
46745,
58,
73,
12962,
198,
220,
220,
220,
374,
17,
796,
10385,
7,
5317,
11,
2124,
13,
4033,
46745,
58,
73,
10,
16,
12962,
532,
352,
198,
220,
220,
220,
14496,
50,
29572,
38469,
7,
87,
13,
808,
7762,
58,
81,
16,
25,
81,
17,
4357,
2124,
13,
27305,
7762,
58,
81,
16,
25,
81,
17,
4357,
2546,
7,
87,
11,
352,
4008,
198,
437,
198,
198,
8818,
651,
9630,
7,
87,
3712,
46141,
50,
29572,
46912,
7902,
49,
11,
1312,
3712,
46541,
11,
7904,
5216,
261,
8,
198,
220,
220,
220,
2198,
65,
3733,
7,
87,
11,
1058,
11,
1312,
8,
198,
220,
220,
220,
269,
16,
796,
10385,
7,
5317,
11,
2124,
13,
808,
46745,
58,
72,
12962,
198,
220,
220,
220,
269,
17,
796,
10385,
7,
5317,
11,
2124,
13,
808,
46745,
58,
72,
10,
16,
12962,
532,
352,
198,
220,
220,
220,
14496,
50,
29572,
38469,
7,
87,
13,
4033,
7762,
58,
66,
16,
25,
66,
17,
4357,
2124,
13,
27305,
7762,
58,
66,
16,
25,
66,
17,
4357,
2546,
7,
87,
11,
362,
4008,
198,
437,
198,
198,
2,
11314,
24314,
198,
2,
16926,
46,
27183,
198,
1136,
9630,
7,
32,
3712,
46141,
50,
29572,
46912,
34,
6173,
11,
1312,
3712,
46541,
11,
7904,
5216,
261,
8,
796,
14496,
50,
29572,
38469,
7,
82,
29572,
7,
32,
58,
72,
11,
352,
25,
437,
60,
4008,
198,
2,
16926,
46,
27183,
198,
1136,
9630,
7,
32,
3712,
46141,
50,
29572,
46912,
7902,
49,
11,
7904,
5216,
261,
11,
474,
3712,
46541,
8,
796,
14496,
50,
29572,
38469,
7,
82,
29572,
7,
32,
58,
16,
25,
437,
11,
474,
60,
4008,
198,
198,
8818,
651,
9630,
7,
32,
3712,
46141,
50,
29572,
46912,
34,
6173,
90,
51,
5512,
1312,
15,
3712,
46541,
11,
1312,
16,
3712,
46541,
8,
810,
309,
198,
220,
220,
220,
285,
11,
299,
796,
2546,
7,
32,
8,
198,
220,
220,
220,
611,
5145,
7,
16,
19841,
1312,
15,
19841,
285,
11405,
352,
19841,
1312,
16,
19841,
299,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
33,
3733,
12331,
28955,
198,
220,
220,
220,
886,
198,
220,
220,
220,
374,
16,
796,
2558,
7,
32,
13,
4033,
46745,
58,
72,
16,
12962,
198,
220,
220,
220,
374,
17,
796,
2558,
7,
32,
13,
4033,
46745,
58,
72,
16,
10,
16,
45297,
16,
8,
198,
220,
220,
220,
357,
81,
16,
1875,
374,
17,
8,
11405,
1441,
6632,
7,
51,
8,
198,
220,
220,
220,
374,
16,
796,
2989,
82,
9741,
11085,
7,
32,
13,
808,
7762,
11,
1312,
15,
11,
374,
16,
11,
374,
17,
11,
7308,
13,
18743,
13,
39746,
8,
198,
220,
220,
220,
14808,
81,
16,
1875,
374,
17,
8,
8614,
357,
32,
13,
808,
7762,
58,
81,
16,
60,
14512,
1312,
15,
4008,
5633,
6632,
7,
51,
8,
1058,
317,
13,
27305,
7762,
58,
81,
16,
60,
198,
437,
198,
198,
8818,
651,
9630,
7,
32,
3712,
46141,
50,
29572,
46912,
7902,
49,
90,
51,
5512,
1312,
15,
3712,
46541,
11,
1312,
16,
3712,
46541,
8,
810,
309,
198,
220,
220,
220,
285,
11,
299,
796,
2546,
7,
32,
8,
198,
220,
220,
220,
611,
5145,
7,
16,
19841,
1312,
15,
19841,
285,
11405,
352,
19841,
1312,
16,
19841,
299,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
33,
3733,
12331,
28955,
198,
220,
220,
220,
886,
198,
220,
220,
220,
269,
16,
796,
2558,
7,
32,
13,
808,
46745,
58,
72,
15,
12962,
198,
220,
220,
220,
269,
17,
796,
2558,
7,
32,
13,
808,
46745,
58,
72,
15,
10,
16,
45297,
16,
8,
198,
220,
220,
220,
357,
66,
16,
1875,
269,
17,
8,
11405,
1441,
6632,
7,
51,
8,
198,
220,
220,
220,
269,
16,
796,
2989,
82,
9741,
11085,
7,
32,
13,
4033,
7762,
11,
1312,
16,
11,
269,
16,
11,
269,
17,
11,
7308,
13,
18743,
13,
39746,
8,
198,
220,
220,
220,
14808,
66,
16,
1875,
269,
17,
8,
8614,
357,
32,
13,
4033,
7762,
58,
66,
16,
60,
14512,
1312,
16,
4008,
5633,
6632,
7,
51,
8,
1058,
317,
13,
27305,
7762,
58,
66,
16,
60,
198,
437,
198,
198,
2,
34099,
329,
6376,
278,
656,
4600,
46141,
50,
29572,
38469,
63,
82,
198,
8818,
4808,
2777,
1136,
9630,
7,
76,
3712,
46541,
11,
299,
89,
521,
3712,
46141,
38469,
90,
40533,
5512,
299,
89,
2100,
3712,
46141,
38469,
90,
51,
85,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1312,
3712,
46541,
8,
810,
1391,
51,
85,
11,
40533,
92,
198,
220,
220,
220,
21065,
796,
2989,
82,
9741,
11085,
7,
27305,
521,
11,
10385,
7,
40533,
11,
1312,
4008,
198,
220,
220,
220,
357,
4178,
19841,
285,
11405,
299,
89,
521,
58,
4178,
60,
6624,
1312,
8,
5633,
299,
89,
2100,
58,
4178,
60,
1058,
6632,
7,
51,
85,
8,
198,
437,
198,
198,
8818,
2824,
7,
53,
721,
3712,
46141,
50,
29572,
38469,
8,
198,
220,
220,
220,
1338,
17208,
38469,
7,
53,
721,
13,
67,
12078,
58,
16,
4357,
2824,
7,
53,
721,
13,
72,
46745,
828,
2824,
7,
53,
721,
13,
27305,
7762,
4008,
198,
437,
198,
198,
8818,
2824,
7,
19044,
3712,
46141,
50,
29572,
46912,
34,
6173,
8,
198,
220,
220,
220,
1338,
17208,
46912,
34,
6173,
7,
19044,
13,
67,
12078,
58,
16,
4357,
6550,
13,
67,
12078,
58,
17,
4357,
2824,
7,
19044,
13,
4033,
46745,
828,
2824,
7,
19044,
13,
808,
7762,
828,
2824,
7,
19044,
13,
27305,
7762,
4008,
198,
437,
198,
8818,
2824,
7,
19044,
3712,
46141,
50,
29572,
46912,
7902,
49,
8,
198,
220,
220,
220,
5752,
46745,
796,
2824,
7,
19044,
13,
808,
46745,
8,
198,
220,
220,
220,
951,
7762,
796,
2824,
7,
19044,
13,
4033,
7762,
8,
198,
220,
220,
220,
299,
89,
7762,
796,
2824,
7,
19044,
13,
27305,
7762,
8,
198,
220,
220,
220,
1303,
41571,
1148,
198,
220,
220,
220,
314,
796,
2092,
7,
4033,
7762,
8,
198,
220,
220,
220,
3753,
796,
352,
198,
220,
220,
220,
329,
5752,
796,
352,
1058,
2546,
7,
19044,
38381,
16,
4357,
479,
796,
5752,
46745,
58,
808,
60,
1058,
357,
808,
46745,
58,
808,
10,
16,
45297,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
314,
58,
24588,
60,
796,
5752,
198,
220,
220,
220,
220,
220,
220,
220,
3753,
15853,
352,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
29877,
7,
40,
11,
4033,
7762,
11,
27305,
7762,
11,
19044,
13,
67,
12078,
58,
16,
4357,
19044,
13,
67,
12078,
58,
17,
12962,
198,
437,
198,
198,
49736,
7,
70,
3712,
46141,
50,
29572,
46912,
8,
796,
4731,
7,
70,
8,
198,
49736,
7,
70,
3712,
46141,
50,
29572,
38469,
8,
796,
4731,
7,
70,
8,
198,
198,
46141,
50,
29572,
38469,
7,
72,
46745,
3712,
38469,
90,
40533,
5512,
299,
89,
7762,
3712,
38469,
90,
51,
5512,
5391,
82,
3712,
5317,
8,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
16953,
27,
25,
46541,
92,
796,
14496,
50,
29572,
38469,
90,
51,
92,
7,
46141,
19182,
7,
1102,
1851,
7,
38469,
90,
34,
600,
5512,
72,
46745,
36911,
14496,
19182,
7,
27305,
7762,
828,
5391,
82,
11,
10385,
7,
34,
600,
11,
13664,
7,
27305,
7762,
22305,
198,
46141,
50,
29572,
38469,
7,
72,
46745,
3712,
46141,
19182,
90,
40533,
5512,
299,
89,
7762,
3712,
46141,
19182,
90,
51,
5512,
5391,
82,
3712,
5317,
8,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
16953,
27,
25,
46541,
92,
796,
14496,
50,
29572,
38469,
90,
51,
92,
7,
72,
46745,
11,
299,
89,
7762,
11,
5391,
82,
11,
10385,
7,
34,
600,
11,
13664,
7,
27305,
7762,
22305,
198,
198,
46141,
50,
29572,
46912,
34,
6173,
7,
4033,
46745,
3712,
38469,
90,
40533,
5512,
5752,
7762,
3712,
38469,
90,
40533,
5512,
299,
89,
7762,
3712,
38469,
90,
51,
5512,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
30072,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
40533,
27,
25,
46541,
92,
796,
14496,
50,
29572,
46912,
34,
6173,
90,
51,
92,
7,
46141,
19182,
7,
1102,
1851,
7,
38469,
90,
34,
600,
5512,
4033,
46745,
36911,
14496,
19182,
7,
1102,
1851,
7,
38469,
90,
34,
600,
5512,
808,
7762,
36911,
14496,
19182,
7,
27305,
7762,
828,
5391,
82,
11,
10385,
7,
34,
600,
11,
13664,
7,
27305,
7762,
22305,
198,
46141,
50,
29572,
46912,
34,
6173,
7,
4033,
46745,
3712,
46141,
19182,
90,
40533,
5512,
5752,
7762,
3712,
46141,
19182,
90,
40533,
5512,
299,
89,
7762,
3712,
46141,
19182,
90,
51,
5512,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
30072,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
40533,
27,
25,
46541,
92,
796,
14496,
50,
29572,
46912,
34,
6173,
90,
51,
92,
7,
4033,
46745,
11,
5752,
7762,
11,
299,
89,
7762,
11,
5391,
82,
11,
10385,
7,
34,
600,
11,
13664,
7,
27305,
7762,
22305,
198,
46141,
50,
29572,
46912,
34,
6173,
7,
4033,
46745,
3712,
46141,
19182,
90,
40533,
5512,
5752,
7762,
3712,
46141,
19182,
90,
40533,
5512,
299,
89,
7762,
3712,
46141,
19182,
90,
51,
5512,
299,
27305,
11,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
30072,
810,
1391,
51,
27,
25,
3629,
292,
43879,
11,
40533,
27,
25,
46541,
92,
796,
14496,
50,
29572,
46912,
34,
6173,
90,
51,
92,
7,
4033,
46745,
11,
5752,
7762,
11,
299,
89,
7762,
11,
5391,
82,
11,
299,
27305,
8,
198,
198,
46141,
50,
29572,
46912,
7902,
49,
7,
808,
46745,
3712,
46141,
19182,
11,
951,
7762,
3712,
46141,
19182,
11,
299,
89,
7762,
3712,
46141,
19182,
90,
51,
5512,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
30072,
810,
309,
796,
14496,
50,
29572,
46912,
7902,
49,
90,
51,
92,
7,
808,
46745,
11,
951,
7762,
11,
299,
89,
7762,
11,
5391,
82,
11,
10385,
7,
34,
600,
11,
13664,
7,
27305,
7762,
22305,
198,
46141,
50,
29572,
46912,
7902,
49,
7,
808,
46745,
3712,
46141,
19182,
11,
951,
7762,
3712,
46141,
19182,
11,
299,
89,
7762,
3712,
46141,
19182,
90,
51,
5512,
299,
27305,
11,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
30072,
810,
309,
796,
14496,
50,
29572,
46912,
7902,
49,
90,
51,
92,
7,
808,
46745,
11,
951,
7762,
11,
299,
89,
7762,
11,
5391,
82,
11,
299,
27305,
8,
198,
198,
46141,
50,
29572,
46912,
4462,
49,
7,
808,
46745,
3712,
46141,
19182,
11,
951,
7762,
3712,
46141,
19182,
11,
299,
89,
7762,
3712,
46141,
19182,
90,
51,
5512,
2512,
29271,
11,
26672,
11,
299,
27305,
11,
5391,
82,
3712,
11251,
29291,
90,
17,
11,
5317,
30072,
810,
309,
796,
14496,
50,
29572,
46912,
4462,
49,
90,
51,
92,
7,
808,
46745,
11,
951,
7762,
11,
299,
89,
7762,
11,
5391,
82,
11,
2512,
29271,
11,
26672,
11,
299,
27305,
8,
198,
198,
46141,
50,
29572,
38469,
7,
53,
721,
3712,
50,
29572,
38469,
8,
220,
220,
220,
796,
14496,
50,
29572,
38469,
7,
53,
721,
13,
27305,
521,
11,
38692,
13,
27305,
2100,
11,
2546,
7,
53,
721,
38381,
16,
12962,
198,
46141,
50,
29572,
46912,
34,
6173,
7,
53,
721,
3712,
50,
29572,
38469,
8,
220,
220,
220,
796,
14496,
50,
29572,
46912,
34,
6173,
26933,
16,
4357,
38692,
13,
27305,
521,
11,
38692,
13,
27305,
2100,
11,
2546,
7,
53,
721,
4008,
198,
46141,
50,
29572,
38469,
7,
19044,
3712,
50,
29572,
46912,
34,
6173,
8,
796,
2546,
7,
19044,
11,
17,
8,
6624,
352,
5633,
14496,
50,
29572,
38469,
7,
19044,
13,
808,
2100,
11,
6550,
13,
27305,
2100,
11,
2546,
7,
19044,
38381,
16,
12962,
1058,
3714,
7,
28100,
1713,
12331,
7203,
464,
5128,
4578,
1276,
423,
257,
2060,
5721,
48774,
198,
46141,
50,
29572,
46912,
34,
6173,
7,
19044,
3712,
50,
29572,
46912,
34,
6173,
8,
796,
14496,
50,
29572,
46912,
34,
6173,
7,
19044,
13,
4033,
20692,
11,
6550,
13,
808,
2100,
11,
6550,
13,
27305,
2100,
11,
2546,
7,
19044,
4008,
198,
46141,
50,
29572,
46912,
7902,
49,
7,
19044,
3712,
50,
29572,
46912,
34,
6173,
8,
796,
5078,
17,
6359,
81,
7,
46141,
50,
29572,
46912,
34,
6173,
7,
19044,
4008,
198,
198,
38610,
7,
53,
721,
3712,
46141,
50,
29572,
38469,
8,
796,
14496,
50,
29572,
38469,
7,
30073,
7,
53,
721,
13,
72,
46745,
828,
2092,
7,
53,
721,
13,
27305,
7762,
828,
38692,
13,
67,
12078,
58,
16,
12962,
198,
38610,
7,
19044,
3712,
46141,
50,
29572,
46912,
34,
6173,
8,
796,
14496,
50,
29572,
46912,
34,
6173,
7,
30073,
7,
19044,
13,
4033,
46745,
828,
4866,
7,
19044,
13,
808,
7762,
828,
2092,
7,
19044,
13,
27305,
7762,
828,
6550,
13,
20471,
89,
11,
6550,
13,
67,
12078,
8,
198,
38610,
7,
19044,
3712,
46141,
50,
29572,
46912,
7902,
49,
8,
796,
14496,
50,
29572,
46912,
7902,
49,
7,
30073,
7,
19044,
13,
808,
46745,
828,
4866,
7,
19044,
13,
4033,
7762,
828,
2092,
7,
19044,
13,
27305,
7762,
828,
6550,
13,
20471,
89,
11,
6550,
13,
67,
12078,
8,
198,
38610,
7,
19044,
3712,
46141,
50,
29572,
46912,
4462,
49,
8,
796,
14496,
50,
29572,
46912,
4462,
49,
7,
30073,
7,
19044,
13,
808,
46745,
828,
4866,
7,
19044,
13,
4033,
7762,
828,
2092,
7,
19044,
13,
27305,
7762,
828,
6550,
13,
9967,
29271,
11,
6550,
13,
15908,
11,
6550,
13,
20471,
89,
11,
6550,
13,
67,
12078,
8,
198,
198,
8818,
4866,
1462,
0,
7,
67,
301,
3712,
46141,
50,
29572,
38469,
11,
12351,
3712,
46141,
50,
29572,
38469,
8,
198,
220,
220,
220,
611,
29636,
13,
67,
12078,
14512,
12351,
13,
67,
12078,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
818,
5936,
7609,
1338,
17208,
20650,
2546,
48774,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
72,
46745,
11,
12351,
13,
72,
46745,
8,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
27305,
7762,
11,
12351,
13,
27305,
7762,
8,
198,
220,
220,
220,
29636,
13,
20471,
89,
796,
12351,
13,
20471,
89,
198,
220,
220,
220,
29636,
198,
437,
198,
198,
8818,
4866,
1462,
0,
7,
67,
301,
3712,
46141,
50,
29572,
46912,
34,
6173,
11,
12351,
3712,
46141,
50,
29572,
46912,
34,
6173,
8,
198,
220,
220,
220,
611,
29636,
13,
67,
12078,
14512,
12351,
13,
67,
12078,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
818,
5936,
7609,
1338,
17208,
24936,
2546,
48774,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
4033,
46745,
11,
12351,
13,
4033,
46745,
8,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
808,
7762,
11,
12351,
13,
808,
7762,
8,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
27305,
7762,
11,
12351,
13,
27305,
7762,
8,
198,
220,
220,
220,
29636,
13,
20471,
89,
796,
12351,
13,
20471,
89,
198,
220,
220,
220,
29636,
198,
437,
198,
198,
8818,
4866,
1462,
0,
7,
67,
301,
3712,
46141,
50,
29572,
46912,
7902,
49,
11,
12351,
3712,
46141,
50,
29572,
46912,
7902,
49,
8,
198,
220,
220,
220,
611,
29636,
13,
67,
12078,
14512,
12351,
13,
67,
12078,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
818,
5936,
7609,
1338,
17208,
24936,
2546,
48774,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
808,
46745,
11,
12351,
13,
808,
46745,
8,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
4033,
7762,
11,
12351,
13,
4033,
7762,
8,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
27305,
7762,
11,
12351,
13,
27305,
7762,
8,
198,
220,
220,
220,
29636,
13,
20471,
89,
796,
12351,
13,
20471,
89,
198,
220,
220,
220,
29636,
198,
437,
198,
198,
8818,
4866,
1462,
0,
7,
67,
301,
3712,
46141,
50,
29572,
46912,
4462,
49,
11,
12351,
3712,
46141,
50,
29572,
46912,
4462,
49,
8,
198,
220,
220,
220,
611,
29636,
13,
67,
12078,
14512,
12351,
13,
67,
12078,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
818,
5936,
7609,
1338,
17208,
24936,
2546,
48774,
198,
220,
220,
220,
886,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
808,
46745,
11,
12351,
13,
808,
46745,
8,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
4033,
7762,
11,
12351,
13,
4033,
7762,
8,
198,
220,
220,
220,
4866,
1462,
0,
7,
67,
301,
13,
27305,
7762,
11,
12351,
13,
27305,
7762,
8,
198,
220,
220,
220,
29636,
13,
15908,
796,
12351,
13,
15908,
198,
220,
220,
220,
29636,
13,
20471,
89,
796,
12351,
13,
20471,
89,
198,
220,
220,
220,
29636,
198,
437,
198,
198,
8818,
4866,
1462,
0,
7,
67,
301,
3712,
46141,
50,
29572,
46912,
42598,
33,
11,
12351,
3712,
46141,
50,
29572,
46912,
42598,
33,
8,
198,
220,
220,
220,
611,
29636,
13,
67,
12078,
14512,
12351,
13,
67,
12078,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
818,
5936,
7609,
1338,
17208,
24936,
2546,
48774,
198,
220,
220,
220,
886,
198,
220,
220,
220,
29636,
13,
19044,
796,
12351,
13,
19044,
198,
220,
220,
220,
29636,
13,
20471,
89,
796,
12351,
13,
20471,
89,
198,
220,
220,
220,
29636,
198,
437,
198,
198,
30073,
7,
53,
721,
3712,
46141,
50,
29572,
38469,
8,
796,
4866,
1462,
0,
7,
38610,
7,
53,
721,
828,
53,
721,
8,
198,
30073,
7,
19044,
3712,
46141,
50,
29572,
46912,
34,
6173,
8,
796,
4866,
1462,
0,
7,
38610,
7,
19044,
828,
19044,
8,
198,
30073,
7,
19044,
3712,
46141,
50,
29572,
46912,
7902,
49,
8,
796,
4866,
1462,
0,
7,
38610,
7,
19044,
828,
19044,
8,
198,
30073,
7,
19044,
3712,
46141,
50,
29572,
46912,
4462,
49,
8,
796,
4866,
1462,
0,
7,
38610,
7,
19044,
828,
19044,
8,
198
] | 2.326374 | 5,748 |
using Serialization
struct RunnerProcResult
exitcode::Int64
result::Union{RunnerOutput, Nothing}
stdout::AbstractString
stderr::AbstractString
end
RunnerProcResult(s::Int64, r::Any, e::Nothing) = RunnerProcResult(s, r, "")
function readpipe!(p::Pipe)
close(p.in)
return read(p, String)
end
"""
launch_runner_proc(testsuite, submissionfile, functionname[; debug])
Launch a runner subprocess and get the resulting `RunnerProcResult`.
**Note:** This function uses `deserialize` and so bugs may cause the Julia
process to crash without warning (no error, no backtrace, etc.) if the
serialized input is invalid.
"""
function launch_runner_proc(
testsuite::TestSuite,
submissionfile::String,
functionname::Union{AbstractString, Symbol},
;
debug::String=get(ENV, "JULIA_DEBUG", ""),
)
functionname = Symbol(functionname)
input_path, output_path = tempname(), tempname()
runner_input = RunnerInput(testsuite, submissionfile, functionname, output_path)
# Julia makes it *very* hard to actually get the id of a subprocess, so
# we generate a random string here to be able to track what logs are comming
# from what process. Note that we use an alphabetic rather than a number to
# prevent confusion with the process id.
log_id = String(rand('a':'z', 6))
try
open(io -> serialize(io, runner_input), input_path, "w")
@debug "Launching runner subprocess." submissionfile JULIA_EXE
submissionfile = realpath(submissionfile)
# proc_in, proc_out, proc_err = Pipe(), Pipe(), Pipe()
stdout_pipe, stderr_pipe = Pipe(), Pipe()
# jl_cmd = "using ComparativeAutograder: runner_main; runner_main()"
jl_env = copy(ENV)
jl_env["JULIA_DEBUG"] = debug
proc = run(pipeline(
Cmd(`$(Base.julia_cmd()) -e $RUNNER_CMD $input_path`, env=jl_env),
stdout=stdout_pipe,
stderr=stderr_pipe,
); wait=false)
@debug "Spawned runner process."
stdout_task = @async readpipe!(stdout_pipe)
stderr_task = @async readpipe!(stderr_pipe)
# Wait for the subprocess to complete.
wait(proc)
status = proc.exitcode
@debug "Runner process ($log_id) exited." status stdout_task stderr_task
stdout_str, stderr_str = fetch.([stdout_task, stderr_task])
# Fetch the RunnerOutput.
runner_output = nothing
try
runner_output = open(io -> deserialize(io), output_path, "r")
typeassert(runner_output, RunnerOutput)
catch exc
@error "An error occurred while trying to read the runner output file." exc
end
return RunnerProcResult(status, runner_output, stdout_str, stderr_str)
finally
rm.([input_path, output_path], force=true)
end
end
| [
3500,
23283,
1634,
198,
198,
7249,
21529,
2964,
66,
23004,
198,
220,
220,
220,
8420,
8189,
3712,
5317,
2414,
198,
220,
220,
220,
1255,
3712,
38176,
90,
49493,
26410,
11,
10528,
92,
198,
220,
220,
220,
14367,
448,
3712,
23839,
10100,
198,
220,
220,
220,
336,
1082,
81,
3712,
23839,
10100,
198,
437,
198,
198,
49493,
2964,
66,
23004,
7,
82,
3712,
5317,
2414,
11,
374,
3712,
7149,
11,
304,
3712,
18465,
8,
796,
21529,
2964,
66,
23004,
7,
82,
11,
374,
11,
366,
4943,
198,
198,
8818,
1100,
34360,
0,
7,
79,
3712,
47,
3757,
8,
198,
220,
220,
220,
1969,
7,
79,
13,
259,
8,
198,
220,
220,
220,
1441,
1100,
7,
79,
11,
10903,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
4219,
62,
16737,
62,
36942,
7,
9288,
2385,
578,
11,
14498,
7753,
11,
2163,
3672,
58,
26,
14257,
12962,
198,
198,
38296,
257,
17490,
850,
14681,
290,
651,
262,
7186,
4600,
49493,
2964,
66,
23004,
44646,
198,
198,
1174,
6425,
25,
1174,
770,
2163,
3544,
4600,
8906,
48499,
1096,
63,
290,
523,
11316,
743,
2728,
262,
22300,
198,
14681,
284,
7014,
1231,
6509,
357,
3919,
4049,
11,
645,
736,
40546,
11,
3503,
2014,
611,
262,
198,
46911,
1143,
5128,
318,
12515,
13,
198,
37811,
198,
8818,
4219,
62,
16737,
62,
36942,
7,
198,
220,
220,
220,
1332,
2385,
578,
3712,
14402,
5606,
578,
11,
198,
220,
220,
220,
14498,
7753,
3712,
10100,
11,
198,
220,
220,
220,
2163,
3672,
3712,
38176,
90,
23839,
10100,
11,
38357,
5512,
198,
220,
220,
220,
2162,
198,
220,
220,
220,
14257,
3712,
10100,
28,
1136,
7,
1677,
53,
11,
366,
41,
6239,
3539,
62,
30531,
1600,
366,
12340,
198,
8,
198,
220,
220,
220,
2163,
3672,
796,
38357,
7,
8818,
3672,
8,
198,
220,
220,
220,
5128,
62,
6978,
11,
5072,
62,
6978,
796,
20218,
3672,
22784,
20218,
3672,
3419,
198,
220,
220,
220,
17490,
62,
15414,
796,
21529,
20560,
7,
9288,
2385,
578,
11,
14498,
7753,
11,
2163,
3672,
11,
5072,
62,
6978,
8,
628,
220,
220,
220,
1303,
22300,
1838,
340,
1635,
548,
9,
1327,
284,
1682,
651,
262,
4686,
286,
257,
850,
14681,
11,
523,
198,
220,
220,
220,
1303,
356,
7716,
257,
4738,
4731,
994,
284,
307,
1498,
284,
2610,
644,
17259,
389,
725,
278,
198,
220,
220,
220,
1303,
422,
644,
1429,
13,
5740,
326,
356,
779,
281,
435,
746,
33312,
2138,
621,
257,
1271,
284,
198,
220,
220,
220,
1303,
2948,
10802,
351,
262,
1429,
4686,
13,
198,
220,
220,
220,
2604,
62,
312,
796,
10903,
7,
25192,
10786,
64,
10354,
6,
89,
3256,
718,
4008,
198,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
1280,
7,
952,
4613,
11389,
1096,
7,
952,
11,
17490,
62,
15414,
828,
5128,
62,
6978,
11,
366,
86,
4943,
628,
220,
220,
220,
220,
220,
220,
220,
2488,
24442,
366,
46182,
10813,
17490,
850,
14681,
526,
14498,
7753,
49349,
3539,
62,
6369,
36,
198,
220,
220,
220,
220,
220,
220,
220,
14498,
7753,
796,
1103,
6978,
7,
7266,
3411,
7753,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
13834,
62,
259,
11,
13834,
62,
448,
11,
13834,
62,
8056,
796,
36039,
22784,
36039,
22784,
36039,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
14367,
448,
62,
34360,
11,
336,
1082,
81,
62,
34360,
796,
36039,
22784,
36039,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
474,
75,
62,
28758,
796,
366,
3500,
22565,
876,
16541,
519,
81,
5067,
25,
17490,
62,
12417,
26,
17490,
62,
12417,
3419,
1,
198,
220,
220,
220,
220,
220,
220,
220,
474,
75,
62,
24330,
796,
4866,
7,
1677,
53,
8,
198,
220,
220,
220,
220,
220,
220,
220,
474,
75,
62,
24330,
14692,
41,
6239,
3539,
62,
30531,
8973,
796,
14257,
198,
220,
220,
220,
220,
220,
220,
220,
13834,
796,
1057,
7,
79,
541,
4470,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
327,
9132,
7,
63,
3,
7,
14881,
13,
73,
43640,
62,
28758,
28955,
532,
68,
720,
49,
4944,
21479,
62,
34,
12740,
720,
15414,
62,
6978,
47671,
17365,
28,
20362,
62,
24330,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14367,
448,
28,
19282,
448,
62,
34360,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
336,
1082,
81,
28,
301,
1082,
81,
62,
34360,
11,
198,
220,
220,
220,
220,
220,
220,
220,
5619,
4043,
28,
9562,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
24442,
366,
49855,
276,
17490,
1429,
526,
628,
220,
220,
220,
220,
220,
220,
220,
14367,
448,
62,
35943,
796,
2488,
292,
13361,
1100,
34360,
0,
7,
19282,
448,
62,
34360,
8,
198,
220,
220,
220,
220,
220,
220,
220,
336,
1082,
81,
62,
35943,
796,
2488,
292,
13361,
1100,
34360,
0,
7,
301,
1082,
81,
62,
34360,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
16314,
329,
262,
850,
14681,
284,
1844,
13,
198,
220,
220,
220,
220,
220,
220,
220,
4043,
7,
36942,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3722,
796,
13834,
13,
37023,
8189,
198,
220,
220,
220,
220,
220,
220,
220,
2488,
24442,
366,
49493,
1429,
7198,
6404,
62,
312,
8,
34710,
526,
3722,
14367,
448,
62,
35943,
336,
1082,
81,
62,
35943,
198,
220,
220,
220,
220,
220,
220,
220,
14367,
448,
62,
2536,
11,
336,
1082,
81,
62,
2536,
796,
21207,
12195,
58,
19282,
448,
62,
35943,
11,
336,
1082,
81,
62,
35943,
12962,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
376,
7569,
262,
21529,
26410,
13,
198,
220,
220,
220,
220,
220,
220,
220,
17490,
62,
22915,
796,
2147,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17490,
62,
22915,
796,
1280,
7,
952,
4613,
748,
48499,
1096,
7,
952,
828,
5072,
62,
6978,
11,
366,
81,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2099,
30493,
7,
16737,
62,
22915,
11,
21529,
26410,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4929,
2859,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2488,
18224,
366,
2025,
4049,
5091,
981,
2111,
284,
1100,
262,
17490,
5072,
2393,
526,
2859,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
21529,
2964,
66,
23004,
7,
13376,
11,
17490,
62,
22915,
11,
14367,
448,
62,
2536,
11,
336,
1082,
81,
62,
2536,
8,
198,
220,
220,
220,
3443,
198,
220,
220,
220,
220,
220,
220,
220,
42721,
12195,
58,
15414,
62,
6978,
11,
5072,
62,
6978,
4357,
2700,
28,
7942,
8,
198,
220,
220,
220,
886,
198,
437,
198
] | 2.526176 | 1,127 |
<filename>src/formulae.jl
export formula_FR, formula_PR, formula_HS, formula_HZ
function formula_FR(∇f, ∇ft, s, d)
β = (∇ft⋅∇ft) / (∇f⋅∇f)
return β
end
function formula_PR(∇f, ∇ft, s, d)
y = ∇ft - ∇f
β = (∇ft⋅y) / (∇f⋅∇f)
return β
end
function formula_HS(∇f, ∇ft, s, d)
y = ∇ft - ∇f
β = (∇ft⋅y) / (d⋅y)
return β
end
function formula_HZ(∇f, ∇ft, s, d)
y = ∇ft - ∇f
n2y = y⋅y
β1 = (y⋅d)
β = ((y - 2 * d * n2y / β1)⋅∇ft) / β1
return β
end
| [
27,
34345,
29,
10677,
14,
687,
377,
3609,
13,
20362,
198,
39344,
10451,
62,
10913,
11,
10451,
62,
4805,
11,
10451,
62,
7998,
11,
10451,
62,
39,
57,
198,
198,
8818,
10451,
62,
10913,
7,
24861,
229,
69,
11,
18872,
229,
701,
11,
264,
11,
288,
8,
628,
220,
220,
220,
27169,
796,
357,
24861,
229,
701,
158,
233,
227,
24861,
229,
701,
8,
1220,
357,
24861,
229,
69,
158,
233,
227,
24861,
229,
69,
8,
628,
220,
220,
220,
1441,
27169,
198,
437,
198,
198,
8818,
10451,
62,
4805,
7,
24861,
229,
69,
11,
18872,
229,
701,
11,
264,
11,
288,
8,
628,
220,
220,
220,
331,
796,
18872,
229,
701,
532,
18872,
229,
69,
198,
220,
220,
220,
27169,
796,
357,
24861,
229,
701,
158,
233,
227,
88,
8,
1220,
357,
24861,
229,
69,
158,
233,
227,
24861,
229,
69,
8,
628,
220,
220,
220,
1441,
27169,
198,
437,
198,
198,
8818,
10451,
62,
7998,
7,
24861,
229,
69,
11,
18872,
229,
701,
11,
264,
11,
288,
8,
628,
220,
220,
220,
331,
796,
18872,
229,
701,
532,
18872,
229,
69,
198,
220,
220,
220,
27169,
796,
357,
24861,
229,
701,
158,
233,
227,
88,
8,
1220,
357,
67,
158,
233,
227,
88,
8,
628,
220,
220,
220,
1441,
27169,
198,
437,
198,
198,
8818,
10451,
62,
39,
57,
7,
24861,
229,
69,
11,
18872,
229,
701,
11,
264,
11,
288,
8,
628,
220,
220,
220,
331,
796,
18872,
229,
701,
532,
18872,
229,
69,
198,
220,
220,
220,
299,
17,
88,
796,
331,
158,
233,
227,
88,
198,
220,
220,
220,
27169,
16,
796,
357,
88,
158,
233,
227,
67,
8,
198,
220,
220,
220,
27169,
796,
14808,
88,
532,
362,
1635,
288,
1635,
299,
17,
88,
1220,
27169,
16,
8,
158,
233,
227,
24861,
229,
701,
8,
1220,
27169,
16,
628,
220,
220,
220,
1441,
27169,
198,
437,
198
] | 1.597444 | 313 |
# ------------------------------------------------------------------
# Licensed under the MIT License. See LICENSE in the project root.
# ------------------------------------------------------------------
"""
Pyramid(p1, p2, p3, p4, p5)
A pyramid with points `p1`, `p2`, `p3`, `p4`, `p5`.
"""
struct Pyramid{Dim,T,V<:AbstractVector{Point{Dim,T}}} <: Polyhedron{Dim,T}
vertices::V
end
| [
2,
16529,
438,
198,
2,
49962,
739,
262,
17168,
13789,
13,
4091,
38559,
24290,
287,
262,
1628,
6808,
13,
198,
2,
16529,
438,
198,
198,
37811,
198,
220,
220,
220,
41450,
7,
79,
16,
11,
279,
17,
11,
279,
18,
11,
279,
19,
11,
279,
20,
8,
198,
198,
32,
27944,
351,
2173,
4600,
79,
16,
47671,
4600,
79,
17,
47671,
4600,
79,
18,
47671,
4600,
79,
19,
47671,
4600,
79,
20,
44646,
198,
37811,
198,
7249,
41450,
90,
29271,
11,
51,
11,
53,
27,
25,
23839,
38469,
90,
12727,
90,
29271,
11,
51,
42535,
1279,
25,
12280,
704,
1313,
90,
29271,
11,
51,
92,
198,
220,
9421,
1063,
3712,
53,
198,
437,
198
] | 3.438596 | 114 |
using HiQGA.transD_GP
include("BarPhysics.jl")
include("BarPhysicsInversion.jl")
using .BarPhysicsInversion
# Forward setttings
# dummy physics struct defined in BarPhysics.jl
F = BarPhysics.Bar(25, rand(10))
# some dummy forward
@info BarPhysics.returnphysics!(F, rand(3))
# struct for data and physics operator defined in BarPhysicsInversion.jl
FOp = BarPhysicsInversion.BarInversion(rand(10), F)
## Inverse settings
# prior bounds and setings
fbounds = [0 1.]
xall = collect(permutedims(0:0.1:1))
xbounds = permutedims([extrema(xall)...])
λ = vec(diff(xbounds, dims=2))
nmin, nmax = 2, 5
demean, sampledc = false, true
# McMC proposals
δ = 0.1*diff(fbounds, dims=2)[1]
sdev_pos = abs.(vec(diff(xbounds, dims=2)))
sdev_prop = abs.(vec(0.05*diff(fbounds, dims=2)))
K = transD_GP.GP.OrstUhn()
# make MCMC options using prior and proposals
opt = transD_GP.OptionsStat(nmin = nmin,
nmax = nmax,
xbounds = xbounds,
fbounds = fbounds,
xall = xall,
λ = λ,
δ = δ,
demean = demean,
sampledc = sampledc,
sdev_prop = sdev_prop,
sdev_pos = sdev_pos,
quasimultid = false,
K = K
)
## Put forward and inverse together
# initialise a random model
m = transD_GP.init(opt)
# compute misfit
transD_GP.get_misfit(m, opt, FOp)
# if you've gotten till here you're golden
# you don't really need to initialize a model and compute
# misfit outside a module | [
3500,
15902,
48,
9273,
13,
7645,
35,
62,
16960,
198,
17256,
7203,
10374,
2725,
23154,
13,
20362,
4943,
198,
17256,
7203,
10374,
2725,
23154,
818,
9641,
13,
20362,
4943,
198,
3500,
764,
10374,
2725,
23154,
818,
9641,
198,
2,
19530,
900,
926,
654,
198,
2,
31548,
11887,
2878,
5447,
287,
2409,
2725,
23154,
13,
20362,
198,
37,
796,
2409,
2725,
23154,
13,
10374,
7,
1495,
11,
43720,
7,
940,
4008,
198,
198,
2,
617,
31548,
2651,
198,
31,
10951,
2409,
2725,
23154,
13,
7783,
746,
23154,
0,
7,
37,
11,
43720,
7,
18,
4008,
198,
198,
2,
2878,
329,
1366,
290,
11887,
10088,
5447,
287,
2409,
2725,
23154,
818,
9641,
13,
20362,
220,
198,
6080,
79,
796,
2409,
2725,
23154,
818,
9641,
13,
10374,
818,
9641,
7,
25192,
7,
940,
828,
376,
8,
198,
198,
2235,
554,
4399,
6460,
198,
2,
3161,
22303,
290,
900,
654,
198,
21855,
3733,
796,
685,
15,
352,
8183,
220,
198,
87,
439,
796,
2824,
7,
16321,
7241,
12078,
7,
15,
25,
15,
13,
16,
25,
16,
4008,
198,
30894,
3733,
796,
9943,
7241,
12078,
26933,
2302,
260,
2611,
7,
87,
439,
26513,
12962,
198,
39377,
796,
43030,
7,
26069,
7,
30894,
3733,
11,
5391,
82,
28,
17,
4008,
198,
77,
1084,
11,
299,
9806,
796,
362,
11,
642,
198,
9536,
11025,
11,
35846,
66,
796,
3991,
11,
2081,
198,
2,
1982,
9655,
11628,
198,
138,
112,
796,
657,
13,
16,
9,
26069,
7,
21855,
3733,
11,
5391,
82,
28,
17,
38381,
16,
60,
198,
82,
7959,
62,
1930,
796,
2352,
12195,
35138,
7,
26069,
7,
30894,
3733,
11,
5391,
82,
28,
17,
22305,
198,
82,
7959,
62,
22930,
796,
2352,
12195,
35138,
7,
15,
13,
2713,
9,
26069,
7,
21855,
3733,
11,
5391,
82,
28,
17,
22305,
198,
42,
796,
1007,
35,
62,
16960,
13,
16960,
13,
5574,
301,
52,
21116,
3419,
198,
198,
2,
787,
13122,
9655,
3689,
1262,
3161,
290,
11628,
198,
8738,
796,
1007,
35,
62,
16960,
13,
29046,
17126,
7,
77,
1084,
796,
299,
1084,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
9806,
796,
299,
9806,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
65,
3733,
796,
2124,
65,
3733,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
277,
65,
3733,
796,
277,
65,
3733,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
439,
796,
2124,
439,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7377,
119,
796,
7377,
119,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7377,
112,
796,
7377,
112,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1357,
11025,
796,
1357,
11025,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
35846,
66,
796,
35846,
66,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
7959,
62,
22930,
796,
264,
7959,
62,
22930,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
264,
7959,
62,
1930,
796,
264,
7959,
62,
1930,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
627,
292,
320,
586,
312,
796,
3991,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
509,
796,
509,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
198,
2235,
5930,
2651,
290,
34062,
1978,
198,
2,
4238,
786,
257,
4738,
2746,
198,
76,
796,
1007,
35,
62,
16960,
13,
15003,
7,
8738,
8,
220,
198,
198,
2,
24061,
2984,
11147,
198,
7645,
35,
62,
16960,
13,
1136,
62,
76,
4468,
270,
7,
76,
11,
2172,
11,
11895,
79,
8,
198,
198,
2,
611,
345,
1053,
7891,
10597,
994,
345,
821,
10861,
198,
2,
345,
836,
470,
1107,
761,
284,
41216,
257,
2746,
290,
24061,
198,
2,
2984,
11147,
2354,
257,
8265
] | 2.026928 | 817 |
<reponame>twadleigh/OpenEXR.jl
module OpenEXR
export load_exr, save_exr
using FileIO, Colors
module C
using OpenEXR_jll
using Colors
const ImfHalf = Float16
const ImfRgba = RGBA{ImfHalf}
include("OpenEXR_common.jl")
include("OpenEXR_api.jl")
const IMF_WRITE_RGBA = IMF_WRITE_RGB + IMF_WRITE_A
end # module C
const MAGIC = Cint(C.IMF_MAGIC)
@enum Compression::Cint begin
NO_COMPRESSION = C.IMF_NO_COMPRESSION
RLE_COMPRESSION = C.IMF_RLE_COMPRESSION
ZIPS_COMPRESSION = C.IMF_ZIPS_COMPRESSION
ZIP_COMPRESSION = C.IMF_ZIP_COMPRESSION
PIZ_COMPRESSION = C.IMF_PIZ_COMPRESSION
PXR24_COMPRESSION = C.IMF_PXR24_COMPRESSION
B44_COMPRESSION = C.IMF_B44_COMPRESSION
B44A_COMPRESSION = C.IMF_B44A_COMPRESSION
DWAA_COMPRESSION = C.IMF_DWAA_COMPRESSION
DWAB_COMPRESSION = C.IMF_DWAB_COMPRESSION
end
@enum RgbaChannels::Cint begin
WRITE_R = C.IMF_WRITE_R
WRITE_G = C.IMF_WRITE_G
WRITE_B = C.IMF_WRITE_B
WRITE_A = C.IMF_WRITE_A
WRITE_Y = C.IMF_WRITE_Y
WRITE_C = C.IMF_WRITE_C
WRITE_RGB = C.IMF_WRITE_RGB
WRITE_RGBA = C.IMF_WRITE_RGBA
WRITE_YC = C.IMF_WRITE_YC
WRITE_YA = C.IMF_WRITE_YA
WRITE_YCA = C.IMF_WRITE_YCA
end
function check(ret)
ret == typeof(ret)(0) && error(unsafe_string(C.ImfErrorMessage()))
end
"""
load_exr(filename)::(Array{RGBA{Float16},2}, RgbaChannels)
Returns the image data contained in `filename` along with flags representing the on-disk
storage format.
"""
function load_exr(filename)
infile = C.ImfOpenInputFile(filename) # open the file
check(infile)
chans = RgbaChannels(C.ImfInputChannels(infile))
try
# get the header
hdr = C.ImfInputHeader(infile)
# read its data window
xmin = Ref{Cint}()
ymin = Ref{Cint}()
xmax = Ref{Cint}()
ymax = Ref{Cint}()
C.ImfHeaderDataWindow(hdr, xmin, ymin, xmax, ymax)
# compute the window size
width = xmax[] - xmin[] + 1
height = ymax[] - ymin[] + 1
# allocate space for the result and get its strides
data = Array{C.ImfRgba,2}(undef, height, width)
(xstride, ystride) = strides(data)
# get the pointer to the data, shifting it according to the expected window
dataptr =
Base.unsafe_convert(Ptr{C.ImfRgba}, data) - xmin[] * xstride - ymin[] * ystride
# copy the data
check(C.ImfInputSetFrameBuffer(infile, dataptr, ystride, xstride))
check(C.ImfInputReadPixels(infile, ymin[], ymax[]))
# return the loaded raster along with the channels
return (data, chans)
finally
check(C.ImfCloseInputFile(infile))
end
end
"""
save_exr(filename, image[, compression[, channels]])
Save `image` as an OpenEXR file in `filename`, storing the data in a format
indicated by `channels` using the `compression` algorithm.
"""
function save_exr(
filename,
image::AbstractArray{C.ImfRgba,2},
compression::Compression = ZIP_COMPRESSION,
channels::RgbaChannels = WRITE_RGBA,
)
# get the size of the data
(height, width) = size(image)
# create a new header
hdr = C.ImfNewHeader()
check(hdr)
try
# set the compression
C.ImfHeaderSetCompression(hdr, compression)
# set the correct window sizes
C.ImfHeaderSetDataWindow(hdr, 0, 0, width - 1, height - 1)
C.ImfHeaderSetDisplayWindow(hdr, 0, 0, width - 1, height - 1)
# open the output file
outfile = C.ImfOpenOutputFile(filename, hdr, channels)
check(outfile)
try
# get the strides and a pointer to the raster
(xstride, ystride) = strides(image)
dataptr = Base.unsafe_convert(Ptr{C.ImfRgba}, image)
# copy the data
check(C.ImfOutputSetFrameBuffer(outfile, dataptr, ystride, xstride))
check(C.ImfOutputWritePixels(outfile, height))
finally
check(C.ImfCloseOutputFile(outfile))
end
finally
C.ImfDeleteHeader(hdr)
end
nothing
end
function save_exr(
filename,
image::AbstractArray{T,2},
compression::Compression = ZIP_COMPRESSION,
channels::RgbaChannels = WRITE_RGBA,
) where {T}
save_exr(filename, (c -> convert(C.ImfRgba, c)).(image), compression, channels)
end
"""
load(filename)::Array{[RGB|RGBA|Gray|GrayA]{Float16},2}
Returns the image data contained in `filename`.
"""
function load(filename::AbstractString)
(rgba, chans) = load_exr(filename)
if chans == WRITE_YA
return (c -> convert(GrayA{Float16}, c)).(rgba)
elseif chans == WRITE_Y
return (c -> convert(Gray{Float16}, c)).(rgba)
elseif UInt32(chans) & UInt32(WRITE_A) == 0x00
return (c -> convert(RGB{Float16}, c)).(rgba)
else
return rgba
end
end
"""
save(filename, image[, compression])
Save `image` as an OpenEXR file in `filename` using the `compression` algorithm.
"""
function save(
filename::AbstractString,
image::AbstractArray{T,2},
compression::Compression = ZIP_COMPRESSION,
) where {T<:Transparent3}
save_exr(filename, image, compression, WRITE_RGBA)
end
function save(
filename::AbstractString,
image::AbstractArray{T,2},
compression::Compression = ZIP_COMPRESSION,
) where {T<:Color3}
save_exr(filename, image, compression, WRITE_RGB)
end
function save(
filename::AbstractString,
image::AbstractArray{T,2},
compression::Compression = ZIP_COMPRESSION,
) where {T<:TransparentGray}
save_exr(filename, image, compression, WRITE_YA)
end
function save(
filename::AbstractString,
image::AbstractArray{T,2},
compression::Compression = ZIP_COMPRESSION,
) where {T<:AbstractGray}
save_exr(filename, image, compression, WRITE_Y)
end
# FileIO interface
load(f::File{DataFormat{:EXR}}, args...) = load(f.filename, args...)
save(f::File{DataFormat{:EXR}}, args...) = save(f.filename, args...)
end # module OpenEXR
| [
27,
7856,
261,
480,
29,
4246,
35166,
394,
14,
11505,
6369,
49,
13,
20362,
198,
21412,
4946,
6369,
49,
198,
198,
39344,
3440,
62,
1069,
81,
11,
3613,
62,
1069,
81,
198,
198,
3500,
9220,
9399,
11,
29792,
198,
198,
21412,
327,
198,
3500,
4946,
6369,
49,
62,
73,
297,
198,
3500,
29792,
198,
9979,
1846,
69,
31305,
796,
48436,
1433,
198,
9979,
1846,
69,
49,
70,
7012,
796,
34359,
4339,
90,
3546,
69,
31305,
92,
198,
17256,
7203,
11505,
6369,
49,
62,
11321,
13,
20362,
4943,
198,
17256,
7203,
11505,
6369,
49,
62,
15042,
13,
20362,
4943,
198,
9979,
25375,
62,
18564,
12709,
62,
48192,
4339,
796,
25375,
62,
18564,
12709,
62,
36982,
1343,
25375,
62,
18564,
12709,
62,
32,
198,
437,
220,
1303,
8265,
327,
198,
198,
9979,
28263,
2149,
796,
327,
600,
7,
34,
13,
3955,
37,
62,
45820,
2149,
8,
198,
198,
31,
44709,
3082,
2234,
3712,
34,
600,
2221,
198,
220,
220,
220,
8005,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
15285,
62,
9858,
32761,
2849,
198,
220,
220,
220,
371,
2538,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
49,
2538,
62,
9858,
32761,
2849,
198,
220,
220,
220,
1168,
47643,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
57,
47643,
62,
9858,
32761,
2849,
198,
220,
220,
220,
42977,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
57,
4061,
62,
9858,
32761,
2849,
198,
220,
220,
220,
350,
14887,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
11901,
57,
62,
9858,
32761,
2849,
198,
220,
220,
220,
350,
55,
49,
1731,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
47,
55,
49,
1731,
62,
9858,
32761,
2849,
198,
220,
220,
220,
347,
2598,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
33,
2598,
62,
9858,
32761,
2849,
198,
220,
220,
220,
347,
2598,
32,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
33,
2598,
32,
62,
9858,
32761,
2849,
198,
220,
220,
220,
29652,
3838,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
42955,
3838,
62,
9858,
32761,
2849,
198,
220,
220,
220,
29652,
6242,
62,
9858,
32761,
2849,
796,
327,
13,
3955,
37,
62,
42955,
6242,
62,
9858,
32761,
2849,
198,
437,
198,
198,
31,
44709,
371,
70,
7012,
1925,
8961,
3712,
34,
600,
2221,
198,
220,
220,
220,
44423,
62,
49,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
49,
198,
220,
220,
220,
44423,
62,
38,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
38,
198,
220,
220,
220,
44423,
62,
33,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
33,
198,
220,
220,
220,
44423,
62,
32,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
32,
198,
220,
220,
220,
44423,
62,
56,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
56,
198,
220,
220,
220,
44423,
62,
34,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
34,
198,
220,
220,
220,
44423,
62,
36982,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
36982,
198,
220,
220,
220,
44423,
62,
48192,
4339,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
48192,
4339,
198,
220,
220,
220,
44423,
62,
44816,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
44816,
198,
220,
220,
220,
44423,
62,
44947,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
44947,
198,
220,
220,
220,
44423,
62,
56,
8141,
796,
327,
13,
3955,
37,
62,
18564,
12709,
62,
56,
8141,
198,
437,
198,
198,
8818,
2198,
7,
1186,
8,
198,
220,
220,
220,
1005,
6624,
2099,
1659,
7,
1186,
5769,
15,
8,
11405,
4049,
7,
13271,
8635,
62,
8841,
7,
34,
13,
3546,
69,
12331,
12837,
3419,
4008,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3440,
62,
1069,
81,
7,
34345,
2599,
37498,
19182,
90,
48192,
4339,
90,
43879,
1433,
5512,
17,
5512,
371,
70,
7012,
1925,
8961,
8,
198,
198,
35561,
262,
2939,
1366,
7763,
287,
4600,
34345,
63,
1863,
351,
9701,
10200,
262,
319,
12,
39531,
198,
35350,
5794,
13,
198,
37811,
198,
8818,
3440,
62,
1069,
81,
7,
34345,
8,
198,
220,
220,
220,
1167,
576,
796,
327,
13,
3546,
69,
11505,
20560,
8979,
7,
34345,
8,
220,
1303,
1280,
262,
2393,
198,
220,
220,
220,
2198,
7,
259,
7753,
8,
198,
220,
220,
220,
442,
504,
796,
371,
70,
7012,
1925,
8961,
7,
34,
13,
3546,
69,
20560,
1925,
8961,
7,
259,
7753,
4008,
198,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
651,
262,
13639,
198,
220,
220,
220,
220,
220,
220,
220,
289,
7109,
796,
327,
13,
3546,
69,
20560,
39681,
7,
259,
7753,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
1100,
663,
1366,
4324,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
1084,
796,
6524,
90,
34,
600,
92,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
331,
1084,
796,
6524,
90,
34,
600,
92,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
9806,
796,
6524,
90,
34,
600,
92,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
331,
9806,
796,
6524,
90,
34,
600,
92,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
327,
13,
3546,
69,
39681,
6601,
27703,
7,
71,
7109,
11,
2124,
1084,
11,
331,
1084,
11,
2124,
9806,
11,
331,
9806,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
24061,
262,
4324,
2546,
198,
220,
220,
220,
220,
220,
220,
220,
9647,
796,
2124,
9806,
21737,
532,
2124,
1084,
21737,
1343,
352,
198,
220,
220,
220,
220,
220,
220,
220,
6001,
796,
331,
9806,
21737,
532,
331,
1084,
21737,
1343,
352,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
31935,
2272,
329,
262,
1255,
290,
651,
663,
35002,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
15690,
90,
34,
13,
3546,
69,
49,
70,
7012,
11,
17,
92,
7,
917,
891,
11,
6001,
11,
9647,
8,
198,
220,
220,
220,
220,
220,
220,
220,
357,
87,
2536,
485,
11,
331,
2536,
485,
8,
796,
35002,
7,
7890,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
651,
262,
17562,
284,
262,
1366,
11,
15852,
340,
1864,
284,
262,
2938,
4324,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
20692,
796,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
13271,
8635,
62,
1102,
1851,
7,
46745,
90,
34,
13,
3546,
69,
49,
70,
7012,
5512,
1366,
8,
532,
2124,
1084,
21737,
1635,
2124,
2536,
485,
532,
331,
1084,
21737,
1635,
331,
2536,
485,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
4866,
262,
1366,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
7,
34,
13,
3546,
69,
20560,
7248,
19778,
28632,
7,
259,
7753,
11,
1366,
20692,
11,
331,
2536,
485,
11,
2124,
2536,
485,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
7,
34,
13,
3546,
69,
20560,
5569,
47,
14810,
7,
259,
7753,
11,
331,
1084,
58,
4357,
331,
9806,
21737,
4008,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
1441,
262,
9639,
374,
1603,
1863,
351,
262,
9619,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
7890,
11,
442,
504,
8,
198,
220,
220,
220,
3443,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
7,
34,
13,
3546,
69,
26125,
20560,
8979,
7,
259,
7753,
4008,
198,
220,
220,
220,
886,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3613,
62,
1069,
81,
7,
34345,
11,
2939,
58,
11,
19794,
58,
11,
9619,
11907,
8,
198,
198,
16928,
4600,
9060,
63,
355,
281,
4946,
6369,
49,
2393,
287,
4600,
34345,
47671,
23069,
262,
1366,
287,
257,
5794,
198,
521,
3474,
416,
4600,
354,
8961,
63,
1262,
262,
4600,
5589,
2234,
63,
11862,
13,
198,
37811,
198,
8818,
3613,
62,
1069,
81,
7,
198,
220,
220,
220,
29472,
11,
198,
220,
220,
220,
2939,
3712,
23839,
19182,
90,
34,
13,
3546,
69,
49,
70,
7012,
11,
17,
5512,
198,
220,
220,
220,
19794,
3712,
7293,
2234,
796,
42977,
62,
9858,
32761,
2849,
11,
198,
220,
220,
220,
9619,
3712,
49,
70,
7012,
1925,
8961,
796,
44423,
62,
48192,
4339,
11,
198,
8,
198,
220,
220,
220,
1303,
651,
262,
2546,
286,
262,
1366,
198,
220,
220,
220,
357,
17015,
11,
9647,
8,
796,
2546,
7,
9060,
8,
628,
220,
220,
220,
1303,
2251,
257,
649,
13639,
198,
220,
220,
220,
289,
7109,
796,
327,
13,
3546,
69,
3791,
39681,
3419,
198,
220,
220,
220,
2198,
7,
71,
7109,
8,
198,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
900,
262,
19794,
198,
220,
220,
220,
220,
220,
220,
220,
327,
13,
3546,
69,
39681,
7248,
7293,
2234,
7,
71,
7109,
11,
19794,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
900,
262,
3376,
4324,
10620,
198,
220,
220,
220,
220,
220,
220,
220,
327,
13,
3546,
69,
39681,
7248,
6601,
27703,
7,
71,
7109,
11,
657,
11,
657,
11,
9647,
532,
352,
11,
6001,
532,
352,
8,
198,
220,
220,
220,
220,
220,
220,
220,
327,
13,
3546,
69,
39681,
7248,
23114,
27703,
7,
71,
7109,
11,
657,
11,
657,
11,
9647,
532,
352,
11,
6001,
532,
352,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
1280,
262,
5072,
2393,
198,
220,
220,
220,
220,
220,
220,
220,
503,
7753,
796,
327,
13,
3546,
69,
11505,
26410,
8979,
7,
34345,
11,
289,
7109,
11,
9619,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
7,
448,
7753,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
651,
262,
35002,
290,
257,
17562,
284,
262,
374,
1603,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
87,
2536,
485,
11,
331,
2536,
485,
8,
796,
35002,
7,
9060,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1366,
20692,
796,
7308,
13,
13271,
8635,
62,
1102,
1851,
7,
46745,
90,
34,
13,
3546,
69,
49,
70,
7012,
5512,
2939,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
4866,
262,
1366,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2198,
7,
34,
13,
3546,
69,
26410,
7248,
19778,
28632,
7,
448,
7753,
11,
1366,
20692,
11,
331,
2536,
485,
11,
2124,
2536,
485,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2198,
7,
34,
13,
3546,
69,
26410,
16594,
47,
14810,
7,
448,
7753,
11,
6001,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
3443,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2198,
7,
34,
13,
3546,
69,
26125,
26410,
8979,
7,
448,
7753,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
3443,
198,
220,
220,
220,
220,
220,
220,
220,
327,
13,
3546,
69,
38727,
39681,
7,
71,
7109,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2147,
198,
437,
198,
198,
8818,
3613,
62,
1069,
81,
7,
198,
220,
220,
220,
29472,
11,
198,
220,
220,
220,
2939,
3712,
23839,
19182,
90,
51,
11,
17,
5512,
198,
220,
220,
220,
19794,
3712,
7293,
2234,
796,
42977,
62,
9858,
32761,
2849,
11,
198,
220,
220,
220,
9619,
3712,
49,
70,
7012,
1925,
8961,
796,
44423,
62,
48192,
4339,
11,
198,
8,
810,
1391,
51,
92,
198,
220,
220,
220,
3613,
62,
1069,
81,
7,
34345,
11,
357,
66,
4613,
10385,
7,
34,
13,
3546,
69,
49,
70,
7012,
11,
269,
29720,
7,
9060,
828,
19794,
11,
9619,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3440,
7,
34345,
2599,
25,
19182,
90,
58,
36982,
91,
48192,
4339,
91,
46130,
91,
46130,
32,
60,
90,
43879,
1433,
5512,
17,
92,
198,
198,
35561,
262,
2939,
1366,
7763,
287,
4600,
34345,
44646,
198,
37811,
198,
8818,
3440,
7,
34345,
3712,
23839,
10100,
8,
198,
220,
220,
220,
357,
41345,
7012,
11,
442,
504,
8,
796,
3440,
62,
1069,
81,
7,
34345,
8,
198,
220,
220,
220,
611,
442,
504,
6624,
44423,
62,
44947,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
66,
4613,
10385,
7,
46130,
32,
90,
43879,
1433,
5512,
269,
29720,
7,
41345,
7012,
8,
198,
220,
220,
220,
2073,
361,
442,
504,
6624,
44423,
62,
56,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
66,
4613,
10385,
7,
46130,
90,
43879,
1433,
5512,
269,
29720,
7,
41345,
7012,
8,
198,
220,
220,
220,
2073,
361,
471,
5317,
2624,
7,
354,
504,
8,
1222,
471,
5317,
2624,
7,
18564,
12709,
62,
32,
8,
6624,
657,
87,
405,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
357,
66,
4613,
10385,
7,
36982,
90,
43879,
1433,
5512,
269,
29720,
7,
41345,
7012,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
48670,
7012,
198,
220,
220,
220,
886,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
3613,
7,
34345,
11,
2939,
58,
11,
19794,
12962,
198,
198,
16928,
4600,
9060,
63,
355,
281,
4946,
6369,
49,
2393,
287,
4600,
34345,
63,
1262,
262,
4600,
5589,
2234,
63,
11862,
13,
198,
37811,
198,
8818,
3613,
7,
198,
220,
220,
220,
29472,
3712,
23839,
10100,
11,
198,
220,
220,
220,
2939,
3712,
23839,
19182,
90,
51,
11,
17,
5512,
198,
220,
220,
220,
19794,
3712,
7293,
2234,
796,
42977,
62,
9858,
32761,
2849,
11,
198,
8,
810,
1391,
51,
27,
25,
8291,
8000,
18,
92,
198,
220,
220,
220,
3613,
62,
1069,
81,
7,
34345,
11,
2939,
11,
19794,
11,
44423,
62,
48192,
4339,
8,
198,
437,
198,
198,
8818,
3613,
7,
198,
220,
220,
220,
29472,
3712,
23839,
10100,
11,
198,
220,
220,
220,
2939,
3712,
23839,
19182,
90,
51,
11,
17,
5512,
198,
220,
220,
220,
19794,
3712,
7293,
2234,
796,
42977,
62,
9858,
32761,
2849,
11,
198,
8,
810,
1391,
51,
27,
25,
10258,
18,
92,
198,
220,
220,
220,
3613,
62,
1069,
81,
7,
34345,
11,
2939,
11,
19794,
11,
44423,
62,
36982,
8,
198,
437,
198,
198,
8818,
3613,
7,
198,
220,
220,
220,
29472,
3712,
23839,
10100,
11,
198,
220,
220,
220,
2939,
3712,
23839,
19182,
90,
51,
11,
17,
5512,
198,
220,
220,
220,
19794,
3712,
7293,
2234,
796,
42977,
62,
9858,
32761,
2849,
11,
198,
8,
810,
1391,
51,
27,
25,
8291,
8000,
46130,
92,
198,
220,
220,
220,
3613,
62,
1069,
81,
7,
34345,
11,
2939,
11,
19794,
11,
44423,
62,
44947,
8,
198,
437,
198,
198,
8818,
3613,
7,
198,
220,
220,
220,
29472,
3712,
23839,
10100,
11,
198,
220,
220,
220,
2939,
3712,
23839,
19182,
90,
51,
11,
17,
5512,
198,
220,
220,
220,
19794,
3712,
7293,
2234,
796,
42977,
62,
9858,
32761,
2849,
11,
198,
8,
810,
1391,
51,
27,
25,
23839,
46130,
92,
198,
220,
220,
220,
3613,
62,
1069,
81,
7,
34345,
11,
2939,
11,
19794,
11,
44423,
62,
56,
8,
198,
437,
198,
198,
2,
9220,
9399,
7071,
198,
2220,
7,
69,
3712,
8979,
90,
6601,
26227,
90,
25,
6369,
49,
92,
5512,
26498,
23029,
796,
3440,
7,
69,
13,
34345,
11,
26498,
23029,
198,
21928,
7,
69,
3712,
8979,
90,
6601,
26227,
90,
25,
6369,
49,
92,
5512,
26498,
23029,
796,
3613,
7,
69,
13,
34345,
11,
26498,
23029,
198,
198,
437,
220,
1303,
8265,
4946,
6369,
49,
198
] | 2.31919 | 2,569 |
using NativeSVG
dr =
Drawing(width = "5cm", height = "4cm") do
desc() do
str("Four separate rectangles")
end
rect(x = "0.5cm", y = "0.5cm", width = "2cm", height = "1cm")
rect(x = "0.5cm", y = "2cm", width = "1cm", height = "1.5cm")
rect(x = "3cm", y = "0.5cm", width = "1.5cm", height = "2cm")
rect(x = "3.5cm", y = "3cm", width = "1cm", height = "0.5cm")
#Show outline of viewport using 'rect' element
rect(
x = ".01cm",
y = ".01cm",
width = "4.98cm",
height = "3.98cm",
fill = "none",
stroke = "blue",
stroke_width = ".02cm"
)
end
display(dr)
dr =
Drawing(width = "5cm", height = "5cm") do
desc() do
str("Two groups, each of two rectangles")
end
g(id = "group1", fill = "red") do
rect(x = "1cm", y = "1cm", width = "1cm", height = "1cm")
rect(x = "3cm", y = "1cm", width = "1cm", height = "1cm")
end
g(id = "group2", fill = "blue") do
rect(x = "1cm", y = "3cm", width = "1cm", height = "1cm")
rect(x = "3cm", y = "3cm", width = "1cm", height = "1cm")
end
# Show outline of viewport using 'rect' element
rect(
x = ".01cm",
y = ".01cm",
width = "4.98cm",
height = "4.98cm",
fill = "none",
stroke = "blue",
stroke_width = ".02cm"
)
end
display(dr)
dr =
Drawing(
xmlns!xlink = "http://www.w3.org/1999/xlink",
width = "200",
height = "100",
viewBox = "0 0 200 100"
) do
title() do
str("Style inheritance and the use element")
end
desc() do
str("""Two circles, one of which is a re-styled clone of the other.
This file demonstrates one of the cases where
the shadow-DOM style matching rules in SVG 2
have a different effect than the SVG 1.1 style cloning rules.
The original circle on the left
should have blue fill
and green stroke.
In a conforming SVG 1.1 user agent,
the re-used circle on the right
should have orange fill and green stroke.
In a conforming SVG 2 user agent,
the re-used circle should have orange fill and purple stroke.
In all cases,
the stroke should be partially transparent
and 20 units wide,
relative to a total circle diameter of 100 units.""")
end
style(type = "text/css") do
str("""circle { stroke-opacity: 0.7; }
.special circle { stroke: green; }
use { stroke: purple;
fill: orange; }""")
end
g(class = "special", style = "fill: blue") do
circle(
id = "c",
cy = "50",
cx = "50",
r = "40",
stroke_width = "20"
)
end
use(xlink!href = "#c", x = "100")
end
| [
3500,
12547,
50,
43490,
198,
198,
7109,
796,
198,
220,
220,
220,
40027,
7,
10394,
796,
366,
20,
11215,
1600,
6001,
796,
366,
19,
11215,
4943,
466,
198,
220,
220,
220,
220,
220,
220,
220,
1715,
3419,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
965,
7203,
15137,
4553,
13621,
27787,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
87,
796,
366,
15,
13,
20,
11215,
1600,
331,
796,
366,
15,
13,
20,
11215,
1600,
9647,
796,
366,
17,
11215,
1600,
6001,
796,
366,
16,
11215,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
87,
796,
366,
15,
13,
20,
11215,
1600,
331,
796,
366,
17,
11215,
1600,
9647,
796,
366,
16,
11215,
1600,
6001,
796,
366,
16,
13,
20,
11215,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
87,
796,
366,
18,
11215,
1600,
331,
796,
366,
15,
13,
20,
11215,
1600,
9647,
796,
366,
16,
13,
20,
11215,
1600,
6001,
796,
366,
17,
11215,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
87,
796,
366,
18,
13,
20,
11215,
1600,
331,
796,
366,
18,
11215,
1600,
9647,
796,
366,
16,
11215,
1600,
6001,
796,
366,
15,
13,
20,
11215,
4943,
628,
220,
220,
220,
1303,
15307,
19001,
286,
1570,
634,
1262,
705,
2554,
6,
5002,
198,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
796,
27071,
486,
11215,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
331,
796,
27071,
486,
11215,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9647,
796,
366,
19,
13,
4089,
11215,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6001,
796,
366,
18,
13,
4089,
11215,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6070,
796,
366,
23108,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14000,
796,
366,
17585,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14000,
62,
10394,
796,
27071,
2999,
11215,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
886,
198,
13812,
7,
7109,
8,
198,
198,
7109,
796,
198,
220,
220,
220,
40027,
7,
10394,
796,
366,
20,
11215,
1600,
6001,
796,
366,
20,
11215,
4943,
466,
198,
220,
220,
220,
220,
220,
220,
220,
1715,
3419,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
965,
7203,
7571,
2628,
11,
1123,
286,
734,
13621,
27787,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
308,
7,
312,
796,
366,
8094,
16,
1600,
6070,
796,
366,
445,
4943,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
87,
796,
366,
16,
11215,
1600,
331,
796,
366,
16,
11215,
1600,
9647,
796,
366,
16,
11215,
1600,
6001,
796,
366,
16,
11215,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
87,
796,
366,
18,
11215,
1600,
331,
796,
366,
16,
11215,
1600,
9647,
796,
366,
16,
11215,
1600,
6001,
796,
366,
16,
11215,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
308,
7,
312,
796,
366,
8094,
17,
1600,
6070,
796,
366,
17585,
4943,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
87,
796,
366,
16,
11215,
1600,
331,
796,
366,
18,
11215,
1600,
9647,
796,
366,
16,
11215,
1600,
6001,
796,
366,
16,
11215,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
87,
796,
366,
18,
11215,
1600,
331,
796,
366,
18,
11215,
1600,
9647,
796,
366,
16,
11215,
1600,
6001,
796,
366,
16,
11215,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
1303,
5438,
19001,
286,
1570,
634,
1262,
705,
2554,
6,
5002,
198,
220,
220,
220,
220,
220,
220,
220,
13621,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
796,
27071,
486,
11215,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
331,
796,
27071,
486,
11215,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9647,
796,
366,
19,
13,
4089,
11215,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6001,
796,
366,
19,
13,
4089,
11215,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6070,
796,
366,
23108,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14000,
796,
366,
17585,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14000,
62,
10394,
796,
27071,
2999,
11215,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
886,
198,
13812,
7,
7109,
8,
198,
198,
7109,
796,
198,
220,
220,
220,
40027,
7,
198,
220,
220,
220,
220,
220,
220,
220,
35555,
5907,
0,
87,
8726,
796,
366,
4023,
1378,
2503,
13,
86,
18,
13,
2398,
14,
18946,
14,
87,
8726,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
9647,
796,
366,
2167,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
6001,
796,
366,
3064,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
1570,
14253,
796,
366,
15,
657,
939,
1802,
1,
198,
220,
220,
220,
1267,
466,
198,
220,
220,
220,
220,
220,
220,
220,
3670,
3419,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
965,
7203,
21466,
24155,
290,
262,
779,
5002,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
1715,
3419,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
965,
7203,
15931,
7571,
13332,
11,
530,
286,
543,
318,
257,
302,
12,
34365,
992,
17271,
286,
262,
584,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
770,
2393,
15687,
530,
286,
262,
2663,
810,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
262,
9082,
12,
39170,
3918,
12336,
3173,
287,
45809,
362,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
423,
257,
1180,
1245,
621,
262,
45809,
352,
13,
16,
3918,
45973,
3173,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
383,
2656,
9197,
319,
262,
1364,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
815,
423,
4171,
6070,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
290,
4077,
14000,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
554,
257,
369,
15464,
45809,
352,
13,
16,
2836,
5797,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
262,
302,
12,
1484,
9197,
319,
262,
826,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
815,
423,
10912,
6070,
290,
4077,
14000,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
554,
257,
369,
15464,
45809,
362,
2836,
5797,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
262,
302,
12,
1484,
9197,
815,
423,
10912,
6070,
290,
14032,
14000,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
554,
477,
2663,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
262,
14000,
815,
307,
12387,
13245,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
290,
1160,
4991,
3094,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3585,
284,
257,
2472,
9197,
14753,
286,
1802,
4991,
32203,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
3918,
7,
4906,
796,
366,
5239,
14,
25471,
4943,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
965,
7203,
15931,
45597,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
14000,
12,
404,
4355,
25,
657,
13,
22,
26,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
764,
20887,
9197,
1391,
14000,
25,
4077,
26,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
779,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1391,
14000,
25,
14032,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6070,
25,
10912,
26,
1782,
15931,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
308,
7,
4871,
796,
366,
20887,
1600,
3918,
796,
366,
20797,
25,
4171,
4943,
466,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
9197,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4686,
796,
366,
66,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3075,
796,
366,
1120,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
43213,
796,
366,
1120,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
374,
796,
366,
1821,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14000,
62,
10394,
796,
366,
1238,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
779,
7,
87,
8726,
0,
33257,
796,
25113,
66,
1600,
2124,
796,
366,
3064,
4943,
198,
220,
220,
220,
886,
198
] | 1.840556 | 1,800 |
#Kronecker delta function
#23/07/2017
function krondelt(ii,jj)
if ii==jj
kronecker = 1
else
kronecker = 0
end
return kronecker
end
| [
2,
42,
33171,
15280,
25979,
2163,
198,
2,
1954,
14,
2998,
14,
5539,
198,
198,
8818,
479,
81,
623,
2120,
7,
4178,
11,
41098,
8,
198,
220,
611,
21065,
855,
41098,
198,
220,
220,
220,
479,
33171,
15280,
796,
352,
198,
220,
2073,
198,
220,
220,
220,
479,
33171,
15280,
796,
657,
198,
220,
886,
198,
220,
1441,
479,
33171,
15280,
198,
437,
198
] | 2.3125 | 64 |
<reponame>mfkiwl/CUDA.jl<filename>lib/cusolver/linalg.jl
# implementation of LinearAlgebra interfaces
using LinearAlgebra
using ..CUBLAS: CublasFloat
function copy_cublasfloat(A::CuMatrix{T}) where {T}
cublasfloat = promote_type(Float32, T)
if !(cublasfloat <: CublasFloat)
throw(ArgumentError("cannot promote eltype $T to a CUBLAS float"))
end
return copyto!(similar(A, cublasfloat), A)
end
# matrix division
const CuMatOrAdj{T} = Union{CuMatrix,
LinearAlgebra.Adjoint{T, <:CuMatrix{T}},
LinearAlgebra.Transpose{T, <:CuMatrix{T}}}
const CuOrAdj{T} = Union{CuVecOrMat,
LinearAlgebra.Adjoint{T, <:CuVecOrMat{T}},
LinearAlgebra.Transpose{T, <:CuVecOrMat{T}}}
function Base.:\(_A::CuMatOrAdj, _B::CuOrAdj)
A, B = copy_cublasfloat(_A), copy_cublasfloat(_B)
A, ipiv = CUSOLVER.getrf!(A)
return CUSOLVER.getrs!('N', A, ipiv, B)
end
# patch JuliaLang/julia#40899 to create a CuArray
# (see https://github.com/JuliaLang/julia/pull/41331#issuecomment-868374522)
if VERSION >= v"1.7-"
_zeros(::Type{T}, b::AbstractVector, n::Integer) where {T} = CUDA.zeros(T, max(length(b), n))
_zeros(::Type{T}, B::AbstractMatrix, n::Integer) where {T} = CUDA.zeros(T, max(size(B, 1), n), size(B, 2))
function Base.:\(F::Union{LinearAlgebra.LAPACKFactorizations{<:Any,<:CuArray},
Adjoint{<:Any,<:LinearAlgebra.LAPACKFactorizations{<:Any,<:CuArray}}},
B::AbstractVecOrMat)
m, n = size(F)
if m != size(B, 1)
throw(DimensionMismatch("arguments must have the same number of rows"))
end
TFB = typeof(oneunit(eltype(B)) / oneunit(eltype(F)))
FF = Factorization{TFB}(F)
# For wide problem we (often) compute a minimum norm solution. The solution
# is larger than the right hand side so we use size(F, 2).
BB = _zeros(TFB, B, n)
if n > size(B, 1)
# Underdetermined
copyto!(view(BB, 1:m, :), B)
else
copyto!(BB, B)
end
ldiv!(FF, BB)
# For tall problems, we compute a least squares solution so only part
# of the rhs should be returned from \ while ldiv! uses (and returns)
# the complete rhs
return LinearAlgebra._cut_B(BB, 1:n)
end
end
# factorizations
using LinearAlgebra: Factorization, AbstractQ
## QR
if VERSION >= v"1.8-"
LinearAlgebra.qr!(A::CuMatrix{T}) where T = QR(geqrf!(A::CuMatrix{T})...)
# conversions
CuMatrix(F::Union{QR,QRCompactWY}) = CuArray(AbstractArray(F))
CuArray(F::Union{QR,QRCompactWY}) = CuMatrix(F)
CuMatrix(F::QRPivoted) = CuArray(AbstractArray(F))
CuArray(F::QRPivoted) = CuMatrix(F)
function LinearAlgebra.ldiv!(_qr::QR, b::CuArray)
_x = UpperTriangular(_qr.R) \ (_qr.Q' * reshape(b,length(b),1))
b .= vec(_x)
unsafe_free!(_x)
return b
end
function LinearAlgebra.ldiv!(x::CuArray, _qr::QR, b::CuArray)
_x = UpperTriangular(_qr.R) \ (_qr.Q' * reshape(b,length(b),1))
x .= vec(_x)
unsafe_free!(_x)
return x
end
# conversions of factorizations
CuArray(Q::AbstractQ) = CuMatrix(Q)
CuArray{T}(Q::AbstractQ) where {T} = CuMatrix{T}(Q)
CuMatrix(Q::AbstractQ{T}) where {T} = CuMatrix{T}(Q)
CuMatrix{T}(Q::AbstractQ{S}) where {T,S} =
CuMatrix{T}(lmul!(Q, CuMatrix{S}(I, size(Q, 1), min(size(Q.factors)...))))
# avoid the CPU array in the above mul!
Matrix{T}(Q::QRPackedQ{S,<:CuArray,<:CuArray}) where {T,S} = Array(CuMatrix{T}(Q))
Matrix{T}(Q::QRCompactWYQ{S,<:CuArray,<:CuArray}) where {T,S} = Array(CuMatrix{T}(Q))
function Base.getindex(Q::QRPackedQ{<:Any, <:CuArray}, ::Colon, j::Int)
y = CUDA.zeros(eltype(Q), size(Q, 2))
y[j] = 1
lmul!(Q, y)
end
# multiplication by Q
LinearAlgebra.lmul!(A::QRPackedQ{T,<:CuArray,<:CuArray},
B::CuVecOrMat{T}) where {T<:Number} =
ormqr!('L', 'N', A.factors, A.τ, B)
LinearAlgebra.lmul!(adjA::Adjoint{T,<:QRPackedQ{T,<:CuArray,<:CuArray}},
B::CuVecOrMat{T}) where {T<:Real} =
ormqr!('L', 'T', parent(adjA).factors, parent(adjA).τ, B)
LinearAlgebra.lmul!(adjA::Adjoint{T,<:QRPackedQ{T,<:CuArray,<:CuArray}},
B::CuVecOrMat{T}) where {T<:Complex} =
ormqr!('L', 'C', parent(adjA).factors, parent(adjA).τ, B)
LinearAlgebra.lmul!(trA::Transpose{T,<:QRPackedQ{T,<:CuArray,<:CuArray}},
B::CuVecOrMat{T}) where {T<:Number} =
ormqr!('L', 'T', parent(trA).factors, parent(trA).τ, B)
else
struct CuQR{T,S<:AbstractMatrix} <: Factorization{T}
factors::S
τ::CuVector{T}
CuQR{T,S}(factors::AbstractMatrix{T}, τ::CuVector{T}) where {T,S<:AbstractMatrix} = new(factors, τ)
end
struct CuQRPackedQ{T,S<:AbstractMatrix} <: AbstractQ{T}
factors::CuMatrix{T}
τ::CuVector{T}
CuQRPackedQ{T,S}(factors::AbstractMatrix{T}, τ::CuVector{T}) where {T,S<:AbstractMatrix} = new(factors, τ)
end
CuQR(factors::AbstractMatrix{T}, τ::CuVector{T}) where {T} =
CuQR{T,typeof(factors)}(factors, τ)
CuQRPackedQ(factors::AbstractMatrix{T}, τ::CuVector{T}) where {T} =
CuQRPackedQ{T,typeof(factors)}(factors, τ)
# AbstractQ's `size` is the size of the full matrix,
# while `Matrix(Q)` only gives the compact Q.
# See JuliaLang/julia#26591 and JuliaGPU/CUDA.jl#969.
CuMatrix{T}(Q::AbstractQ{S}) where {T,S} = convert(CuArray, Matrix{T}(Q))
CuMatrix(Q::AbstractQ{T}) where {T} = CuMatrix{T}(Q)
CuArray{T}(Q::AbstractQ) where {T} = CuMatrix{T}(Q)
CuArray(Q::AbstractQ) = CuMatrix(Q)
LinearAlgebra.qr!(A::CuMatrix{T}) where T = CuQR(geqrf!(A::CuMatrix{T})...)
Base.size(A::CuQR) = size(A.factors)
Base.size(A::CuQRPackedQ, dim::Integer) = 0 < dim ? (dim <= 2 ? size(A.factors, 1) : 1) : throw(BoundsError())
CUDA.CuMatrix(A::CuQRPackedQ) = orgqr!(copy(A.factors), A.τ)
CUDA.CuArray(A::CuQRPackedQ) = CuMatrix(A)
Base.Matrix(A::CuQRPackedQ) = Matrix(CuMatrix(A))
function Base.getproperty(A::CuQR, d::Symbol)
m, n = size(getfield(A, :factors))
if d == :R
return triu!(A.factors[1:min(m, n), 1:n])
elseif d == :Q
return CuQRPackedQ(A.factors, A.τ)
else
getfield(A, d)
end
end
# iteration for destructuring into components
Base.iterate(S::CuQR) = (S.Q, Val(:R))
Base.iterate(S::CuQR, ::Val{:R}) = (S.R, Val(:done))
Base.iterate(S::CuQR, ::Val{:done}) = nothing
# Apply changes Q from the left
LinearAlgebra.lmul!(A::CuQRPackedQ{T,S}, B::CuVecOrMat{T}) where {T<:Number, S<:CuMatrix} =
ormqr!('L', 'N', A.factors, A.τ, B)
LinearAlgebra.lmul!(adjA::Adjoint{T,<:CuQRPackedQ{T,S}}, B::CuVecOrMat{T}) where {T<:Real, S<:CuMatrix} =
ormqr!('L', 'T', parent(adjA).factors, parent(adjA).τ, B)
LinearAlgebra.lmul!(adjA::Adjoint{T,<:CuQRPackedQ{T,S}}, B::CuVecOrMat{T}) where {T<:Complex, S<:CuMatrix} =
ormqr!('L', 'C', parent(adjA).factors, parent(adjA).τ, B)
LinearAlgebra.lmul!(trA::Transpose{T,<:CuQRPackedQ{T,S}}, B::CuVecOrMat{T}) where {T<:Number, S<:CuMatrix} =
ormqr!('L', 'T', parent(trA).factors, parent(trA).τ, B)
function Base.getindex(A::CuQRPackedQ{T, S}, i::Int, j::Int) where {T, S}
assertscalar("CuQRPackedQ getindex")
x = CUDA.zeros(T, size(A, 2))
x[j] = 1
lmul!(A, x)
return x[i]
end
function Base.show(io::IO, F::CuQR)
println(io, "$(typeof(F)) with factors Q and R:")
show(io, F.Q)
println(io)
show(io, F.R)
end
# https://github.com/JuliaLang/julia/pull/32887
LinearAlgebra.det(Q::CuQRPackedQ{<:Real}) = isodd(count(!iszero, Q.τ)) ? -1 : 1
LinearAlgebra.det(Q::CuQRPackedQ) = prod(τ -> iszero(τ) ? one(τ) : -sign(τ)^2, Q.τ)
function LinearAlgebra.ldiv!(_qr::CuQR, b::CuArray)
_x = UpperTriangular(_qr.R) \ (_qr.Q' * reshape(b,length(b),1))
b .= vec(_x)
unsafe_free!(_x)
return b
end
function LinearAlgebra.ldiv!(x::CuArray,_qr::CuQR, b::CuArray)
_x = UpperTriangular(_qr.R) \ (_qr.Q' * reshape(b,length(b),1))
x .= vec(_x)
unsafe_free!(_x)
return x
end
end
## SVD
abstract type SVDAlgorithm end
struct QRAlgorithm <: SVDAlgorithm end
struct JacobiAlgorithm <: SVDAlgorithm end
if VERSION >= v"1.8-"
LinearAlgebra.svd!(A::CuMatrix{T}; full::Bool=false,
alg::SVDAlgorithm=JacobiAlgorithm()) where {T} =
_svd!(A, full, alg)
LinearAlgebra.svd(A::CuMatrix; full=false, alg::SVDAlgorithm=JacobiAlgorithm()) =
_svd!(copy_cublasfloat(A), full, alg)
_svd!(A::CuMatrix{T}, full::Bool, alg::SVDAlgorithm) where T =
throw(ArgumentError("Unsupported value for `alg` keyword."))
function _svd!(A::CuMatrix{T}, full::Bool, alg::QRAlgorithm) where T
U, S, Vt = gesvd!(full ? 'A' : 'S', full ? 'A' : 'S', A)
return SVD(U, S, Vt)
end
function _svd!(A::CuMatrix{T}, full::Bool, alg::JacobiAlgorithm) where T
U, S, V = gesvdj!('V', Int(!full), A)
return SVD(U, S, V')
end
else
struct CuSVD{T,Tr,A<:AbstractMatrix{T}} <: LinearAlgebra.Factorization{T}
U::CuMatrix{T}
S::CuVector{Tr}
V::A
end
# iteration for destructuring into components
Base.iterate(S::CuSVD) = (S.U, Val(:S))
Base.iterate(S::CuSVD, ::Val{:S}) = (S.S, Val(:V))
Base.iterate(S::CuSVD, ::Val{:V}) = (S.V, Val(:done))
Base.iterate(S::CuSVD, ::Val{:done}) = nothing
@inline function Base.getproperty(S::CuSVD, s::Symbol)
if s === :Vt
return getfield(S, :V)'
else
return getfield(S, s)
end
end
LinearAlgebra.svd!(A::CuMatrix{T}; full::Bool=false,
alg::SVDAlgorithm=JacobiAlgorithm()) where {T} =
_svd!(A, full, alg)
LinearAlgebra.svd(A::CuMatrix; full=false, alg::SVDAlgorithm=JacobiAlgorithm()) =
_svd!(copy_cublasfloat(A), full, alg)
_svd!(A::CuMatrix{T}, full::Bool, alg::SVDAlgorithm) where T =
throw(ArgumentError("Unsupported value for `alg` keyword."))
function _svd!(A::CuMatrix{T}, full::Bool, alg::QRAlgorithm) where T
U, s, Vt = gesvd!(full ? 'A' : 'S', full ? 'A' : 'S', A::CuMatrix{T})
return CuSVD(U, s, Vt')
end
function _svd!(A::CuMatrix{T}, full::Bool, alg::JacobiAlgorithm) where T
return CuSVD(gesvdj!('V', Int(!full), A::CuMatrix{T})...)
end
end
LinearAlgebra.svdvals!(A::CuMatrix{T}; alg::SVDAlgorithm=JacobiAlgorithm()) where {T} =
_svdvals!(A, alg)
LinearAlgebra.svdvals(A::CuMatrix; alg::SVDAlgorithm=JacobiAlgorithm()) =
_svdvals!(copy_cublasfloat(A), alg)
_svdvals!(A::CuMatrix{T}, alg::SVDAlgorithm) where T =
throw(ArgumentError("Unsupported value for `alg` keyword."))
_svdvals!(A::CuMatrix{T}, alg::QRAlgorithm) where T = gesvd!('N', 'N', A::CuMatrix{T})[2]
_svdvals!(A::CuMatrix{T}, alg::JacobiAlgorithm) where T = gesvdj!('N', 1, A::CuMatrix{T})[2]
## LU
if VERSION >= v"1.8-"
function LinearAlgebra.lu!(A::StridedCuMatrix{T}, ::RowMaximum; check::Bool = true) where {T}
lpt = getrf!(A)
check && LinearAlgebra.checknonsingular(lpt[3])
return LU(lpt[1], lpt[2], Int(lpt[3]))
end
# GPU-compatible accessors of the LU decomposition properties
function Base.getproperty(F::LU{T,<:StridedCuMatrix}, d::Symbol) where T
m, n = size(F)
if d === :L
L = tril!(getfield(F, :factors)[1:m, 1:min(m,n)])
L[1:min(m,n)+1:end] .= one(T) # set the diagonal (linear indexing trick)
return L
else
invoke(getproperty, Tuple{LU{T,<:StridedMatrix}, Symbol}, F, d)
end
end
# LAPACK's pivoting sequence needs to be iterated sequentially...
# TODO: figure out a GPU-compatible way to get the permutation matrix
LinearAlgebra.ipiv2perm(v::CuVector{T}, maxi::Integer) where T =
LinearAlgebra.ipiv2perm(Array(v), maxi)
end
## cholesky
if VERSION >= v"1.8-"
function LinearAlgebra.cholesky(A::LinearAlgebra.RealHermSymComplexHerm{<:Real,<:CuMatrix},
::Val{false}=Val(false); check::Bool = true)
C, info = LinearAlgebra._chol!(copy(parent(A)), A.uplo == 'U' ? UpperTriangular : LowerTriangular)
return Cholesky(C.data, A.uplo, info)
end
end
| [
27,
7856,
261,
480,
29,
76,
69,
4106,
40989,
14,
43633,
5631,
13,
20362,
27,
34345,
29,
8019,
14,
9042,
14375,
14,
75,
1292,
70,
13,
20362,
198,
2,
7822,
286,
44800,
2348,
29230,
20314,
198,
198,
3500,
44800,
2348,
29230,
198,
3500,
11485,
43633,
9148,
1921,
25,
7070,
21921,
43879,
198,
198,
8818,
4866,
62,
66,
549,
21921,
22468,
7,
32,
3712,
46141,
46912,
90,
51,
30072,
810,
1391,
51,
92,
198,
220,
220,
220,
13617,
21921,
22468,
796,
7719,
62,
4906,
7,
43879,
2624,
11,
309,
8,
198,
220,
220,
220,
611,
5145,
7,
66,
549,
21921,
22468,
1279,
25,
7070,
21921,
43879,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
66,
34574,
7719,
1288,
4906,
720,
51,
284,
257,
29369,
9148,
1921,
12178,
48774,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
4866,
1462,
0,
7,
38610,
7,
32,
11,
13617,
21921,
22468,
828,
317,
8,
198,
437,
198,
198,
2,
17593,
7297,
198,
198,
9979,
14496,
19044,
5574,
2782,
73,
90,
51,
92,
796,
4479,
90,
46141,
46912,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44800,
2348,
29230,
13,
2782,
73,
1563,
90,
51,
11,
1279,
25,
46141,
46912,
90,
51,
92,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44800,
2348,
29230,
13,
8291,
3455,
90,
51,
11,
1279,
25,
46141,
46912,
90,
51,
42535,
198,
9979,
14496,
5574,
2782,
73,
90,
51,
92,
796,
4479,
90,
46141,
53,
721,
5574,
19044,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44800,
2348,
29230,
13,
2782,
73,
1563,
90,
51,
11,
1279,
25,
46141,
53,
721,
5574,
19044,
90,
51,
92,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44800,
2348,
29230,
13,
8291,
3455,
90,
51,
11,
1279,
25,
46141,
53,
721,
5574,
19044,
90,
51,
42535,
198,
198,
8818,
7308,
13,
7479,
28264,
32,
3712,
46141,
19044,
5574,
2782,
73,
11,
4808,
33,
3712,
46141,
5574,
2782,
73,
8,
198,
220,
220,
220,
317,
11,
347,
796,
4866,
62,
66,
549,
21921,
22468,
28264,
32,
828,
4866,
62,
66,
549,
21921,
22468,
28264,
33,
8,
198,
220,
220,
220,
317,
11,
20966,
452,
796,
327,
2937,
3535,
5959,
13,
1136,
41871,
0,
7,
32,
8,
198,
220,
220,
220,
1441,
327,
2937,
3535,
5959,
13,
1136,
3808,
0,
10786,
45,
3256,
317,
11,
20966,
452,
11,
347,
8,
198,
437,
198,
198,
2,
8529,
22300,
43,
648,
14,
73,
43640,
2,
26200,
2079,
284,
2251,
257,
14496,
19182,
198,
2,
357,
3826,
3740,
1378,
12567,
13,
785,
14,
16980,
544,
43,
648,
14,
73,
43640,
14,
31216,
14,
44103,
3132,
2,
21949,
23893,
12,
23,
3104,
2718,
2231,
1828,
8,
198,
361,
44156,
2849,
18189,
410,
1,
16,
13,
22,
21215,
198,
62,
9107,
418,
7,
3712,
6030,
90,
51,
5512,
275,
3712,
23839,
38469,
11,
299,
3712,
46541,
8,
810,
1391,
51,
92,
796,
29369,
5631,
13,
9107,
418,
7,
51,
11,
3509,
7,
13664,
7,
65,
828,
299,
4008,
198,
62,
9107,
418,
7,
3712,
6030,
90,
51,
5512,
347,
3712,
23839,
46912,
11,
299,
3712,
46541,
8,
810,
1391,
51,
92,
796,
29369,
5631,
13,
9107,
418,
7,
51,
11,
3509,
7,
7857,
7,
33,
11,
352,
828,
299,
828,
2546,
7,
33,
11,
362,
4008,
198,
8818,
7308,
13,
7479,
7,
37,
3712,
38176,
90,
14993,
451,
2348,
29230,
13,
43,
2969,
8120,
41384,
4582,
90,
27,
25,
7149,
11,
27,
25,
46141,
19182,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1215,
73,
1563,
90,
27,
25,
7149,
11,
27,
25,
14993,
451,
2348,
29230,
13,
43,
2969,
8120,
41384,
4582,
90,
27,
25,
7149,
11,
27,
25,
46141,
19182,
11709,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
347,
3712,
23839,
53,
721,
5574,
19044,
8,
198,
220,
220,
220,
285,
11,
299,
796,
2546,
7,
37,
8,
198,
220,
220,
220,
611,
285,
14512,
2546,
7,
33,
11,
352,
8,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
29271,
3004,
44,
1042,
963,
7203,
853,
2886,
1276,
423,
262,
976,
1271,
286,
15274,
48774,
198,
220,
220,
220,
886,
628,
220,
220,
220,
24958,
33,
796,
2099,
1659,
7,
505,
20850,
7,
417,
4906,
7,
33,
4008,
1220,
530,
20850,
7,
417,
4906,
7,
37,
22305,
198,
220,
220,
220,
18402,
796,
27929,
1634,
90,
10234,
33,
92,
7,
37,
8,
628,
220,
220,
220,
1303,
1114,
3094,
1917,
356,
357,
28950,
8,
24061,
257,
5288,
2593,
4610,
13,
383,
4610,
198,
220,
220,
220,
1303,
318,
4025,
621,
262,
826,
1021,
1735,
523,
356,
779,
2546,
7,
37,
11,
362,
737,
198,
220,
220,
220,
12597,
796,
4808,
9107,
418,
7,
10234,
33,
11,
347,
11,
299,
8,
628,
220,
220,
220,
611,
299,
1875,
2546,
7,
33,
11,
352,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
4698,
67,
23444,
198,
220,
220,
220,
220,
220,
220,
220,
4866,
1462,
0,
7,
1177,
7,
15199,
11,
352,
25,
76,
11,
1058,
828,
347,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
4866,
1462,
0,
7,
15199,
11,
347,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
300,
7146,
0,
7,
5777,
11,
12597,
8,
628,
220,
220,
220,
1303,
1114,
7331,
2761,
11,
356,
24061,
257,
1551,
24438,
4610,
523,
691,
636,
198,
220,
220,
220,
1303,
286,
262,
9529,
82,
815,
307,
4504,
422,
3467,
981,
300,
7146,
0,
3544,
357,
392,
5860,
8,
198,
220,
220,
220,
1303,
262,
1844,
9529,
82,
198,
220,
220,
220,
1441,
44800,
2348,
29230,
13557,
8968,
62,
33,
7,
15199,
11,
352,
25,
77,
8,
198,
437,
198,
437,
628,
198,
2,
5766,
4582,
198,
198,
3500,
44800,
2348,
29230,
25,
27929,
1634,
11,
27741,
48,
198,
198,
2235,
42137,
198,
198,
361,
44156,
2849,
18189,
410,
1,
16,
13,
23,
21215,
198,
198,
14993,
451,
2348,
29230,
13,
80,
81,
0,
7,
32,
3712,
46141,
46912,
90,
51,
30072,
810,
309,
796,
42137,
7,
469,
80,
41871,
0,
7,
32,
3712,
46141,
46912,
90,
51,
30072,
23029,
198,
198,
2,
32626,
198,
46141,
46912,
7,
37,
3712,
38176,
90,
48,
49,
11,
48,
49,
7293,
529,
54,
56,
30072,
796,
14496,
19182,
7,
23839,
19182,
7,
37,
4008,
198,
46141,
19182,
7,
37,
3712,
38176,
90,
48,
49,
11,
48,
49,
7293,
529,
54,
56,
30072,
796,
14496,
46912,
7,
37,
8,
198,
46141,
46912,
7,
37,
3712,
48,
20031,
452,
5191,
8,
796,
14496,
19182,
7,
23839,
19182,
7,
37,
4008,
198,
46141,
19182,
7,
37,
3712,
48,
20031,
452,
5191,
8,
796,
14496,
46912,
7,
37,
8,
198,
198,
8818,
44800,
2348,
29230,
13,
335,
452,
0,
28264,
80,
81,
3712,
48,
49,
11,
275,
3712,
46141,
19182,
8,
198,
220,
220,
220,
4808,
87,
796,
20390,
14824,
21413,
28264,
80,
81,
13,
49,
8,
3467,
44104,
80,
81,
13,
48,
6,
1635,
27179,
1758,
7,
65,
11,
13664,
7,
65,
828,
16,
4008,
198,
220,
220,
220,
275,
764,
28,
43030,
28264,
87,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
28264,
87,
8,
198,
220,
220,
220,
1441,
275,
198,
437,
198,
198,
8818,
44800,
2348,
29230,
13,
335,
452,
0,
7,
87,
3712,
46141,
19182,
11,
4808,
80,
81,
3712,
48,
49,
11,
275,
3712,
46141,
19182,
8,
198,
220,
220,
220,
4808,
87,
796,
20390,
14824,
21413,
28264,
80,
81,
13,
49,
8,
3467,
44104,
80,
81,
13,
48,
6,
1635,
27179,
1758,
7,
65,
11,
13664,
7,
65,
828,
16,
4008,
198,
220,
220,
220,
2124,
764,
28,
43030,
28264,
87,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
28264,
87,
8,
198,
220,
220,
220,
1441,
2124,
198,
437,
198,
198,
2,
32626,
286,
5766,
4582,
198,
46141,
19182,
7,
48,
3712,
23839,
48,
8,
796,
14496,
46912,
7,
48,
8,
198,
46141,
19182,
90,
51,
92,
7,
48,
3712,
23839,
48,
8,
810,
1391,
51,
92,
796,
14496,
46912,
90,
51,
92,
7,
48,
8,
198,
46141,
46912,
7,
48,
3712,
23839,
48,
90,
51,
30072,
810,
1391,
51,
92,
796,
14496,
46912,
90,
51,
92,
7,
48,
8,
198,
46141,
46912,
90,
51,
92,
7,
48,
3712,
23839,
48,
90,
50,
30072,
810,
1391,
51,
11,
50,
92,
796,
198,
220,
220,
220,
14496,
46912,
90,
51,
92,
7,
75,
76,
377,
0,
7,
48,
11,
14496,
46912,
90,
50,
92,
7,
40,
11,
2546,
7,
48,
11,
352,
828,
949,
7,
7857,
7,
48,
13,
22584,
669,
26513,
35514,
198,
2,
3368,
262,
9135,
7177,
287,
262,
2029,
35971,
0,
198,
46912,
90,
51,
92,
7,
48,
3712,
48,
20031,
6021,
48,
90,
50,
11,
27,
25,
46141,
19182,
11,
27,
25,
46141,
19182,
30072,
810,
1391,
51,
11,
50,
92,
796,
15690,
7,
46141,
46912,
90,
51,
92,
7,
48,
4008,
198,
46912,
90,
51,
92,
7,
48,
3712,
48,
49,
7293,
529,
54,
56,
48,
90,
50,
11,
27,
25,
46141,
19182,
11,
27,
25,
46141,
19182,
30072,
810,
1391,
51,
11,
50,
92,
796,
15690,
7,
46141,
46912,
90,
51,
92,
7,
48,
4008,
198,
198,
8818,
7308,
13,
1136,
9630,
7,
48,
3712,
48,
20031,
6021,
48,
90,
27,
25,
7149,
11,
1279,
25,
46141,
19182,
5512,
7904,
5216,
261,
11,
474,
3712,
5317,
8,
198,
220,
220,
220,
331,
796,
29369,
5631,
13,
9107,
418,
7,
417,
4906,
7,
48,
828,
2546,
7,
48,
11,
362,
4008,
198,
220,
220,
220,
331,
58,
73,
60,
796,
352,
198,
220,
220,
220,
300,
76,
377,
0,
7,
48,
11,
331,
8,
198,
437,
198,
198,
2,
48473,
416,
1195,
198,
14993,
451,
2348,
29230,
13,
75,
76,
377,
0,
7,
32,
3712,
48,
20031,
6021,
48,
90,
51,
11,
27,
25,
46141,
19182,
11,
27,
25,
46141,
19182,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
347,
3712,
46141,
53,
721,
5574,
19044,
90,
51,
30072,
810,
1391,
51,
27,
25,
15057,
92,
796,
198,
220,
220,
220,
393,
76,
80,
81,
0,
10786,
43,
3256,
705,
45,
3256,
317,
13,
22584,
669,
11,
317,
13,
32830,
11,
347,
8,
198,
14993,
451,
2348,
29230,
13,
75,
76,
377,
0,
7,
41255,
32,
3712,
2782,
73,
1563,
90,
51,
11,
27,
25,
48,
20031,
6021,
48,
90,
51,
11,
27,
25,
46141,
19182,
11,
27,
25,
46141,
19182,
92,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
347,
3712,
46141,
53,
721,
5574,
19044,
90,
51,
30072,
810,
1391,
51,
27,
25,
15633,
92,
796,
198,
220,
220,
220,
393,
76,
80,
81,
0,
10786,
43,
3256,
705,
51,
3256,
2560,
7,
41255,
32,
737,
22584,
669,
11,
2560,
7,
41255,
32,
737,
32830,
11,
347,
8,
198,
14993,
451,
2348,
29230,
13,
75,
76,
377,
0,
7,
41255,
32,
3712,
2782,
73,
1563,
90,
51,
11,
27,
25,
48,
20031,
6021,
48,
90,
51,
11,
27,
25,
46141,
19182,
11,
27,
25,
46141,
19182,
92,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
347,
3712,
46141,
53,
721,
5574,
19044,
90,
51,
30072,
810,
1391,
51,
27,
25,
5377,
11141,
92,
796,
198,
220,
220,
220,
393,
76,
80,
81,
0,
10786,
43,
3256,
705,
34,
3256,
2560,
7,
41255,
32,
737,
22584,
669,
11,
2560,
7,
41255,
32,
737,
32830,
11,
347,
8,
198,
14993,
451,
2348,
29230,
13,
75,
76,
377,
0,
7,
2213,
32,
3712,
8291,
3455,
90,
51,
11,
27,
25,
48,
20031,
6021,
48,
90,
51,
11,
27,
25,
46141,
19182,
11,
27,
25,
46141,
19182,
92,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
347,
3712,
46141,
53,
721,
5574,
19044,
90,
51,
30072,
810,
1391,
51,
27,
25,
15057,
92,
796,
198,
220,
220,
220,
393,
76,
80,
81,
0,
10786,
43,
3256,
705,
51,
3256,
2560,
7,
2213,
32,
737,
22584,
669,
11,
2560,
7,
2213,
32,
737,
32830,
11,
347,
8,
198,
198,
17772,
198,
198,
7249,
14496,
48,
49,
90,
51,
11,
50,
27,
25,
23839,
46912,
92,
1279,
25,
27929,
1634,
90,
51,
92,
198,
220,
220,
220,
5087,
3712,
50,
198,
220,
220,
220,
46651,
3712,
46141,
38469,
90,
51,
92,
198,
220,
220,
220,
14496,
48,
49,
90,
51,
11,
50,
92,
7,
22584,
669,
3712,
23839,
46912,
90,
51,
5512,
46651,
3712,
46141,
38469,
90,
51,
30072,
810,
1391,
51,
11,
50,
27,
25,
23839,
46912,
92,
796,
649,
7,
22584,
669,
11,
46651,
8,
198,
437,
198,
198,
7249,
14496,
48,
20031,
6021,
48,
90,
51,
11,
50,
27,
25,
23839,
46912,
92,
1279,
25,
27741,
48,
90,
51,
92,
198,
220,
220,
220,
5087,
3712,
46141,
46912,
90,
51,
92,
198,
220,
220,
220,
46651,
3712,
46141,
38469,
90,
51,
92,
198,
220,
220,
220,
14496,
48,
20031,
6021,
48,
90,
51,
11,
50,
92,
7,
22584,
669,
3712,
23839,
46912,
90,
51,
5512,
46651,
3712,
46141,
38469,
90,
51,
30072,
810,
1391,
51,
11,
50,
27,
25,
23839,
46912,
92,
796,
649,
7,
22584,
669,
11,
46651,
8,
198,
437,
198,
198,
46141,
48,
49,
7,
22584,
669,
3712,
23839,
46912,
90,
51,
5512,
46651,
3712,
46141,
38469,
90,
51,
30072,
810,
1391,
51,
92,
796,
198,
220,
220,
220,
14496,
48,
49,
90,
51,
11,
4906,
1659,
7,
22584,
669,
38165,
7,
22584,
669,
11,
46651,
8,
198,
46141,
48,
20031,
6021,
48,
7,
22584,
669,
3712,
23839,
46912,
90,
51,
5512,
46651,
3712,
46141,
38469,
90,
51,
30072,
810,
1391,
51,
92,
796,
198,
220,
220,
220,
14496,
48,
20031,
6021,
48,
90,
51,
11,
4906,
1659,
7,
22584,
669,
38165,
7,
22584,
669,
11,
46651,
8,
198,
198,
2,
27741,
48,
338,
4600,
7857,
63,
318,
262,
2546,
286,
262,
1336,
17593,
11,
198,
2,
981,
4600,
46912,
7,
48,
8,
63,
691,
3607,
262,
16001,
1195,
13,
198,
2,
4091,
22300,
43,
648,
14,
73,
43640,
2,
2075,
48952,
290,
22300,
33346,
14,
43633,
5631,
13,
20362,
2,
38819,
13,
198,
46141,
46912,
90,
51,
92,
7,
48,
3712,
23839,
48,
90,
50,
30072,
810,
1391,
51,
11,
50,
92,
796,
10385,
7,
46141,
19182,
11,
24936,
90,
51,
92,
7,
48,
4008,
198,
46141,
46912,
7,
48,
3712,
23839,
48,
90,
51,
30072,
810,
1391,
51,
92,
796,
14496,
46912,
90,
51,
92,
7,
48,
8,
198,
46141,
19182,
90,
51,
92,
7,
48,
3712,
23839,
48,
8,
810,
1391,
51,
92,
796,
14496,
46912,
90,
51,
92,
7,
48,
8,
198,
46141,
19182,
7,
48,
3712,
23839,
48,
8,
796,
14496,
46912,
7,
48,
8,
198,
198,
14993,
451,
2348,
29230,
13,
80,
81,
0,
7,
32,
3712,
46141,
46912,
90,
51,
30072,
810,
309,
796,
14496,
48,
49,
7,
469,
80,
41871,
0,
7,
32,
3712,
46141,
46912,
90,
51,
30072,
23029,
198,
14881,
13,
7857,
7,
32,
3712,
46141,
48,
49,
8,
796,
2546,
7,
32,
13,
22584,
669,
8,
198,
14881,
13,
7857,
7,
32,
3712,
46141,
48,
20031,
6021,
48,
11,
5391,
3712,
46541,
8,
796,
657,
1279,
5391,
5633,
357,
27740,
19841,
362,
5633,
2546,
7,
32,
13,
22584,
669,
11,
352,
8,
1058,
352,
8,
1058,
3714,
7,
33,
3733,
12331,
28955,
198,
43633,
5631,
13,
46141,
46912,
7,
32,
3712,
46141,
48,
20031,
6021,
48,
8,
796,
8745,
80,
81,
0,
7,
30073,
7,
32,
13,
22584,
669,
828,
317,
13,
32830,
8,
198,
43633,
5631,
13,
46141,
19182,
7,
32,
3712,
46141,
48,
20031,
6021,
48,
8,
796,
14496,
46912,
7,
32,
8,
198,
14881,
13,
46912,
7,
32,
3712,
46141,
48,
20031,
6021,
48,
8,
796,
24936,
7,
46141,
46912,
7,
32,
4008,
198,
198,
8818,
7308,
13,
1136,
26745,
7,
32,
3712,
46141,
48,
49,
11,
288,
3712,
13940,
23650,
8,
198,
220,
220,
220,
285,
11,
299,
796,
2546,
7,
1136,
3245,
7,
32,
11,
1058,
22584,
669,
4008,
198,
220,
220,
220,
611,
288,
6624,
1058,
49,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
1333,
84,
0,
7,
32,
13,
22584,
669,
58,
16,
25,
1084,
7,
76,
11,
299,
828,
352,
25,
77,
12962,
198,
220,
220,
220,
2073,
361,
288,
6624,
1058,
48,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
14496,
48,
20031,
6021,
48,
7,
32,
13,
22584,
669,
11,
317,
13,
32830,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
651,
3245,
7,
32,
11,
288,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2,
24415,
329,
15256,
870,
656,
6805,
198,
14881,
13,
2676,
378,
7,
50,
3712,
46141,
48,
49,
8,
796,
357,
50,
13,
48,
11,
3254,
7,
25,
49,
4008,
198,
14881,
13,
2676,
378,
7,
50,
3712,
46141,
48,
49,
11,
7904,
7762,
90,
25,
49,
30072,
796,
357,
50,
13,
49,
11,
3254,
7,
25,
28060,
4008,
198,
14881,
13,
2676,
378,
7,
50,
3712,
46141,
48,
49,
11,
7904,
7762,
90,
25,
28060,
30072,
796,
2147,
198,
198,
2,
27967,
2458,
1195,
422,
262,
1364,
198,
14993,
451,
2348,
29230,
13,
75,
76,
377,
0,
7,
32,
3712,
46141,
48,
20031,
6021,
48,
90,
51,
11,
50,
5512,
347,
3712,
46141,
53,
721,
5574,
19044,
90,
51,
30072,
810,
1391,
51,
27,
25,
15057,
11,
311,
27,
25,
46141,
46912,
92,
796,
198,
220,
220,
220,
393,
76,
80,
81,
0,
10786,
43,
3256,
705,
45,
3256,
317,
13,
22584,
669,
11,
317,
13,
32830,
11,
347,
8,
198,
14993,
451,
2348,
29230,
13,
75,
76,
377,
0,
7,
41255,
32,
3712,
2782,
73,
1563,
90,
51,
11,
27,
25,
46141,
48,
20031,
6021,
48,
90,
51,
11,
50,
92,
5512,
347,
3712,
46141,
53,
721,
5574,
19044,
90,
51,
30072,
810,
1391,
51,
27,
25,
15633,
11,
311,
27,
25,
46141,
46912,
92,
796,
198,
220,
220,
220,
393,
76,
80,
81,
0,
10786,
43,
3256,
705,
51,
3256,
2560,
7,
41255,
32,
737,
22584,
669,
11,
2560,
7,
41255,
32,
737,
32830,
11,
347,
8,
198,
14993,
451,
2348,
29230,
13,
75,
76,
377,
0,
7,
41255,
32,
3712,
2782,
73,
1563,
90,
51,
11,
27,
25,
46141,
48,
20031,
6021,
48,
90,
51,
11,
50,
92,
5512,
347,
3712,
46141,
53,
721,
5574,
19044,
90,
51,
30072,
810,
1391,
51,
27,
25,
5377,
11141,
11,
311,
27,
25,
46141,
46912,
92,
796,
198,
220,
220,
220,
393,
76,
80,
81,
0,
10786,
43,
3256,
705,
34,
3256,
2560,
7,
41255,
32,
737,
22584,
669,
11,
2560,
7,
41255,
32,
737,
32830,
11,
347,
8,
198,
14993,
451,
2348,
29230,
13,
75,
76,
377,
0,
7,
2213,
32,
3712,
8291,
3455,
90,
51,
11,
27,
25,
46141,
48,
20031,
6021,
48,
90,
51,
11,
50,
92,
5512,
347,
3712,
46141,
53,
721,
5574,
19044,
90,
51,
30072,
810,
1391,
51,
27,
25,
15057,
11,
311,
27,
25,
46141,
46912,
92,
796,
198,
220,
220,
220,
393,
76,
80,
81,
0,
10786,
43,
3256,
705,
51,
3256,
2560,
7,
2213,
32,
737,
22584,
669,
11,
2560,
7,
2213,
32,
737,
32830,
11,
347,
8,
198,
198,
8818,
7308,
13,
1136,
9630,
7,
32,
3712,
46141,
48,
20031,
6021,
48,
90,
51,
11,
311,
5512,
1312,
3712,
5317,
11,
474,
3712,
5317,
8,
810,
1391,
51,
11,
311,
92,
198,
220,
220,
220,
6818,
1416,
282,
283,
7203,
46141,
48,
20031,
6021,
48,
651,
9630,
4943,
198,
220,
220,
220,
2124,
796,
29369,
5631,
13,
9107,
418,
7,
51,
11,
2546,
7,
32,
11,
362,
4008,
198,
220,
220,
220,
2124,
58,
73,
60,
796,
352,
198,
220,
220,
220,
300,
76,
377,
0,
7,
32,
11,
2124,
8,
198,
220,
220,
220,
1441,
2124,
58,
72,
60,
198,
437,
198,
198,
8818,
7308,
13,
12860,
7,
952,
3712,
9399,
11,
376,
3712,
46141,
48,
49,
8,
198,
220,
220,
220,
44872,
7,
952,
11,
17971,
7,
4906,
1659,
7,
37,
4008,
351,
5087,
1195,
290,
371,
25,
4943,
198,
220,
220,
220,
905,
7,
952,
11,
376,
13,
48,
8,
198,
220,
220,
220,
44872,
7,
952,
8,
198,
220,
220,
220,
905,
7,
952,
11,
376,
13,
49,
8,
198,
437,
198,
198,
2,
3740,
1378,
12567,
13,
785,
14,
16980,
544,
43,
648,
14,
73,
43640,
14,
31216,
14,
34256,
5774,
198,
14993,
451,
2348,
29230,
13,
15255,
7,
48,
3712,
46141,
48,
20031,
6021,
48,
90,
27,
25,
15633,
30072,
796,
318,
5088,
7,
9127,
7,
0,
271,
22570,
11,
1195,
13,
32830,
4008,
5633,
532,
16,
1058,
352,
198,
14993,
451,
2348,
29230,
13,
15255,
7,
48,
3712,
46141,
48,
20031,
6021,
48,
8,
796,
40426,
7,
32830,
4613,
318,
22570,
7,
32830,
8,
5633,
530,
7,
32830,
8,
1058,
532,
12683,
7,
32830,
8,
61,
17,
11,
1195,
13,
32830,
8,
198,
198,
8818,
44800,
2348,
29230,
13,
335,
452,
0,
28264,
80,
81,
3712,
46141,
48,
49,
11,
275,
3712,
46141,
19182,
8,
198,
220,
220,
220,
4808,
87,
796,
20390,
14824,
21413,
28264,
80,
81,
13,
49,
8,
3467,
44104,
80,
81,
13,
48,
6,
1635,
27179,
1758,
7,
65,
11,
13664,
7,
65,
828,
16,
4008,
198,
220,
220,
220,
275,
764,
28,
43030,
28264,
87,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
28264,
87,
8,
198,
220,
220,
220,
1441,
275,
198,
437,
198,
198,
8818,
44800,
2348,
29230,
13,
335,
452,
0,
7,
87,
3712,
46141,
19182,
11,
62,
80,
81,
3712,
46141,
48,
49,
11,
275,
3712,
46141,
19182,
8,
198,
220,
220,
220,
4808,
87,
796,
20390,
14824,
21413,
28264,
80,
81,
13,
49,
8,
3467,
44104,
80,
81,
13,
48,
6,
1635,
27179,
1758,
7,
65,
11,
13664,
7,
65,
828,
16,
4008,
198,
220,
220,
220,
2124,
764,
28,
43030,
28264,
87,
8,
198,
220,
220,
220,
21596,
62,
5787,
0,
28264,
87,
8,
198,
220,
220,
220,
1441,
2124,
198,
437,
198,
198,
437,
198,
198,
2235,
311,
8898,
198,
198,
397,
8709,
2099,
311,
8898,
2348,
42289,
886,
198,
7249,
42137,
2348,
42289,
1279,
25,
311,
8898,
2348,
42289,
886,
198,
7249,
12806,
72,
2348,
42289,
1279,
25,
311,
8898,
2348,
42289,
886,
198,
198,
361,
44156,
2849,
18189,
410,
1,
16,
13,
23,
21215,
198,
198,
14993,
451,
2348,
29230,
13,
82,
20306,
0,
7,
32,
3712,
46141,
46912,
90,
51,
19629,
1336,
3712,
33,
970,
28,
9562,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
435,
70,
3712,
50,
8898,
2348,
42289,
28,
28821,
13411,
2348,
42289,
28955,
810,
1391,
51,
92,
796,
198,
220,
220,
220,
4808,
82,
20306,
0,
7,
32,
11,
1336,
11,
435,
70,
8,
198,
14993,
451,
2348,
29230,
13,
82,
20306,
7,
32,
3712,
46141,
46912,
26,
1336,
28,
9562,
11,
435,
70,
3712,
50,
8898,
2348,
42289,
28,
28821,
13411,
2348,
42289,
28955,
796,
198,
220,
220,
220,
4808,
82,
20306,
0,
7,
30073,
62,
66,
549,
21921,
22468,
7,
32,
828,
1336,
11,
435,
70,
8,
198,
198,
62,
82,
20306,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
1336,
3712,
33,
970,
11,
435,
70,
3712,
50,
8898,
2348,
42289,
8,
810,
309,
796,
198,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
3118,
15999,
1988,
329,
4600,
14016,
63,
21179,
526,
4008,
198,
8818,
4808,
82,
20306,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
1336,
3712,
33,
970,
11,
435,
70,
3712,
48,
49,
2348,
42289,
8,
810,
309,
198,
220,
220,
220,
471,
11,
311,
11,
569,
83,
796,
308,
274,
20306,
0,
7,
12853,
5633,
705,
32,
6,
1058,
705,
50,
3256,
1336,
5633,
705,
32,
6,
1058,
705,
50,
3256,
317,
8,
198,
220,
220,
220,
1441,
311,
8898,
7,
52,
11,
311,
11,
569,
83,
8,
198,
437,
198,
8818,
4808,
82,
20306,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
1336,
3712,
33,
970,
11,
435,
70,
3712,
28821,
13411,
2348,
42289,
8,
810,
309,
198,
220,
220,
220,
471,
11,
311,
11,
569,
796,
308,
274,
20306,
73,
0,
10786,
53,
3256,
2558,
7,
0,
12853,
828,
317,
8,
198,
220,
220,
220,
1441,
311,
8898,
7,
52,
11,
311,
11,
569,
11537,
198,
437,
198,
198,
17772,
628,
198,
7249,
14496,
50,
8898,
90,
51,
11,
2898,
11,
32,
27,
25,
23839,
46912,
90,
51,
11709,
1279,
25,
44800,
2348,
29230,
13,
41384,
1634,
90,
51,
92,
198,
220,
220,
220,
471,
3712,
46141,
46912,
90,
51,
92,
198,
220,
220,
220,
311,
3712,
46141,
38469,
90,
2898,
92,
198,
220,
220,
220,
569,
3712,
32,
198,
437,
198,
198,
2,
24415,
329,
15256,
870,
656,
6805,
198,
14881,
13,
2676,
378,
7,
50,
3712,
46141,
50,
8898,
8,
796,
357,
50,
13,
52,
11,
3254,
7,
25,
50,
4008,
198,
14881,
13,
2676,
378,
7,
50,
3712,
46141,
50,
8898,
11,
7904,
7762,
90,
25,
50,
30072,
796,
357,
50,
13,
50,
11,
3254,
7,
25,
53,
4008,
198,
14881,
13,
2676,
378,
7,
50,
3712,
46141,
50,
8898,
11,
7904,
7762,
90,
25,
53,
30072,
796,
357,
50,
13,
53,
11,
3254,
7,
25,
28060,
4008,
198,
14881,
13,
2676,
378,
7,
50,
3712,
46141,
50,
8898,
11,
7904,
7762,
90,
25,
28060,
30072,
796,
2147,
198,
198,
31,
45145,
2163,
7308,
13,
1136,
26745,
7,
50,
3712,
46141,
50,
8898,
11,
264,
3712,
13940,
23650,
8,
198,
220,
220,
220,
611,
264,
24844,
1058,
53,
83,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
651,
3245,
7,
50,
11,
1058,
53,
33047,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
651,
3245,
7,
50,
11,
264,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
14993,
451,
2348,
29230,
13,
82,
20306,
0,
7,
32,
3712,
46141,
46912,
90,
51,
19629,
1336,
3712,
33,
970,
28,
9562,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
435,
70,
3712,
50,
8898,
2348,
42289,
28,
28821,
13411,
2348,
42289,
28955,
810,
1391,
51,
92,
796,
198,
220,
220,
220,
4808,
82,
20306,
0,
7,
32,
11,
1336,
11,
435,
70,
8,
198,
14993,
451,
2348,
29230,
13,
82,
20306,
7,
32,
3712,
46141,
46912,
26,
1336,
28,
9562,
11,
435,
70,
3712,
50,
8898,
2348,
42289,
28,
28821,
13411,
2348,
42289,
28955,
796,
198,
220,
220,
220,
4808,
82,
20306,
0,
7,
30073,
62,
66,
549,
21921,
22468,
7,
32,
828,
1336,
11,
435,
70,
8,
198,
198,
62,
82,
20306,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
1336,
3712,
33,
970,
11,
435,
70,
3712,
50,
8898,
2348,
42289,
8,
810,
309,
796,
198,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
3118,
15999,
1988,
329,
4600,
14016,
63,
21179,
526,
4008,
198,
8818,
4808,
82,
20306,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
1336,
3712,
33,
970,
11,
435,
70,
3712,
48,
49,
2348,
42289,
8,
810,
309,
198,
220,
220,
220,
471,
11,
264,
11,
569,
83,
796,
308,
274,
20306,
0,
7,
12853,
5633,
705,
32,
6,
1058,
705,
50,
3256,
1336,
5633,
705,
32,
6,
1058,
705,
50,
3256,
317,
3712,
46141,
46912,
90,
51,
30072,
198,
220,
220,
220,
1441,
14496,
50,
8898,
7,
52,
11,
264,
11,
569,
83,
11537,
198,
437,
198,
8818,
4808,
82,
20306,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
1336,
3712,
33,
970,
11,
435,
70,
3712,
28821,
13411,
2348,
42289,
8,
810,
309,
198,
220,
220,
220,
1441,
14496,
50,
8898,
7,
3212,
20306,
73,
0,
10786,
53,
3256,
2558,
7,
0,
12853,
828,
317,
3712,
46141,
46912,
90,
51,
30072,
23029,
198,
437,
198,
198,
437,
198,
198,
14993,
451,
2348,
29230,
13,
82,
20306,
12786,
0,
7,
32,
3712,
46141,
46912,
90,
51,
19629,
435,
70,
3712,
50,
8898,
2348,
42289,
28,
28821,
13411,
2348,
42289,
28955,
810,
1391,
51,
92,
796,
198,
220,
220,
220,
4808,
82,
20306,
12786,
0,
7,
32,
11,
435,
70,
8,
198,
14993,
451,
2348,
29230,
13,
82,
20306,
12786,
7,
32,
3712,
46141,
46912,
26,
435,
70,
3712,
50,
8898,
2348,
42289,
28,
28821,
13411,
2348,
42289,
28955,
796,
198,
220,
220,
220,
4808,
82,
20306,
12786,
0,
7,
30073,
62,
66,
549,
21921,
22468,
7,
32,
828,
435,
70,
8,
198,
198,
62,
82,
20306,
12786,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
435,
70,
3712,
50,
8898,
2348,
42289,
8,
810,
309,
796,
198,
220,
220,
220,
3714,
7,
28100,
1713,
12331,
7203,
3118,
15999,
1988,
329,
4600,
14016,
63,
21179,
526,
4008,
198,
62,
82,
20306,
12786,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
435,
70,
3712,
48,
49,
2348,
42289,
8,
810,
309,
796,
308,
274,
20306,
0,
10786,
45,
3256,
705,
45,
3256,
317,
3712,
46141,
46912,
90,
51,
30072,
58,
17,
60,
198,
62,
82,
20306,
12786,
0,
7,
32,
3712,
46141,
46912,
90,
51,
5512,
435,
70,
3712,
28821,
13411,
2348,
42289,
8,
810,
309,
796,
308,
274,
20306,
73,
0,
10786,
45,
3256,
352,
11,
317,
3712,
46141,
46912,
90,
51,
30072,
58,
17,
60,
198,
198,
2235,
50168,
198,
198,
361,
44156,
2849,
18189,
410,
1,
16,
13,
23,
21215,
198,
198,
8818,
44800,
2348,
29230,
13,
2290,
0,
7,
32,
3712,
13290,
1384,
46141,
46912,
90,
51,
5512,
7904,
25166,
40541,
26,
2198,
3712,
33,
970,
796,
2081,
8,
810,
1391,
51,
92,
198,
220,
220,
220,
300,
457,
796,
651,
41871,
0,
7,
32,
8,
198,
220,
220,
220,
2198,
11405,
44800,
2348,
29230,
13,
9122,
77,
684,
278,
934,
7,
75,
457,
58,
18,
12962,
198,
220,
220,
220,
1441,
50168,
7,
75,
457,
58,
16,
4357,
300,
457,
58,
17,
4357,
2558,
7,
75,
457,
58,
18,
60,
4008,
198,
437,
198,
198,
2,
11362,
12,
38532,
1895,
669,
286,
262,
50168,
26969,
9150,
6608,
198,
8818,
7308,
13,
1136,
26745,
7,
37,
3712,
41596,
90,
51,
11,
27,
25,
13290,
1384,
46141,
46912,
5512,
288,
3712,
13940,
23650,
8,
810,
309,
198,
220,
220,
220,
285,
11,
299,
796,
2546,
7,
37,
8,
198,
220,
220,
220,
611,
288,
24844,
1058,
43,
198,
220,
220,
220,
220,
220,
220,
220,
406,
796,
491,
346,
0,
7,
1136,
3245,
7,
37,
11,
1058,
22584,
669,
38381,
16,
25,
76,
11,
352,
25,
1084,
7,
76,
11,
77,
8,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
406,
58,
16,
25,
1084,
7,
76,
11,
77,
47762,
16,
25,
437,
60,
764,
28,
530,
7,
51,
8,
220,
220,
1303,
900,
262,
40039,
357,
29127,
6376,
278,
6908,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
406,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
26342,
7,
1136,
26745,
11,
309,
29291,
90,
41596,
90,
51,
11,
27,
25,
13290,
1384,
46912,
5512,
38357,
5512,
376,
11,
288,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2,
406,
2969,
8120,
338,
16767,
10720,
8379,
2476,
284,
307,
11629,
515,
4726,
3746,
986,
198,
2,
16926,
46,
25,
3785,
503,
257,
11362,
12,
38532,
835,
284,
651,
262,
9943,
7094,
17593,
198,
14993,
451,
2348,
29230,
13,
541,
452,
17,
16321,
7,
85,
3712,
46141,
38469,
90,
51,
5512,
3509,
72,
3712,
46541,
8,
810,
309,
796,
198,
220,
220,
220,
44800,
2348,
29230,
13,
541,
452,
17,
16321,
7,
19182,
7,
85,
828,
3509,
72,
8,
198,
198,
437,
198,
198,
2235,
442,
4316,
2584,
198,
198,
361,
44156,
2849,
18189,
410,
1,
16,
13,
23,
21215,
198,
220,
220,
220,
2163,
44800,
2348,
29230,
13,
354,
4316,
2584,
7,
32,
3712,
14993,
451,
2348,
29230,
13,
15633,
48523,
43094,
5377,
11141,
48523,
90,
27,
25,
15633,
11,
27,
25,
46141,
46912,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7904,
7762,
90,
9562,
92,
28,
7762,
7,
9562,
1776,
2198,
3712,
33,
970,
796,
2081,
8,
198,
220,
220,
220,
220,
220,
220,
220,
327,
11,
7508,
796,
44800,
2348,
29230,
13557,
354,
349,
0,
7,
30073,
7,
8000,
7,
32,
36911,
317,
13,
84,
489,
78,
6624,
705,
52,
6,
5633,
20390,
14824,
21413,
1058,
16048,
14824,
21413,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
609,
4316,
2584,
7,
34,
13,
7890,
11,
317,
13,
84,
489,
78,
11,
7508,
8,
198,
220,
220,
220,
886,
198,
437,
198
] | 2.123241 | 5,542 |
using Gadfly, DataArrays, RDatasets
plot(dataset("datasets", "iris"),
layer(x=:SepalLength, y=:SepalWidth, Geom.point),
layer([sin, cos], 0, 25))
| [
198,
3500,
20925,
12254,
11,
6060,
3163,
20477,
11,
371,
27354,
292,
1039,
198,
198,
29487,
7,
19608,
292,
316,
7203,
19608,
292,
1039,
1600,
366,
29616,
12340,
198,
220,
220,
220,
220,
7679,
7,
87,
28,
25,
19117,
282,
24539,
11,
331,
28,
25,
19117,
282,
30916,
11,
2269,
296,
13,
4122,
828,
198,
220,
220,
220,
220,
7679,
26933,
31369,
11,
8615,
4357,
657,
11,
1679,
4008,
198
] | 2.257143 | 70 |
## J e W e L s
function JWL(name::AbstractString)
Pkg.project(Pkg.Types.Context(),name,tempdir())
folder = joinpath(tempdir(),name)
open(joinpath(folder,"include.jl"), "w") do f
Base.write(f, """
[compat]
julia = "1.6"
""" * string(VERSION))
end
open(joinpath(folder,"include.jl"), "w") do f
Base.write(f, """
# Use this file to `import` any relevant packages*,
# and to define your own functions for use in the workbook.
# It will be `include`d when the jwl workbook is opened.
# * (don't forget to add packages to the `Project.toml` too)
""")
end
return JWL(name, folder, Workbook())
end
Base.show(io::IO, j::JWL) = Base.print(io, "JWL " * string(j.name) * " with " * string(j.wb) * " in " * dirname(j.folder)) | [
2235,
449,
304,
370,
304,
406,
264,
198,
8818,
449,
54,
43,
7,
3672,
3712,
23839,
10100,
8,
198,
220,
220,
220,
350,
10025,
13,
16302,
7,
47,
10025,
13,
31431,
13,
21947,
22784,
3672,
11,
29510,
15908,
28955,
198,
220,
220,
220,
9483,
796,
4654,
6978,
7,
29510,
15908,
22784,
3672,
8,
198,
220,
220,
220,
1280,
7,
22179,
6978,
7,
43551,
553,
17256,
13,
20362,
12340,
366,
86,
4943,
466,
277,
198,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
13564,
7,
69,
11,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
685,
5589,
265,
60,
198,
220,
220,
220,
220,
220,
220,
220,
474,
43640,
796,
366,
16,
13,
21,
1,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
1635,
4731,
7,
43717,
4008,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1280,
7,
22179,
6978,
7,
43551,
553,
17256,
13,
20362,
12340,
366,
86,
4943,
466,
277,
198,
220,
220,
220,
220,
220,
220,
220,
7308,
13,
13564,
7,
69,
11,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
5765,
428,
2393,
284,
4600,
11748,
63,
597,
5981,
10392,
25666,
220,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
290,
284,
8160,
534,
898,
5499,
329,
779,
287,
262,
670,
2070,
13,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
632,
481,
307,
4600,
17256,
63,
67,
618,
262,
474,
40989,
670,
2070,
318,
4721,
13,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
1635,
357,
9099,
470,
6044,
284,
751,
10392,
284,
262,
4600,
16775,
13,
39532,
75,
63,
1165,
8,
628,
220,
220,
220,
220,
220,
220,
220,
13538,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
449,
54,
43,
7,
3672,
11,
9483,
11,
5521,
2070,
28955,
198,
437,
198,
198,
14881,
13,
12860,
7,
952,
3712,
9399,
11,
474,
3712,
41,
54,
43,
8,
796,
7308,
13,
4798,
7,
952,
11,
366,
41,
54,
43,
366,
1635,
4731,
7,
73,
13,
3672,
8,
1635,
366,
351,
366,
1635,
4731,
7,
73,
13,
39346,
8,
1635,
366,
287,
366,
1635,
26672,
3672,
7,
73,
13,
43551,
4008
] | 2.279452 | 365 |
module Archimedes
using LinearAlgebra
using Statistics
using Unitful
using Luxor
const _current_luxor_drawing = Ref{Luxor.Drawing}()
export Point2D,
PointMass,
mass,
getx,
gety,
radius,
bbox,
centroid,
gravitycenter,
draw,
drawing,
current_drawing,
BoxShip,
corners,
labeled_point,
buoyancycenter,
toship,
isocarene,
metacenter,
setopacity,
puttext
struct Point2D
x::typeof(1.0u"m")
y::typeof(1.0u"m")
end
getx(p::Point2D) = p.x
gety(p::Point2D) = p.y
Base.:-(a::Point2D, b::Point2D) = Point2D(a.x-b.x, a.y-b.y)
Base.:+(a::Point2D, b::Point2D) = Point2D(a.x+b.x, a.y+b.y)
Base.:*(a::Point2D, b::Number) = Point2D(a.x*b, a.y*b)
Base.:*(b::Number, a::Point2D) = Point2D(a.x*b, a.y*b)
Base.:/(a::Point2D, b::Number) = Point2D(a.x/b, a.y/b)
LinearAlgebra.norm(a::Point2D) = sqrt(a.x^2 + a.y^2)
struct PointMass
coordinates::Point2D
mass::typeof(1.0u"kg")
radius::typeof(1.0u"m")
end
PointMass(x,y,m,r) = PointMass(Point2D(x,y),m,r)
coords(p::PointMass) = p.coordinates
mass(p::PointMass) = p.mass
getx(p::PointMass) = getx(coords(p))
gety(p::PointMass) = gety(coords(p))
radius(p::PointMass) = p.radius
"""
Get the bounding box (xmin, xmax, ymin, ymax) of an array of pointmasses
"""
bbox(pointmasses) = (extrema(getx.(pointmasses))..., extrema(gety.(pointmasses))...)
"""
Get the centroid of an array of pointmasses
"""
centroid(pointmasses) = Point2D(mean(getx.(pointmasses)), mean(gety.(pointmasses)))
"""
Get the center of gravity
"""
function gravitycenter(pointmasses)
m = sum(mass.(pointmasses))
x = sum(getx.(pointmasses) .* mass.(pointmasses)) / m
y = sum(gety.(pointmasses) .* mass.(pointmasses)) / m
r = sqrt(sum(radius.(pointmasses) .^ 2))
return PointMass(x, y, m, r)
end
"""
Helper to map the points with units to pixel-coordinates
"""
struct CoordMapping
origin::Point2D
scaling::typeof(1.0/(1.0u"m"))
end
function CoordMapping(width::Number, bbox::Tuple)
(xmin,xmax,ymin,ymax) = bbox
center = Point2D(mean((xmin,xmax)), mean((ymin,ymax)))
scaling = width/(xmax-xmin)
return CoordMapping(center, scaling)
end
scale(x, mapping::CoordMapping) = x*mapping.scaling
function remap(p, mapping)
(xoff, yoff) = (getx(mapping.origin), gety(mapping.origin))
return Luxor.Point(((getx(p)-xoff, -(gety(p)-yoff)).*mapping.scaling)...)
end
"""
Initialize a drawing, returing the point mapping
"""
function drawing(bbox, figwidth=300)
(xmin,xmax,ymin,ymax) = bbox
ar = (xmax-xmin)/(ymax-ymin)
figheight = Int(round(figwidth/ar))
margin = 30
bottom_padding = 40
_current_luxor_drawing[] = Drawing(figwidth+2*margin, figheight+2*margin+bottom_padding, :svg)
origin()
background("white")
return CoordMapping(figwidth, bbox)
end
function puttext(txt, p::Point2D, mapping::CoordMapping)
sethue("black")
c = remap(p,mapping)
text(txt, c, halign=:center, valign=:top)
end
"""
Draws a pointmass into the current context
"""
function draw(p::PointMass, mapping::CoordMapping; hue="black")
sethue(hue)
c = remap(p,mapping)
r = scale(radius(p), mapping)
circle(c, r, :fill)
spacing = 5.0
step = 10.0
text("x = $(getx(p))", Point(c.x,c.y+r+spacing), halign=:center, valign=:top)
text("y = $(gety(p))", Point(c.x,c.y+r+spacing+step), halign=:center, valign=:top)
text("m = $(mass(p))", Point(c.x,c.y+r+spacing+2*step), halign=:center, valign=:top)
end
function draw(p::Point2D, mapping::CoordMapping, r=5.0; hue="black", label="")
sethue(hue)
c = remap(p,mapping)
circle(c, r, :fill)
if label != ""
text(label, Point(c.x+1.2*r,c.y+1.2*r), halign=:center, valign=:top)
end
end
"""
Shows the drawing and removes the temp file
"""
function current_drawing()
finish()
return _current_luxor_drawing[]
end
struct BoxShip
width::typeof(1.0u"m")
height::typeof(1.0u"m")
draft::typeof(1.0u"m")
KG::typeof(1.0u"m")
heel::Float64
vshift::typeof(1.0u"m")
BoxShip(width, height, draft, KG, heel=0.0, vshift=0.0u"m") = new(width,height,draft,KG,heel,vshift)
end
forward_trans(p, s::BoxShip) = Point2D(cos(s.heel)*getx(p) - sin(s.heel)*gety(p), sin(s.heel)*getx(p) + cos(s.heel)*gety(p) + s.vshift)
inverse_trans(p, s::BoxShip) = Point2D(cos(s.heel)*getx(p) + sin(s.heel)*(gety(p) - s.vshift), -sin(s.heel)*getx(p) + cos(s.heel)*(gety(p) - s.vshift))
"""
Convert position p to ship coordinates
"""
toship(p, s) = inverse_trans(p, s) - Point2D(0.0u"m", s.height/2 - s.draft)
function corners(s::BoxShip)
x = s.width/2
ymax = s.height-s.draft
ymin = -s.draft
return forward_trans.(Point2D.([-x,x,x,-x], [ymin,ymin,ymax,ymax]), Ref(s))
end
function waterline(s::BoxShip)
x = 1.4*s.width/2
y = 0.0u"m"
return (Point2D(-x,y), Point2D(x,y))
end
function gravitycenter(s::BoxShip)
return forward_trans(Point2D(0.0u"m", s.KG-s.draft), s)
end
bbox(s::BoxShip) = 1.4 .* (-s.width/2, s.width/2, -s.draft, s.height-s.draft)
function wl_intersect(p1, p2)
x1 = getx(p1)
y1 = gety(p1)
x2 = getx(p2)
y2 = gety(p2)
r = (x2-x1)/(y2-y1)
return Point2D(-y1*r+x1, 0.0u"m")
end
"""
Corners of the underwater part
"""
function carene(s::BoxShip)
ship_pts = corners(s)
N = length(ship_pts)
pts_above = collect(Iterators.filter((p) -> gety(p[2]) > 0u"m", enumerate(ship_pts)))
sort!(pts_above, lt = (a,b) -> getx(a[2]) < getx(b[2]))
l1 = pts_above[1][1]
l2 = l1 % N + 1
wl_left = wl_intersect(ship_pts[l1], ship_pts[l2])
r1 = pts_above[end][1]
r2 = (r1 - 2 + N) % N + 1
wl_right = wl_intersect(ship_pts[r1], ship_pts[r2])
pts_below = collect(Iterators.filter((p) -> gety(p[2]) < 0u"m", enumerate(ship_pts)))
sort!(pts_below, lt = (a,b) -> getx(a[2]) < getx(b[2]))
return (getindex.(pts_below, 2)..., wl_right, wl_left)
end
function metacenter(s::BoxShip)
trap = carene(s)
w_wl = getx(trap[end-1]) - getx(trap[end])
F = inverse_trans(Point2D((getx(trap[end-1]) + getx(trap[end]))/2, 0.0u"m"),s)
BM = (w_wl^3 / 12)/carene_area(s)
B = inverse_trans(buoyancycenter(s),s)
nvec = F - B
Mship = B + Point2D(BM*sin(s.heel), BM*cos(s.heel))
return forward_trans(Mship, s)
end
"""
Make a 3-vector out of a Point2D
"""
vec3(p::Point2D) = [getx(p), gety(p), 0.0u"m"]
"""
Area of a triangle
"""
function area(pts)
v = vec3.(pts)
return abs(cross(v[3]-v[1], v[2]-v[1])[3])/2
end
function triangulate(pts::Union{AbstractArray{ET},NTuple{N,ET} where N}) where ET
c = centroid(pts)
triags = Array{NTuple{3,ET}}(undef,length(pts))
N = length(pts)
for i in 1:length(pts)
triags[i] = (c, pts[i], pts[i%N+1])
end
return triags
end
function buoyancycenter(s::BoxShip)
trap = carene(s)
triags = triangulate(trap)
areas = area.(triags)
centroids = centroid.(triags)
A = sum(areas)
x = sum(getx.(centroids) .* areas) / A
y = sum(gety.(centroids) .* areas) / A
return Point2D(x,y)
end
function carene_area(s::BoxShip)
trap = carene(s)
triags = triangulate(trap)
return sum(area.(triags))
end
function isocarene(s0, θ)
θ0 = s0.heel
T = s0.draft
DT_l = -T
DT_u = T
A0 = carene_area(s0)
for i in 1:50
DT = (DT_u+DT_l)/2
s1 = BoxShip(s0.width, s0.height, T, s0.KG, θ+θ0, DT)
A1 = carene_area(s1)
if abs(A1-A0)/A0 < 1e-8
return s1
end
if A1 < A0
DT_u = DT
else
DT_l = DT
end
end
error("isocarene did not converge")
end
function labeled_point(p, label, hue="black", radius=5.0)
sethue(hue)
circle(p, radius, :fill)
text(label, Point(p.x+1.2*radius,p.y+1.2*radius), halign=:center, valign=:top)
end
function draw(m::CoordMapping, s::BoxShip, transformation=((p,::BoxShip) -> p); showM=true, showB=true)
ship_pts = transformation.(corners(s),Ref(s))
p = remap.(ship_pts, Ref(m))
sethue("black")
line(p[1], p[2], :stroke)
line(p[2], p[3], :stroke)
line(p[4], p[1], :stroke)
sethue("darkgrey")
line(p[3], p[4], :stroke)
labeled_point(remap(transformation(gravitycenter(s),s),m), "G")
if showM || showB
M = remap(transformation(metacenter(s),s),m)
B = remap(transformation(buoyancycenter(s),s),m)
if showM
labeled_point(M, "M")
end
if showB
labeled_point(B, "B", "red")
end
if showM && showB
setdash("dot")
line(M, B, :stroke)
setdash("solid")
end
end
wl = remap.(transformation.(waterline(s),Ref(s)), Ref(m))
sethue("blue")
line(wl[1], wl[2], :stroke)
#trap = carene(s)
#F = remap(transformation(Point2D((getx(trap[end-1]) + getx(trap[end]))/2, 0.0u"m"),s),m)
#labeled_point(F, "F", "blue")
return m
end
function draw(s::BoxShip, figwidth=300, transformation=((p,::BoxShip) -> p); showM=true, showB=true)
draw(drawing(bbox(s), figwidth), s, transformation, showM=showM, showB=showB)
end
setopacity = Luxor.setopacity
end # module
| [
21412,
5579,
320,
37507,
198,
198,
3500,
44800,
2348,
29230,
198,
3500,
14370,
198,
198,
3500,
11801,
913,
198,
3500,
17145,
273,
198,
198,
9979,
4808,
14421,
62,
22564,
273,
62,
19334,
278,
796,
6524,
90,
43,
2821,
273,
13,
25302,
278,
92,
3419,
198,
198,
39344,
6252,
17,
35,
11,
198,
220,
220,
220,
220,
220,
220,
6252,
20273,
11,
198,
220,
220,
220,
220,
220,
220,
2347,
11,
198,
220,
220,
220,
220,
220,
220,
651,
87,
11,
198,
220,
220,
220,
220,
220,
220,
651,
88,
11,
198,
220,
220,
220,
220,
220,
220,
16874,
11,
198,
220,
220,
220,
220,
220,
220,
275,
3524,
11,
198,
220,
220,
220,
220,
220,
220,
1247,
3882,
11,
198,
220,
220,
220,
220,
220,
220,
13522,
16159,
11,
198,
220,
220,
220,
220,
220,
220,
3197,
11,
198,
220,
220,
220,
220,
220,
220,
8263,
11,
198,
220,
220,
220,
220,
220,
220,
1459,
62,
19334,
278,
11,
198,
220,
220,
220,
220,
220,
220,
8315,
25586,
11,
198,
220,
220,
220,
220,
220,
220,
14371,
11,
198,
220,
220,
220,
220,
220,
220,
15494,
62,
4122,
11,
198,
220,
220,
220,
220,
220,
220,
36675,
3883,
16159,
11,
198,
220,
220,
220,
220,
220,
220,
284,
6720,
11,
198,
220,
220,
220,
220,
220,
220,
318,
420,
533,
710,
11,
198,
220,
220,
220,
220,
220,
220,
1138,
330,
9255,
11,
198,
220,
220,
220,
220,
220,
220,
900,
404,
4355,
11,
198,
220,
220,
220,
220,
220,
220,
1234,
5239,
198,
198,
7249,
6252,
17,
35,
198,
220,
220,
220,
2124,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
76,
4943,
198,
220,
220,
220,
331,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
76,
4943,
198,
437,
198,
1136,
87,
7,
79,
3712,
12727,
17,
35,
8,
796,
279,
13,
87,
198,
1136,
88,
7,
79,
3712,
12727,
17,
35,
8,
796,
279,
13,
88,
198,
14881,
11207,
30420,
64,
3712,
12727,
17,
35,
11,
275,
3712,
12727,
17,
35,
8,
796,
6252,
17,
35,
7,
64,
13,
87,
12,
65,
13,
87,
11,
257,
13,
88,
12,
65,
13,
88,
8,
198,
14881,
11207,
33747,
64,
3712,
12727,
17,
35,
11,
275,
3712,
12727,
17,
35,
8,
796,
6252,
17,
35,
7,
64,
13,
87,
10,
65,
13,
87,
11,
257,
13,
88,
10,
65,
13,
88,
8,
198,
14881,
11207,
9,
7,
64,
3712,
12727,
17,
35,
11,
275,
3712,
15057,
8,
796,
6252,
17,
35,
7,
64,
13,
87,
9,
65,
11,
257,
13,
88,
9,
65,
8,
198,
14881,
11207,
9,
7,
65,
3712,
15057,
11,
257,
3712,
12727,
17,
35,
8,
796,
6252,
17,
35,
7,
64,
13,
87,
9,
65,
11,
257,
13,
88,
9,
65,
8,
198,
14881,
11207,
29006,
64,
3712,
12727,
17,
35,
11,
275,
3712,
15057,
8,
796,
6252,
17,
35,
7,
64,
13,
87,
14,
65,
11,
257,
13,
88,
14,
65,
8,
198,
14993,
451,
2348,
29230,
13,
27237,
7,
64,
3712,
12727,
17,
35,
8,
796,
19862,
17034,
7,
64,
13,
87,
61,
17,
1343,
257,
13,
88,
61,
17,
8,
198,
198,
7249,
6252,
20273,
198,
220,
220,
220,
22715,
3712,
12727,
17,
35,
198,
220,
220,
220,
2347,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
10025,
4943,
198,
220,
220,
220,
16874,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
76,
4943,
198,
437,
198,
12727,
20273,
7,
87,
11,
88,
11,
76,
11,
81,
8,
796,
6252,
20273,
7,
12727,
17,
35,
7,
87,
11,
88,
828,
76,
11,
81,
8,
198,
1073,
3669,
7,
79,
3712,
12727,
20273,
8,
796,
279,
13,
37652,
17540,
198,
22208,
7,
79,
3712,
12727,
20273,
8,
796,
279,
13,
22208,
198,
1136,
87,
7,
79,
3712,
12727,
20273,
8,
796,
651,
87,
7,
1073,
3669,
7,
79,
4008,
198,
1136,
88,
7,
79,
3712,
12727,
20273,
8,
796,
651,
88,
7,
1073,
3669,
7,
79,
4008,
198,
42172,
7,
79,
3712,
12727,
20273,
8,
796,
279,
13,
42172,
198,
198,
37811,
198,
3855,
262,
5421,
278,
3091,
357,
87,
1084,
11,
2124,
9806,
11,
331,
1084,
11,
331,
9806,
8,
286,
281,
7177,
286,
966,
76,
13978,
198,
37811,
198,
65,
3524,
7,
4122,
76,
13978,
8,
796,
357,
2302,
260,
2611,
7,
1136,
87,
12195,
4122,
76,
13978,
4008,
986,
11,
1070,
260,
2611,
7,
1136,
88,
12195,
4122,
76,
13978,
4008,
23029,
198,
198,
37811,
198,
3855,
262,
1247,
3882,
286,
281,
7177,
286,
966,
76,
13978,
198,
37811,
198,
1087,
3882,
7,
4122,
76,
13978,
8,
796,
6252,
17,
35,
7,
32604,
7,
1136,
87,
12195,
4122,
76,
13978,
36911,
1612,
7,
1136,
88,
12195,
4122,
76,
13978,
22305,
198,
198,
37811,
198,
3855,
262,
3641,
286,
13522,
198,
37811,
198,
8818,
13522,
16159,
7,
4122,
76,
13978,
8,
198,
220,
285,
796,
2160,
7,
22208,
12195,
4122,
76,
13978,
4008,
198,
220,
2124,
796,
2160,
7,
1136,
87,
12195,
4122,
76,
13978,
8,
764,
9,
2347,
12195,
4122,
76,
13978,
4008,
1220,
285,
198,
220,
331,
796,
2160,
7,
1136,
88,
12195,
4122,
76,
13978,
8,
764,
9,
2347,
12195,
4122,
76,
13978,
4008,
1220,
285,
198,
220,
374,
796,
19862,
17034,
7,
16345,
7,
42172,
12195,
4122,
76,
13978,
8,
764,
61,
362,
4008,
198,
220,
1441,
6252,
20273,
7,
87,
11,
331,
11,
285,
11,
374,
8,
198,
437,
198,
198,
37811,
198,
47429,
284,
3975,
262,
2173,
351,
4991,
284,
17465,
12,
37652,
17540,
198,
37811,
198,
7249,
22819,
44,
5912,
198,
220,
8159,
3712,
12727,
17,
35,
198,
220,
20796,
3712,
4906,
1659,
7,
16,
13,
15,
29006,
16,
13,
15,
84,
1,
76,
48774,
198,
437,
198,
198,
8818,
22819,
44,
5912,
7,
10394,
3712,
15057,
11,
275,
3524,
3712,
51,
29291,
8,
198,
220,
357,
87,
1084,
11,
87,
9806,
11,
88,
1084,
11,
4948,
897,
8,
796,
275,
3524,
198,
220,
3641,
796,
6252,
17,
35,
7,
32604,
19510,
87,
1084,
11,
87,
9806,
36911,
1612,
19510,
88,
1084,
11,
4948,
897,
22305,
198,
220,
20796,
796,
9647,
29006,
87,
9806,
12,
87,
1084,
8,
198,
220,
1441,
22819,
44,
5912,
7,
16159,
11,
20796,
8,
198,
437,
198,
198,
9888,
7,
87,
11,
16855,
3712,
7222,
585,
44,
5912,
8,
796,
2124,
9,
76,
5912,
13,
1416,
4272,
198,
198,
8818,
816,
499,
7,
79,
11,
16855,
8,
198,
220,
357,
87,
2364,
11,
331,
2364,
8,
796,
357,
1136,
87,
7,
76,
5912,
13,
47103,
828,
651,
88,
7,
76,
5912,
13,
47103,
4008,
198,
220,
1441,
17145,
273,
13,
12727,
19510,
7,
1136,
87,
7,
79,
13219,
87,
2364,
11,
532,
7,
1136,
88,
7,
79,
13219,
88,
2364,
29720,
9,
76,
5912,
13,
1416,
4272,
8,
23029,
198,
437,
198,
198,
37811,
198,
24243,
1096,
257,
8263,
11,
1005,
870,
262,
966,
16855,
198,
37811,
198,
8818,
8263,
7,
65,
3524,
11,
2336,
10394,
28,
6200,
8,
198,
220,
357,
87,
1084,
11,
87,
9806,
11,
88,
1084,
11,
4948,
897,
8,
796,
275,
3524,
198,
220,
610,
796,
357,
87,
9806,
12,
87,
1084,
20679,
7,
4948,
897,
12,
88,
1084,
8,
198,
220,
2336,
17015,
796,
2558,
7,
744,
7,
5647,
10394,
14,
283,
4008,
198,
220,
10330,
796,
1542,
198,
220,
4220,
62,
39231,
796,
2319,
198,
220,
4808,
14421,
62,
22564,
273,
62,
19334,
278,
21737,
796,
40027,
7,
5647,
10394,
10,
17,
9,
36153,
11,
2336,
17015,
10,
17,
9,
36153,
10,
22487,
62,
39231,
11,
1058,
21370,
70,
8,
198,
220,
8159,
3419,
198,
220,
4469,
7203,
11186,
4943,
198,
220,
1441,
22819,
44,
5912,
7,
5647,
10394,
11,
275,
3524,
8,
198,
437,
198,
198,
8818,
1234,
5239,
7,
14116,
11,
279,
3712,
12727,
17,
35,
11,
16855,
3712,
7222,
585,
44,
5912,
8,
198,
220,
900,
71,
518,
7203,
13424,
4943,
198,
220,
269,
796,
816,
499,
7,
79,
11,
76,
5912,
8,
198,
220,
2420,
7,
14116,
11,
269,
11,
10284,
570,
28,
25,
16159,
11,
1188,
570,
28,
25,
4852,
8,
198,
437,
198,
198,
37811,
198,
25302,
82,
257,
966,
22208,
656,
262,
1459,
4732,
198,
37811,
198,
8818,
3197,
7,
79,
3712,
12727,
20273,
11,
16855,
3712,
7222,
585,
44,
5912,
26,
37409,
2625,
13424,
4943,
198,
220,
900,
71,
518,
7,
71,
518,
8,
198,
220,
269,
796,
816,
499,
7,
79,
11,
76,
5912,
8,
198,
220,
374,
796,
5046,
7,
42172,
7,
79,
828,
16855,
8,
198,
220,
9197,
7,
66,
11,
374,
11,
1058,
20797,
8,
198,
220,
31050,
796,
642,
13,
15,
198,
220,
2239,
796,
838,
13,
15,
198,
220,
2420,
7203,
87,
796,
29568,
1136,
87,
7,
79,
4008,
1600,
6252,
7,
66,
13,
87,
11,
66,
13,
88,
10,
81,
10,
2777,
4092,
828,
10284,
570,
28,
25,
16159,
11,
1188,
570,
28,
25,
4852,
8,
198,
220,
2420,
7203,
88,
796,
29568,
1136,
88,
7,
79,
4008,
1600,
6252,
7,
66,
13,
87,
11,
66,
13,
88,
10,
81,
10,
2777,
4092,
10,
9662,
828,
10284,
570,
28,
25,
16159,
11,
1188,
570,
28,
25,
4852,
8,
198,
220,
2420,
7203,
76,
796,
29568,
22208,
7,
79,
4008,
1600,
6252,
7,
66,
13,
87,
11,
66,
13,
88,
10,
81,
10,
2777,
4092,
10,
17,
9,
9662,
828,
10284,
570,
28,
25,
16159,
11,
1188,
570,
28,
25,
4852,
8,
198,
437,
198,
198,
8818,
3197,
7,
79,
3712,
12727,
17,
35,
11,
16855,
3712,
7222,
585,
44,
5912,
11,
374,
28,
20,
13,
15,
26,
37409,
2625,
13424,
1600,
6167,
2625,
4943,
198,
220,
900,
71,
518,
7,
71,
518,
8,
198,
220,
269,
796,
816,
499,
7,
79,
11,
76,
5912,
8,
198,
220,
9197,
7,
66,
11,
374,
11,
1058,
20797,
8,
198,
220,
611,
6167,
14512,
13538,
198,
220,
220,
220,
2420,
7,
18242,
11,
6252,
7,
66,
13,
87,
10,
16,
13,
17,
9,
81,
11,
66,
13,
88,
10,
16,
13,
17,
9,
81,
828,
10284,
570,
28,
25,
16159,
11,
1188,
570,
28,
25,
4852,
8,
198,
220,
886,
198,
437,
198,
198,
37811,
198,
2484,
1666,
262,
8263,
290,
20694,
262,
20218,
2393,
198,
37811,
198,
8818,
1459,
62,
19334,
278,
3419,
198,
220,
5461,
3419,
198,
220,
1441,
4808,
14421,
62,
22564,
273,
62,
19334,
278,
21737,
198,
437,
198,
198,
7249,
8315,
25586,
198,
220,
9647,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
76,
4943,
198,
220,
6001,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
76,
4943,
198,
220,
4538,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
76,
4943,
198,
220,
509,
38,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
76,
4943,
198,
220,
24703,
3712,
43879,
2414,
198,
220,
410,
30846,
3712,
4906,
1659,
7,
16,
13,
15,
84,
1,
76,
4943,
628,
220,
8315,
25586,
7,
10394,
11,
6001,
11,
4538,
11,
509,
38,
11,
24703,
28,
15,
13,
15,
11,
410,
30846,
28,
15,
13,
15,
84,
1,
76,
4943,
796,
649,
7,
10394,
11,
17015,
11,
35679,
11,
42,
38,
11,
258,
417,
11,
85,
30846,
8,
198,
437,
198,
198,
11813,
62,
7645,
7,
79,
11,
264,
3712,
14253,
25586,
8,
796,
6252,
17,
35,
7,
6966,
7,
82,
13,
258,
417,
27493,
1136,
87,
7,
79,
8,
532,
7813,
7,
82,
13,
258,
417,
27493,
1136,
88,
7,
79,
828,
220,
7813,
7,
82,
13,
258,
417,
27493,
1136,
87,
7,
79,
8,
1343,
8615,
7,
82,
13,
258,
417,
27493,
1136,
88,
7,
79,
8,
1343,
264,
13,
85,
30846,
8,
198,
259,
4399,
62,
7645,
7,
79,
11,
264,
3712,
14253,
25586,
8,
796,
6252,
17,
35,
7,
6966,
7,
82,
13,
258,
417,
27493,
1136,
87,
7,
79,
8,
1343,
7813,
7,
82,
13,
258,
417,
27493,
7,
1136,
88,
7,
79,
8,
532,
264,
13,
85,
30846,
828,
532,
31369,
7,
82,
13,
258,
417,
27493,
1136,
87,
7,
79,
8,
1343,
8615,
7,
82,
13,
258,
417,
27493,
7,
1136,
88,
7,
79,
8,
532,
264,
13,
85,
30846,
4008,
198,
198,
37811,
198,
3103,
1851,
2292,
279,
284,
4074,
22715,
198,
37811,
198,
83,
418,
1056,
7,
79,
11,
264,
8,
796,
34062,
62,
7645,
7,
79,
11,
264,
8,
532,
6252,
17,
35,
7,
15,
13,
15,
84,
1,
76,
1600,
264,
13,
17015,
14,
17,
532,
264,
13,
35679,
8,
198,
198,
8818,
14371,
7,
82,
3712,
14253,
25586,
8,
198,
220,
2124,
796,
264,
13,
10394,
14,
17,
198,
220,
331,
9806,
796,
264,
13,
17015,
12,
82,
13,
35679,
198,
220,
331,
1084,
796,
532,
82,
13,
35679,
198,
220,
1441,
2651,
62,
7645,
12195,
12727,
17,
35,
12195,
58,
12,
87,
11,
87,
11,
87,
12095,
87,
4357,
685,
88,
1084,
11,
88,
1084,
11,
4948,
897,
11,
4948,
897,
46570,
6524,
7,
82,
4008,
198,
437,
198,
198,
8818,
1660,
1370,
7,
82,
3712,
14253,
25586,
8,
198,
220,
2124,
796,
352,
13,
19,
9,
82,
13,
10394,
14,
17,
198,
220,
331,
796,
657,
13,
15,
84,
1,
76,
1,
198,
220,
1441,
357,
12727,
17,
35,
32590,
87,
11,
88,
828,
6252,
17,
35,
7,
87,
11,
88,
4008,
198,
437,
198,
198,
8818,
13522,
16159,
7,
82,
3712,
14253,
25586,
8,
198,
220,
1441,
2651,
62,
7645,
7,
12727,
17,
35,
7,
15,
13,
15,
84,
1,
76,
1600,
264,
13,
42,
38,
12,
82,
13,
35679,
828,
264,
8,
198,
437,
198,
198,
65,
3524,
7,
82,
3712,
14253,
25586,
8,
796,
352,
13,
19,
764,
9,
13841,
82,
13,
10394,
14,
17,
11,
264,
13,
10394,
14,
17,
11,
532,
82,
13,
35679,
11,
264,
13,
17015,
12,
82,
13,
35679,
8,
198,
198,
8818,
266,
75,
62,
3849,
8831,
7,
79,
16,
11,
279,
17,
8,
198,
220,
2124,
16,
796,
651,
87,
7,
79,
16,
8,
198,
220,
331,
16,
796,
651,
88,
7,
79,
16,
8,
198,
220,
2124,
17,
796,
651,
87,
7,
79,
17,
8,
198,
220,
331,
17,
796,
651,
88,
7,
79,
17,
8,
198,
220,
374,
796,
357,
87,
17,
12,
87,
16,
20679,
7,
88,
17,
12,
88,
16,
8,
198,
220,
1441,
6252,
17,
35,
32590,
88,
16,
9,
81,
10,
87,
16,
11,
657,
13,
15,
84,
1,
76,
4943,
198,
437,
198,
198,
37811,
198,
41389,
364,
286,
262,
21258,
636,
198,
37811,
198,
8818,
1337,
710,
7,
82,
3712,
14253,
25586,
8,
198,
220,
4074,
62,
457,
82,
796,
14371,
7,
82,
8,
198,
220,
399,
796,
4129,
7,
6720,
62,
457,
82,
8,
198,
220,
43344,
62,
29370,
796,
2824,
7,
29993,
2024,
13,
24455,
19510,
79,
8,
4613,
651,
88,
7,
79,
58,
17,
12962,
1875,
657,
84,
1,
76,
1600,
27056,
378,
7,
6720,
62,
457,
82,
22305,
198,
220,
3297,
0,
7,
457,
82,
62,
29370,
11,
300,
83,
796,
357,
64,
11,
65,
8,
4613,
651,
87,
7,
64,
58,
17,
12962,
1279,
651,
87,
7,
65,
58,
17,
60,
4008,
198,
220,
300,
16,
796,
43344,
62,
29370,
58,
16,
7131,
16,
60,
198,
220,
300,
17,
796,
300,
16,
4064,
399,
1343,
352,
198,
220,
266,
75,
62,
9464,
796,
266,
75,
62,
3849,
8831,
7,
6720,
62,
457,
82,
58,
75,
16,
4357,
4074,
62,
457,
82,
58,
75,
17,
12962,
198,
220,
374,
16,
796,
43344,
62,
29370,
58,
437,
7131,
16,
60,
198,
220,
374,
17,
796,
357,
81,
16,
532,
362,
1343,
399,
8,
4064,
399,
1343,
352,
198,
220,
266,
75,
62,
3506,
796,
266,
75,
62,
3849,
8831,
7,
6720,
62,
457,
82,
58,
81,
16,
4357,
4074,
62,
457,
82,
58,
81,
17,
12962,
198,
220,
43344,
62,
35993,
796,
2824,
7,
29993,
2024,
13,
24455,
19510,
79,
8,
4613,
651,
88,
7,
79,
58,
17,
12962,
1279,
657,
84,
1,
76,
1600,
27056,
378,
7,
6720,
62,
457,
82,
22305,
198,
220,
3297,
0,
7,
457,
82,
62,
35993,
11,
300,
83,
796,
357,
64,
11,
65,
8,
4613,
651,
87,
7,
64,
58,
17,
12962,
1279,
651,
87,
7,
65,
58,
17,
60,
4008,
198,
220,
1441,
357,
1136,
9630,
12195,
457,
82,
62,
35993,
11,
362,
26513,
11,
266,
75,
62,
3506,
11,
266,
75,
62,
9464,
8,
198,
437,
198,
198,
8818,
1138,
330,
9255,
7,
82,
3712,
14253,
25586,
8,
198,
220,
12840,
796,
1337,
710,
7,
82,
8,
198,
220,
266,
62,
40989,
796,
651,
87,
7,
46670,
58,
437,
12,
16,
12962,
532,
651,
87,
7,
46670,
58,
437,
12962,
198,
220,
376,
796,
34062,
62,
7645,
7,
12727,
17,
35,
19510,
1136,
87,
7,
46670,
58,
437,
12,
16,
12962,
1343,
651,
87,
7,
46670,
58,
437,
60,
4008,
14,
17,
11,
657,
13,
15,
84,
1,
76,
12340,
82,
8,
198,
220,
29944,
796,
357,
86,
62,
40989,
61,
18,
1220,
1105,
20679,
6651,
710,
62,
20337,
7,
82,
8,
198,
220,
347,
796,
34062,
62,
7645,
7,
11110,
726,
3883,
16159,
7,
82,
828,
82,
8,
198,
220,
299,
35138,
796,
376,
532,
347,
198,
220,
337,
6720,
796,
347,
1343,
6252,
17,
35,
7,
12261,
9,
31369,
7,
82,
13,
258,
417,
828,
29944,
9,
6966,
7,
82,
13,
258,
417,
4008,
198,
220,
1441,
2651,
62,
7645,
7,
44,
6720,
11,
264,
8,
198,
437,
198,
198,
37811,
198,
12050,
257,
513,
12,
31364,
503,
286,
257,
6252,
17,
35,
198,
37811,
198,
35138,
18,
7,
79,
3712,
12727,
17,
35,
8,
796,
685,
1136,
87,
7,
79,
828,
651,
88,
7,
79,
828,
657,
13,
15,
84,
1,
76,
8973,
198,
198,
37811,
198,
30547,
286,
257,
22950,
198,
37811,
198,
8818,
1989,
7,
457,
82,
8,
198,
220,
410,
796,
43030,
18,
12195,
457,
82,
8,
198,
220,
1441,
2352,
7,
19692,
7,
85,
58,
18,
45297,
85,
58,
16,
4357,
410,
58,
17,
45297,
85,
58,
16,
12962,
58,
18,
12962,
14,
17,
198,
437,
198,
198,
8818,
1333,
648,
5039,
7,
457,
82,
3712,
38176,
90,
23839,
19182,
90,
2767,
5512,
11251,
29291,
90,
45,
11,
2767,
92,
810,
399,
30072,
810,
12152,
198,
220,
269,
796,
1247,
3882,
7,
457,
82,
8,
198,
220,
1333,
3775,
796,
15690,
90,
11251,
29291,
90,
18,
11,
2767,
11709,
7,
917,
891,
11,
13664,
7,
457,
82,
4008,
198,
220,
399,
796,
4129,
7,
457,
82,
8,
198,
220,
329,
1312,
287,
352,
25,
13664,
7,
457,
82,
8,
198,
220,
220,
220,
1333,
3775,
58,
72,
60,
796,
357,
66,
11,
43344,
58,
72,
4357,
43344,
58,
72,
4,
45,
10,
16,
12962,
198,
220,
886,
198,
220,
1441,
1333,
3775,
198,
437,
198,
198,
8818,
36675,
3883,
16159,
7,
82,
3712,
14253,
25586,
8,
198,
220,
12840,
796,
1337,
710,
7,
82,
8,
198,
220,
1333,
3775,
796,
1333,
648,
5039,
7,
46670,
8,
198,
220,
3006,
796,
1989,
12195,
28461,
3775,
8,
198,
220,
1247,
305,
2340,
796,
1247,
3882,
12195,
28461,
3775,
8,
198,
220,
317,
796,
2160,
7,
533,
292,
8,
198,
220,
2124,
796,
2160,
7,
1136,
87,
12195,
1087,
305,
2340,
8,
764,
9,
3006,
8,
1220,
317,
198,
220,
331,
796,
2160,
7,
1136,
88,
12195,
1087,
305,
2340,
8,
764,
9,
3006,
8,
1220,
317,
198,
220,
1441,
6252,
17,
35,
7,
87,
11,
88,
8,
198,
437,
198,
198,
8818,
1337,
710,
62,
20337,
7,
82,
3712,
14253,
25586,
8,
198,
220,
12840,
796,
1337,
710,
7,
82,
8,
198,
220,
1333,
3775,
796,
1333,
648,
5039,
7,
46670,
8,
198,
220,
1441,
2160,
7,
20337,
12195,
28461,
3775,
4008,
198,
437,
198,
198,
8818,
318,
420,
533,
710,
7,
82,
15,
11,
7377,
116,
8,
198,
220,
7377,
116,
15,
796,
264,
15,
13,
258,
417,
198,
220,
309,
796,
264,
15,
13,
35679,
198,
220,
24311,
62,
75,
796,
532,
51,
198,
220,
24311,
62,
84,
796,
309,
198,
220,
317,
15,
796,
1337,
710,
62,
20337,
7,
82,
15,
8,
198,
220,
329,
1312,
287,
352,
25,
1120,
198,
220,
220,
220,
24311,
796,
357,
24544,
62,
84,
10,
24544,
62,
75,
20679,
17,
198,
220,
220,
220,
264,
16,
796,
8315,
25586,
7,
82,
15,
13,
10394,
11,
264,
15,
13,
17015,
11,
309,
11,
264,
15,
13,
42,
38,
11,
7377,
116,
10,
138,
116,
15,
11,
24311,
8,
198,
220,
220,
220,
317,
16,
796,
1337,
710,
62,
20337,
7,
82,
16,
8,
198,
220,
220,
220,
611,
2352,
7,
32,
16,
12,
32,
15,
20679,
32,
15,
1279,
352,
68,
12,
23,
198,
220,
220,
220,
220,
220,
1441,
264,
16,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
317,
16,
1279,
317,
15,
198,
220,
220,
220,
220,
220,
24311,
62,
84,
796,
24311,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
24311,
62,
75,
796,
24311,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
4049,
7203,
271,
420,
533,
710,
750,
407,
47873,
4943,
198,
437,
198,
198,
8818,
15494,
62,
4122,
7,
79,
11,
6167,
11,
37409,
2625,
13424,
1600,
16874,
28,
20,
13,
15,
8,
198,
220,
900,
71,
518,
7,
71,
518,
8,
198,
220,
9197,
7,
79,
11,
16874,
11,
1058,
20797,
8,
198,
220,
2420,
7,
18242,
11,
6252,
7,
79,
13,
87,
10,
16,
13,
17,
9,
42172,
11,
79,
13,
88,
10,
16,
13,
17,
9,
42172,
828,
10284,
570,
28,
25,
16159,
11,
1188,
570,
28,
25,
4852,
8,
198,
437,
198,
198,
8818,
3197,
7,
76,
3712,
7222,
585,
44,
5912,
11,
264,
3712,
14253,
25586,
11,
13389,
16193,
7,
79,
11,
3712,
14253,
25586,
8,
4613,
279,
1776,
905,
44,
28,
7942,
11,
905,
33,
28,
7942,
8,
198,
220,
4074,
62,
457,
82,
796,
13389,
12195,
20772,
364,
7,
82,
828,
8134,
7,
82,
4008,
198,
220,
279,
796,
816,
499,
12195,
6720,
62,
457,
82,
11,
6524,
7,
76,
4008,
198,
220,
900,
71,
518,
7203,
13424,
4943,
198,
220,
1627,
7,
79,
58,
16,
4357,
279,
58,
17,
4357,
1058,
30757,
8,
198,
220,
1627,
7,
79,
58,
17,
4357,
279,
58,
18,
4357,
1058,
30757,
8,
198,
220,
1627,
7,
79,
58,
19,
4357,
279,
58,
16,
4357,
1058,
30757,
8,
198,
220,
900,
71,
518,
7203,
21953,
49502,
4943,
198,
220,
1627,
7,
79,
58,
18,
4357,
279,
58,
19,
4357,
1058,
30757,
8,
198,
220,
15494,
62,
4122,
7,
2787,
499,
7,
7645,
1161,
7,
46453,
16159,
7,
82,
828,
82,
828,
76,
828,
366,
38,
4943,
198,
220,
611,
905,
44,
8614,
905,
33,
198,
220,
220,
220,
337,
796,
816,
499,
7,
7645,
1161,
7,
4164,
330,
9255,
7,
82,
828,
82,
828,
76,
8,
198,
220,
220,
220,
347,
796,
816,
499,
7,
7645,
1161,
7,
11110,
726,
3883,
16159,
7,
82,
828,
82,
828,
76,
8,
198,
220,
220,
220,
611,
905,
44,
198,
220,
220,
220,
220,
220,
15494,
62,
4122,
7,
44,
11,
366,
44,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
905,
33,
198,
220,
220,
220,
220,
220,
15494,
62,
4122,
7,
33,
11,
366,
33,
1600,
366,
445,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
905,
44,
11405,
905,
33,
198,
220,
220,
220,
220,
220,
900,
42460,
7203,
26518,
4943,
198,
220,
220,
220,
220,
220,
1627,
7,
44,
11,
347,
11,
1058,
30757,
8,
198,
220,
220,
220,
220,
220,
900,
42460,
7203,
39390,
4943,
198,
220,
220,
220,
886,
198,
220,
886,
198,
220,
266,
75,
796,
816,
499,
12195,
7645,
1161,
12195,
7050,
1370,
7,
82,
828,
8134,
7,
82,
36911,
6524,
7,
76,
4008,
198,
220,
900,
71,
518,
7203,
17585,
4943,
198,
220,
1627,
7,
40989,
58,
16,
4357,
266,
75,
58,
17,
4357,
1058,
30757,
8,
198,
220,
1303,
46670,
796,
1337,
710,
7,
82,
8,
198,
220,
1303,
37,
796,
816,
499,
7,
7645,
1161,
7,
12727,
17,
35,
19510,
1136,
87,
7,
46670,
58,
437,
12,
16,
12962,
1343,
651,
87,
7,
46670,
58,
437,
60,
4008,
14,
17,
11,
657,
13,
15,
84,
1,
76,
12340,
82,
828,
76,
8,
198,
220,
1303,
18242,
276,
62,
4122,
7,
37,
11,
366,
37,
1600,
366,
17585,
4943,
198,
220,
1441,
285,
198,
437,
198,
198,
8818,
3197,
7,
82,
3712,
14253,
25586,
11,
2336,
10394,
28,
6200,
11,
13389,
16193,
7,
79,
11,
3712,
14253,
25586,
8,
4613,
279,
1776,
905,
44,
28,
7942,
11,
905,
33,
28,
7942,
8,
198,
220,
3197,
7,
19334,
278,
7,
65,
3524,
7,
82,
828,
2336,
10394,
828,
264,
11,
13389,
11,
905,
44,
28,
12860,
44,
11,
905,
33,
28,
12860,
33,
8,
198,
437,
198,
198,
2617,
404,
4355,
796,
17145,
273,
13,
2617,
404,
4355,
198,
198,
437,
1303,
8265,
198
] | 2.136837 | 4,129 |
<filename>src/DiscretisedFluidQueues.jl
module DiscretisedFluidQueues
import Jacobi, LinearAlgebra, SparseArrays, StaticArrays
import Base: *, +, size, show, getindex, setindex!, sum
# Types
export Model, DiscretisedFluidQueue, BoundedFluidQueue, Phase, PhaseSet # Queues are <:Model
export AbstractMatrixExponential, ConcentratedMatrixExponential, MatrixExponential
export Mesh, DGMesh, FRAPMesh, FVMesh # are <:Mesh
export Generator, FullGenerator, LazyGenerator # are <:Generator
export SFMDistribution, AbstractIntegrationMethod, AutoQuadrature, Quadrature, TrapezoidRule
export ExplicitRungeKuttaScheme, ForwardEuler, Heuns, StableRK3, StableRK4 # Euler, RungeKutta4 <: TimeIntegrationScheme
export Simulation
# Functions
export augment_model, membership, N₋, N₊, n_phases, phases, rates # Model methods
export cell_nodes, Δ, n_bases_per_cell, n_bases_per_phase, n_intervals, total_n_bases # Mesh methods
export interior_point_mass, left_point_mass, right_point_mass, integrate_time # SFMDistribution methods
export simulate, fixed_time, n_jumps, first_exit_x # Simulation methods
export build_lazy_generator, build_full_generator, static_generator
export cme_params, pdf, ccdf, cdf, build_me, cell_probs
export normalised_closing_operator_cdf, normalised_closing_operator_pdf
export naive_normalised_closing_operator_cdf, naive_normalised_closing_operator_pdf
export unnormalised_closing_operator_cdf, unnormalised_closing_operator_pdf
export limit, Limiter, NoLimiter, GeneralisedMUSCL
# model
include("1_SFM.jl")
include("2_abstract_mesh.jl") # things which apply to all meshes
include("2a_discretised_fluid_queue.jl")
include("3_lazy_generators.jl")
include("4_full_generators.jl")
# auxillary functions
include("6_ME_tools.jl") # used in FRAPApproximation.jl
include("7_polynomials.jl") # used in discontinuous_Galerkin.jl
include("8_discontinuous_Galerkin.jl")
include("9_finite_volume_method.jl")
include("10_FRAP_approximation.jl")
include("11_distributions.jl")
include("11c_extend_Base_operations.jl")
include("11d_limiters.jl")
include("12_time_integration.jl")
include("13_simulate.jl")
include("14_error_metrics.jl")
end
| [
27,
34345,
29,
10677,
14,
15642,
1186,
1417,
37,
2290,
312,
15681,
947,
13,
20362,
198,
21412,
8444,
1186,
1417,
37,
2290,
312,
15681,
947,
198,
198,
11748,
12806,
72,
11,
44800,
2348,
29230,
11,
1338,
17208,
3163,
20477,
11,
36125,
3163,
20477,
198,
11748,
7308,
25,
1635,
11,
1343,
11,
2546,
11,
905,
11,
651,
9630,
11,
900,
9630,
28265,
2160,
198,
198,
2,
24897,
198,
39344,
9104,
11,
8444,
1186,
1417,
37,
2290,
312,
34991,
11,
347,
6302,
37,
2290,
312,
34991,
11,
18983,
11,
18983,
7248,
1303,
4670,
947,
389,
1279,
25,
17633,
198,
39344,
27741,
46912,
16870,
35470,
11,
37613,
4111,
46912,
16870,
35470,
11,
24936,
16870,
35470,
220,
198,
39344,
47529,
11,
360,
15548,
5069,
11,
8782,
2969,
37031,
11,
376,
15996,
5069,
1303,
389,
1279,
25,
37031,
198,
39344,
35986,
11,
6462,
8645,
1352,
11,
406,
12582,
8645,
1352,
1303,
389,
1279,
25,
8645,
1352,
198,
39344,
14362,
12740,
396,
3890,
11,
27741,
34500,
1358,
17410,
11,
11160,
4507,
41909,
1300,
11,
20648,
81,
1300,
11,
4759,
46057,
1868,
31929,
198,
39344,
11884,
10987,
469,
42,
315,
8326,
27054,
1326,
11,
19530,
36,
18173,
11,
679,
13271,
11,
520,
540,
49,
42,
18,
11,
520,
540,
49,
42,
19,
1303,
412,
18173,
11,
5660,
469,
42,
315,
8326,
19,
1279,
25,
3862,
34500,
1358,
27054,
1326,
198,
39344,
41798,
198,
198,
2,
40480,
220,
198,
39344,
35016,
62,
19849,
11,
9931,
11,
399,
158,
224,
233,
11,
399,
158,
224,
232,
11,
299,
62,
746,
1386,
11,
21164,
11,
3965,
1303,
9104,
5050,
220,
198,
39344,
2685,
62,
77,
4147,
11,
37455,
11,
299,
62,
65,
1386,
62,
525,
62,
3846,
11,
299,
62,
65,
1386,
62,
525,
62,
40715,
11,
299,
62,
3849,
12786,
11,
2472,
62,
77,
62,
65,
1386,
1303,
47529,
5050,
220,
198,
39344,
11087,
62,
4122,
62,
22208,
11,
1364,
62,
4122,
62,
22208,
11,
826,
62,
4122,
62,
22208,
11,
19386,
62,
2435,
1303,
14362,
12740,
396,
3890,
5050,
198,
39344,
29308,
11,
5969,
62,
2435,
11,
299,
62,
73,
8142,
11,
717,
62,
37023,
62,
87,
1303,
41798,
5050,
198,
39344,
1382,
62,
75,
12582,
62,
8612,
1352,
11,
1382,
62,
12853,
62,
8612,
1352,
11,
9037,
62,
8612,
1352,
198,
39344,
269,
1326,
62,
37266,
11,
37124,
11,
36624,
7568,
11,
269,
7568,
11,
1382,
62,
1326,
11,
2685,
62,
1676,
1443,
198,
39344,
3487,
1417,
62,
565,
2752,
62,
46616,
62,
66,
7568,
11,
3487,
1417,
62,
565,
2752,
62,
46616,
62,
12315,
198,
39344,
24354,
62,
11265,
1417,
62,
565,
2752,
62,
46616,
62,
66,
7568,
11,
24354,
62,
11265,
1417,
62,
565,
2752,
62,
46616,
62,
12315,
220,
198,
39344,
555,
11265,
1417,
62,
565,
2752,
62,
46616,
62,
66,
7568,
11,
555,
11265,
1417,
62,
565,
2752,
62,
46616,
62,
12315,
198,
39344,
4179,
11,
7576,
2676,
11,
1400,
19352,
2676,
11,
3611,
1417,
44,
2937,
5097,
198,
198,
2,
2746,
198,
17256,
7203,
16,
62,
20802,
44,
13,
20362,
4943,
198,
198,
17256,
7203,
17,
62,
397,
8709,
62,
76,
5069,
13,
20362,
4943,
1303,
1243,
543,
4174,
284,
477,
48754,
198,
17256,
7203,
17,
64,
62,
15410,
1186,
1417,
62,
35522,
312,
62,
36560,
13,
20362,
4943,
198,
17256,
7203,
18,
62,
75,
12582,
62,
8612,
2024,
13,
20362,
4943,
198,
17256,
7203,
19,
62,
12853,
62,
8612,
2024,
13,
20362,
4943,
198,
198,
2,
27506,
15856,
5499,
198,
17256,
7203,
21,
62,
11682,
62,
31391,
13,
20362,
4943,
1303,
973,
287,
8782,
2969,
4677,
13907,
18991,
13,
20362,
198,
17256,
7203,
22,
62,
35428,
26601,
8231,
13,
20362,
4943,
1303,
973,
287,
19936,
5623,
62,
26552,
263,
5116,
13,
20362,
198,
198,
17256,
7203,
23,
62,
15410,
756,
259,
5623,
62,
26552,
263,
5116,
13,
20362,
4943,
198,
17256,
7203,
24,
62,
69,
9504,
62,
29048,
62,
24396,
13,
20362,
4943,
198,
17256,
7203,
940,
62,
10913,
2969,
62,
1324,
13907,
18991,
13,
20362,
4943,
198,
198,
17256,
7203,
1157,
62,
17080,
2455,
507,
13,
20362,
4943,
198,
17256,
7203,
1157,
66,
62,
2302,
437,
62,
14881,
62,
3575,
602,
13,
20362,
4943,
198,
17256,
7203,
1157,
67,
62,
32374,
364,
13,
20362,
4943,
198,
198,
17256,
7203,
1065,
62,
2435,
62,
18908,
1358,
13,
20362,
4943,
198,
198,
17256,
7203,
1485,
62,
14323,
5039,
13,
20362,
4943,
198,
198,
17256,
7203,
1415,
62,
18224,
62,
4164,
10466,
13,
20362,
4943,
198,
198,
437,
198
] | 2.929348 | 736 |
abstract type DisplayNoBuffer <: AbstractNumDisplay end
scan_rate(d::DisplayNoBuffer) = ceil(Int, 10^6 / d.usDelay) # Hz
size(d::DisplayNoBuffer) = length(d.digits_pins)
# update wave based on buffer
function generate_wave(d::DisplayNoBuffer)
# create new wave based on d.buffer
# number of pulses is equal to limit
pulse = PiGPIOC.gpioPulse_t[]
# set pause after each blink
inactivePeriod = ceil(Int, d.usDelay * (1 - d.intensity / 16))
gpioOffPause = 0x0
gpioOnPause = 0x0
for j in 1:d.limit
if d.digits_pins[j] >= 0
if d.inverted_digits
gpioOnPause |= 1 << d.digits_pins[j]
else
gpioOffPause |= 1 << d.digits_pins[j] # turn off all digit pins
end
end
end
# set active state
activePeriod = ceil(Int, d.usDelay * d.intensity / 16)
for i in 1:d.limit
gpioOn = 0x0
gpioOff = 0x0
# digits
for j in 1:d.limit
if d.digits_pins[j] >= 0
if xor(i == j, d.inverted_digits)
gpioOn |= 1 << d.digits_pins[j]
else
gpioOff |= 1 << d.digits_pins[j]
end
end
end
# if decode mode than 1
decode_i = (decode(d) >> (i - 1)) % 2
# sectors
buffer_i = d.buffer[i]
if decode_i == 0
value = buffer_i
else
value = NUM_TRANSLATOR[buffer_i % 0b00010000] # get 4 least significant bits
dp_state = buffer_i >> 7
value += dp_state << 7
end
for j in 1:8
if d.sectors_pins[j] >= 0
if xor(value % 2 == 1, d.inverted_sectors)
gpioOn |= 1 << d.sectors_pins[j]
else
gpioOff |= 1 << d.sectors_pins[j]
end
end
value >>= 1
end
push!(pulse, PiGPIOC.gpioPulse_t(gpioOn, gpioOff, activePeriod)) # on, off, usDelay
push!(pulse, PiGPIOC.gpioPulse_t(gpioOnPause, gpioOffPause, inactivePeriod))
end
PiGPIOC.gpioWaveAddGeneric(d.limit * 2, pulse)
wave_id = PiGPIOC.gpioWaveCreate()
if wave_id < 0
# return Upon success a wave id greater than or equal to 0 is returned,
# otherwise PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL,
# or PI_NO_WAVEFORM_ID
throw("Error in 'PiGPIOC.gpioWaveCreate()' with code: $(wave_id)")
end
return wave_id
end
"""
function update(d::DisplayNoBuffer)
Generates a sequence of pulses based on buffer, decode_mode, intensity, limit, and runs pulses repeatedly.
The function is used internally after buffer and modes changes.
If a display is in shutdown mode, the function does nothing.
"""
function update(d::DisplayNoBuffer)
# do nothing in shutdown mode
if PiGPIOC.gpioWaveTxBusy() == 1
wave_id = d.test_mode ? generate_test_wave(d) : generate_wave(d)
run_wave(wave_id)
end
end
function shutdown_mode_off(d::DisplayNoBuffer)
# do nothing in normal mode or test mode
if PiGPIOC.gpioWaveTxBusy() == 0
wave_id = d.test_mode ? generate_test_wave(d) : generate_wave(d)
run_wave(wave_id)
end
end
function shutdown_mode_on(d::DisplayNoBuffer)
# stop current wave
PiGPIOC.gpioWaveTxStop()
# clear pins
PiGPIOC.gpioWrite(d.digits_pins, 0)
PiGPIOC.gpioWrite(d.sectors_pins, 0)
end
function test_mode_off(d::DisplayNoBuffer)
# do nothing in normal mode
if d.test_mode
d.test_mode = false
update(d)
end
end
function test_mode_on(d::DisplayNoBuffer)
# do nothing in test mode
if !d.test_mode
d.test_mode = true
update(d)
end
end
function set_limit(d::DisplayNoBuffer, limit::Int = size(d))
@assert 1 <= limit <= size(d) "limit must be between 1 and $(size(d)), got $limit"
d.limit = limit
update(d)
# set empty states
pins_to_free = (d.limit+1):size(d)
PiGPIOC.gpioWrite(d.digits_pins[pins_to_free], !d.inverted_digits ? 0 : 1)
end
function set_intensity(d::DisplayNoBuffer, intensity::Int = 16)
@assert 1 <= intensity <= 16 "intensity must be between 1 and 16, got $intensity"
d.intensity = intensity
update(d)
end
"""
function write_digit(
indicator::DisplayBCD,
digit::Union{UInt8, Nothing},
position::Int
)
Writes a digit to the position. The result of the execution is changing one digit in a particular digit.
## Arguments
- `indicator` : object representing display device
- `digit` : decimal value from 0 to 9 or `nothing`. The last means an empty digit.
Values from 10 to 14 are also possible here but results to miningless symbols.
Value 15 means an empty digit and it is the same as `nothing`.
- `position` : number of digit to write starting from 1 which mean less significant digit.
The maximal value depends on available digits, so it should be `<= length(indicator.digit_pins)`
"""
function write_digit(
d::DisplayNoBuffer,
value::UInt8,
position::Int
)
@assert 1 <= position <= 8 "position must be between 1 and 8, got $position"
d.buffer[position] = value
# update only in normal mode
if !d.test_mode
update(d)
end
end
#= This can change all digits in Display
"""
function write_number(
indicator::DisplayBCD,
digit_vector::AbstractArray{D},
dp_position::Union(Int,Nothing) = nothing
) where D <: Union{UInt8, Nothing}
Writes several digits to the positions. The result of the execution is updating the whole number.
If `digit_vector` is shorter than number of digits the rest digits will be empty.
## Arguments
- `indicator` : object representing display device
- `digit_vector` : vector of decimal values from 0 to 9 or `nothing`. The same meaning as `digit` in `write_digit()`.
The first element of vector will be write to the less significant digit, etc.
- `dp_position` : position of dot in display
## Example
```
# d is 4-digit display
write_number(d, [1,2])
# the result is __321
write_number(d, [1,2,3,4])
# the result is 4321
write_number(d, [1,2,3,4,5,6])
# the result is 4321
```
"""
function write_number(
indicator::DisplayNoBuffer,
digit_vector::AbstractArray{Int}, # digit from 0 to 9
dp_position::Int
)
# TODO: check digit_vector
l = length(digit_vector)
for i in 1:length(indicator.digits_pins)
if i > l || digit_vector[i] >= 0
indicator.buffer[i] = empty_digit(indicator)
else
indicator.buffer[i] = NUM_TRANSLATOR[digit_vector[i]]
end
end
fill!(indicator.dp_buffer, 0b0)
if dp_position >= 0 && 1 <= dp_position <= length(indicator.digits_pins)
indicator.dp_buffer[dp_position] = 0b1
end
update(indicator)
end
=#
| [
397,
8709,
2099,
16531,
2949,
28632,
1279,
25,
27741,
33111,
23114,
886,
198,
198,
35836,
62,
4873,
7,
67,
3712,
23114,
2949,
28632,
8,
796,
2906,
346,
7,
5317,
11,
838,
61,
21,
1220,
288,
13,
385,
13856,
323,
8,
1303,
26109,
198,
198,
7857,
7,
67,
3712,
23114,
2949,
28632,
8,
796,
4129,
7,
67,
13,
12894,
896,
62,
49556,
8,
198,
198,
2,
4296,
6769,
1912,
319,
11876,
198,
8818,
7716,
62,
19204,
7,
67,
3712,
23114,
2949,
28632,
8,
198,
220,
220,
220,
1303,
2251,
649,
6769,
1912,
319,
288,
13,
22252,
198,
220,
220,
220,
1303,
1271,
286,
37783,
318,
4961,
284,
4179,
198,
220,
220,
220,
19445,
796,
13993,
38,
11901,
4503,
13,
31197,
952,
47,
9615,
62,
83,
21737,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1303,
900,
14985,
706,
1123,
21019,
198,
220,
220,
220,
28621,
5990,
2101,
796,
2906,
346,
7,
5317,
11,
288,
13,
385,
13856,
323,
1635,
357,
16,
532,
288,
13,
47799,
1220,
1467,
4008,
198,
220,
220,
220,
27809,
952,
9362,
49991,
796,
657,
87,
15,
198,
220,
220,
220,
27809,
952,
2202,
49991,
796,
657,
87,
15,
198,
220,
220,
220,
329,
474,
287,
352,
25,
67,
13,
32374,
198,
220,
220,
220,
220,
220,
220,
220,
611,
288,
13,
12894,
896,
62,
49556,
58,
73,
60,
18189,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
288,
13,
259,
13658,
62,
12894,
896,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27809,
952,
2202,
49991,
930,
28,
352,
9959,
288,
13,
12894,
896,
62,
49556,
58,
73,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27809,
952,
9362,
49991,
930,
28,
352,
9959,
288,
13,
12894,
896,
62,
49556,
58,
73,
60,
1303,
1210,
572,
477,
16839,
20567,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1303,
900,
4075,
1181,
198,
220,
220,
220,
4075,
5990,
2101,
796,
2906,
346,
7,
5317,
11,
288,
13,
385,
13856,
323,
1635,
288,
13,
47799,
1220,
1467,
8,
198,
220,
220,
220,
329,
1312,
287,
352,
25,
67,
13,
32374,
198,
220,
220,
220,
220,
220,
220,
220,
27809,
952,
2202,
796,
657,
87,
15,
198,
220,
220,
220,
220,
220,
220,
220,
27809,
952,
9362,
796,
657,
87,
15,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
19561,
198,
220,
220,
220,
220,
220,
220,
220,
329,
474,
287,
352,
25,
67,
13,
32374,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
288,
13,
12894,
896,
62,
49556,
58,
73,
60,
18189,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
2124,
273,
7,
72,
6624,
474,
11,
288,
13,
259,
13658,
62,
12894,
896,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27809,
952,
2202,
930,
28,
352,
9959,
288,
13,
12894,
896,
62,
49556,
58,
73,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27809,
952,
9362,
930,
28,
352,
9959,
288,
13,
12894,
896,
62,
49556,
58,
73,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
611,
36899,
4235,
621,
352,
198,
220,
220,
220,
220,
220,
220,
220,
36899,
62,
72,
796,
357,
12501,
1098,
7,
67,
8,
9609,
357,
72,
532,
352,
4008,
4064,
362,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
16020,
198,
220,
220,
220,
220,
220,
220,
220,
11876,
62,
72,
796,
288,
13,
22252,
58,
72,
60,
198,
220,
220,
220,
220,
220,
220,
220,
611,
36899,
62,
72,
6624,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1988,
796,
11876,
62,
72,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1988,
796,
36871,
62,
5446,
1565,
8634,
25633,
58,
22252,
62,
72,
4064,
657,
65,
18005,
2388,
60,
1303,
651,
604,
1551,
2383,
10340,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
288,
79,
62,
5219,
796,
11876,
62,
72,
9609,
767,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1988,
15853,
288,
79,
62,
5219,
9959,
767,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
329,
474,
287,
352,
25,
23,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
288,
13,
325,
5217,
62,
49556,
58,
73,
60,
18189,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
2124,
273,
7,
8367,
4064,
362,
6624,
352,
11,
288,
13,
259,
13658,
62,
325,
5217,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27809,
952,
2202,
930,
28,
352,
9959,
288,
13,
325,
5217,
62,
49556,
58,
73,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
27809,
952,
9362,
930,
28,
352,
9959,
288,
13,
325,
5217,
62,
49556,
58,
73,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1988,
9609,
28,
352,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
79,
9615,
11,
13993,
38,
11901,
4503,
13,
31197,
952,
47,
9615,
62,
83,
7,
31197,
952,
2202,
11,
27809,
952,
9362,
11,
4075,
5990,
2101,
4008,
1303,
319,
11,
572,
11,
514,
13856,
323,
198,
220,
220,
220,
220,
220,
220,
220,
4574,
0,
7,
79,
9615,
11,
13993,
38,
11901,
4503,
13,
31197,
952,
47,
9615,
62,
83,
7,
31197,
952,
2202,
49991,
11,
27809,
952,
9362,
49991,
11,
28621,
5990,
2101,
4008,
198,
220,
220,
220,
886,
628,
220,
220,
220,
13993,
38,
11901,
4503,
13,
31197,
952,
39709,
4550,
46189,
7,
67,
13,
32374,
1635,
362,
11,
19445,
8,
198,
220,
220,
220,
6769,
62,
312,
796,
13993,
38,
11901,
4503,
13,
31197,
952,
39709,
16447,
3419,
198,
220,
220,
220,
611,
6769,
62,
312,
1279,
657,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
1441,
14438,
1943,
257,
6769,
4686,
3744,
621,
393,
4961,
284,
657,
318,
4504,
11,
220,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
4306,
30434,
62,
39494,
9936,
62,
15543,
6089,
21389,
11,
30434,
62,
51,
6684,
62,
10725,
56,
62,
22923,
11,
30434,
62,
51,
6684,
62,
10725,
56,
62,
31559,
11,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
393,
30434,
62,
15285,
62,
15543,
6089,
21389,
62,
2389,
198,
220,
220,
220,
220,
220,
220,
220,
3714,
7203,
12331,
287,
705,
38729,
38,
11901,
4503,
13,
31197,
952,
39709,
16447,
3419,
6,
351,
2438,
25,
29568,
19204,
62,
312,
8,
4943,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
6769,
62,
312,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
2163,
4296,
7,
67,
3712,
23114,
2949,
28632,
8,
198,
198,
8645,
689,
257,
8379,
286,
37783,
1912,
319,
11876,
11,
36899,
62,
14171,
11,
12245,
11,
4179,
11,
290,
4539,
37783,
7830,
13,
198,
464,
2163,
318,
973,
20947,
706,
11876,
290,
12881,
2458,
13,
198,
1532,
257,
3359,
318,
287,
18325,
4235,
11,
262,
2163,
857,
2147,
13,
220,
198,
37811,
198,
8818,
4296,
7,
67,
3712,
23114,
2949,
28632,
8,
198,
220,
220,
220,
1303,
466,
2147,
287,
18325,
4235,
198,
220,
220,
220,
611,
13993,
38,
11901,
4503,
13,
31197,
952,
39709,
46047,
16286,
88,
3419,
6624,
352,
198,
220,
220,
220,
220,
220,
220,
220,
6769,
62,
312,
796,
288,
13,
9288,
62,
14171,
5633,
7716,
62,
9288,
62,
19204,
7,
67,
8,
1058,
7716,
62,
19204,
7,
67,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1057,
62,
19204,
7,
19204,
62,
312,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
18325,
62,
14171,
62,
2364,
7,
67,
3712,
23114,
2949,
28632,
8,
198,
220,
220,
220,
1303,
466,
2147,
287,
3487,
4235,
393,
1332,
4235,
198,
220,
220,
220,
611,
13993,
38,
11901,
4503,
13,
31197,
952,
39709,
46047,
16286,
88,
3419,
6624,
657,
198,
220,
220,
220,
220,
220,
220,
220,
6769,
62,
312,
796,
288,
13,
9288,
62,
14171,
5633,
7716,
62,
9288,
62,
19204,
7,
67,
8,
1058,
7716,
62,
19204,
7,
67,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1057,
62,
19204,
7,
19204,
62,
312,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
18325,
62,
14171,
62,
261,
7,
67,
3712,
23114,
2949,
28632,
8,
198,
220,
220,
220,
1303,
2245,
1459,
6769,
198,
220,
220,
220,
13993,
38,
11901,
4503,
13,
31197,
952,
39709,
46047,
19485,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
1303,
1598,
20567,
198,
220,
220,
220,
13993,
38,
11901,
4503,
13,
31197,
952,
16594,
7,
67,
13,
12894,
896,
62,
49556,
11,
657,
8,
198,
220,
220,
220,
13993,
38,
11901,
4503,
13,
31197,
952,
16594,
7,
67,
13,
325,
5217,
62,
49556,
11,
657,
8,
198,
437,
198,
198,
8818,
1332,
62,
14171,
62,
2364,
7,
67,
3712,
23114,
2949,
28632,
8,
198,
220,
220,
220,
1303,
466,
2147,
287,
3487,
4235,
198,
220,
220,
220,
611,
288,
13,
9288,
62,
14171,
198,
220,
220,
220,
220,
220,
220,
220,
288,
13,
9288,
62,
14171,
796,
3991,
198,
220,
220,
220,
220,
220,
220,
220,
4296,
7,
67,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
1332,
62,
14171,
62,
261,
7,
67,
3712,
23114,
2949,
28632,
8,
198,
220,
220,
220,
1303,
466,
2147,
287,
1332,
4235,
198,
220,
220,
220,
611,
5145,
67,
13,
9288,
62,
14171,
198,
220,
220,
220,
220,
220,
220,
220,
288,
13,
9288,
62,
14171,
796,
2081,
198,
220,
220,
220,
220,
220,
220,
220,
4296,
7,
67,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
8818,
900,
62,
32374,
7,
67,
3712,
23114,
2949,
28632,
11,
4179,
3712,
5317,
796,
2546,
7,
67,
4008,
198,
220,
220,
220,
2488,
30493,
352,
19841,
4179,
19841,
2546,
7,
67,
8,
366,
32374,
1276,
307,
1022,
352,
290,
29568,
7857,
7,
67,
36911,
1392,
720,
32374,
1,
198,
220,
220,
220,
288,
13,
32374,
796,
4179,
628,
220,
220,
220,
4296,
7,
67,
8,
198,
220,
220,
220,
1303,
900,
6565,
2585,
198,
220,
220,
220,
20567,
62,
1462,
62,
5787,
796,
357,
67,
13,
32374,
10,
16,
2599,
7857,
7,
67,
8,
198,
220,
220,
220,
13993,
38,
11901,
4503,
13,
31197,
952,
16594,
7,
67,
13,
12894,
896,
62,
49556,
58,
49556,
62,
1462,
62,
5787,
4357,
5145,
67,
13,
259,
13658,
62,
12894,
896,
5633,
657,
1058,
352,
8,
198,
437,
198,
198,
8818,
900,
62,
47799,
7,
67,
3712,
23114,
2949,
28632,
11,
12245,
3712,
5317,
796,
1467,
8,
198,
220,
220,
220,
2488,
30493,
352,
19841,
12245,
19841,
1467,
366,
47799,
1276,
307,
1022,
352,
290,
1467,
11,
1392,
720,
47799,
1,
198,
220,
220,
220,
288,
13,
47799,
796,
12245,
198,
220,
220,
220,
220,
198,
220,
220,
220,
4296,
7,
67,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
2163,
3551,
62,
27003,
7,
198,
220,
220,
220,
220,
220,
220,
220,
16916,
3712,
23114,
2749,
35,
11,
198,
220,
220,
220,
220,
220,
220,
220,
16839,
3712,
38176,
90,
52,
5317,
23,
11,
10528,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
2292,
3712,
5317,
198,
220,
220,
220,
1267,
198,
198,
20257,
274,
257,
16839,
284,
262,
2292,
13,
383,
1255,
286,
262,
9706,
318,
5609,
530,
16839,
287,
257,
1948,
16839,
13,
220,
198,
198,
2235,
20559,
2886,
198,
198,
12,
4600,
521,
26407,
63,
1058,
2134,
10200,
3359,
3335,
198,
198,
12,
4600,
27003,
63,
1058,
32465,
1988,
422,
657,
284,
860,
393,
4600,
22366,
44646,
383,
938,
1724,
281,
6565,
16839,
13,
198,
220,
220,
220,
220,
220,
220,
220,
27068,
422,
838,
284,
1478,
389,
635,
1744,
994,
475,
2482,
284,
9691,
1203,
14354,
13,
198,
220,
220,
220,
220,
220,
220,
220,
11052,
1315,
1724,
281,
6565,
16839,
290,
340,
318,
262,
976,
355,
4600,
22366,
44646,
198,
198,
12,
4600,
9150,
63,
1058,
1271,
286,
16839,
284,
3551,
3599,
422,
352,
543,
1612,
1342,
2383,
16839,
13,
198,
220,
220,
220,
220,
220,
220,
220,
383,
40708,
1988,
8338,
319,
1695,
19561,
11,
523,
340,
815,
307,
4600,
27,
28,
4129,
7,
521,
26407,
13,
27003,
62,
49556,
8,
63,
198,
220,
198,
37811,
198,
8818,
3551,
62,
27003,
7,
198,
220,
220,
220,
288,
3712,
23114,
2949,
28632,
11,
198,
220,
220,
220,
1988,
3712,
52,
5317,
23,
11,
198,
220,
220,
220,
2292,
3712,
5317,
198,
8,
198,
220,
220,
220,
2488,
30493,
352,
19841,
2292,
19841,
807,
366,
9150,
1276,
307,
1022,
352,
290,
807,
11,
1392,
720,
9150,
1,
198,
220,
220,
220,
288,
13,
22252,
58,
9150,
60,
796,
1988,
628,
220,
220,
220,
1303,
4296,
691,
287,
3487,
4235,
198,
220,
220,
220,
611,
5145,
67,
13,
9288,
62,
14171,
198,
220,
220,
220,
220,
220,
220,
220,
4296,
7,
67,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
2,
28,
770,
460,
1487,
477,
19561,
287,
16531,
198,
37811,
198,
220,
220,
220,
2163,
3551,
62,
17618,
7,
198,
220,
220,
220,
220,
220,
220,
220,
16916,
3712,
23114,
2749,
35,
11,
198,
220,
220,
220,
220,
220,
220,
220,
16839,
62,
31364,
3712,
23839,
19182,
90,
35,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
288,
79,
62,
9150,
3712,
38176,
7,
5317,
11,
18465,
8,
796,
2147,
198,
220,
220,
220,
1267,
810,
360,
1279,
25,
4479,
90,
52,
5317,
23,
11,
10528,
92,
198,
198,
20257,
274,
1811,
19561,
284,
262,
6116,
13,
383,
1255,
286,
262,
9706,
318,
19698,
262,
2187,
1271,
13,
198,
1532,
4600,
27003,
62,
31364,
63,
318,
12238,
621,
1271,
286,
19561,
262,
1334,
19561,
481,
307,
6565,
13,
198,
198,
2235,
20559,
2886,
198,
198,
12,
4600,
521,
26407,
63,
1058,
2134,
10200,
3359,
3335,
198,
198,
12,
4600,
27003,
62,
31364,
63,
1058,
15879,
286,
32465,
3815,
422,
657,
284,
860,
393,
4600,
22366,
44646,
383,
976,
3616,
355,
4600,
27003,
63,
287,
4600,
13564,
62,
27003,
3419,
44646,
198,
220,
220,
220,
383,
717,
5002,
286,
15879,
481,
307,
3551,
284,
262,
1342,
2383,
16839,
11,
3503,
13,
198,
198,
12,
4600,
26059,
62,
9150,
63,
1058,
2292,
286,
16605,
287,
3359,
198,
2235,
17934,
198,
198,
15506,
63,
198,
2,
288,
318,
604,
12,
27003,
3359,
198,
13564,
62,
17618,
7,
67,
11,
685,
16,
11,
17,
12962,
198,
2,
262,
1255,
318,
11593,
36453,
198,
198,
13564,
62,
17618,
7,
67,
11,
685,
16,
11,
17,
11,
18,
11,
19,
12962,
198,
2,
262,
1255,
318,
5946,
2481,
198,
198,
13564,
62,
17618,
7,
67,
11,
685,
16,
11,
17,
11,
18,
11,
19,
11,
20,
11,
21,
12962,
198,
2,
262,
1255,
318,
5946,
2481,
198,
15506,
63,
198,
37811,
198,
8818,
3551,
62,
17618,
7,
198,
220,
220,
220,
16916,
3712,
23114,
2949,
28632,
11,
198,
220,
220,
220,
16839,
62,
31364,
3712,
23839,
19182,
90,
5317,
5512,
1303,
16839,
422,
657,
284,
860,
198,
220,
220,
220,
288,
79,
62,
9150,
3712,
5317,
198,
8,
198,
220,
220,
220,
1303,
16926,
46,
25,
2198,
16839,
62,
31364,
198,
220,
220,
220,
300,
796,
4129,
7,
27003,
62,
31364,
8,
198,
220,
220,
220,
329,
1312,
287,
352,
25,
13664,
7,
521,
26407,
13,
12894,
896,
62,
49556,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1312,
1875,
300,
8614,
16839,
62,
31364,
58,
72,
60,
18189,
657,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16916,
13,
22252,
58,
72,
60,
796,
6565,
62,
27003,
7,
521,
26407,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16916,
13,
22252,
58,
72,
60,
796,
36871,
62,
5446,
1565,
8634,
25633,
58,
27003,
62,
31364,
58,
72,
11907,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
6070,
0,
7,
521,
26407,
13,
26059,
62,
22252,
11,
657,
65,
15,
8,
198,
220,
220,
220,
611,
288,
79,
62,
9150,
18189,
657,
11405,
352,
19841,
288,
79,
62,
9150,
19841,
4129,
7,
521,
26407,
13,
12894,
896,
62,
49556,
8,
198,
220,
220,
220,
220,
220,
220,
220,
16916,
13,
26059,
62,
22252,
58,
26059,
62,
9150,
60,
796,
657,
65,
16,
198,
220,
220,
220,
886,
628,
220,
220,
220,
4296,
7,
521,
26407,
8,
198,
437,
198,
46249,
198
] | 2.315984 | 2,978 |
<reponame>fstiffo/aoc-2020-julia
const Passport = Dict{String,String}
function readinput(filepath)
function parsepassport(str)
p = Passport()
ss = split(str, r"\s")
for s in ss
m = match(r"([a-z]{3}):(.+)$", s)
p[m[1]] = m[2]
end
p
end
strs = open(filepath) do file
split(strip(read(file, String)), "\n\n")
end
map(parsepassport, strs)
end
# First Half
allrqdflds(p) = length(keys(p)) == (haskey(p, "cid") ? 8 : 7) # Treat cid as optional.
passports = readinput("inputs/day04.txt")
count(allrqdflds, passports)
# Count valid passports - those that have all required fields.
# Second Half
function allvldflds(p)
# True if all required fields are both present and valid
if !allrqdflds(p)
return false
end
if !(parse(Int, p["byr"]) ∈ 1920:2002)
# byr (Birth Year) - four digits; at least 1920 and at most 2002
return false
end
if !(parse(Int, p["iyr"]) ∈ 2010:2020)
# iyr (Issue Year) - four digits; at least 2010 and at most 2020
return false
end
if !(parse(Int, p["eyr"]) ∈ 2020:2030)
# eyr (Expiration Year) - four digits; at least 2020 and at most 2030
return false
end
m = match(r"^(\d+)(cm|in)$", p["hgt"])
if isnothing(m)
# hgt (Height) - a number followed by either cm or in
return false
elseif m[2] == "cm"
if !(parse(Int, m[1]) ∈ 150:193)
# If cm, the number must be at least 150 and at most 193
return false
end
else
if !(parse(Int, m[1]) ∈ 59:76)
# If in, the number must be at least 59 and at most 76
return false
end
end
if isnothing(match(r"^#[0-9|a-f]{6}$", p["hcl"]))
# hcl (Hair Color) - a # followed by exactly six characters 0-9 or a-f
return false
end
if isnothing(match(r"^(amb|blu|brn|gry|grn|hzl|oth){1}$", p["ecl"]))
# ecl (Eye Color) - exactly one of: amb blu brn gry grn hzl oth
return false
end
if isnothing(match(r"^\d{9}$", p["pid"]))
# pid (Passport ID) - a nine-digit number, including leading zeroes
return false
end
true
end
passports = readinput("inputs/day04.txt")
count(allvldflds, passports)
# Count the number of valid passports - those that have
# all required fields and valid values
| [
27,
7856,
261,
480,
29,
69,
301,
733,
78,
14,
64,
420,
12,
42334,
12,
73,
43640,
198,
9979,
6251,
634,
796,
360,
713,
90,
10100,
11,
10100,
92,
198,
198,
8818,
1100,
15414,
7,
7753,
6978,
8,
628,
220,
220,
220,
2163,
21136,
6603,
634,
7,
2536,
8,
198,
220,
220,
220,
220,
220,
220,
220,
279,
796,
6251,
634,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
37786,
796,
6626,
7,
2536,
11,
374,
1,
59,
82,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
329,
264,
287,
37786,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
285,
796,
2872,
7,
81,
18109,
58,
64,
12,
89,
60,
90,
18,
92,
2599,
7,
13,
28988,
3,
1600,
264,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
279,
58,
76,
58,
16,
11907,
796,
285,
58,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
279,
198,
220,
220,
220,
886,
628,
220,
220,
220,
965,
82,
796,
1280,
7,
7753,
6978,
8,
466,
2393,
198,
220,
220,
220,
220,
220,
220,
220,
6626,
7,
36311,
7,
961,
7,
7753,
11,
10903,
36911,
37082,
77,
59,
77,
4943,
198,
220,
220,
220,
886,
198,
220,
220,
220,
3975,
7,
29572,
6603,
634,
11,
965,
82,
8,
198,
437,
628,
198,
2,
3274,
13139,
198,
198,
439,
81,
80,
7568,
335,
82,
7,
79,
8,
796,
4129,
7,
13083,
7,
79,
4008,
6624,
357,
10134,
2539,
7,
79,
11,
366,
66,
312,
4943,
5633,
807,
1058,
767,
8,
1303,
11217,
269,
312,
355,
11902,
13,
198,
198,
6603,
3742,
796,
1100,
15414,
7203,
15414,
82,
14,
820,
3023,
13,
14116,
4943,
198,
9127,
7,
439,
81,
80,
7568,
335,
82,
11,
33052,
8,
198,
2,
2764,
4938,
33052,
532,
883,
326,
423,
477,
2672,
7032,
13,
628,
198,
2,
5498,
13139,
198,
198,
8818,
477,
85,
335,
69,
335,
82,
7,
79,
8,
198,
220,
220,
220,
1303,
6407,
611,
477,
2672,
7032,
389,
1111,
1944,
290,
4938,
628,
220,
220,
220,
611,
5145,
439,
81,
80,
7568,
335,
82,
7,
79,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
886,
628,
220,
220,
220,
611,
5145,
7,
29572,
7,
5317,
11,
279,
14692,
1525,
81,
8973,
8,
18872,
230,
14062,
25,
16942,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
416,
81,
357,
38480,
6280,
8,
532,
1440,
19561,
26,
379,
1551,
14062,
290,
379,
749,
6244,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
5145,
7,
29572,
7,
5317,
11,
279,
14692,
72,
2417,
8973,
8,
18872,
230,
3050,
25,
42334,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
1312,
2417,
357,
45147,
6280,
8,
532,
1440,
19561,
26,
379,
1551,
3050,
290,
379,
749,
12131,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
5145,
7,
29572,
7,
5317,
11,
279,
14692,
68,
2417,
8973,
8,
18872,
230,
12131,
25,
1238,
1270,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
1926,
81,
357,
3109,
10514,
6280,
8,
532,
1440,
19561,
26,
379,
1551,
12131,
290,
379,
749,
25054,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
886,
198,
220,
220,
220,
285,
796,
2872,
7,
81,
1,
61,
38016,
67,
10,
5769,
11215,
91,
259,
8,
3,
1600,
279,
14692,
71,
13655,
8973,
8,
198,
220,
220,
220,
611,
318,
22366,
7,
76,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
289,
13655,
357,
23106,
8,
532,
257,
1271,
3940,
416,
2035,
12067,
393,
287,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
2073,
361,
285,
58,
17,
60,
6624,
366,
11215,
1,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5145,
7,
29572,
7,
5317,
11,
285,
58,
16,
12962,
18872,
230,
6640,
25,
24943,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1002,
12067,
11,
262,
1271,
1276,
307,
379,
1551,
6640,
290,
379,
749,
29691,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5145,
7,
29572,
7,
5317,
11,
285,
58,
16,
12962,
18872,
230,
7863,
25,
4304,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
1002,
287,
11,
262,
1271,
1276,
307,
379,
1551,
7863,
290,
379,
749,
8684,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
318,
22366,
7,
15699,
7,
81,
1,
61,
2,
58,
15,
12,
24,
91,
64,
12,
69,
60,
90,
21,
92,
3,
1600,
279,
14692,
71,
565,
8973,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
289,
565,
357,
39,
958,
5315,
8,
532,
257,
1303,
3940,
416,
3446,
2237,
3435,
657,
12,
24,
393,
257,
12,
69,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
318,
22366,
7,
15699,
7,
81,
1,
61,
7,
4131,
91,
65,
2290,
91,
1671,
77,
91,
70,
563,
91,
2164,
77,
91,
32179,
75,
91,
849,
19953,
16,
92,
3,
1600,
279,
14692,
68,
565,
8973,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
304,
565,
357,
24876,
5315,
8,
532,
3446,
530,
286,
25,
4915,
48208,
865,
77,
308,
563,
1036,
77,
289,
48274,
267,
400,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
886,
198,
220,
220,
220,
611,
318,
22366,
7,
15699,
7,
81,
1,
61,
59,
67,
90,
24,
92,
3,
1600,
279,
14692,
35317,
8973,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
46514,
357,
14478,
634,
4522,
8,
532,
257,
5193,
12,
27003,
1271,
11,
1390,
3756,
1976,
263,
3028,
628,
220,
220,
220,
220,
220,
220,
220,
1441,
3991,
198,
220,
220,
220,
886,
198,
220,
220,
220,
2081,
198,
437,
198,
198,
6603,
3742,
796,
1100,
15414,
7203,
15414,
82,
14,
820,
3023,
13,
14116,
4943,
198,
9127,
7,
439,
85,
335,
69,
335,
82,
11,
33052,
8,
198,
2,
2764,
262,
1271,
286,
4938,
33052,
532,
883,
326,
423,
198,
2,
477,
2672,
7032,
290,
4938,
3815,
198
] | 2.181081 | 1,110 |
<reponame>clintonTE/CCA
module Minvar
##################Dependencies####################
using Revise
if pwd() ∉ LOAD_PATH
push!(LOAD_PATH,pwd())
end
if "$(pwd())\\data" ∉ LOAD_PATH
push!(LOAD_PATH,"$(pwd())\\data")
end
using DataFrames, Distributions, GZip, ForwardDiff, Dates, LinearAlgebra, Statistics,
Measures, Formatting, StatsBase, Distributions, DataStructures, Finometrics, Distributed,
Serialization, CSV, Random, Distributed#, Gadfly, Fontconfig, Cairo NOTE: uncomment for graphs
#########################Exported functions##########
export testportfolio,
testcov,
testtrisectedportfolio,
matlab2julia,
mathematica2julia,
testω,
testposteriors,
estimateminvariance,
initializepar, #need this to set up the parallelization
cleanup
################Priors and initial vlaues############
#Priors
const D_θG = 0.16^2/20 #current vix converted to daily
const D_δ²G = .76/20*2 #reasonably diffuse prior from volatiltiy of the vix multiplied by 2
const D_αG = 1.01 #Pick a diffuse prior, but want the expectation to exist
const D_βG = 7.0e-5 / 2.0 * (D_αG - 1.0) #derive from vix of vix (See documentation)
const D_αP = D_αG
const D_βP = D_βG * 2.0 * (D_αP - 1.0) #expect this is more volatile.
const D_θSG = D_θG
const D_δ²SG = D_δ²G*2.0 #more uncertain
const D_θSGP = D_θG
const D_δ²SGP = D_δ²G*4.0 #most uncertain
#Initial Parameter Values
const D_σ²G=.001
const D_ζ²G= .004
const D_ζ²P = .009
const D_SG = .002
const D_SGP = .003
##############Other constants and methedological parameters############
#const TEX_PATH = "C:\\Users\\Clinton\\Dropbox\\Apps\\Overleaf\\Endowment Project"
#const GRAPH_PATH = TEX_PATH * "\\sub\\fig"
#const WORKING_PATH = pwd() * "\\working"
const OUT_NAME = "test"
const OUT_PATH = "output"
const N_BURN = 100
const N_SAMPLES = 100
const DATA_NAME = "sampledata"
const DATA_PATH = pwd() * "\\data"
const DATE_BEGIN = Date(2015,1,1)
const DATE_END = Date(2016,12,31)
const DATE_FORMAT = "yyyymmdd"
const MAX_WORKERS = Base.Sys.CPU_THREADS ÷ 2 # gets num of physical cores
const NUM_TEST_ASSETS = 100 #this shouldn't make a big difference in the results
const MIN_ADJUSTMENT = 0.75 #smaller values->more extreme weights allowed for test portfolio
#without this throws an error on each run if already defined
if !(@isdefined RANDOM_WEIGHT_DIST)
const RANDOM_WEIGHT_DIST = TriangularDist(-1.0,1.5,1/NUM_TEST_ASSETS)
end
#############File linkage###############################
include("code\\MinvarPar.jl")
include("code\\Universe.jl")
include("code\\Portfolio.jl")
include("code\\Parameters.jl")
include("code\\Posteriors.jl")
include("code\\TrisectedPortfolio.jl")
include("code\\X2Julia.jl")
include("code\\Estimation.jl")
include("code\\Testsandoneoffs.jl")
end
| [
27,
7856,
261,
480,
29,
37821,
9328,
14,
4093,
32,
198,
21412,
1855,
7785,
198,
14468,
2235,
35,
2690,
3976,
14468,
4242,
198,
3500,
5416,
786,
198,
198,
361,
220,
279,
16993,
3419,
18872,
231,
17579,
2885,
62,
34219,
198,
220,
4574,
0,
7,
35613,
62,
34219,
11,
79,
16993,
28955,
198,
437,
198,
198,
361,
17971,
7,
79,
16993,
28955,
6852,
7890,
1,
18872,
231,
17579,
2885,
62,
34219,
198,
220,
4574,
0,
7,
35613,
62,
34219,
553,
3,
7,
79,
16993,
28955,
6852,
7890,
4943,
198,
437,
198,
198,
3500,
6060,
35439,
11,
46567,
507,
11,
402,
41729,
11,
19530,
28813,
11,
44712,
11,
44800,
2348,
29230,
11,
14370,
11,
198,
220,
220,
45040,
11,
18980,
889,
11,
20595,
14881,
11,
46567,
507,
11,
6060,
44909,
942,
11,
4463,
908,
10466,
11,
4307,
6169,
11,
198,
220,
23283,
1634,
11,
220,
44189,
11,
14534,
11,
4307,
6169,
2,
11,
20925,
12254,
11,
24060,
11250,
11,
23732,
24550,
25,
8820,
434,
329,
28770,
628,
198,
14468,
7804,
2,
3109,
9213,
5499,
7804,
2235,
198,
39344,
1332,
634,
13652,
11,
198,
220,
1332,
66,
709,
11,
198,
220,
1332,
2213,
271,
11197,
634,
13652,
11,
198,
220,
2603,
23912,
17,
73,
43640,
11,
198,
220,
33161,
64,
17,
73,
43640,
11,
198,
220,
1332,
49535,
11,
198,
220,
1332,
79,
6197,
12706,
11,
198,
220,
3959,
265,
14857,
25641,
590,
11,
198,
220,
4238,
528,
538,
283,
11,
1303,
31227,
428,
284,
900,
510,
262,
10730,
1634,
198,
220,
27425,
198,
198,
14468,
47,
8657,
290,
4238,
410,
75,
559,
274,
7804,
4242,
198,
2,
47,
8657,
198,
9979,
360,
62,
138,
116,
38,
796,
657,
13,
1433,
61,
17,
14,
1238,
1303,
14421,
410,
844,
11513,
284,
4445,
198,
9979,
360,
62,
138,
112,
31185,
38,
796,
764,
4304,
14,
1238,
9,
17,
1303,
41181,
1346,
42864,
3161,
422,
2322,
265,
2326,
7745,
286,
262,
410,
844,
33096,
416,
362,
198,
9979,
360,
62,
17394,
38,
796,
352,
13,
486,
1303,
31686,
257,
42864,
3161,
11,
475,
765,
262,
17507,
284,
2152,
198,
9979,
360,
62,
26638,
38,
796,
767,
13,
15,
68,
12,
20,
1220,
362,
13,
15,
1635,
357,
35,
62,
17394,
38,
532,
352,
13,
15,
8,
1303,
1082,
425,
422,
410,
844,
286,
410,
844,
357,
6214,
10314,
8,
198,
9979,
360,
62,
17394,
47,
796,
360,
62,
17394,
38,
198,
9979,
360,
62,
26638,
47,
796,
360,
62,
26638,
38,
1635,
362,
13,
15,
1635,
357,
35,
62,
17394,
47,
532,
352,
13,
15,
8,
1303,
1069,
806,
428,
318,
517,
22750,
13,
198,
9979,
360,
62,
138,
116,
38475,
796,
360,
62,
138,
116,
38,
198,
9979,
360,
62,
138,
112,
31185,
38475,
796,
360,
62,
138,
112,
31185,
38,
9,
17,
13,
15,
1303,
3549,
8627,
198,
9979,
360,
62,
138,
116,
50,
16960,
796,
360,
62,
138,
116,
38,
198,
9979,
360,
62,
138,
112,
31185,
50,
16960,
796,
360,
62,
138,
112,
31185,
38,
9,
19,
13,
15,
1303,
1712,
8627,
628,
198,
2,
24243,
25139,
2357,
27068,
198,
9979,
360,
62,
38392,
31185,
38,
28,
13,
8298,
198,
9979,
360,
62,
138,
114,
31185,
38,
28,
764,
22914,
198,
9979,
360,
62,
138,
114,
31185,
47,
796,
764,
28694,
198,
9979,
360,
62,
38475,
796,
764,
21601,
198,
9979,
360,
62,
50,
16960,
796,
764,
11245,
198,
198,
7804,
4242,
2235,
6395,
38491,
290,
1138,
704,
2770,
10007,
7804,
4242,
198,
2,
9979,
309,
6369,
62,
34219,
796,
366,
34,
25,
6852,
14490,
6852,
16549,
6852,
26932,
3524,
6852,
48433,
6852,
5886,
33201,
6852,
12915,
36569,
4935,
1,
198,
2,
9979,
10863,
31300,
62,
34219,
796,
309,
6369,
62,
34219,
1635,
366,
6852,
7266,
6852,
5647,
1,
198,
2,
9979,
30936,
2751,
62,
34219,
796,
279,
16993,
3419,
1635,
366,
6852,
16090,
1,
198,
198,
9979,
16289,
62,
20608,
796,
366,
9288,
1,
198,
9979,
16289,
62,
34219,
796,
366,
22915,
1,
198,
198,
9979,
399,
62,
33,
27064,
796,
1802,
198,
9979,
399,
62,
49302,
6489,
1546,
796,
1802,
198,
198,
9979,
42865,
62,
20608,
796,
366,
37687,
10137,
1045,
1,
198,
9979,
42865,
62,
34219,
796,
279,
16993,
3419,
1635,
366,
6852,
7890,
1,
198,
198,
9979,
360,
6158,
62,
33,
43312,
796,
7536,
7,
4626,
11,
16,
11,
16,
8,
198,
9979,
360,
6158,
62,
10619,
796,
220,
7536,
7,
5304,
11,
1065,
11,
3132,
8,
198,
9979,
360,
6158,
62,
21389,
1404,
796,
366,
22556,
22556,
3020,
1860,
1,
198,
198,
9979,
25882,
62,
33249,
4877,
796,
7308,
13,
44387,
13,
36037,
62,
4221,
15675,
50,
6184,
115,
362,
1303,
3011,
997,
286,
3518,
21758,
198,
198,
9979,
36871,
62,
51,
6465,
62,
10705,
32716,
796,
1802,
1303,
5661,
6584,
470,
787,
257,
1263,
3580,
287,
262,
2482,
198,
9979,
20625,
62,
2885,
25008,
10979,
796,
657,
13,
2425,
1303,
17470,
263,
3815,
3784,
3549,
3257,
19590,
3142,
329,
1332,
15320,
198,
198,
2,
19419,
428,
12542,
281,
4049,
319,
1123,
1057,
611,
1541,
5447,
198,
361,
5145,
7,
31,
271,
23211,
46920,
2662,
62,
8845,
9947,
62,
35,
8808,
8,
198,
220,
1500,
46920,
2662,
62,
8845,
9947,
62,
35,
8808,
796,
7563,
21413,
20344,
32590,
16,
13,
15,
11,
16,
13,
20,
11,
16,
14,
41359,
62,
51,
6465,
62,
10705,
32716,
8,
198,
437,
198,
198,
7804,
4242,
2,
8979,
45945,
14468,
7804,
4242,
21017,
198,
17256,
7203,
8189,
6852,
9452,
7785,
10044,
13,
20362,
4943,
198,
17256,
7203,
8189,
6852,
3118,
3997,
13,
20362,
4943,
198,
17256,
7203,
8189,
6852,
13924,
13652,
13,
20362,
4943,
198,
17256,
7203,
8189,
6852,
48944,
13,
20362,
4943,
198,
17256,
7203,
8189,
6852,
47,
6197,
12706,
13,
20362,
4943,
198,
17256,
7203,
8189,
6852,
51,
2442,
11197,
13924,
13652,
13,
20362,
4943,
198,
17256,
7203,
8189,
6852,
55,
17,
16980,
544,
13,
20362,
4943,
198,
17256,
7203,
8189,
6852,
22362,
18991,
13,
20362,
4943,
198,
17256,
7203,
8189,
6852,
51,
3558,
392,
505,
8210,
13,
20362,
4943,
198,
437,
198
] | 2.761809 | 995 |
module Extrema_Test
using Compat
using Compat.Test
using EAGOSmoothMcCormickGrad
using IntervalArithmetic
using StaticArrays
function about(calc,val,tol)
return (val - tol <= calc <= val + tol)
end
EAGOSmoothMcCormickGrad.set_diff_relax(0)
a = seed_g(Float64,1,2)
xIBox = [Interval(-3.0,8.0)]
mBox = mid.(xIBox)
X = SMCg{2,Float64}(4.5,4.5,a,a,xIBox[1],false,xIBox,mBox)
out = min(3,X)
println("out 1: $out")
@test about(out.cc,3.0,1E-1)
@test about(out.cv,1.0909090909090908,1E-1)
@test about(out.cc_grad[1],0.0,1E-4)
@test about(out.cc_grad[2],0.0,1E-1)
@test about(out.cv_grad[1],0.545455,1E-4)
@test about(out.cv_grad[2],0.0,1E-1)
@test about(out.Intv.lo,-3,1E-4)
@test about(out.Intv.hi,8,1E-4)
a = seed_g(Float64,1,2)
xIBox = [Interval(-3.0,8.0)]
mBox = mid.(xIBox)
X = SMCg{2,Float64}(4.5,4.5,a,a,xIBox[1],false,xIBox,mBox)
out = max(5,X)
println("out 2: $out")
@test about(out.cc,7.045454545454545,1E-1)
@test about(out.cv,5.0,1E-1)
@test about(out.cc_grad[1],0.272727,1E-4)
@test about(out.cc_grad[2],0.0,1E-1)
@test about(out.cv_grad[1],0.0,1E-4)
@test about(out.cv_grad[2],0.0,1E-1)
@test about(out.Intv.lo,-3,1E-4)
@test about(out.Intv.hi,8,1E-4)
EAGOSmoothMcCormickGrad.set_diff_relax(1)
a = seed_g(Float64,1,2)
xIBox = [Interval(-3.0,8.0)]
mBox = mid.(xIBox)
X = SMCg{2,Float64}(4.5,4.5,a,a,xIBox[1],false,xIBox,mBox)
out = min(3,X)
println("out 3: $out")
@test about(out.cc,3.0,1E-1)
@test about(out.cv,1.0909090909090908,1E-1)
@test about(out.cc_grad[1],0.0,1E-4)
@test about(out.cc_grad[2],0.0,1E-1)
@test about(out.cv_grad[1],0.545455,1E-4)
@test about(out.cv_grad[2],0.0,1E-1)
@test about(out.Intv.lo,-3,1E-4)
@test about(out.Intv.hi,8,1E-4)
a = seed_g(Float64,1,2)
xIBox = [Interval(-3.0,8.0)]
mBox = mid.(xIBox)
X = SMCg{2,Float64}(4.5,4.5,a,a,xIBox[1],false,xIBox,mBox)
out = max(5,X)
println("out 4: $out")
@test about(out.cc,7.045454545454545,1E-1)
@test about(out.cv,5.0,1E-1)
@test about(out.cc_grad[1],0.272727,1E-4)
@test about(out.cc_grad[2],0.0,1E-1)
@test about(out.cv_grad[1],0.0,1E-4)
@test about(out.cv_grad[2],0.0,1E-1)
@test about(out.Intv.lo,-3,1E-4)
@test about(out.Intv.hi,8,1E-4)
end
| [
21412,
5683,
260,
2611,
62,
14402,
198,
198,
3500,
3082,
265,
198,
3500,
3082,
265,
13,
14402,
198,
3500,
412,
4760,
2640,
76,
5226,
30464,
579,
624,
42731,
198,
3500,
4225,
2100,
3163,
29848,
198,
3500,
36125,
3163,
20477,
198,
198,
8818,
546,
7,
9948,
66,
11,
2100,
11,
83,
349,
8,
198,
220,
220,
220,
1441,
357,
2100,
532,
284,
75,
19841,
42302,
19841,
1188,
1343,
284,
75,
8,
198,
437,
198,
198,
36,
4760,
2640,
76,
5226,
30464,
579,
624,
42731,
13,
2617,
62,
26069,
62,
2411,
897,
7,
15,
8,
198,
198,
64,
796,
9403,
62,
70,
7,
43879,
2414,
11,
16,
11,
17,
8,
198,
87,
9865,
1140,
796,
685,
9492,
2100,
32590,
18,
13,
15,
11,
23,
13,
15,
15437,
198,
76,
14253,
796,
3095,
12195,
87,
9865,
1140,
8,
198,
55,
796,
9447,
34,
70,
90,
17,
11,
43879,
2414,
92,
7,
19,
13,
20,
11,
19,
13,
20,
11,
64,
11,
64,
11,
87,
9865,
1140,
58,
16,
4357,
9562,
11,
87,
9865,
1140,
11,
76,
14253,
8,
198,
448,
796,
949,
7,
18,
11,
55,
8,
198,
35235,
7203,
448,
352,
25,
720,
448,
4943,
198,
31,
9288,
546,
7,
448,
13,
535,
11,
18,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
11,
16,
13,
2931,
2931,
2931,
2931,
2931,
2931,
2931,
2919,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
535,
62,
9744,
58,
16,
4357,
15,
13,
15,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
535,
62,
9744,
58,
17,
4357,
15,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
62,
9744,
58,
16,
4357,
15,
13,
45326,
30505,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
62,
9744,
58,
17,
4357,
15,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
5317,
85,
13,
5439,
12095,
18,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
5317,
85,
13,
5303,
11,
23,
11,
16,
36,
12,
19,
8,
198,
198,
64,
796,
9403,
62,
70,
7,
43879,
2414,
11,
16,
11,
17,
8,
198,
87,
9865,
1140,
796,
685,
9492,
2100,
32590,
18,
13,
15,
11,
23,
13,
15,
15437,
198,
76,
14253,
796,
3095,
12195,
87,
9865,
1140,
8,
198,
55,
796,
9447,
34,
70,
90,
17,
11,
43879,
2414,
92,
7,
19,
13,
20,
11,
19,
13,
20,
11,
64,
11,
64,
11,
87,
9865,
1140,
58,
16,
4357,
9562,
11,
87,
9865,
1140,
11,
76,
14253,
8,
198,
448,
796,
3509,
7,
20,
11,
55,
8,
198,
35235,
7203,
448,
362,
25,
720,
448,
4943,
198,
31,
9288,
546,
7,
448,
13,
535,
11,
22,
13,
40350,
2231,
2231,
2231,
2231,
2231,
2231,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
11,
20,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
535,
62,
9744,
58,
16,
4357,
15,
13,
1983,
1983,
1983,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
535,
62,
9744,
58,
17,
4357,
15,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
62,
9744,
58,
16,
4357,
15,
13,
15,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
62,
9744,
58,
17,
4357,
15,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
5317,
85,
13,
5439,
12095,
18,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
5317,
85,
13,
5303,
11,
23,
11,
16,
36,
12,
19,
8,
628,
198,
36,
4760,
2640,
76,
5226,
30464,
579,
624,
42731,
13,
2617,
62,
26069,
62,
2411,
897,
7,
16,
8,
198,
198,
64,
796,
9403,
62,
70,
7,
43879,
2414,
11,
16,
11,
17,
8,
198,
87,
9865,
1140,
796,
685,
9492,
2100,
32590,
18,
13,
15,
11,
23,
13,
15,
15437,
198,
76,
14253,
796,
3095,
12195,
87,
9865,
1140,
8,
198,
55,
796,
9447,
34,
70,
90,
17,
11,
43879,
2414,
92,
7,
19,
13,
20,
11,
19,
13,
20,
11,
64,
11,
64,
11,
87,
9865,
1140,
58,
16,
4357,
9562,
11,
87,
9865,
1140,
11,
76,
14253,
8,
198,
448,
796,
949,
7,
18,
11,
55,
8,
198,
35235,
7203,
448,
513,
25,
720,
448,
4943,
198,
31,
9288,
546,
7,
448,
13,
535,
11,
18,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
11,
16,
13,
2931,
2931,
2931,
2931,
2931,
2931,
2931,
2919,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
535,
62,
9744,
58,
16,
4357,
15,
13,
15,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
535,
62,
9744,
58,
17,
4357,
15,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
62,
9744,
58,
16,
4357,
15,
13,
45326,
30505,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
62,
9744,
58,
17,
4357,
15,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
5317,
85,
13,
5439,
12095,
18,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
5317,
85,
13,
5303,
11,
23,
11,
16,
36,
12,
19,
8,
198,
198,
64,
796,
9403,
62,
70,
7,
43879,
2414,
11,
16,
11,
17,
8,
198,
87,
9865,
1140,
796,
685,
9492,
2100,
32590,
18,
13,
15,
11,
23,
13,
15,
15437,
198,
76,
14253,
796,
3095,
12195,
87,
9865,
1140,
8,
198,
55,
796,
9447,
34,
70,
90,
17,
11,
43879,
2414,
92,
7,
19,
13,
20,
11,
19,
13,
20,
11,
64,
11,
64,
11,
87,
9865,
1140,
58,
16,
4357,
9562,
11,
87,
9865,
1140,
11,
76,
14253,
8,
198,
448,
796,
3509,
7,
20,
11,
55,
8,
198,
35235,
7203,
448,
604,
25,
720,
448,
4943,
198,
31,
9288,
546,
7,
448,
13,
535,
11,
22,
13,
40350,
2231,
2231,
2231,
2231,
2231,
2231,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
11,
20,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
535,
62,
9744,
58,
16,
4357,
15,
13,
1983,
1983,
1983,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
535,
62,
9744,
58,
17,
4357,
15,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
62,
9744,
58,
16,
4357,
15,
13,
15,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
33967,
62,
9744,
58,
17,
4357,
15,
13,
15,
11,
16,
36,
12,
16,
8,
198,
31,
9288,
546,
7,
448,
13,
5317,
85,
13,
5439,
12095,
18,
11,
16,
36,
12,
19,
8,
198,
31,
9288,
546,
7,
448,
13,
5317,
85,
13,
5303,
11,
23,
11,
16,
36,
12,
19,
8,
198,
198,
437,
198
] | 1.784641 | 1,198 |
# --------------------------------------------------------------------
# Requires
# --------------------------------------------------------------------
import .GLM
using StatsModels
using StatsBase
using Tables: columntable, istable
import StatsModels: TableRegressionModel, RegressionModel
import StatsBase: modelmatrix
const INNERMOD = Union{GLM.GeneralizedLinearModel, GLM.LinearModel}
# --------------------------------------------------------------------
# GLM Methods
# --------------------------------------------------------------------
# TODO: Find a good name for it
# invinvpseudohessian
# ....
invpseudohessian(m::TableRegressionModel{T}) where T<:INNERMOD = GLM.invchol(m.model.pp).*dispersion(m.model.rr)
invpseudohessian(m::T) where T<:INNERMOD = GLM.invchol(m.pp).*dispersion(m.rr)
chol(m::TableRegressionModel{T}) where T<:INNERMOD = chol(m.model)
chol(m::T) where T<:INNERMOD = m.pp.chol
modmatrix(m::TableRegressionModel{T}) where T<:INNERMOD = modmatrix(m.model)
modmatrix(m::T) where T<:GLM.GeneralizedLinearModel = sqrt.(m.rr.wrkwt).*modelmatrix(m)
function modmatrix(m::T) where T<:GLM.LinearModel
X = modelmatrix(m)
if !isempty(m.rr.wts)
sqrt.(m.rr.wts).*X
else
copy(X)
end
end
numobs(m::TableRegressionModel) = length(m.model.rr.y)
numobs(m::INNERMOD) = length(m.rr.y)
dof_resid(m::TableRegressionModel) = numobs(m) - length(coef(m))
dof_resid(m::INNERMOD) = numobs(m) - length(coef(m))
StatsModels.hasintercept(m::TableRegressionModel) = "(Intercept)" ∈ coefnames(m)
interceptindex(m::INNERMOD) = findfirst(map(x->allequal(x), eachcol(modmatrix(m))))
function StatsModels.hasintercept(m::INNERMOD)
hasint = findfirst(map(x->allequal(x), eachcol(modmatrix(m))))
hasint === nothing ? false : true
end
dispersion(m::TableRegressionModel{T}) where T<:GLM.GeneralizedLinearModel = dispersion(m.model.rr)
dispersion(m::TableRegressionModel{T}) where T<:GLM.LinearModel = 1
dispersion(m::GLM.GeneralizedLinearModel) = dispersion(m.rr)
dispersion(m::GLM.LinearModel) = 1
dispersion(rr::GLM.GlmResp{T1, T2, T3}) where {T1, T2, T3} = 1
dispersion(rr::GLM.LmResp) = 1
function dispersion(rr::GLM.GlmResp{T1, T2, T3}) where {T1, T2<:Union{GLM.Gamma, GLM.Bernoulli, GLM.InverseGaussian}, T3}
sum(abs2, rr.wrkwt.*rr.wrkresid)/sum(rr.wrkwt)
end
resid(m::TableRegressionModel{T}) where T<:INNERMOD = resid(m.model)
function resid(m::T) where T<:GLM.LinearModel
if !isempty(m.rr.wts)
sqrt.(m.rr.wts).*residuals(m)
else
copy(residuals(m))
end
end
function resid(m::T) where T<:GLM.GeneralizedLinearModel
sqrt.(m.rr.wrkwt).*m.rr.wrkresid
end
momentmatrix(m::TableRegressionModel{T}) where T<:INNERMOD = momentmatrix(m.model)
momentmatrix(m::INNERMOD) = (modmatrix(m).*resid(m))./dispersion(m)
# TODO: move to the interface file
# hasresiduals(m::INNERMOD) = true
# hasmodelmatrix(m::TableRegressionModel{T}) where T<:INNERMOD = true
# --------------------------------------------------------------------
# HAC GLM Methods
# --------------------------------------------------------------------
function StatsBase.vcov(k::HAC, m; prewhite=false, dof_adjustment::Bool=true, scale::Real=1)
return _vcov(k, m, prewhite, dof_adjustment, scale)
end
function _vcov(k::HAC, m, prewhite::Bool, dof_adjustment::Bool, scale::Real)
setupkernelweights!(k, m)
B = invpseudohessian(m)
mm = momentmatrix(m)
A = lrvar(k, mm; prewhite=prewhite, demean=false)
scale *= (dof_adjustment ? numobs(m)^2/dof_resid(m) : numobs(m))
V = Symmetric((B*A*B).*scale)
return V
end
vcovmatrix(
k::HAC,
m::RegressionModel,
factorization=Cholesky;
prewhite=false,
dof_adjustment::Bool=true,
scale::Real=1,
) = _vcovmatrix(k, m, prewhite, dof_adjustment, scale, factorization)
function _vcovmatrix(
k::HAC,
m::RegressionModel,
prewhite::Bool,
dof_adjustment::Bool,
scale::Real,
::Type{Cholesky},
)
V = _vcov(k, m, prewhite, dof_adjustment, scale)
return CovarianceMatrix(cholesky(V, check=true), k, V)
end
function _vcovmatrix(
k::HAC,
m::RegressionModel,
prewhite::Bool,
dof_adjustment::Bool,
scale::Real,
::Type{SVD},
)
V = _vcov(k, m, prewhite, dof_adjustment, scale)
return CovarianceMatrix(svd(V.data), k, V)
end
# --------------------------------------------------------------------
# HC GLM Methods
# --------------------------------------------------------------------
hatmatrix(m::TableRegressionModel{T}, x) where T<:INNERMOD = hatmatrix(m.model, x)
function hatmatrix(m::T, x) where T<:INNERMOD
cf = m.pp.chol.UL::UpperTriangular
rdiv!(x, cf)
return sum(x.^2, dims = 2)
end
adjfactor(k::HC0, m::RegressionModel, x) = one(first(x))
adjfactor(k::HC1, m::RegressionModel, x) = numobs(m)./dof_resid(m)
adjfactor(k::HC2, m::RegressionModel, x) = one(first(x)) ./(one(first(x)).-hatmatrix(m, x))
adjfactor(k::HC3, m::RegressionModel, x) = one(first(x))./(one(first(x)).-hatmatrix(m, x)).^2
function adjfactor(k::HC4, m::RegressionModel, x)
n, p = size(x)
tone = one(eltype(x))
h = hatmatrix(m, x)
@inbounds for j in eachindex(h)
delta = min(4, n*h[j]/p)
h[j] = tone/(tone-h[j])^delta
end
return h
end
function adjfactor(k::HC4m, m::RegressionModel, x)
n, p = size(x)
tone = one(eltype(x))
h = hatmatrix(m, x)
@inbounds for j in eachindex(h)
delta = min(tone, n*h[j]/p) + min(1.5, n*h[j]/p)
h[j] = tone/(tone-h[j])^delta
end
return h
end
function adjfactor(k::HC5, m::RegressionModel, x)
n, p = size(x)
tone = one(eltype(x))
h = hatmatrix(m, x)
mx = max(n*0.7*maximum(h)/p, 4)
@inbounds for j in eachindex(h)
alpha = min(n*h[j]/p, mx)
h[j] = tone/sqrt((tone-h[j])^alpha)
end
return h
end
adjust!(m, adj::AbstractFloat) = m
adjust!(m, adj::AbstractMatrix) = m.*sqrt.(adj)
StatsBase.vcov(k::HC, m::RegressionModel; scale::Real=1) = _vcov(k, m, scale)
function _vcov(k::HC, m::RegressionModel, scale)
B = invpseudohessian(m)
mm = momentmatrix(m)
adj = adjfactor(k, m, modmatrix(m))
mm = adjust!(mm, adj)
scale *= length(adj) > 1 ? one(first(adj)) : adj
A = mm'*mm
return Symmetric((B*A*B).*scale)
end
vcovmatrix(k::HC, m::RegressionModel, factorization=Cholesky; scale::Real=1) =
_vcovmatrix(k, m, scale, Val{:factorization})
function _vcovmatrix(k::HC, m::RegressionModel, scale::Real, ::Type{Cholesky})
V = _vcov(k, m, scale)
CovarianceMatrix(cholesky(V, check=true), k, V)
end
function _vcovmatrix(k::HC, m::RegressionModel, scale::Real, ::Type{SVD})
V = _vcov(k, m, scale)
CovarianceMatrix(svd(V), k, V)
end
# --------------------------------------------------------------------
# CRHC GLM Methods
# --------------------------------------------------------------------
function installcache(k::CRHC, m::RegressionModel)
X = modmatrix(m)
res = resid(m)
f = categorize(k.cl)
(X, res), sf = bysort((X, res), f)
ci = clustersintervals(sf)
p = size(X, 2)
cf = chol(m)
Shat = Matrix{eltype(res)}(undef,p,p)
return CRHCCache(similar(X), X, res, similar(X, (0,0)), cf, Shat, ci, sf)
end
function StatsBase.vcov(k::CRHC, m::RegressionModel; scale::Real=1)
knew = recast(k, m)
length(knew.cl) == numobs(m) || throw(ArgumentError(k, "the length of the cluster variable must be $(numobs(m))"))
cache = installcache(knew, m)
return _vcov(knew, m, cache, scale)
end
function vcovmatrix(k::CRHC, m::RegressionModel, factorization = Cholesky; scale::Real=1)
knew = recast(k, m)
cache = installcache(knew, m)
df = dofadjustment(knew, cache)
return _vcovmatrix(knew, m, cache, scale, factorization)
end
function _vcov(k::CRHC, m::RegressionModel, cache::CRHCCache, scale::Real)
B = invpseudohessian(m)
res = adjustresid!(k, cache)
cache.momentmatrix .= cache.modelmatrix.*res
df = dofadjustment(k, cache)
scale *= df
Shat = clusterize!(cache)
return Symmetric((B*Shat*B).*scale)
end
function _vcovmatrix(
k::HC,
m::RegressionModel,
cache::CRHCCache,
scale::Real,
::Type{Cholesky}
)
V = _vcov(k, m, cache, scale)
CovarianceMatrix(cholesky(V, check=true), k, V)
end
function _vcovmatrix(
k::HC,
m::RegressionModel,
cache::CRHCCache,
scale::Real,
::Type{SVD}
)
V = _vcov(k, m, cache, cache)
CovarianceMatrix(svd(V.data), k, V)
end
# -----------------------------------------------------------------------------
# CRHC GLM - Trick to use vcov(CRHC1(:cluster, df), ::GLM)
# -----------------------------------------------------------------------------
StatsBase.stderror(k::RobustVariance, m::RegressionModel; kwargs...) = sqrt.(diag(vcov(k, m; kwargs...)))
StatsBase.stderror(v::CovarianceMatrix) = sqrt.(diag(v.V))
# -----------------------------------------------------------------------------
# CRHC GLM - Trick to use vcov(CRHC1(:cluster, df), ::GLM)
# -----------------------------------------------------------------------------
recast(k::CRHC{T,D}, m::INNERMOD) where {T<:AbstractVector, D<:Nothing} = k
recast(k::CRHC{T,D}, m::TableRegressionModel) where {T<:AbstractVector, D<:Nothing} = k
reterm(k::CRHC{T,D}, m::TableRegressionModel) where {T, D} = tuple(k.cl...)
function recast(k::CRHC{T,D}, m::TableRegressionModel) where {T<:Symbol, D}
@assert istable(k.df) "`df` must be a DataFrames"
t = k.cl
if length(k.df[!, t]) == length(m.mf.data[1])
## The dimension fit
id = compress(categorical(k.df[:,t]))
return renew(k, id)
else
f = m.mf.f
frm = f.lhs ~ tuple(f.rhs.terms..., Term(t))
nt = NamedTuple{tuple(StatsModels.termvars(frm)...)}(columntable(k.df))
idx = StatsModels.missing_omit(nt)[2]
id = compress(categorical(k.df[idx,t]))
return renew(k, id)
end
# ct = columntable(clus)
# length_unique = map(x->length(unique(x)), ct)
# fg = 1:prod(length_unique)
# #cl = map(x->compress(categorical(x)), eachcol(x))
# clus[!, :clusid] .= size(clus, 2) > 1 ? zero(Int) : clus[!, tterms[1]]
# if length(tterms) > 1
# for (i,j) in enumerate(groupby(clus, [tterms...]))
# j[:, :clusid] .= fg[i]
# end
# end
# id = compress(categorical(clus[!, :clusid]))
end
# -----------------------------------------------------------------------------
# optimalbandwidth method
# -----------------------------------------------------------------------------
function optimalbandwidth(
k::HAC,
m::TableRegressionModel{F};
kwargs...
) where F<:INNERMOD
setupkernelweights!(k, m)
optimalbandwidth(k, m.model; kwargs...)
end
function optimalbandwidth(k::HAC, m::F; prewhite=false) where F<:INNERMOD
mm = momentmatrix(m)
setupkernelweights!(k, m)
mmm, D = prewhiter(mm, Val{prewhite})
return optimalbandwidth(k, mmm; prewhite=prewhite)
end
function setupkernelweights!(k, m::TableRegressionModel{T}) where T<:INNERMOD
β = coef(m)
resize!(k.weights, length(β))
"(Intercept)" ∈ coefnames(m) ? (k.weights .= 1.0; k.weights[1] = 0.0) : k.weights .= 1.0
return nothing
end
function setupkernelweights!(k, m::T) where T<:INNERMOD
cf = coef(m)
resize!(k.weights, length(cf))
fill!(k.weights, 1)
i = interceptindex(m)
i !== nothing && (k.weights[i] = 0)
return nothing
end
| [
2,
16529,
650,
198,
2,
26848,
198,
2,
16529,
650,
198,
11748,
764,
8763,
44,
198,
3500,
20595,
5841,
1424,
198,
3500,
20595,
14881,
198,
3500,
33220,
25,
951,
388,
429,
540,
11,
318,
11487,
198,
198,
11748,
20595,
5841,
1424,
25,
8655,
8081,
2234,
17633,
11,
3310,
2234,
17633,
198,
11748,
20595,
14881,
25,
2746,
6759,
8609,
198,
198,
9979,
3268,
21479,
33365,
796,
4479,
90,
8763,
44,
13,
12218,
1143,
14993,
451,
17633,
11,
10188,
44,
13,
14993,
451,
17633,
92,
198,
2,
16529,
650,
198,
2,
10188,
44,
25458,
198,
2,
16529,
650,
198,
198,
2,
16926,
46,
25,
9938,
257,
922,
1438,
329,
340,
198,
2,
800,
16340,
7752,
12003,
33979,
666,
198,
2,
19424,
198,
16340,
7752,
12003,
33979,
666,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
1268,
21479,
33365,
796,
10188,
44,
13,
16340,
354,
349,
7,
76,
13,
19849,
13,
381,
737,
9,
6381,
79,
6900,
7,
76,
13,
19849,
13,
21062,
8,
198,
16340,
7752,
12003,
33979,
666,
7,
76,
3712,
51,
8,
810,
309,
27,
25,
1268,
21479,
33365,
796,
10188,
44,
13,
16340,
354,
349,
7,
76,
13,
381,
737,
9,
6381,
79,
6900,
7,
76,
13,
21062,
8,
198,
198,
354,
349,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
1268,
21479,
33365,
796,
442,
349,
7,
76,
13,
19849,
8,
198,
354,
349,
7,
76,
3712,
51,
8,
810,
309,
27,
25,
1268,
21479,
33365,
796,
285,
13,
381,
13,
354,
349,
198,
198,
4666,
6759,
8609,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
1268,
21479,
33365,
796,
953,
6759,
8609,
7,
76,
13,
19849,
8,
198,
4666,
6759,
8609,
7,
76,
3712,
51,
8,
810,
309,
27,
25,
8763,
44,
13,
12218,
1143,
14993,
451,
17633,
796,
19862,
17034,
12195,
76,
13,
21062,
13,
18351,
46265,
83,
737,
9,
19849,
6759,
8609,
7,
76,
8,
198,
8818,
953,
6759,
8609,
7,
76,
3712,
51,
8,
810,
309,
27,
25,
8763,
44,
13,
14993,
451,
17633,
198,
220,
220,
220,
1395,
796,
2746,
6759,
8609,
7,
76,
8,
198,
220,
220,
220,
611,
5145,
271,
28920,
7,
76,
13,
21062,
13,
86,
912,
8,
198,
220,
220,
220,
220,
220,
220,
220,
19862,
17034,
12195,
76,
13,
21062,
13,
86,
912,
737,
9,
55,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
4866,
7,
55,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
22510,
8158,
7,
76,
3712,
10962,
8081,
2234,
17633,
8,
796,
4129,
7,
76,
13,
19849,
13,
21062,
13,
88,
8,
198,
22510,
8158,
7,
76,
3712,
1268,
21479,
33365,
8,
796,
4129,
7,
76,
13,
21062,
13,
88,
8,
198,
67,
1659,
62,
411,
312,
7,
76,
3712,
10962,
8081,
2234,
17633,
8,
796,
997,
8158,
7,
76,
8,
532,
4129,
7,
1073,
891,
7,
76,
4008,
198,
67,
1659,
62,
411,
312,
7,
76,
3712,
1268,
21479,
33365,
8,
796,
997,
8158,
7,
76,
8,
532,
4129,
7,
1073,
891,
7,
76,
4008,
628,
198,
29668,
5841,
1424,
13,
10134,
3849,
984,
7,
76,
3712,
10962,
8081,
2234,
17633,
8,
796,
30629,
9492,
984,
16725,
18872,
230,
763,
891,
14933,
7,
76,
8,
198,
3849,
984,
9630,
7,
76,
3712,
1268,
21479,
33365,
8,
796,
1064,
11085,
7,
8899,
7,
87,
3784,
6765,
13255,
7,
87,
828,
1123,
4033,
7,
4666,
6759,
8609,
7,
76,
35514,
198,
8818,
20595,
5841,
1424,
13,
10134,
3849,
984,
7,
76,
3712,
1268,
21479,
33365,
8,
198,
220,
220,
220,
468,
600,
796,
1064,
11085,
7,
8899,
7,
87,
3784,
6765,
13255,
7,
87,
828,
1123,
4033,
7,
4666,
6759,
8609,
7,
76,
35514,
198,
220,
220,
220,
468,
600,
24844,
2147,
5633,
3991,
1058,
2081,
198,
437,
198,
198,
6381,
79,
6900,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
8763,
44,
13,
12218,
1143,
14993,
451,
17633,
796,
4596,
6900,
7,
76,
13,
19849,
13,
21062,
8,
198,
6381,
79,
6900,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
8763,
44,
13,
14993,
451,
17633,
796,
352,
198,
6381,
79,
6900,
7,
76,
3712,
8763,
44,
13,
12218,
1143,
14993,
451,
17633,
8,
796,
4596,
6900,
7,
76,
13,
21062,
8,
198,
6381,
79,
6900,
7,
76,
3712,
8763,
44,
13,
14993,
451,
17633,
8,
796,
352,
198,
6381,
79,
6900,
7,
21062,
3712,
8763,
44,
13,
9861,
76,
19309,
90,
51,
16,
11,
309,
17,
11,
309,
18,
30072,
810,
1391,
51,
16,
11,
309,
17,
11,
309,
18,
92,
796,
352,
198,
6381,
79,
6900,
7,
21062,
3712,
8763,
44,
13,
43,
76,
19309,
8,
796,
352,
198,
8818,
4596,
6900,
7,
21062,
3712,
8763,
44,
13,
9861,
76,
19309,
90,
51,
16,
11,
309,
17,
11,
309,
18,
30072,
810,
1391,
51,
16,
11,
309,
17,
27,
25,
38176,
90,
8763,
44,
13,
34777,
2611,
11,
10188,
44,
13,
23927,
280,
15516,
11,
10188,
44,
13,
818,
4399,
35389,
31562,
5512,
309,
18,
92,
198,
220,
220,
220,
2160,
7,
8937,
17,
11,
374,
81,
13,
18351,
46265,
83,
15885,
21062,
13,
18351,
74,
411,
312,
20679,
16345,
7,
21062,
13,
18351,
46265,
83,
8,
198,
437,
198,
198,
411,
312,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
1268,
21479,
33365,
796,
15384,
7,
76,
13,
19849,
8,
198,
8818,
15384,
7,
76,
3712,
51,
8,
810,
309,
27,
25,
8763,
44,
13,
14993,
451,
17633,
198,
220,
220,
220,
611,
5145,
271,
28920,
7,
76,
13,
21062,
13,
86,
912,
8,
198,
220,
220,
220,
220,
220,
220,
220,
19862,
17034,
12195,
76,
13,
21062,
13,
86,
912,
737,
9,
411,
312,
723,
82,
7,
76,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
4866,
7,
411,
312,
723,
82,
7,
76,
4008,
198,
220,
220,
220,
886,
198,
437,
198,
8818,
15384,
7,
76,
3712,
51,
8,
810,
309,
27,
25,
8763,
44,
13,
12218,
1143,
14993,
451,
17633,
198,
220,
220,
220,
19862,
17034,
12195,
76,
13,
21062,
13,
18351,
46265,
83,
737,
9,
76,
13,
21062,
13,
18351,
74,
411,
312,
198,
437,
198,
198,
32542,
298,
6759,
8609,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
1268,
21479,
33365,
796,
2589,
6759,
8609,
7,
76,
13,
19849,
8,
198,
32542,
298,
6759,
8609,
7,
76,
3712,
1268,
21479,
33365,
8,
796,
357,
4666,
6759,
8609,
7,
76,
737,
9,
411,
312,
7,
76,
29720,
14,
6381,
79,
6900,
7,
76,
8,
198,
198,
2,
16926,
46,
25,
1445,
284,
262,
7071,
2393,
198,
2,
468,
411,
312,
723,
82,
7,
76,
3712,
1268,
21479,
33365,
8,
796,
2081,
198,
2,
468,
19849,
6759,
8609,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
1268,
21479,
33365,
796,
2081,
198,
198,
2,
16529,
650,
198,
2,
367,
2246,
10188,
44,
25458,
198,
2,
16529,
650,
198,
8818,
20595,
14881,
13,
28435,
709,
7,
74,
3712,
39,
2246,
11,
285,
26,
662,
11186,
28,
9562,
11,
466,
69,
62,
23032,
434,
3712,
33,
970,
28,
7942,
11,
5046,
3712,
15633,
28,
16,
8,
198,
220,
220,
220,
1441,
4808,
28435,
709,
7,
74,
11,
285,
11,
662,
11186,
11,
466,
69,
62,
23032,
434,
11,
5046,
8,
198,
437,
198,
198,
8818,
4808,
28435,
709,
7,
74,
3712,
39,
2246,
11,
285,
11,
662,
11186,
3712,
33,
970,
11,
466,
69,
62,
23032,
434,
3712,
33,
970,
11,
5046,
3712,
15633,
8,
198,
220,
220,
220,
9058,
33885,
43775,
0,
7,
74,
11,
285,
8,
198,
220,
220,
220,
347,
220,
796,
800,
7752,
12003,
33979,
666,
7,
76,
8,
198,
220,
220,
220,
8085,
796,
2589,
6759,
8609,
7,
76,
8,
198,
220,
220,
220,
317,
796,
300,
81,
7785,
7,
74,
11,
8085,
26,
662,
11186,
28,
79,
1809,
71,
578,
11,
1357,
11025,
28,
9562,
8,
198,
220,
220,
220,
5046,
1635,
28,
357,
67,
1659,
62,
23032,
434,
5633,
997,
8158,
7,
76,
8,
61,
17,
14,
67,
1659,
62,
411,
312,
7,
76,
8,
1058,
997,
8158,
7,
76,
4008,
198,
220,
220,
220,
569,
796,
1632,
3020,
19482,
19510,
33,
9,
32,
9,
33,
737,
9,
9888,
8,
198,
220,
220,
220,
1441,
569,
198,
437,
198,
198,
28435,
709,
6759,
8609,
7,
198,
220,
220,
220,
479,
3712,
39,
2246,
11,
198,
220,
220,
220,
285,
3712,
8081,
2234,
17633,
11,
198,
220,
220,
220,
5766,
1634,
28,
1925,
4316,
2584,
26,
198,
220,
220,
220,
662,
11186,
28,
9562,
11,
198,
220,
220,
220,
466,
69,
62,
23032,
434,
3712,
33,
970,
28,
7942,
11,
198,
220,
220,
220,
5046,
3712,
15633,
28,
16,
11,
198,
8,
796,
4808,
28435,
709,
6759,
8609,
7,
74,
11,
285,
11,
662,
11186,
11,
466,
69,
62,
23032,
434,
11,
5046,
11,
5766,
1634,
8,
198,
198,
8818,
4808,
28435,
709,
6759,
8609,
7,
198,
220,
220,
220,
479,
3712,
39,
2246,
11,
198,
220,
220,
220,
285,
3712,
8081,
2234,
17633,
11,
198,
220,
220,
220,
662,
11186,
3712,
33,
970,
11,
198,
220,
220,
220,
466,
69,
62,
23032,
434,
3712,
33,
970,
11,
198,
220,
220,
220,
5046,
3712,
15633,
11,
198,
220,
220,
220,
7904,
6030,
90,
1925,
4316,
2584,
5512,
198,
8,
198,
220,
220,
220,
569,
796,
4808,
28435,
709,
7,
74,
11,
285,
11,
662,
11186,
11,
466,
69,
62,
23032,
434,
11,
5046,
8,
198,
220,
220,
220,
1441,
39751,
2743,
590,
46912,
7,
354,
4316,
2584,
7,
53,
11,
2198,
28,
7942,
828,
479,
11,
569,
8,
198,
437,
198,
198,
8818,
4808,
28435,
709,
6759,
8609,
7,
198,
220,
220,
220,
479,
3712,
39,
2246,
11,
198,
220,
220,
220,
285,
3712,
8081,
2234,
17633,
11,
198,
220,
220,
220,
662,
11186,
3712,
33,
970,
11,
198,
220,
220,
220,
466,
69,
62,
23032,
434,
3712,
33,
970,
11,
198,
220,
220,
220,
5046,
3712,
15633,
11,
198,
220,
220,
220,
7904,
6030,
90,
50,
8898,
5512,
198,
8,
198,
220,
220,
220,
569,
796,
4808,
28435,
709,
7,
74,
11,
285,
11,
662,
11186,
11,
466,
69,
62,
23032,
434,
11,
5046,
8,
198,
220,
220,
220,
1441,
39751,
2743,
590,
46912,
7,
82,
20306,
7,
53,
13,
7890,
828,
479,
11,
569,
8,
198,
437,
198,
198,
2,
16529,
650,
198,
2,
27327,
10188,
44,
25458,
220,
198,
2,
16529,
650,
198,
5183,
6759,
8609,
7,
76,
3712,
10962,
8081,
2234,
17633,
90,
51,
5512,
2124,
8,
810,
309,
27,
25,
1268,
21479,
33365,
796,
6877,
6759,
8609,
7,
76,
13,
19849,
11,
2124,
8,
198,
198,
8818,
6877,
6759,
8609,
7,
76,
3712,
51,
11,
2124,
8,
810,
309,
27,
25,
1268,
21479,
33365,
198,
220,
220,
220,
30218,
796,
285,
13,
381,
13,
354,
349,
13,
6239,
3712,
52,
2848,
14824,
21413,
198,
220,
220,
220,
374,
7146,
0,
7,
87,
11,
30218,
8,
198,
220,
220,
220,
1441,
2160,
7,
87,
13,
61,
17,
11,
5391,
82,
796,
362,
8,
198,
886,
198,
198,
41255,
31412,
7,
74,
3712,
16045,
15,
11,
285,
3712,
8081,
2234,
17633,
11,
2124,
8,
796,
530,
7,
11085,
7,
87,
4008,
198,
41255,
31412,
7,
74,
3712,
16045,
16,
11,
285,
3712,
8081,
2234,
17633,
11,
2124,
8,
796,
997,
8158,
7,
76,
737,
14,
67,
1659,
62,
411,
312,
7,
76,
8,
198,
41255,
31412,
7,
74,
3712,
16045,
17,
11,
285,
3712,
8081,
2234,
17633,
11,
2124,
8,
796,
530,
7,
11085,
7,
87,
4008,
24457,
7,
505,
7,
11085,
7,
87,
29720,
12,
5183,
6759,
8609,
7,
76,
11,
2124,
4008,
198,
41255,
31412,
7,
74,
3712,
16045,
18,
11,
285,
3712,
8081,
2234,
17633,
11,
2124,
8,
796,
530,
7,
11085,
7,
87,
29720,
29006,
505,
7,
11085,
7,
87,
29720,
12,
5183,
6759,
8609,
7,
76,
11,
2124,
29720,
61,
17,
198,
198,
8818,
9224,
31412,
7,
74,
3712,
16045,
19,
11,
285,
3712,
8081,
2234,
17633,
11,
2124,
8,
198,
220,
220,
220,
299,
11,
279,
796,
2546,
7,
87,
8,
198,
220,
220,
220,
8216,
796,
530,
7,
417,
4906,
7,
87,
4008,
198,
220,
220,
220,
289,
796,
6877,
6759,
8609,
7,
76,
11,
2124,
8,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
474,
287,
1123,
9630,
7,
71,
8,
198,
220,
220,
220,
220,
220,
220,
220,
25979,
796,
949,
7,
19,
11,
299,
9,
71,
58,
73,
60,
14,
79,
8,
198,
220,
220,
220,
220,
220,
220,
220,
289,
58,
73,
60,
796,
8216,
29006,
41527,
12,
71,
58,
73,
12962,
61,
67,
12514,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
289,
198,
437,
198,
198,
8818,
9224,
31412,
7,
74,
3712,
16045,
19,
76,
11,
285,
3712,
8081,
2234,
17633,
11,
2124,
8,
198,
220,
220,
220,
299,
11,
279,
796,
2546,
7,
87,
8,
198,
220,
220,
220,
8216,
796,
530,
7,
417,
4906,
7,
87,
4008,
198,
220,
220,
220,
289,
796,
6877,
6759,
8609,
7,
76,
11,
2124,
8,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
474,
287,
1123,
9630,
7,
71,
8,
198,
220,
220,
220,
220,
220,
220,
220,
25979,
796,
949,
7,
41527,
11,
299,
9,
71,
58,
73,
60,
14,
79,
8,
1343,
949,
7,
16,
13,
20,
11,
299,
9,
71,
58,
73,
60,
14,
79,
8,
198,
220,
220,
220,
220,
220,
220,
220,
289,
58,
73,
60,
796,
8216,
29006,
41527,
12,
71,
58,
73,
12962,
61,
67,
12514,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
289,
198,
437,
198,
198,
8818,
9224,
31412,
7,
74,
3712,
16045,
20,
11,
285,
3712,
8081,
2234,
17633,
11,
2124,
8,
198,
220,
220,
220,
299,
11,
279,
796,
2546,
7,
87,
8,
198,
220,
220,
220,
8216,
796,
530,
7,
417,
4906,
7,
87,
4008,
198,
220,
220,
220,
289,
796,
6877,
6759,
8609,
7,
76,
11,
2124,
8,
198,
220,
220,
220,
285,
87,
796,
3509,
7,
77,
9,
15,
13,
22,
9,
47033,
7,
71,
20679,
79,
11,
604,
8,
198,
220,
220,
220,
2488,
259,
65,
3733,
329,
474,
287,
1123,
9630,
7,
71,
8,
198,
220,
220,
220,
220,
220,
220,
220,
17130,
796,
949,
7,
77,
9,
71,
58,
73,
60,
14,
79,
11,
285,
87,
8,
198,
220,
220,
220,
220,
220,
220,
220,
289,
58,
73,
60,
796,
8216,
14,
31166,
17034,
19510,
41527,
12,
71,
58,
73,
12962,
61,
26591,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
289,
198,
437,
198,
198,
23032,
0,
7,
76,
11,
9224,
3712,
23839,
43879,
8,
796,
285,
198,
23032,
0,
7,
76,
11,
9224,
3712,
23839,
46912,
8,
796,
285,
15885,
31166,
17034,
12195,
41255,
8,
198,
198,
29668,
14881,
13,
28435,
709,
7,
74,
3712,
16045,
11,
285,
3712,
8081,
2234,
17633,
26,
5046,
3712,
15633,
28,
16,
8,
796,
4808,
28435,
709,
7,
74,
11,
285,
11,
5046,
8,
198,
198,
8818,
4808,
28435,
709,
7,
74,
3712,
16045,
11,
285,
3712,
8081,
2234,
17633,
11,
5046,
8,
198,
220,
220,
220,
347,
220,
796,
800,
7752,
12003,
33979,
666,
7,
76,
8,
198,
220,
220,
220,
8085,
796,
2589,
6759,
8609,
7,
76,
8,
198,
220,
220,
220,
9224,
796,
9224,
31412,
7,
74,
11,
285,
11,
953,
6759,
8609,
7,
76,
4008,
198,
220,
220,
220,
8085,
796,
4532,
0,
7,
3020,
11,
9224,
8,
198,
220,
220,
220,
5046,
1635,
28,
4129,
7,
41255,
8,
1875,
352,
5633,
530,
7,
11085,
7,
41255,
4008,
1058,
9224,
198,
220,
220,
220,
317,
796,
8085,
6,
9,
3020,
198,
220,
220,
220,
1441,
1632,
3020,
19482,
19510,
33,
9,
32,
9,
33,
737,
9,
9888,
8,
198,
437,
198,
198,
28435,
709,
6759,
8609,
7,
74,
3712,
16045,
11,
285,
3712,
8081,
2234,
17633,
11,
5766,
1634,
28,
1925,
4316,
2584,
26,
5046,
3712,
15633,
28,
16,
8,
796,
198,
220,
220,
220,
4808,
28435,
709,
6759,
8609,
7,
74,
11,
285,
11,
5046,
11,
3254,
90,
25,
31412,
1634,
30072,
198,
198,
8818,
4808,
28435,
709,
6759,
8609,
7,
74,
3712,
16045,
11,
285,
3712,
8081,
2234,
17633,
11,
5046,
3712,
15633,
11,
7904,
6030,
90,
1925,
4316,
2584,
30072,
198,
220,
220,
220,
569,
796,
4808,
28435,
709,
7,
74,
11,
285,
11,
5046,
8,
198,
220,
220,
220,
39751,
2743,
590,
46912,
7,
354,
4316,
2584,
7,
53,
11,
2198,
28,
7942,
828,
479,
11,
569,
8,
198,
437,
198,
198,
8818,
4808,
28435,
709,
6759,
8609,
7,
74,
3712,
16045,
11,
285,
3712,
8081,
2234,
17633,
11,
5046,
3712,
15633,
11,
7904,
6030,
90,
50,
8898,
30072,
198,
220,
220,
220,
569,
796,
4808,
28435,
709,
7,
74,
11,
285,
11,
5046,
8,
198,
220,
220,
220,
39751,
2743,
590,
46912,
7,
82,
20306,
7,
53,
828,
479,
11,
569,
8,
198,
437,
198,
198,
2,
16529,
650,
198,
2,
8740,
16045,
10188,
44,
25458,
198,
2,
16529,
650,
198,
198,
8818,
2721,
23870,
7,
74,
3712,
9419,
16045,
11,
285,
3712,
8081,
2234,
17633,
8,
198,
220,
220,
220,
1395,
796,
953,
6759,
8609,
7,
76,
8,
198,
220,
220,
220,
581,
796,
15384,
7,
76,
8,
198,
220,
220,
220,
277,
796,
17851,
1096,
7,
74,
13,
565,
8,
198,
220,
220,
220,
357,
55,
11,
581,
828,
264,
69,
796,
416,
30619,
19510,
55,
11,
581,
828,
277,
8,
198,
220,
220,
220,
269,
72,
796,
23163,
3849,
12786,
7,
28202,
8,
198,
220,
220,
220,
279,
796,
2546,
7,
55,
11,
362,
8,
198,
220,
220,
220,
30218,
796,
442,
349,
7,
76,
8,
198,
220,
220,
220,
911,
265,
796,
24936,
90,
417,
4906,
7,
411,
38165,
7,
917,
891,
11,
79,
11,
79,
8,
198,
220,
220,
220,
1441,
8740,
39,
4093,
4891,
7,
38610,
7,
55,
828,
1395,
11,
581,
11,
2092,
7,
55,
11,
357,
15,
11,
15,
36911,
30218,
11,
911,
265,
11,
269,
72,
11,
264,
69,
8,
198,
437,
198,
198,
8818,
20595,
14881,
13,
28435,
709,
7,
74,
3712,
9419,
16045,
11,
285,
3712,
8081,
2234,
17633,
26,
5046,
3712,
15633,
28,
16,
8,
198,
220,
220,
220,
2993,
796,
664,
459,
7,
74,
11,
285,
8,
198,
220,
220,
220,
4129,
7,
74,
3605,
13,
565,
8,
6624,
997,
8158,
7,
76,
8,
8614,
3714,
7,
28100,
1713,
12331,
7,
74,
11,
366,
1169,
4129,
286,
262,
13946,
7885,
1276,
307,
29568,
22510,
8158,
7,
76,
4008,
48774,
198,
220,
220,
220,
12940,
796,
2721,
23870,
7,
74,
3605,
11,
285,
8,
198,
220,
220,
220,
1441,
4808,
28435,
709,
7,
74,
3605,
11,
285,
11,
12940,
11,
5046,
8,
198,
437,
198,
198,
8818,
410,
66,
709,
6759,
8609,
7,
74,
3712,
9419,
16045,
11,
285,
3712,
8081,
2234,
17633,
11,
5766,
1634,
796,
609,
4316,
2584,
26,
5046,
3712,
15633,
28,
16,
8,
198,
220,
220,
220,
2993,
796,
664,
459,
7,
74,
11,
285,
8,
198,
220,
220,
220,
12940,
796,
2721,
23870,
7,
74,
3605,
11,
285,
8,
198,
220,
220,
220,
47764,
796,
466,
69,
23032,
434,
7,
74,
3605,
11,
12940,
8,
198,
220,
220,
220,
1441,
4808,
28435,
709,
6759,
8609,
7,
74,
3605,
11,
285,
11,
12940,
11,
5046,
11,
5766,
1634,
8,
198,
437,
198,
198,
8818,
4808,
28435,
709,
7,
74,
3712,
9419,
16045,
11,
285,
3712,
8081,
2234,
17633,
11,
12940,
3712,
9419,
39,
4093,
4891,
11,
5046,
3712,
15633,
8,
198,
220,
220,
220,
347,
796,
800,
7752,
12003,
33979,
666,
7,
76,
8,
198,
220,
220,
220,
581,
796,
4532,
411,
312,
0,
7,
74,
11,
12940,
8,
198,
220,
220,
220,
12940,
13,
32542,
298,
6759,
8609,
764,
28,
12940,
13,
19849,
6759,
8609,
15885,
411,
198,
220,
220,
220,
47764,
796,
466,
69,
23032,
434,
7,
74,
11,
12940,
8,
198,
220,
220,
220,
5046,
1635,
28,
47764,
198,
220,
220,
220,
911,
265,
796,
13946,
1096,
0,
7,
23870,
8,
198,
220,
220,
220,
1441,
1632,
3020,
19482,
19510,
33,
9,
2484,
265,
9,
33,
737,
9,
9888,
8,
198,
437,
198,
198,
8818,
4808,
28435,
709,
6759,
8609,
7,
198,
220,
220,
220,
479,
3712,
16045,
11,
198,
220,
220,
220,
285,
3712,
8081,
2234,
17633,
11,
198,
220,
220,
220,
12940,
3712,
9419,
39,
4093,
4891,
11,
198,
220,
220,
220,
5046,
3712,
15633,
11,
198,
220,
220,
220,
7904,
6030,
90,
1925,
4316,
2584,
92,
198,
8,
198,
220,
220,
220,
569,
796,
4808,
28435,
709,
7,
74,
11,
285,
11,
12940,
11,
5046,
8,
198,
220,
220,
220,
39751,
2743,
590,
46912,
7,
354,
4316,
2584,
7,
53,
11,
2198,
28,
7942,
828,
479,
11,
569,
8,
198,
437,
198,
198,
8818,
4808,
28435,
709,
6759,
8609,
7,
198,
220,
220,
220,
479,
3712,
16045,
11,
198,
220,
220,
220,
285,
3712,
8081,
2234,
17633,
11,
198,
220,
220,
220,
12940,
3712,
9419,
39,
4093,
4891,
11,
198,
220,
220,
220,
5046,
3712,
15633,
11,
198,
220,
220,
220,
7904,
6030,
90,
50,
8898,
92,
198,
8,
198,
220,
220,
220,
569,
796,
4808,
28435,
709,
7,
74,
11,
285,
11,
12940,
11,
12940,
8,
198,
220,
220,
220,
39751,
2743,
590,
46912,
7,
82,
20306,
7,
53,
13,
7890,
828,
479,
11,
569,
8,
198,
437,
198,
198,
2,
16529,
32501,
198,
2,
8740,
16045,
10188,
44,
532,
30028,
284,
779,
410,
66,
709,
7,
9419,
16045,
16,
7,
25,
565,
5819,
11,
47764,
828,
7904,
8763,
44,
8,
198,
2,
16529,
32501,
198,
29668,
14881,
13,
301,
1082,
1472,
7,
74,
3712,
14350,
436,
23907,
590,
11,
285,
3712,
8081,
2234,
17633,
26,
479,
86,
22046,
23029,
796,
19862,
17034,
12195,
10989,
363,
7,
28435,
709,
7,
74,
11,
285,
26,
479,
86,
22046,
986,
22305,
198,
29668,
14881,
13,
301,
1082,
1472,
7,
85,
3712,
34,
709,
2743,
590,
46912,
8,
796,
19862,
17034,
12195,
10989,
363,
7,
85,
13,
53,
4008,
198,
198,
2,
16529,
32501,
198,
2,
8740,
16045,
10188,
44,
532,
30028,
284,
779,
410,
66,
709,
7,
9419,
16045,
16,
7,
25,
565,
5819,
11,
47764,
828,
7904,
8763,
44,
8,
198,
2,
16529,
32501,
198,
260,
2701,
7,
74,
3712,
9419,
16045,
90,
51,
11,
35,
5512,
285,
3712,
1268,
21479,
33365,
8,
810,
1391,
51,
27,
25,
23839,
38469,
11,
360,
27,
25,
18465,
92,
796,
479,
198,
260,
2701,
7,
74,
3712,
9419,
16045,
90,
51,
11,
35,
5512,
285,
3712,
10962,
8081,
2234,
17633,
8,
810,
1391,
51,
27,
25,
23839,
38469,
11,
360,
27,
25,
18465,
92,
796,
479,
198,
260,
4354,
7,
74,
3712,
9419,
16045,
90,
51,
11,
35,
5512,
285,
3712,
10962,
8081,
2234,
17633,
8,
810,
1391,
51,
11,
360,
92,
796,
46545,
7,
74,
13,
565,
23029,
198,
198,
8818,
664,
459,
7,
74,
3712,
9419,
16045,
90,
51,
11,
35,
5512,
285,
3712,
10962,
8081,
2234,
17633,
8,
810,
1391,
51,
27,
25,
13940,
23650,
11,
360,
92,
198,
220,
220,
220,
2488,
30493,
318,
11487,
7,
74,
13,
7568,
8,
366,
63,
7568,
63,
1276,
307,
257,
6060,
35439,
1,
198,
220,
220,
220,
256,
796,
479,
13,
565,
198,
220,
220,
220,
611,
4129,
7,
74,
13,
7568,
58,
28265,
256,
12962,
6624,
4129,
7,
76,
13,
76,
69,
13,
7890,
58,
16,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
22492,
383,
15793,
4197,
198,
220,
220,
220,
220,
220,
220,
220,
4686,
796,
27413,
7,
66,
2397,
12409,
7,
74,
13,
7568,
58,
45299,
83,
60,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
6931,
7,
74,
11,
4686,
8,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
277,
796,
285,
13,
76,
69,
13,
69,
198,
220,
220,
220,
220,
220,
220,
220,
1216,
76,
796,
277,
13,
75,
11994,
5299,
46545,
7,
69,
13,
81,
11994,
13,
38707,
986,
11,
35118,
7,
83,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
299,
83,
796,
34441,
51,
29291,
90,
83,
29291,
7,
29668,
5841,
1424,
13,
4354,
85,
945,
7,
8310,
76,
8,
23029,
92,
7,
4033,
388,
429,
540,
7,
74,
13,
7568,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
4686,
87,
796,
20595,
5841,
1424,
13,
45688,
62,
296,
270,
7,
429,
38381,
17,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4686,
796,
27413,
7,
66,
2397,
12409,
7,
74,
13,
7568,
58,
312,
87,
11,
83,
60,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
6931,
7,
74,
11,
4686,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1303,
269,
83,
796,
951,
388,
429,
540,
7,
2527,
8,
198,
220,
220,
220,
1303,
4129,
62,
34642,
796,
3975,
7,
87,
3784,
13664,
7,
34642,
7,
87,
36911,
269,
83,
8,
198,
220,
220,
220,
1303,
277,
70,
796,
352,
25,
1676,
67,
7,
13664,
62,
34642,
8,
198,
220,
220,
220,
1303,
1303,
565,
796,
3975,
7,
87,
3784,
5589,
601,
7,
66,
2397,
12409,
7,
87,
36911,
1123,
4033,
7,
87,
4008,
198,
220,
220,
220,
1303,
537,
385,
58,
28265,
1058,
2527,
312,
60,
764,
28,
2546,
7,
2527,
11,
362,
8,
1875,
352,
5633,
6632,
7,
5317,
8,
1058,
537,
385,
58,
28265,
256,
38707,
58,
16,
11907,
198,
220,
220,
220,
1303,
611,
4129,
7,
83,
38707,
8,
1875,
352,
198,
220,
220,
220,
1303,
220,
220,
220,
220,
329,
357,
72,
11,
73,
8,
287,
27056,
378,
7,
8094,
1525,
7,
2527,
11,
685,
83,
38707,
22345,
4008,
198,
220,
220,
220,
1303,
220,
220,
220,
220,
220,
220,
220,
220,
474,
58,
45299,
1058,
2527,
312,
60,
764,
28,
277,
70,
58,
72,
60,
198,
220,
220,
220,
1303,
220,
220,
220,
220,
886,
198,
220,
220,
220,
1303,
886,
198,
220,
220,
220,
1303,
4686,
796,
27413,
7,
66,
2397,
12409,
7,
2527,
58,
28265,
1058,
2527,
312,
60,
4008,
220,
220,
220,
220,
198,
437,
628,
198,
2,
16529,
32501,
198,
2,
16586,
3903,
10394,
2446,
198,
2,
16529,
32501,
198,
8818,
16586,
3903,
10394,
7,
198,
220,
220,
220,
479,
3712,
39,
2246,
11,
198,
220,
220,
220,
285,
3712,
10962,
8081,
2234,
17633,
90,
37,
19629,
198,
220,
220,
220,
479,
86,
22046,
986,
198,
8,
810,
376,
27,
25,
1268,
21479,
33365,
198,
220,
220,
220,
9058,
33885,
43775,
0,
7,
74,
11,
285,
8,
198,
220,
220,
220,
16586,
3903,
10394,
7,
74,
11,
285,
13,
19849,
26,
479,
86,
22046,
23029,
198,
437,
198,
198,
8818,
16586,
3903,
10394,
7,
74,
3712,
39,
2246,
11,
285,
3712,
37,
26,
662,
11186,
28,
9562,
8,
810,
376,
27,
25,
1268,
21479,
33365,
220,
220,
220,
220,
198,
220,
220,
220,
8085,
796,
2589,
6759,
8609,
7,
76,
8,
198,
220,
220,
220,
9058,
33885,
43775,
0,
7,
74,
11,
285,
8,
198,
220,
220,
220,
285,
3020,
11,
360,
796,
662,
1929,
2676,
7,
3020,
11,
3254,
90,
79,
1809,
71,
578,
30072,
198,
220,
220,
220,
1441,
16586,
3903,
10394,
7,
74,
11,
285,
3020,
26,
662,
11186,
28,
79,
1809,
71,
578,
8,
198,
437,
198,
198,
8818,
9058,
33885,
43775,
0,
7,
74,
11,
285,
3712,
10962,
8081,
2234,
17633,
90,
51,
30072,
810,
309,
27,
25,
1268,
21479,
33365,
198,
220,
220,
220,
27169,
796,
763,
891,
7,
76,
8,
198,
220,
220,
220,
47558,
0,
7,
74,
13,
43775,
11,
4129,
7,
26638,
4008,
198,
220,
220,
220,
30629,
9492,
984,
16725,
18872,
230,
763,
891,
14933,
7,
76,
8,
5633,
357,
74,
13,
43775,
764,
28,
352,
13,
15,
26,
479,
13,
43775,
58,
16,
60,
796,
657,
13,
15,
8,
1058,
479,
13,
43775,
764,
28,
352,
13,
15,
198,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
8818,
9058,
33885,
43775,
0,
7,
74,
11,
285,
3712,
51,
8,
810,
309,
27,
25,
1268,
21479,
33365,
198,
220,
220,
220,
30218,
796,
763,
891,
7,
76,
8,
198,
220,
220,
220,
47558,
0,
7,
74,
13,
43775,
11,
4129,
7,
12993,
4008,
198,
220,
220,
220,
6070,
0,
7,
74,
13,
43775,
11,
352,
8,
198,
220,
220,
220,
1312,
796,
15788,
9630,
7,
76,
8,
198,
220,
220,
220,
1312,
5145,
855,
2147,
11405,
357,
74,
13,
43775,
58,
72,
60,
796,
657,
8,
198,
220,
220,
220,
1441,
2147,
198,
437,
198
] | 2.400378 | 4,758 |
<reponame>SebastianRuffert/SolidStateDetectors.jl<filename>src/Simulation/Capacitance.jl
@doc raw"""
calculate_mutual_capacitance(sim::Simulation, ij::Tuple{Int, Int}; consider_multiplicity::Bool = true)
Returns the mutual capacitance between the contacts with ID `i = ij[1]` and `j = ij[2]`.
It is calculated via the weighting potentials of the contacts, ``\Phi_i^w(\vec{r})`` and ``\Phi_j^w(\vec{r})``:
```math
c_{ij} = \epsilon_0 \int_{World} \nabla \Phi_i^w(\vec{r}) ϵ_r(\vec{r}) \nabla \Phi_j^w(\vec{r}) d\vec{r}
```
!!! note
These are elements of the Mawell Capcitance Matrix. Look up [Capacitances](@ref) for more information.
!!! note
The electric potential as well as the two weighting potentials of both contacts have to be calculated.
## Arguments
* `sim::Simulation`: [`Simulation`](@ref) for which the capacitance matrix is calculated.
* `ij::Tuple{Int,Int}`: Tuple of indices of the contacts for which the capacitance should be calculated.
## Keywords
* `consider_multiplicity::Bool = true`: Whether symmetries of the system should be taken into account.
For example, in case of true coaxial detector center around the origin and calculated on a cartesian grid
with the `x-axis` going from `[0, x_max]` and the `y-axis` going from `[0, y_max]` the multiplicity is 4
and, if `consider_multiplicity == true`, the returned value is already multiplied by 4.
"""
function calculate_mutual_capacitance(sim::Simulation, ij::Tuple{Int, Int}; consider_multiplicity::Bool = true)
_calculate_mutual_capacitance(sim.weighting_potentials[ij[1]], sim.weighting_potentials[ij[2]], sim.ϵ_r; consider_multiplicity)
end
function _calculate_mutual_capacitance(
wpi::WeightingPotential{T,3,CS}, wpj::WeightingPotential{T,3,CS},
ϵ_r::DielectricDistribution{T,3,CS};
consider_multiplicity::Bool = true ) where {T, CS}
int_p1 = interpolated_scalarfield(wpi)
int_p2 = interpolated_scalarfield(wpj)
int_ϵ_r = interpolated_scalarfield(ϵ_r)
cylindrical = CS == Cylindrical
phi_2D = cylindrical && size(wpi, 2) == size(wpj, 2) == 1
grid = phi_2D ? get_2π_potential(wpi, n_points_in_φ = 2).grid : _get_closed_potential(wpi).grid
grid_mps = get_extended_midpoints_grid(grid)
c_ij::T = _calculate_mutual_capacitance(grid, grid_mps, int_ϵ_r, int_p1, int_p2)
phi_2D && (c_ij *= 2)
consider_multiplicity && (c_ij *= multiplicity(grid))
return uconvert(u"pF", c_ij*u"m" * ϵ0*u"F/m" )
end
function _calculate_mutual_capacitance(grid::Grid{T, 3, CS}, grid_mps, int_ϵ_r, int_p1, int_p2) where {T, CS}
c_ij_vector = zeros(Float64, size(grid, 3)-1)
# In some cases, the sum of many Float32's (of different order of magnitudes)
# can lead to large errors on the sum => Use Float64 as the datatype for the sum.
@inbounds Base.Threads.@threads for i3 in 1:size(grid, 3)-1
for i2 in 1:size(grid, 2)-1
for i1 in 1:size(grid, 1)-1
w1, w2, w3 = voxel_widths(grid, i1, i2, i3)
dV = voxel_volume(grid, i1, i2, i3, w1, w2, w3)
pt_voxel_mid = GridPoint(grid_mps, (i1 + 1, i2 + 1, i3 + 1))
ϵ_r_voxel = get_interpolation(int_ϵ_r, pt_voxel_mid, CS)
efs_1 = _approximate_potential_gradient(int_p1, grid, i1, i2, i3, w1, w2, w3)
efs_2 = _approximate_potential_gradient(int_p2, grid, i1, i2, i3, w1, w2, w3)
c_ij_vector[i3] += Float64(sum(efs_1 .* efs_2) * dV * ϵ_r_voxel)
end
end
end
return T(sum(c_ij_vector))
end
function _approximate_potential_gradient(int_p, grid::Grid{T, 3, CS}, i1, i2, i3, w1, w2, w3) where {T, CS}
p000 = get_interpolation(int_p, GridPoint(grid, (i1 , i2 , i3 )), CS)
p100 = get_interpolation(int_p, GridPoint(grid, (i1 + 1, i2 , i3 )), CS)
p010 = get_interpolation(int_p, GridPoint(grid, (i1 , i2 + 1, i3 )), CS)
p110 = get_interpolation(int_p, GridPoint(grid, (i1 + 1, i2 + 1, i3 )), CS)
p001 = get_interpolation(int_p, GridPoint(grid, (i1 , i2 , i3 + 1)), CS)
p101 = get_interpolation(int_p, GridPoint(grid, (i1 + 1, i2 , i3 + 1)), CS)
p011 = get_interpolation(int_p, GridPoint(grid, (i1 , i2 + 1, i3 + 1)), CS)
p111 = get_interpolation(int_p, GridPoint(grid, (i1 + 1, i2 + 1, i3 + 1)), CS)
efv1 = ( (p100 - p000) + (p110 - p010) + (p101 - p001) + (p111 - p011) ) / (4 * w1)
efv2 = if CS == Cylindrical
_w2 = (grid.axes[2].ticks[i2 + 1] - grid.axes[2].ticks[i2])
if i1 == 1
((p110 - p100)/(_w2*grid.axes[1].ticks[i1+1]) +
(p111 - p101)/(_w2*grid.axes[1].ticks[i1+1]) ) / 2
else
((p010 - p000)/(_w2*grid.axes[1].ticks[i1]) +
(p110 - p100)/(_w2*grid.axes[1].ticks[i1+1]) +
(p011 - p001)/(_w2*grid.axes[1].ticks[i1]) +
(p111 - p101)/(_w2*grid.axes[1].ticks[i1+1])) / 4
end
else
( (p010 - p000) + (p110 - p100) + (p011 - p001) + (p111 - p101) ) / (4 * w2)
end
efv3 = ( (p001 - p000) + (p101 - p100) + (p011 - p010) + (p111 - p110) ) / (4 * w3)
return (efv1, efv2, efv3)
end
@doc raw"""
calculate_capacitance_matrix(sim::Simulation{T}; consider_multiplicity::Bool = true) where {T}
Calculates the Maxwell Capacitance `N×N`-Matrix in units of pF,
where `N` is the number of contacts of `sim.detector`.
The individual elements, ``c_{i,j}``, are calculated via
[`calculate_mutual_capacitance(sim::Simulation, (i,j)::Tuple{Int,Int})`](@ref).
The matrix should be symmetric. The difference of `C[i,j]` and `C[j,i]` are due
to numerical precision in the integration due to the different grids of the two weighting potentials.
## Arguments
* `sim::Simulation`: [`Simulation`](@ref) for which the capacitance matrix is calculated.
## Keywords
* `consider_multiplicity::Bool = true`: Whether symmetries of the system should be taken into account.
For example, in case of true coaxial detector center around the origin and calculated on a cartesian grid
with the `x-axis` going from `[0, x_max]` and the `y-axis` going from `[0, y_max]` the multiplicity is 4
and, if `consider_multiplicity == true`, the returned value is already multiplied by 4.
"""
function calculate_capacitance_matrix(sim::Simulation{T}; consider_multiplicity::Bool = true) where {T}
@assert !ismissing(sim.ϵ_r) "The electric potential needs to be calculated first."
@assert !ismissing(sim.weighting_potentials) "The weighting_potentials needs to be calculated first."
n = length(sim.weighting_potentials)
C = zeros(typeof(one(T) * u"pF"), (n, n))
for i in 1:n
for j in 1:n
C[j, i] = if !ismissing(sim.weighting_potentials[i]) && !ismissing(sim.weighting_potentials[j])
calculate_mutual_capacitance(sim, (i, j); consider_multiplicity)
else
missing
end
end
end
return C
end | [
27,
7856,
261,
480,
29,
50,
1765,
459,
666,
49,
1648,
861,
14,
46933,
9012,
47504,
669,
13,
20362,
27,
34345,
29,
10677,
14,
8890,
1741,
14,
15610,
330,
42942,
13,
20362,
198,
31,
15390,
8246,
37811,
198,
220,
220,
220,
15284,
62,
21973,
723,
62,
11128,
330,
42942,
7,
14323,
3712,
8890,
1741,
11,
1312,
73,
3712,
51,
29291,
90,
5317,
11,
2558,
19629,
2074,
62,
47945,
8467,
3712,
33,
970,
796,
2081,
8,
198,
198,
35561,
262,
13584,
18457,
42942,
1022,
262,
13961,
351,
4522,
4600,
72,
796,
1312,
73,
58,
16,
60,
63,
290,
4600,
73,
796,
1312,
73,
58,
17,
60,
44646,
198,
1026,
318,
10488,
2884,
262,
3463,
278,
2785,
82,
286,
262,
13961,
11,
7559,
59,
2725,
72,
62,
72,
61,
86,
38016,
35138,
90,
81,
30072,
15506,
290,
7559,
59,
2725,
72,
62,
73,
61,
86,
38016,
35138,
90,
81,
30072,
15506,
25,
198,
15506,
63,
11018,
198,
66,
23330,
2926,
92,
796,
3467,
538,
18217,
261,
62,
15,
3467,
600,
23330,
10603,
92,
3467,
77,
397,
5031,
3467,
2725,
72,
62,
72,
61,
86,
38016,
35138,
90,
81,
30072,
18074,
113,
62,
81,
38016,
35138,
90,
81,
30072,
3467,
77,
397,
5031,
3467,
2725,
72,
62,
73,
61,
86,
38016,
35138,
90,
81,
30072,
288,
59,
35138,
90,
81,
92,
198,
15506,
63,
198,
198,
10185,
3465,
198,
220,
220,
220,
2312,
389,
4847,
286,
262,
46598,
695,
4476,
66,
42942,
24936,
13,
6803,
510,
685,
15610,
330,
270,
1817,
16151,
31,
5420,
8,
329,
517,
1321,
13,
198,
198,
10185,
3465,
220,
198,
220,
220,
220,
383,
5186,
2785,
355,
880,
355,
262,
734,
3463,
278,
2785,
82,
286,
1111,
13961,
423,
284,
307,
10488,
13,
198,
198,
2235,
20559,
2886,
198,
9,
4600,
14323,
3712,
8890,
1741,
63,
25,
685,
63,
8890,
1741,
63,
16151,
31,
5420,
8,
329,
543,
262,
18457,
42942,
17593,
318,
10488,
13,
198,
9,
4600,
2926,
3712,
51,
29291,
90,
5317,
11,
5317,
92,
63,
25,
309,
29291,
286,
36525,
286,
262,
13961,
329,
543,
262,
18457,
42942,
815,
307,
10488,
13,
220,
198,
198,
2235,
7383,
10879,
220,
198,
9,
4600,
44353,
62,
47945,
8467,
3712,
33,
970,
796,
2081,
63,
25,
10127,
23606,
316,
1678,
286,
262,
1080,
815,
307,
2077,
656,
1848,
13,
220,
198,
220,
220,
220,
1114,
1672,
11,
287,
1339,
286,
2081,
37700,
498,
31029,
3641,
1088,
262,
8159,
290,
10488,
319,
257,
6383,
35610,
10706,
220,
198,
220,
220,
220,
351,
262,
4600,
87,
12,
22704,
63,
1016,
422,
4600,
58,
15,
11,
2124,
62,
9806,
60,
63,
290,
262,
4600,
88,
12,
22704,
63,
1016,
422,
4600,
58,
15,
11,
331,
62,
9806,
60,
63,
262,
15082,
8467,
318,
604,
198,
220,
220,
220,
290,
11,
611,
4600,
44353,
62,
47945,
8467,
6624,
2081,
47671,
262,
4504,
1988,
318,
1541,
33096,
416,
604,
13,
198,
37811,
198,
8818,
15284,
62,
21973,
723,
62,
11128,
330,
42942,
7,
14323,
3712,
8890,
1741,
11,
1312,
73,
3712,
51,
29291,
90,
5317,
11,
2558,
19629,
2074,
62,
47945,
8467,
3712,
33,
970,
796,
2081,
8,
198,
220,
220,
220,
4808,
9948,
3129,
378,
62,
21973,
723,
62,
11128,
330,
42942,
7,
14323,
13,
6551,
278,
62,
13059,
14817,
58,
2926,
58,
16,
60,
4357,
985,
13,
6551,
278,
62,
13059,
14817,
58,
2926,
58,
17,
60,
4357,
985,
13,
139,
113,
62,
81,
26,
2074,
62,
47945,
8467,
8,
198,
437,
628,
198,
8818,
4808,
9948,
3129,
378,
62,
21973,
723,
62,
11128,
330,
42942,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
266,
14415,
3712,
25844,
278,
25396,
1843,
90,
51,
11,
18,
11,
7902,
5512,
266,
79,
73,
3712,
25844,
278,
25396,
1843,
90,
51,
11,
18,
11,
7902,
5512,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18074,
113,
62,
81,
3712,
32423,
801,
1173,
20344,
3890,
90,
51,
11,
18,
11,
7902,
19629,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2074,
62,
47945,
8467,
3712,
33,
970,
796,
2081,
1267,
810,
1391,
51,
11,
9429,
92,
628,
220,
220,
220,
493,
62,
79,
16,
796,
39555,
515,
62,
1416,
282,
283,
3245,
7,
86,
14415,
8,
198,
220,
220,
220,
493,
62,
79,
17,
796,
39555,
515,
62,
1416,
282,
283,
3245,
7,
24142,
73,
8,
198,
220,
220,
220,
493,
62,
139,
113,
62,
81,
796,
39555,
515,
62,
1416,
282,
283,
3245,
7,
139,
113,
62,
81,
8,
198,
220,
220,
220,
17327,
521,
8143,
796,
9429,
6624,
327,
2645,
521,
8143,
198,
220,
220,
220,
872,
72,
62,
17,
35,
796,
17327,
521,
8143,
11405,
2546,
7,
86,
14415,
11,
362,
8,
6624,
2546,
7,
24142,
73,
11,
362,
8,
6624,
352,
198,
220,
220,
220,
10706,
796,
872,
72,
62,
17,
35,
5633,
651,
62,
17,
46582,
62,
13059,
1843,
7,
86,
14415,
11,
299,
62,
13033,
62,
259,
62,
139,
228,
796,
362,
737,
25928,
1058,
4808,
1136,
62,
20225,
62,
13059,
1843,
7,
86,
14415,
737,
25928,
198,
220,
220,
220,
10706,
62,
76,
862,
796,
651,
62,
2302,
1631,
62,
13602,
13033,
62,
25928,
7,
25928,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
269,
62,
2926,
3712,
51,
796,
4808,
9948,
3129,
378,
62,
21973,
723,
62,
11128,
330,
42942,
7,
25928,
11,
10706,
62,
76,
862,
11,
493,
62,
139,
113,
62,
81,
11,
493,
62,
79,
16,
11,
493,
62,
79,
17,
8,
628,
220,
220,
220,
872,
72,
62,
17,
35,
11405,
357,
66,
62,
2926,
1635,
28,
362,
8,
198,
220,
220,
220,
2074,
62,
47945,
8467,
11405,
357,
66,
62,
2926,
1635,
28,
15082,
8467,
7,
25928,
4008,
198,
220,
220,
220,
1441,
334,
1102,
1851,
7,
84,
1,
79,
37,
1600,
269,
62,
2926,
9,
84,
1,
76,
1,
1635,
18074,
113,
15,
9,
84,
1,
37,
14,
76,
1,
1267,
198,
437,
198,
198,
8818,
4808,
9948,
3129,
378,
62,
21973,
723,
62,
11128,
330,
42942,
7,
25928,
3712,
41339,
90,
51,
11,
513,
11,
9429,
5512,
10706,
62,
76,
862,
11,
493,
62,
139,
113,
62,
81,
11,
493,
62,
79,
16,
11,
493,
62,
79,
17,
8,
810,
1391,
51,
11,
9429,
92,
198,
220,
220,
220,
269,
62,
2926,
62,
31364,
796,
1976,
27498,
7,
43879,
2414,
11,
2546,
7,
25928,
11,
513,
13219,
16,
8,
220,
198,
220,
220,
220,
1303,
554,
617,
2663,
11,
262,
2160,
286,
867,
48436,
2624,
338,
357,
1659,
1180,
1502,
286,
7842,
10455,
8,
220,
198,
220,
220,
220,
1303,
460,
1085,
284,
1588,
8563,
319,
262,
2160,
5218,
5765,
48436,
2414,
355,
262,
4818,
265,
2981,
329,
262,
2160,
13,
198,
220,
220,
220,
2488,
259,
65,
3733,
7308,
13,
16818,
82,
13,
31,
16663,
82,
329,
1312,
18,
287,
352,
25,
7857,
7,
25928,
11,
513,
13219,
16,
198,
220,
220,
220,
220,
220,
220,
220,
329,
1312,
17,
287,
352,
25,
7857,
7,
25928,
11,
362,
13219,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
1312,
16,
287,
352,
25,
7857,
7,
25928,
11,
352,
13219,
16,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
266,
16,
11,
266,
17,
11,
266,
18,
796,
410,
1140,
417,
62,
10394,
82,
7,
25928,
11,
1312,
16,
11,
1312,
17,
11,
1312,
18,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
288,
53,
796,
410,
1140,
417,
62,
29048,
7,
25928,
11,
1312,
16,
11,
1312,
17,
11,
1312,
18,
11,
266,
16,
11,
266,
17,
11,
266,
18,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
42975,
62,
85,
1140,
417,
62,
13602,
796,
24846,
12727,
7,
25928,
62,
76,
862,
11,
357,
72,
16,
1343,
352,
11,
1312,
17,
1343,
352,
11,
1312,
18,
1343,
352,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18074,
113,
62,
81,
62,
85,
1140,
417,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
139,
113,
62,
81,
11,
42975,
62,
85,
1140,
417,
62,
13602,
11,
9429,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
304,
9501,
62,
16,
796,
4808,
1324,
13907,
1920,
62,
13059,
1843,
62,
49607,
7,
600,
62,
79,
16,
11,
10706,
11,
1312,
16,
11,
1312,
17,
11,
1312,
18,
11,
266,
16,
11,
266,
17,
11,
266,
18,
8,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
304,
9501,
62,
17,
796,
4808,
1324,
13907,
1920,
62,
13059,
1843,
62,
49607,
7,
600,
62,
79,
17,
11,
10706,
11,
1312,
16,
11,
1312,
17,
11,
1312,
18,
11,
266,
16,
11,
266,
17,
11,
266,
18,
8,
220,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
62,
2926,
62,
31364,
58,
72,
18,
60,
15853,
48436,
2414,
7,
16345,
7,
891,
82,
62,
16,
764,
9,
304,
9501,
62,
17,
8,
1635,
288,
53,
1635,
18074,
113,
62,
81,
62,
85,
1140,
417,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
309,
7,
16345,
7,
66,
62,
2926,
62,
31364,
4008,
198,
437,
198,
198,
8818,
4808,
1324,
13907,
1920,
62,
13059,
1843,
62,
49607,
7,
600,
62,
79,
11,
10706,
3712,
41339,
90,
51,
11,
513,
11,
9429,
5512,
1312,
16,
11,
1312,
17,
11,
1312,
18,
11,
266,
16,
11,
266,
17,
11,
266,
18,
8,
810,
1391,
51,
11,
9429,
92,
198,
220,
220,
220,
279,
830,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
79,
11,
24846,
12727,
7,
25928,
11,
357,
72,
16,
220,
220,
220,
837,
1312,
17,
220,
220,
220,
837,
1312,
18,
220,
220,
220,
1267,
828,
9429,
8,
198,
220,
220,
220,
279,
3064,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
79,
11,
24846,
12727,
7,
25928,
11,
357,
72,
16,
1343,
352,
11,
1312,
17,
220,
220,
220,
837,
1312,
18,
220,
220,
220,
1267,
828,
9429,
8,
198,
220,
220,
220,
279,
20943,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
79,
11,
24846,
12727,
7,
25928,
11,
357,
72,
16,
220,
220,
220,
837,
1312,
17,
1343,
352,
11,
1312,
18,
220,
220,
220,
1267,
828,
9429,
8,
198,
220,
220,
220,
279,
11442,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
79,
11,
24846,
12727,
7,
25928,
11,
357,
72,
16,
1343,
352,
11,
1312,
17,
1343,
352,
11,
1312,
18,
220,
220,
220,
1267,
828,
9429,
8,
198,
220,
220,
220,
279,
8298,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
79,
11,
24846,
12727,
7,
25928,
11,
357,
72,
16,
220,
220,
220,
837,
1312,
17,
220,
220,
220,
837,
1312,
18,
1343,
352,
36911,
9429,
8,
198,
220,
220,
220,
279,
8784,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
79,
11,
24846,
12727,
7,
25928,
11,
357,
72,
16,
1343,
352,
11,
1312,
17,
220,
220,
220,
837,
1312,
18,
1343,
352,
36911,
9429,
8,
198,
220,
220,
220,
279,
28555,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
79,
11,
24846,
12727,
7,
25928,
11,
357,
72,
16,
220,
220,
220,
837,
1312,
17,
1343,
352,
11,
1312,
18,
1343,
352,
36911,
9429,
8,
198,
220,
220,
220,
279,
16243,
796,
651,
62,
3849,
16104,
341,
7,
600,
62,
79,
11,
24846,
12727,
7,
25928,
11,
357,
72,
16,
1343,
352,
11,
1312,
17,
1343,
352,
11,
1312,
18,
1343,
352,
36911,
9429,
8,
198,
220,
220,
220,
304,
69,
85,
16,
796,
357,
357,
79,
3064,
532,
279,
830,
8,
1343,
357,
79,
11442,
532,
279,
20943,
8,
1343,
357,
79,
8784,
532,
279,
8298,
8,
1343,
357,
79,
16243,
532,
279,
28555,
8,
1267,
1220,
357,
19,
1635,
266,
16,
8,
198,
220,
220,
220,
304,
69,
85,
17,
796,
611,
9429,
6624,
327,
2645,
521,
8143,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
86,
17,
796,
357,
25928,
13,
897,
274,
58,
17,
4083,
83,
3378,
58,
72,
17,
1343,
352,
60,
532,
10706,
13,
897,
274,
58,
17,
4083,
83,
3378,
58,
72,
17,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
611,
1312,
16,
6624,
352,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14808,
79,
11442,
532,
279,
3064,
20679,
28264,
86,
17,
9,
25928,
13,
897,
274,
58,
16,
4083,
83,
3378,
58,
72,
16,
10,
16,
12962,
1343,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
79,
16243,
532,
279,
8784,
20679,
28264,
86,
17,
9,
25928,
13,
897,
274,
58,
16,
4083,
83,
3378,
58,
72,
16,
10,
16,
12962,
1267,
1220,
362,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
14808,
79,
20943,
532,
279,
830,
20679,
28264,
86,
17,
9,
25928,
13,
897,
274,
58,
16,
4083,
83,
3378,
58,
72,
16,
12962,
1343,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
79,
11442,
532,
279,
3064,
20679,
28264,
86,
17,
9,
25928,
13,
897,
274,
58,
16,
4083,
83,
3378,
58,
72,
16,
10,
16,
12962,
1343,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
79,
28555,
532,
279,
8298,
20679,
28264,
86,
17,
9,
25928,
13,
897,
274,
58,
16,
4083,
83,
3378,
58,
72,
16,
12962,
1343,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
357,
79,
16243,
532,
279,
8784,
20679,
28264,
86,
17,
9,
25928,
13,
897,
274,
58,
16,
4083,
83,
3378,
58,
72,
16,
10,
16,
60,
4008,
1220,
604,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
357,
357,
79,
20943,
532,
279,
830,
8,
1343,
357,
79,
11442,
532,
279,
3064,
8,
1343,
357,
79,
28555,
532,
279,
8298,
8,
1343,
357,
79,
16243,
532,
279,
8784,
8,
1267,
1220,
357,
19,
1635,
266,
17,
8,
198,
220,
220,
220,
886,
198,
220,
220,
220,
304,
69,
85,
18,
796,
357,
357,
79,
8298,
532,
279,
830,
8,
1343,
357,
79,
8784,
532,
279,
3064,
8,
1343,
357,
79,
28555,
532,
279,
20943,
8,
1343,
357,
79,
16243,
532,
279,
11442,
8,
1267,
1220,
357,
19,
1635,
266,
18,
8,
198,
220,
220,
220,
1441,
357,
891,
85,
16,
11,
304,
69,
85,
17,
11,
304,
69,
85,
18,
8,
198,
437,
628,
198,
198,
31,
15390,
8246,
37811,
198,
220,
220,
220,
15284,
62,
11128,
330,
42942,
62,
6759,
8609,
7,
14323,
3712,
8890,
1741,
90,
51,
19629,
2074,
62,
47945,
8467,
3712,
33,
970,
796,
2081,
8,
810,
1391,
51,
92,
198,
198,
9771,
3129,
689,
262,
28276,
4476,
330,
42942,
4600,
45,
12906,
45,
63,
12,
46912,
287,
4991,
286,
279,
37,
11,
198,
3003,
4600,
45,
63,
318,
262,
1271,
286,
13961,
286,
4600,
14323,
13,
15255,
9250,
44646,
198,
464,
1981,
4847,
11,
7559,
66,
23330,
72,
11,
73,
92,
15506,
11,
389,
10488,
2884,
220,
198,
58,
63,
9948,
3129,
378,
62,
21973,
723,
62,
11128,
330,
42942,
7,
14323,
3712,
8890,
1741,
11,
357,
72,
11,
73,
2599,
25,
51,
29291,
90,
5317,
11,
5317,
30072,
63,
16151,
31,
5420,
737,
198,
464,
17593,
815,
307,
23606,
19482,
13,
383,
3580,
286,
4600,
34,
58,
72,
11,
73,
60,
63,
290,
4600,
34,
58,
73,
11,
72,
60,
63,
389,
2233,
220,
198,
1462,
29052,
15440,
287,
262,
11812,
2233,
284,
262,
1180,
50000,
286,
262,
734,
3463,
278,
2785,
82,
13,
198,
198,
2235,
20559,
2886,
198,
9,
4600,
14323,
3712,
8890,
1741,
63,
25,
685,
63,
8890,
1741,
63,
16151,
31,
5420,
8,
329,
543,
262,
18457,
42942,
17593,
318,
10488,
13,
198,
198,
2235,
7383,
10879,
220,
198,
9,
4600,
44353,
62,
47945,
8467,
3712,
33,
970,
796,
2081,
63,
25,
10127,
23606,
316,
1678,
286,
262,
1080,
815,
307,
2077,
656,
1848,
13,
220,
198,
220,
220,
220,
1114,
1672,
11,
287,
1339,
286,
2081,
37700,
498,
31029,
3641,
1088,
262,
8159,
290,
10488,
319,
257,
6383,
35610,
10706,
220,
198,
220,
220,
220,
351,
262,
4600,
87,
12,
22704,
63,
1016,
422,
4600,
58,
15,
11,
2124,
62,
9806,
60,
63,
290,
262,
4600,
88,
12,
22704,
63,
1016,
422,
4600,
58,
15,
11,
331,
62,
9806,
60,
63,
262,
15082,
8467,
318,
604,
198,
220,
220,
220,
290,
11,
611,
4600,
44353,
62,
47945,
8467,
6624,
2081,
47671,
262,
4504,
1988,
318,
1541,
33096,
416,
604,
13,
198,
37811,
198,
8818,
15284,
62,
11128,
330,
42942,
62,
6759,
8609,
7,
14323,
3712,
8890,
1741,
90,
51,
19629,
2074,
62,
47945,
8467,
3712,
33,
970,
796,
2081,
8,
810,
1391,
51,
92,
198,
220,
220,
220,
2488,
30493,
5145,
1042,
747,
278,
7,
14323,
13,
139,
113,
62,
81,
8,
366,
464,
5186,
2785,
2476,
284,
307,
10488,
717,
526,
198,
220,
220,
220,
2488,
30493,
5145,
1042,
747,
278,
7,
14323,
13,
6551,
278,
62,
13059,
14817,
8,
366,
464,
3463,
278,
62,
13059,
14817,
2476,
284,
307,
10488,
717,
526,
198,
220,
220,
220,
299,
796,
4129,
7,
14323,
13,
6551,
278,
62,
13059,
14817,
8,
198,
220,
220,
220,
327,
796,
1976,
27498,
7,
4906,
1659,
7,
505,
7,
51,
8,
1635,
334,
1,
79,
37,
12340,
357,
77,
11,
299,
4008,
198,
220,
220,
220,
329,
1312,
287,
352,
25,
77,
198,
220,
220,
220,
220,
220,
220,
220,
329,
474,
287,
352,
25,
77,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
327,
58,
73,
11,
1312,
60,
796,
611,
5145,
1042,
747,
278,
7,
14323,
13,
6551,
278,
62,
13059,
14817,
58,
72,
12962,
11405,
5145,
1042,
747,
278,
7,
14323,
13,
6551,
278,
62,
13059,
14817,
58,
73,
12962,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
15284,
62,
21973,
723,
62,
11128,
330,
42942,
7,
14323,
11,
357,
72,
11,
474,
1776,
2074,
62,
47945,
8467,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4814,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
198,
220,
220,
220,
1441,
327,
198,
437
] | 2.214263 | 3,155 |
<gh_stars>0
# Load in the dependencies
using InfiniteOpt, JuMP, MathOptInterface, Distributions, Random,
FastGaussQuadrature, DataStructures
# load the test module
using Test
# Define convenient aliases
const IC = InfiniteOpt.Collections
const MT = InfiniteOpt.MeasureToolbox
const IOTO = InfiniteOpt.TranscriptionOpt
const JuMPC = JuMP.Containers
const MOI = MathOptInterface
const MOIU = MathOptInterface.Utilities
const MOIUC = MathOptInterface.Utilities.CleverDicts
const FGQ = FastGaussQuadrature
const IOMT = InfiniteOpt.MeasureToolbox
# Load in testing utilities
include("utilities.jl")
# Run unit tests
println("----------------------------------------------------------------------------")
println("---------------------------------UNIT TESTS---------------------------------")
println("----------------------------------------------------------------------------")
@time @testset "Collections" begin
include("Collections/VectorTuple.jl")
include("Collections/DualDict.jl")
end
println("")
@time @testset "Datatypes" begin include("datatypes.jl") end
println("")
@time @testset "Utilities" begin include("utility_tests.jl") end
println("")
@time @testset "Infinite Set Methods" begin include("infinite_sets.jl") end
println("")
@time @testset "General Variable Methods" begin
include("general_variables.jl")
end
println("")
@time @testset "Optimizer Setup Methods" begin include("optimizer_setup.jl") end
println("")
@time @testset "Macro Utilities" begin include("macro_utilities.jl") end
println("")
@time @testset "Parameter Methods" begin
@testset "Scalar" begin include("scalar_parameters.jl") end
@testset "Array" begin include("array_parameters.jl") end
end
println("")
@time @testset "Variable Methods" begin
@testset "Infinite Variables" begin include("infinite_variables.jl") end
@testset "Point Variables" begin include("point_variables.jl") end
@testset "Hold Variables" begin include("hold_variables.jl") end
@testset "Info Constraints" begin include("variable_info.jl") end
@testset "Reduced Variables" begin include("reduced_variables.jl") end
end
println("")
@time @testset "Derivative Methods" begin include("derivatives.jl") end
println("")
@time @testset "Operators" begin include("operators.jl") end
println("")
@time @testset "Expression Methods" begin include("expressions.jl") end
println("")
@time @testset "Macro Expressions" begin include("macro_expressions.jl") end
println("")
@time @testset "Measure Methods" begin include("measures.jl") end
println("")
@time @testset "Measure Toolbox Methods" begin
@testset "Integrals" begin include("MeasureToolbox/integrals.jl") end
@testset "Expectations" begin include("MeasureToolbox/expectations.jl") end
@testset "Support Sums" begin include("MeasureToolbox/support_sums.jl") end
end
println("")
@time @testset "Objective Methods" begin include("objective.jl") end
println("")
@time @testset "Constraint Methods" begin include("constraints.jl") end
println("")
@time @testset "Printing Methods" begin include("show.jl") end
println("")
@time @testset "Deletion Methods" begin include("deletion.jl") end
println("")
@time @testset "Expansion Methods" begin include("measure_expansions.jl") end
println("")
@time @testset "Derivative Evaluation" begin include("derivative_evaluation.jl") end
println("")
@time @testset "TranscriptionOpt" begin
@testset "Model" begin include("TranscriptionOpt/model.jl") end
@testset "Measures" begin include("TranscriptionOpt/measure.jl") end
@testset "Transcribe" begin include("TranscriptionOpt/transcribe.jl") end
@testset "Optimize" begin include("TranscriptionOpt/optimize.jl") end
end
println("")
@time @testset "Solution Methods" begin include("optimizer.jl") end
println("")
@time @testset "Solution Queries" begin include("results.jl") end
println("")
@time @testset "Extensions" begin include("extensions.jl") end
println("")
println("----------------------------------------------------------------------------")
println("-----------------------------TESTING COMPLETE!------------------------------")
println("----------------------------------------------------------------------------")
| [
27,
456,
62,
30783,
29,
15,
198,
2,
8778,
287,
262,
20086,
198,
3500,
22380,
27871,
11,
12585,
7378,
11,
16320,
27871,
39317,
11,
46567,
507,
11,
14534,
11,
198,
22968,
35389,
1046,
4507,
41909,
1300,
11,
6060,
44909,
942,
198,
198,
2,
3440,
262,
1332,
8265,
198,
3500,
6208,
198,
198,
2,
2896,
500,
11282,
47217,
198,
9979,
12460,
796,
22380,
27871,
13,
5216,
26448,
198,
9979,
19308,
796,
22380,
27871,
13,
47384,
25391,
3524,
198,
9979,
314,
26631,
796,
22380,
27871,
13,
8291,
6820,
27871,
198,
9979,
12585,
44,
5662,
796,
12585,
7378,
13,
4264,
50221,
198,
9979,
13070,
40,
796,
16320,
27871,
39317,
198,
9979,
13070,
44958,
796,
16320,
27871,
39317,
13,
18274,
2410,
198,
9979,
13070,
40,
9598,
796,
16320,
27871,
39317,
13,
18274,
2410,
13,
34349,
332,
35,
14137,
198,
9979,
25503,
48,
796,
12549,
35389,
1046,
4507,
41909,
1300,
198,
9979,
314,
2662,
51,
796,
22380,
27871,
13,
47384,
25391,
3524,
198,
198,
2,
8778,
287,
4856,
20081,
198,
17256,
7203,
315,
2410,
13,
20362,
4943,
198,
198,
2,
5660,
4326,
5254,
198,
35235,
7203,
10097,
10541,
4943,
198,
35235,
7203,
3880,
12,
4944,
2043,
309,
1546,
4694,
3880,
12,
4943,
198,
35235,
7203,
10097,
10541,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
5216,
26448,
1,
2221,
198,
220,
220,
220,
2291,
7203,
5216,
26448,
14,
38469,
51,
29291,
13,
20362,
4943,
198,
220,
220,
220,
2291,
7203,
5216,
26448,
14,
36248,
35,
713,
13,
20362,
4943,
198,
437,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
27354,
265,
9497,
1,
2221,
2291,
7203,
19608,
265,
9497,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
18274,
2410,
1,
2221,
2291,
7203,
315,
879,
62,
41989,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
18943,
9504,
5345,
25458,
1,
2221,
2291,
7203,
10745,
9504,
62,
28709,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
12218,
35748,
25458,
1,
2221,
198,
220,
220,
220,
2291,
7203,
24622,
62,
25641,
2977,
13,
20362,
4943,
198,
437,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
27871,
320,
7509,
31122,
25458,
1,
2221,
2291,
7203,
40085,
7509,
62,
40406,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
14155,
305,
41086,
1,
2221,
2291,
7203,
20285,
305,
62,
315,
2410,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
36301,
25458,
1,
2221,
198,
220,
220,
2488,
9288,
2617,
366,
3351,
282,
283,
1,
2221,
2291,
7203,
1416,
282,
283,
62,
17143,
7307,
13,
20362,
4943,
886,
198,
220,
220,
2488,
9288,
2617,
366,
19182,
1,
2221,
2291,
7203,
18747,
62,
17143,
7307,
13,
20362,
4943,
886,
198,
437,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
43015,
25458,
1,
2221,
198,
220,
220,
2488,
9288,
2617,
366,
18943,
9504,
15965,
2977,
1,
2221,
2291,
7203,
10745,
9504,
62,
25641,
2977,
13,
20362,
4943,
886,
198,
220,
220,
2488,
9288,
2617,
366,
12727,
15965,
2977,
1,
2221,
2291,
7203,
4122,
62,
25641,
2977,
13,
20362,
4943,
886,
198,
220,
220,
2488,
9288,
2617,
366,
26807,
15965,
2977,
1,
2221,
2291,
7203,
2946,
62,
25641,
2977,
13,
20362,
4943,
886,
198,
220,
220,
2488,
9288,
2617,
366,
12360,
1482,
2536,
6003,
1,
2221,
2291,
7203,
45286,
62,
10951,
13,
20362,
4943,
886,
198,
220,
220,
2488,
9288,
2617,
366,
7738,
19513,
15965,
2977,
1,
2221,
2291,
7203,
445,
19513,
62,
25641,
2977,
13,
20362,
4943,
886,
198,
437,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
28532,
452,
876,
25458,
1,
2221,
2291,
7203,
1082,
452,
2929,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
18843,
2024,
1,
2221,
2291,
7203,
3575,
2024,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
16870,
2234,
25458,
1,
2221,
2291,
7203,
42712,
507,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
14155,
305,
10604,
507,
1,
2221,
2291,
7203,
20285,
305,
62,
42712,
507,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
47384,
25458,
1,
2221,
2291,
7203,
47336,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
47384,
16984,
3524,
25458,
1,
2221,
198,
220,
220,
220,
2488,
9288,
2617,
366,
34500,
30691,
1,
2221,
2291,
7203,
47384,
25391,
3524,
14,
18908,
30691,
13,
20362,
4943,
886,
198,
220,
220,
220,
2488,
9288,
2617,
366,
3109,
806,
602,
1,
2221,
2291,
7203,
47384,
25391,
3524,
14,
1069,
806,
602,
13,
20362,
4943,
886,
198,
220,
220,
220,
2488,
9288,
2617,
366,
15514,
5060,
82,
1,
2221,
2291,
7203,
47384,
25391,
3524,
14,
11284,
62,
82,
5700,
13,
20362,
4943,
886,
198,
437,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
10267,
425,
25458,
1,
2221,
2291,
7203,
15252,
425,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
3103,
2536,
2913,
25458,
1,
2221,
2291,
7203,
1102,
2536,
6003,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
18557,
278,
25458,
1,
2221,
2291,
7203,
12860,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
5005,
1616,
295,
25458,
1,
2221,
2291,
7203,
2934,
1616,
295,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
16870,
5487,
25458,
1,
2221,
2291,
7203,
1326,
5015,
62,
11201,
504,
507,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
28532,
452,
876,
34959,
1,
2221,
2291,
7203,
1082,
452,
876,
62,
18206,
2288,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
8291,
6820,
27871,
1,
2221,
198,
220,
220,
220,
2488,
9288,
2617,
366,
17633,
1,
2221,
2291,
7203,
8291,
6820,
27871,
14,
19849,
13,
20362,
4943,
886,
198,
220,
220,
220,
2488,
9288,
2617,
366,
5308,
13846,
1,
2221,
2291,
7203,
8291,
6820,
27871,
14,
1326,
5015,
13,
20362,
4943,
886,
198,
220,
220,
220,
2488,
9288,
2617,
366,
8291,
66,
4892,
1,
2221,
2291,
7203,
8291,
6820,
27871,
14,
7645,
66,
4892,
13,
20362,
4943,
886,
198,
220,
220,
220,
2488,
9288,
2617,
366,
27871,
48439,
1,
2221,
2291,
7203,
8291,
6820,
27871,
14,
40085,
1096,
13,
20362,
4943,
886,
198,
437,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
46344,
25458,
1,
2221,
2291,
7203,
40085,
7509,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
46344,
2264,
10640,
1,
2221,
2291,
7203,
43420,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
31,
2435,
2488,
9288,
2617,
366,
11627,
5736,
1,
2221,
2291,
7203,
2302,
5736,
13,
20362,
4943,
886,
198,
35235,
7203,
4943,
198,
35235,
7203,
10097,
10541,
4943,
198,
35235,
7203,
1783,
32501,
51,
6465,
2751,
49269,
9328,
0,
1783,
26171,
4943,
198,
35235,
7203,
10097,
10541,
4943,
198
] | 3.510924 | 1,190 |
<reponame>grace-harper-ibm/LinearAlgebraicRepresentation.jl<filename>CAGD.jl/examples/3d/boolSample.jl<gh_stars>0
todisplay = VERSION <= VersionNumber("1.2") ? true : false
using LinearAlgebra
using LinearAlgebraicRepresentation
Lar = LinearAlgebraicRepresentation
using CAGD
if todisplay
using ViewerGL
GL = ViewerGL
include("views.jl")
end
# Rod Generation
# npts = 4
npts = 16
V,_ = Lar.rod()([npts, 1])
EV = [
[[2*i, (2*i+1)%2npts+1] for i = 1 : npts]; # horizontal upper edges
[[2*i-1, (2*i)%2npts+1] for i = 1 : npts]; # horizontal lower edges
[[2*i+1, 2*i+2] for i = 0 : npts-1]; # vertical edges
]
FE = [
[i for i = 1 : npts], # upper face
[npts + i for i = 1 : npts], # lower face
[[i, npts+i, 2*npts+i, 2*npts+i+1] for i = 1:npts-1]..., # vertical faces
[npts, 2*npts, 3*npts, 2*npts+1]
]
FV = Lar.cop2lar(Lar.lar2cop(FE) * Lar.lar2cop(EV))
CV = [collect(1 : size(V,2))]
if todisplay
GL.VIEW([
GL.GLGrid(V,EV,GL.COLORS[1],1)
GL.GLFrame
]);
end
# Three Rods Generation
cyl = Lar.Struct([
Lar.r(0,0,0),
#Lar.s(0.6, 0.6, 2.0),
Lar.s(1.0, 1.0, 1.5),
Lar.t(0,0,-1.5),
(V,CV,FV,EV)
])
cyl = Lar.struct2lar(cyl)
tris = Lar.Struct([
cyl,
Lar.Struct([Lar.r(pi/2,0,0), cyl ]) ,
Lar.Struct([Lar.r(0,pi/2,0), cyl ])
])
V, CV, FV, EV = Lar.struct2lar(tris)
cyls = (V, CV, FV, EV)
# Cube Generation
V, (_, EV, FV, CV) = Lar.cuboid([1,1,1],true,[-1,-1,-1])
cube = (V, CV, FV, EV)
# Sphere Generation
# V, EV, FV = catmullclark(cube[1], cube[3], cube[2], 4)
# sphere = (V, FV, EV)
V, FV = Lar.sphere(1.0)([15,25])
# V, FV = Lar.sphere(1.0)([5,5])
FV = sort(sort.(FV))
function getFaceEdges(fV::Array{Int,1})
return [fV[1], fV[2]], [fV[1], fV[3]], [fV[2], fV[3]]
end
EVs = unique([(map(f -> getFaceEdges(f), FV)...)...])
CV = [collect(1:size(V, 2))]
sphere = (V, CV, FV, EVs)
# Object Creation
carry = Lar.Struct([
cyls,
Lar.s(1.3,1.3,1.3),
cube,
Lar.s(1.4,1.4,1.4),
#Lar.s(1.5,1.5,1.5)
sphere
])
V,CV,FV,EV = Lar.struct2lar(carry)
if todisplay
GL.VIEW([
GL.GLGrid(V,EV,GL.COLORS[1],1)
GL.GLFrame
]);
end
# Model Generation
model = CAGD.Model(V)
cFE = convert(Lar.ChainOp, Lar.coboundary_1(model.G, FV, EV))
CAGD.addModelCells!(model, 1, EV, signed = true)
CAGD.addModelCells!(model, 2, cFE)
# Since CF is only used in boolean evaluation, the sign is not needed:
cFV = Lar.lar2cop(FV)
cCV = Lar.lar2cop(CV)
cCF = convert(Lar.ChainOp, ((cCV*cFV').>0))
CAGD.addModelCells!(model, 3, cCF)
atol = 1e-9;
if todisplay displayModel(model) end
split_model = CAGD.facesplitting(model, atol = atol)
if todisplay displayModel(split_model) end
congr_model = CAGD.mergeModelVertices(split_model, err=atol, signed_merge=true)
#split_model = CAGD.facesplitting(congr_model, atol = atol)
#congr_model = CAGD.mergeModelVertices(split_model, err=atol, signed_merge=true)
if todisplay displayModel(congr_model) end
gift_model = deepcopy(congr_model);
FC, bicon_comps = CAGD.tgw(congr_model, 3)
CAGD.addModelCells!(gift_model, 3, convert(Lar.ChainOp, FC'))
if todisplay viewExplode(gift_model) end
##==============================================================================
## Boolean Decomposition
##==============================================================================
arranged_model, boolean_matrix = CAGD.bool3(model)
bXRod = boolean_matrix[:, 2]
bYRod = boolean_matrix[:, 3]
bZRod = boolean_matrix[:, 4]
bCube = boolean_matrix[:, 5]
bSphe = boolean_matrix[:, 6]
| [
27,
7856,
261,
480,
29,
2164,
558,
12,
9869,
525,
12,
571,
76,
14,
14993,
451,
2348,
29230,
291,
40171,
341,
13,
20362,
27,
34345,
29,
34,
4760,
35,
13,
20362,
14,
1069,
12629,
14,
18,
67,
14,
30388,
36674,
13,
20362,
27,
456,
62,
30783,
29,
15,
198,
83,
375,
271,
1759,
796,
44156,
2849,
19841,
10628,
15057,
7203,
16,
13,
17,
4943,
5633,
2081,
1058,
3991,
198,
198,
3500,
44800,
2348,
29230,
198,
3500,
44800,
2348,
29230,
291,
40171,
341,
198,
43,
283,
796,
44800,
2348,
29230,
291,
40171,
341,
198,
3500,
327,
4760,
35,
198,
361,
284,
13812,
198,
220,
220,
220,
1262,
3582,
263,
8763,
198,
220,
220,
220,
10188,
796,
3582,
263,
8763,
198,
197,
17256,
7203,
33571,
13,
20362,
4943,
198,
437,
198,
198,
2,
6882,
16588,
198,
198,
2,
299,
457,
82,
796,
604,
198,
77,
457,
82,
796,
1467,
198,
53,
11,
62,
796,
25577,
13,
14892,
3419,
26933,
77,
457,
82,
11,
352,
12962,
198,
20114,
796,
685,
198,
220,
220,
220,
16410,
17,
9,
72,
11,
357,
17,
9,
72,
10,
16,
8,
4,
17,
77,
457,
82,
10,
16,
60,
329,
1312,
796,
352,
1058,
299,
457,
82,
11208,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
16021,
6727,
13015,
198,
220,
220,
220,
16410,
17,
9,
72,
12,
16,
11,
357,
17,
9,
72,
8,
4,
17,
77,
457,
82,
10,
16,
60,
329,
1312,
796,
352,
1058,
299,
457,
82,
11208,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
16021,
2793,
13015,
198,
220,
220,
220,
16410,
17,
9,
72,
10,
16,
11,
362,
9,
72,
10,
17,
60,
329,
1312,
796,
657,
1058,
299,
457,
82,
12,
16,
11208,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
11723,
13015,
198,
60,
198,
15112,
796,
685,
198,
220,
220,
220,
685,
72,
329,
1312,
796,
352,
1058,
299,
457,
82,
4357,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
6727,
1986,
198,
220,
220,
220,
685,
77,
457,
82,
1343,
1312,
329,
1312,
796,
352,
1058,
299,
457,
82,
4357,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2793,
1986,
198,
220,
220,
220,
16410,
72,
11,
299,
457,
82,
10,
72,
11,
362,
9,
77,
457,
82,
10,
72,
11,
362,
9,
77,
457,
82,
10,
72,
10,
16,
60,
329,
1312,
796,
352,
25,
77,
457,
82,
12,
16,
60,
986,
11,
220,
220,
220,
1303,
11723,
6698,
198,
220,
220,
220,
685,
77,
457,
82,
11,
362,
9,
77,
457,
82,
11,
513,
9,
77,
457,
82,
11,
362,
9,
77,
457,
82,
10,
16,
60,
198,
60,
198,
37,
53,
796,
25577,
13,
22163,
17,
21681,
7,
43,
283,
13,
21681,
17,
22163,
7,
15112,
8,
1635,
25577,
13,
21681,
17,
22163,
7,
20114,
4008,
198,
33538,
796,
685,
33327,
7,
16,
1058,
2546,
7,
53,
11,
17,
4008,
60,
198,
198,
361,
284,
13812,
198,
220,
220,
220,
10188,
13,
28206,
26933,
198,
220,
220,
220,
220,
220,
220,
220,
10188,
13,
8763,
41339,
7,
53,
11,
20114,
11,
8763,
13,
25154,
20673,
58,
16,
4357,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
10188,
13,
8763,
19778,
198,
220,
220,
220,
2361,
1776,
198,
437,
198,
198,
2,
7683,
6882,
82,
16588,
198,
198,
38801,
796,
25577,
13,
44909,
26933,
198,
220,
220,
220,
25577,
13,
81,
7,
15,
11,
15,
11,
15,
828,
198,
220,
220,
220,
1303,
43,
283,
13,
82,
7,
15,
13,
21,
11,
657,
13,
21,
11,
362,
13,
15,
828,
198,
220,
220,
220,
25577,
13,
82,
7,
16,
13,
15,
11,
352,
13,
15,
11,
352,
13,
20,
828,
198,
220,
220,
220,
25577,
13,
83,
7,
15,
11,
15,
12095,
16,
13,
20,
828,
198,
220,
220,
220,
357,
53,
11,
33538,
11,
37,
53,
11,
20114,
8,
198,
12962,
198,
38801,
796,
25577,
13,
7249,
17,
21681,
7,
38801,
8,
198,
2213,
271,
796,
25577,
13,
44909,
26933,
198,
220,
220,
220,
17327,
11,
198,
220,
220,
220,
25577,
13,
44909,
26933,
43,
283,
13,
81,
7,
14415,
14,
17,
11,
15,
11,
15,
828,
17327,
33761,
837,
198,
220,
220,
220,
25577,
13,
44909,
26933,
43,
283,
13,
81,
7,
15,
11,
14415,
14,
17,
11,
15,
828,
17327,
33761,
198,
12962,
198,
53,
11,
26196,
11,
376,
53,
11,
8696,
796,
25577,
13,
7249,
17,
21681,
7,
2213,
271,
8,
198,
948,
7278,
796,
357,
53,
11,
26196,
11,
376,
53,
11,
8696,
8,
198,
198,
2,
23315,
16588,
198,
198,
53,
11,
44104,
11,
8696,
11,
376,
53,
11,
26196,
8,
796,
25577,
13,
66,
549,
1868,
26933,
16,
11,
16,
11,
16,
4357,
7942,
17414,
12,
16,
12095,
16,
12095,
16,
12962,
198,
40296,
796,
357,
53,
11,
26196,
11,
376,
53,
11,
8696,
8,
198,
198,
2,
31798,
16588,
198,
198,
2,
569,
11,
8696,
11,
376,
53,
796,
3797,
76,
724,
565,
668,
7,
40296,
58,
16,
4357,
23441,
58,
18,
4357,
23441,
58,
17,
4357,
604,
8,
198,
2,
16558,
796,
357,
53,
11,
376,
53,
11,
8696,
8,
198,
198,
53,
11,
376,
53,
796,
25577,
13,
2777,
1456,
7,
16,
13,
15,
5769,
58,
1314,
11,
1495,
12962,
198,
2,
569,
11,
376,
53,
796,
25577,
13,
2777,
1456,
7,
16,
13,
15,
5769,
58,
20,
11,
20,
12962,
198,
37,
53,
796,
3297,
7,
30619,
12195,
37,
53,
4008,
198,
8818,
651,
32388,
7407,
3212,
7,
69,
53,
3712,
19182,
90,
5317,
11,
16,
30072,
198,
220,
220,
220,
1441,
685,
69,
53,
58,
16,
4357,
277,
53,
58,
17,
60,
4357,
685,
69,
53,
58,
16,
4357,
277,
53,
58,
18,
60,
4357,
685,
69,
53,
58,
17,
4357,
277,
53,
58,
18,
11907,
198,
437,
198,
20114,
82,
796,
3748,
26933,
7,
8899,
7,
69,
4613,
651,
32388,
7407,
3212,
7,
69,
828,
376,
53,
8,
23029,
986,
12962,
198,
33538,
796,
685,
33327,
7,
16,
25,
7857,
7,
53,
11,
362,
4008,
60,
198,
2777,
1456,
796,
357,
53,
11,
26196,
11,
376,
53,
11,
46229,
8,
198,
198,
2,
9515,
21582,
198,
198,
34993,
796,
25577,
13,
44909,
26933,
198,
220,
220,
220,
17327,
82,
11,
198,
220,
220,
220,
25577,
13,
82,
7,
16,
13,
18,
11,
16,
13,
18,
11,
16,
13,
18,
828,
198,
220,
220,
220,
23441,
11,
198,
220,
220,
220,
25577,
13,
82,
7,
16,
13,
19,
11,
16,
13,
19,
11,
16,
13,
19,
828,
198,
220,
220,
220,
1303,
43,
283,
13,
82,
7,
16,
13,
20,
11,
16,
13,
20,
11,
16,
13,
20,
8,
198,
220,
220,
220,
16558,
198,
12962,
198,
53,
11,
33538,
11,
37,
53,
11,
20114,
796,
25577,
13,
7249,
17,
21681,
7,
34993,
8,
198,
198,
361,
284,
13812,
198,
220,
220,
220,
10188,
13,
28206,
26933,
198,
220,
220,
220,
220,
220,
220,
220,
10188,
13,
8763,
41339,
7,
53,
11,
20114,
11,
8763,
13,
25154,
20673,
58,
16,
4357,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
10188,
13,
8763,
19778,
198,
220,
220,
220,
2361,
1776,
198,
437,
198,
198,
2,
9104,
16588,
198,
198,
19849,
796,
327,
4760,
35,
13,
17633,
7,
53,
8,
198,
66,
15112,
796,
10385,
7,
43,
283,
13,
35491,
18257,
11,
25577,
13,
66,
672,
633,
560,
62,
16,
7,
19849,
13,
38,
11,
376,
53,
11,
8696,
4008,
198,
34,
4760,
35,
13,
2860,
17633,
34,
19187,
0,
7,
19849,
11,
352,
11,
8696,
11,
4488,
796,
2081,
8,
198,
34,
4760,
35,
13,
2860,
17633,
34,
19187,
0,
7,
19849,
11,
362,
11,
269,
15112,
8,
198,
2,
4619,
18551,
318,
691,
973,
287,
25131,
12660,
11,
262,
1051,
318,
407,
2622,
25,
198,
66,
37,
53,
796,
25577,
13,
21681,
17,
22163,
7,
37,
53,
8,
198,
66,
33538,
796,
25577,
13,
21681,
17,
22163,
7,
33538,
8,
198,
66,
22495,
796,
10385,
7,
43,
283,
13,
35491,
18257,
11,
14808,
66,
33538,
9,
66,
37,
53,
27691,
29,
15,
4008,
198,
34,
4760,
35,
13,
2860,
17633,
34,
19187,
0,
7,
19849,
11,
513,
11,
269,
22495,
8,
628,
198,
265,
349,
796,
352,
68,
12,
24,
26,
198,
361,
284,
13812,
220,
3359,
17633,
7,
19849,
8,
220,
886,
198,
198,
35312,
62,
19849,
796,
327,
4760,
35,
13,
32186,
489,
2535,
7,
19849,
11,
379,
349,
796,
379,
349,
8,
198,
198,
361,
284,
13812,
220,
3359,
17633,
7,
35312,
62,
19849,
8,
220,
886,
198,
198,
36801,
81,
62,
19849,
796,
327,
4760,
35,
13,
647,
469,
17633,
42369,
1063,
7,
35312,
62,
19849,
11,
11454,
28,
265,
349,
11,
4488,
62,
647,
469,
28,
7942,
8,
198,
2,
35312,
62,
19849,
796,
327,
4760,
35,
13,
32186,
489,
2535,
7,
36801,
81,
62,
19849,
11,
379,
349,
796,
379,
349,
8,
198,
2,
36801,
81,
62,
19849,
796,
327,
4760,
35,
13,
647,
469,
17633,
42369,
1063,
7,
35312,
62,
19849,
11,
11454,
28,
265,
349,
11,
4488,
62,
647,
469,
28,
7942,
8,
198,
198,
361,
284,
13812,
220,
3359,
17633,
7,
36801,
81,
62,
19849,
8,
220,
886,
198,
198,
70,
2135,
62,
19849,
796,
2769,
30073,
7,
36801,
81,
62,
19849,
1776,
198,
4851,
11,
275,
4749,
62,
785,
862,
796,
327,
4760,
35,
13,
25297,
86,
7,
36801,
81,
62,
19849,
11,
513,
8,
198,
34,
4760,
35,
13,
2860,
17633,
34,
19187,
0,
7,
70,
2135,
62,
19849,
11,
513,
11,
10385,
7,
43,
283,
13,
35491,
18257,
11,
10029,
6,
4008,
198,
198,
361,
284,
13812,
220,
1570,
18438,
1098,
7,
70,
2135,
62,
19849,
8,
220,
886,
198,
198,
2235,
23926,
25609,
855,
198,
2235,
220,
41146,
4280,
296,
9150,
198,
2235,
23926,
25609,
855,
198,
198,
3258,
5102,
62,
19849,
11,
25131,
62,
6759,
8609,
796,
327,
4760,
35,
13,
30388,
18,
7,
19849,
8,
198,
198,
65,
55,
27917,
796,
25131,
62,
6759,
8609,
58,
45299,
362,
60,
198,
65,
56,
27917,
796,
25131,
62,
6759,
8609,
58,
45299,
513,
60,
198,
65,
57,
27917,
796,
25131,
62,
6759,
8609,
58,
45299,
604,
60,
198,
65,
29071,
796,
25131,
62,
6759,
8609,
58,
45299,
642,
60,
198,
65,
4561,
258,
796,
25131,
62,
6759,
8609,
58,
45299,
718,
60,
198
] | 2.049494 | 1,778 |
using Base: @propagate_inbounds
using OffsetArrays
using JLD2
using Oceananigans.Architectures
using Oceananigans.Grids
using Oceananigans.Fields
using Oceananigans.Grids: topology, total_size, interior_parent_indices, parent_index_range
using Oceananigans.Fields: show_location, interior_view_indices, data_summary, reduced_location
import Oceananigans.Fields: Field, set!, interior, indices
import Oceananigans.Architectures: architecture
struct FieldTimeSeries{LX, LY, LZ, K, I, D, G, T, B, χ} <: AbstractField{LX, LY, LZ, G, T, 4}
data :: D
grid :: G
boundary_conditions :: B
indices :: I
times :: χ
function FieldTimeSeries{LX, LY, LZ, K}(data::D, grid::G, bcs::B,
times::χ, indices::I) where {LX, LY, LZ, K, D, G, B, χ, I}
T = eltype(data)
return new{LX, LY, LZ, K, I, D, G, T, B, χ}(data, grid, bcs, indices, times)
end
end
architecture(fts::FieldTimeSeries) = architecture(fts.grid)
#####
##### Constructors
#####
"""
FieldTimeSeries{LX, LY, LZ}(grid, times, [FT=eltype(grid);]
indices = (:, :, :),
boundary_conditions = nothing)
Return a `FieldTimeSeries` at location `(LX, LY, LZ)`, on `grid`, at `times`.
"""
function FieldTimeSeries{LX, LY, LZ}(grid, times, FT=eltype(grid);
indices = (:, :, :),
boundary_conditions = nothing) where {LX, LY, LZ}
Nt = length(times)
arch = architecture(grid)
loc = (LX, LY, LZ)
space_size = total_size(loc, grid, indices)
underlying_data = zeros(FT, arch, space_size..., Nt)
data = offset_data(underlying_data, grid, loc, indices)
return FieldTimeSeries{LX, LY, LZ, InMemory}(data, grid, boundary_conditions, times, indices)
end
"""
FieldTimeSeries(path, name;
backend = InMemory(),
grid = nothing,
iterations = nothing,
times = nothing)
Returns a `FieldTimeSeries` for the field `name` describing a field's time history from a JLD2 file
located at `path`.
Keyword arguments
=================
- `backend`: `InMemory()` to load data into a 4D array or `OnDisk()` to lazily load data from disk
when indexing into `FieldTimeSeries`.
- `grid`: A grid to associated with data, in the case that the native grid was not serialized
properly.
- `iterations`: Iterations to load. Defaults to all iterations found in the file.
- `times`: Save times to load, as determined through an approximate floating point
comparison to recorded save times. Defaults to times associated with `iterations`.
Takes precedence over `iterations` if `times` is specified.
"""
FieldTimeSeries(path, name; backend=InMemory(), kwargs...) =
FieldTimeSeries(path, name, backend; kwargs...)
#####
##### InMemory time serieses
#####
const InMemoryFieldTimeSeries{LX, LY, LZ} = FieldTimeSeries{LX, LY, LZ, InMemory}
struct UnspecifiedBoundaryConditions end
function FieldTimeSeries(path, name, backend::InMemory;
architecture = nothing,
grid = nothing,
location = nothing,
boundary_conditions = UnspecifiedBoundaryConditions(),
iterations = nothing,
times = nothing)
file = jldopen(path)
# Defaults
isnothing(iterations) && (iterations = parse.(Int, keys(file["timeseries/t"])))
isnothing(times) && (times = [file["timeseries/t/$i"] for i in iterations])
isnothing(location) && (location = file["timeseries/$name/serialized/location"])
if boundary_conditions isa UnspecifiedBoundaryConditions
boundary_conditions = file["timeseries/$name/serialized/boundary_conditions"]
end
indices = try
file["timeseries/$name/serialized/indices"]
catch
(:, :, :)
end
isnothing(grid) && (grid = file["serialized/grid"])
# Default to CPU if neither architecture nor grid is specified
architecture = isnothing(architecture) ? (isnothing(grid) ? CPU() : Architectures.architecture(grid)) : architecture
# This should be removed in a month or two (4/5/2022).
grid = try
on_architecture(architecture, grid)
catch err # Likely, the grid has CuArrays in it...
if grid isa RectilinearGrid # we can try...
Nx = file["grid/Nx"]
Ny = file["grid/Ny"]
Nz = file["grid/Nz"]
Hx = file["grid/Hx"]
Hy = file["grid/Hy"]
Hz = file["grid/Hz"]
xᶠᵃᵃ = file["grid/xᶠᵃᵃ"]
yᵃᶠᵃ = file["grid/yᵃᶠᵃ"]
zᵃᵃᶠ = file["grid/zᵃᵃᶠ"]
x = file["grid/Δxᶠᵃᵃ"] isa Number ? (xᶠᵃᵃ[1], xᶠᵃᵃ[Nx+1]) : xᶠᵃᵃ
y = file["grid/Δyᵃᶠᵃ"] isa Number ? (yᵃᶠᵃ[1], yᵃᶠᵃ[Ny+1]) : yᵃᶠᵃ
z = file["grid/Δzᵃᵃᶠ"] isa Number ? (zᵃᵃᶠ[1], zᵃᵃᶠ[Nz+1]) : zᵃᵃᶠ
topo = topology(grid)
# Reduce for Flat dimensions
domain = NamedTuple((:x, :y, :z)[i] => (x, y, z)[i] for i=1:3 if topo[i] !== Flat)
size = Tuple((Nx, Ny, Nz)[i] for i=1:3 if topo[i] !== Flat)
halo = Tuple((Hx, Hy, Hz)[i] for i=1:3 if topo[i] !== Flat)
RectilinearGrid(architecture; size, halo, topology=topo, domain...)
else
throw(err)
end
end
close(file)
LX, LY, LZ = location
time_series = FieldTimeSeries{LX, LY, LZ}(grid, times; indices, boundary_conditions)
set!(time_series, path, name)
return time_series
end
Base.parent(fts::FieldTimeSeries) = parent(fts.data)
function Base.getindex(fts::InMemoryFieldTimeSeries, n::Int)
underlying_data = view(parent(fts), :, :, :, n)
data = offset_data(underlying_data, fts.grid, location(fts), fts.indices)
boundary_conditions = fts.boundary_conditions
indices = fts.indices
return Field(location(fts), fts.grid; data, boundary_conditions, indices)
end
#####
##### set!
#####
"""
Field(location, path, name, iter;
grid = nothing,
architecture = nothing,
indices = (:, :, :),
boundary_conditions = nothing)
Load a field called `name` saved in a JLD2 file at `path` at `iter`ation.
Unless specified, the `grid` is loaded from `path`.
"""
function Field(location, path::String, name::String, iter;
grid = nothing,
architecture = nothing,
indices = (:, :, :),
boundary_conditions = nothing)
file = jldopen(path)
# Default to CPU if neither architecture nor grid is specified
architecture = isnothing(architecture) ?
(isnothing(grid) ? CPU() : Architectures.architecture(grid)) :
architecture
grid = isnothing(grid) ?
on_architecture(architecture, file["serialized/grid"]) : grid
raw_data = arch_array(architecture, file["timeseries/$name/$iter"])
close(file)
data = offset_data(raw_data, grid, location, indices)
return Field(location, grid; boundary_conditions, indices, data)
end
function set!(time_series::InMemoryFieldTimeSeries, path::String, name::String)
file = jldopen(path)
file_iterations = parse.(Int, keys(file["timeseries/t"]))
file_times = [file["timeseries/t/$i"] for i in file_iterations]
close(file)
for (n, time) in enumerate(time_series.times)
file_index = findfirst(t -> t ≈ time, file_times)
file_iter = file_iterations[file_index]
field_n = Field(location(time_series), path, name, file_iter,
indices = time_series.indices,
boundary_conditions = time_series.boundary_conditions,
grid = time_series.grid)
set!(time_series[n], field_n)
end
return nothing
end
function set!(fts::FieldTimeSeries, fields_vector::AbstractVector{<:AbstractField})
raw_data = parent(fts)
file = jldopen(path)
for (n, field) in enumerate(fields_vector)
raw_data[:, :, :, n] .= parent(field)
end
close(file)
return nothing
end
function interior(fts::FieldTimeSeries)
loc = location(fts)
topo = topology(fts.grid)
sz = size(fts.grid)
halo_sz = halo_size(fts.grid)
i_interior = interior_parent_indices.(loc, topo, sz, halo_sz)
indices = fts.indices
i_view = interior_view_indices.(indices, i_interior)
return view(parent(fts), i_view..., :)
end
interior(fts::FieldTimeSeries, I...) = view(interior(fts), I...)
indices(fts::FieldTimeSeries) = fts.indices
#####
##### OnDisk time serieses
#####
struct OnDiskData
path :: String
name :: String
end
function FieldTimeSeries(path, name, backend::OnDisk; architecture=nothing, grid=nothing)
file = jldopen(path)
if isnothing(grid)
grid = on_architecture(architecture, file["serialized/grid"])
end
iterations = parse.(Int, keys(file["timeseries/t"]))
times = [file["timeseries/t/$i"] for i in iterations]
data = OnDiskData(path, name)
LX, LY, LZ = file["timeseries/$name/serialized/location"]
bcs = file["timeseries/$name/serialized/boundary_conditions"]
indices = file["timeseries/$name/serialized/indices"]
close(file)
return FieldTimeSeries{LX, LY, LZ, OnDisk}(data, grid, bcs, times, indices)
end
#####
##### Methods
#####
# Include the time dimension.
@inline Base.size(fts::FieldTimeSeries) = (size(location(fts), fts.grid, fts.indices)..., length(fts.times))
@propagate_inbounds Base.getindex(f::FieldTimeSeries{LX, LY, LZ, InMemory}, i, j, k, n) where {LX, LY, LZ} = f.data[i, j, k, n]
function Base.getindex(fts::FieldTimeSeries{LX, LY, LZ, OnDisk}, n::Int) where {LX, LY, LZ}
# Load data
arch = architecture(fts)
file = jldopen(fts.data.path)
iter = keys(file["timeseries/t"])[n]
raw_data = arch_array(architecture(fts), file["timeseries/$(fts.data.name)/$iter"])
close(file)
# Wrap Field
loc = (LX, LY, LZ)
field_data = offset_data(raw_data, fts.grid, loc, fts.indices)
return Field(loc, fts.grid; indices=fts.indices, boundary_conditions=fts.boundary_conditions, data=field_data)
end
Base.setindex!(fts::FieldTimeSeries, val, inds...) = Base.setindex!(fts.data, val, inds...)
Base.parent(fts::FieldTimeSeries{LX, LY, LZ, OnDisk}) where {LX, LY, LZ} = nothing
#####
##### Basic support for reductions
#####
##### TODO: support for reductions across _time_ (ie when 4 ∈ dims)
#####
const FTS = FieldTimeSeries
for reduction in (:sum, :maximum, :minimum, :all, :any, :prod)
reduction! = Symbol(reduction, '!')
@eval begin
# Allocating
function Base.$(reduction)(f::Function, fts::FTS; dims=:, kw...)
if dims isa Colon
return Base.$(reduction)($(reduction)(f, fts[n]; kw...) for n in 1:length(fts.times))
else
T = filltype(Base.$(reduction!), fts)
loc = LX, LY, LZ = reduced_location(location(fts); dims)
times = fts.times
rts = FieldTimeSeries{LX, LY, LZ}(grid, times, T; indices=fts.indices)
return Base.$(reduction!)(f, rts, fts; kw...)
end
end
Base.$(reduction)(fts::FTS; kw...) = Base.$(reduction)(identity, fts; kw...)
function Base.$(reduction!)(f::Function,rts::FTS, fts::FTS; dims=:, kw...)
dims isa Tuple && 4 ∈ dims && error("Reduction across the time dimension (dim=4) is not yet supported!")
times = rts.times
for n = 1:length(times)
Base.$(reduction!)(f, rts[i], fts[i]; dims, kw...)
end
return rts
end
Base.$(reduction!)(rts::FTS, fts::FTS; kw...) = Base.$(reduction!)(identity, rts, fts; kw...)
end
end
#####
##### Show methods
#####
backend_str(::InMemory) = "InMemory"
backend_str(::OnDisk) = "OnDisk"
#####
##### show
#####
function Base.summary(fts::FieldTimeSeries{LX, LY, LZ, K}) where {LX, LY, LZ, K}
arch = architecture(fts)
A = typeof(arch)
return string("$(join(size(fts), "×")) FieldTimeSeries{$(backend_str(K()))} located at ", show_location(fts), " on ", A)
end
function Base.show(io::IO, fts::FieldTimeSeries)
prefix = string(summary(fts), '\n',
"├── grid: ", summary(fts.grid), '\n',
"├── indices: ", fts.indices, '\n')
suffix = string("└── data: ", summary(fts.data), '\n',
" └── ", data_summary(fts))
return print(io, prefix, suffix)
end
| [
3500,
7308,
25,
2488,
22930,
37861,
62,
259,
65,
3733,
198,
198,
3500,
3242,
2617,
3163,
20477,
198,
3500,
449,
11163,
17,
198,
198,
3500,
10692,
272,
34090,
13,
19895,
5712,
942,
198,
3500,
10692,
272,
34090,
13,
8642,
2340,
198,
3500,
10692,
272,
34090,
13,
15878,
82,
198,
198,
3500,
10692,
272,
34090,
13,
8642,
2340,
25,
1353,
1435,
11,
2472,
62,
7857,
11,
11087,
62,
8000,
62,
521,
1063,
11,
2560,
62,
9630,
62,
9521,
198,
3500,
10692,
272,
34090,
13,
15878,
82,
25,
905,
62,
24886,
11,
11087,
62,
1177,
62,
521,
1063,
11,
1366,
62,
49736,
11,
5322,
62,
24886,
198,
198,
11748,
10692,
272,
34090,
13,
15878,
82,
25,
7663,
11,
900,
28265,
11087,
11,
36525,
198,
11748,
10692,
272,
34090,
13,
19895,
5712,
942,
25,
10959,
198,
198,
7249,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
509,
11,
314,
11,
360,
11,
402,
11,
309,
11,
347,
11,
18074,
229,
92,
1279,
25,
27741,
15878,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
402,
11,
309,
11,
604,
92,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1366,
7904,
360,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10706,
7904,
402,
198,
220,
220,
220,
18645,
62,
17561,
1756,
7904,
347,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36525,
7904,
314,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1661,
7904,
18074,
229,
628,
220,
220,
220,
2163,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
509,
92,
7,
7890,
3712,
35,
11,
10706,
3712,
38,
11,
275,
6359,
3712,
33,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1661,
3712,
139,
229,
11,
36525,
3712,
40,
8,
810,
1391,
43,
55,
11,
406,
56,
11,
406,
57,
11,
509,
11,
360,
11,
402,
11,
347,
11,
18074,
229,
11,
314,
92,
198,
220,
220,
220,
220,
220,
220,
220,
309,
796,
1288,
4906,
7,
7890,
8,
220,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
649,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
509,
11,
314,
11,
360,
11,
402,
11,
309,
11,
347,
11,
18074,
229,
92,
7,
7890,
11,
10706,
11,
275,
6359,
11,
36525,
11,
1661,
8,
198,
220,
220,
220,
886,
198,
437,
198,
198,
998,
5712,
495,
7,
35594,
3712,
15878,
7575,
27996,
8,
796,
10959,
7,
35594,
13,
25928,
8,
198,
198,
4242,
2,
198,
4242,
2,
28407,
669,
198,
4242,
2,
198,
198,
37811,
198,
220,
220,
220,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
92,
7,
25928,
11,
1661,
11,
685,
9792,
28,
417,
4906,
7,
25928,
1776,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36525,
796,
357,
45299,
1058,
11,
1058,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18645,
62,
17561,
1756,
796,
2147,
8,
198,
198,
13615,
257,
4600,
15878,
7575,
27996,
63,
379,
4067,
4600,
7,
43,
55,
11,
406,
56,
11,
406,
57,
8,
47671,
319,
4600,
25928,
47671,
379,
4600,
22355,
44646,
198,
37811,
198,
8818,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
92,
7,
25928,
11,
1661,
11,
19446,
28,
417,
4906,
7,
25928,
1776,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36525,
796,
357,
45299,
1058,
11,
1058,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18645,
62,
17561,
1756,
796,
2147,
8,
810,
1391,
43,
55,
11,
406,
56,
11,
406,
57,
92,
628,
220,
220,
220,
399,
83,
796,
4129,
7,
22355,
8,
198,
220,
220,
220,
3934,
796,
10959,
7,
25928,
8,
198,
220,
220,
220,
1179,
796,
357,
43,
55,
11,
406,
56,
11,
406,
57,
8,
198,
220,
220,
220,
2272,
62,
7857,
796,
2472,
62,
7857,
7,
17946,
11,
10706,
11,
36525,
8,
198,
220,
220,
220,
10238,
62,
7890,
796,
1976,
27498,
7,
9792,
11,
3934,
11,
2272,
62,
7857,
986,
11,
399,
83,
8,
198,
220,
220,
220,
1366,
796,
11677,
62,
7890,
7,
4625,
3157,
62,
7890,
11,
10706,
11,
1179,
11,
36525,
8,
628,
220,
220,
220,
1441,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
554,
30871,
92,
7,
7890,
11,
10706,
11,
18645,
62,
17561,
1756,
11,
1661,
11,
36525,
8,
198,
437,
198,
198,
37811,
198,
220,
220,
220,
7663,
7575,
27996,
7,
6978,
11,
1438,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
30203,
796,
554,
30871,
22784,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10706,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
34820,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1661,
796,
2147,
8,
198,
198,
35561,
257,
4600,
15878,
7575,
27996,
63,
329,
262,
2214,
4600,
3672,
63,
12059,
257,
2214,
338,
640,
2106,
422,
257,
449,
11163,
17,
2393,
198,
75,
10533,
379,
4600,
6978,
44646,
198,
198,
9218,
4775,
7159,
198,
4770,
28,
198,
198,
12,
4600,
1891,
437,
63,
25,
4600,
818,
30871,
3419,
63,
284,
3440,
1366,
656,
257,
604,
35,
7177,
393,
4600,
2202,
40961,
3419,
63,
284,
37296,
813,
3440,
1366,
422,
11898,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
618,
6376,
278,
656,
4600,
15878,
7575,
27996,
44646,
198,
198,
12,
4600,
25928,
63,
25,
317,
10706,
284,
3917,
351,
1366,
11,
287,
262,
1339,
326,
262,
6868,
10706,
373,
407,
11389,
1143,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6105,
13,
198,
198,
12,
4600,
2676,
602,
63,
25,
40806,
602,
284,
3440,
13,
2896,
13185,
284,
477,
34820,
1043,
287,
262,
2393,
13,
198,
198,
12,
4600,
22355,
63,
25,
12793,
1661,
284,
3440,
11,
355,
5295,
832,
281,
27665,
12462,
966,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7208,
284,
6264,
3613,
1661,
13,
2896,
13185,
284,
1661,
3917,
351,
4600,
2676,
602,
44646,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
33687,
38177,
625,
4600,
2676,
602,
63,
611,
4600,
22355,
63,
318,
7368,
13,
198,
37811,
198,
15878,
7575,
27996,
7,
6978,
11,
1438,
26,
30203,
28,
818,
30871,
22784,
479,
86,
22046,
23029,
796,
198,
220,
220,
220,
7663,
7575,
27996,
7,
6978,
11,
1438,
11,
30203,
26,
479,
86,
22046,
23029,
198,
198,
4242,
2,
198,
4242,
2,
554,
30871,
640,
2168,
274,
198,
4242,
2,
198,
198,
9979,
554,
30871,
15878,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
92,
796,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
554,
30871,
92,
198,
198,
7249,
791,
23599,
49646,
560,
25559,
1756,
886,
198,
198,
8818,
7663,
7575,
27996,
7,
6978,
11,
1438,
11,
30203,
3712,
818,
30871,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10959,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10706,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4067,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18645,
62,
17561,
1756,
796,
791,
23599,
49646,
560,
25559,
1756,
22784,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
34820,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1661,
796,
2147,
8,
628,
220,
220,
220,
2393,
796,
474,
335,
9654,
7,
6978,
8,
628,
220,
220,
220,
1303,
2896,
13185,
198,
220,
220,
220,
318,
22366,
7,
2676,
602,
8,
220,
220,
11405,
357,
2676,
602,
796,
21136,
12195,
5317,
11,
8251,
7,
7753,
14692,
22355,
10640,
14,
83,
8973,
22305,
198,
220,
220,
220,
318,
22366,
7,
22355,
8,
220,
220,
220,
220,
220,
220,
220,
11405,
357,
22355,
220,
220,
220,
220,
220,
796,
685,
7753,
14692,
22355,
10640,
14,
83,
32624,
72,
8973,
329,
1312,
287,
34820,
12962,
198,
220,
220,
220,
318,
22366,
7,
24886,
8,
220,
220,
220,
220,
11405,
357,
24886,
220,
220,
796,
2393,
14692,
22355,
10640,
32624,
3672,
14,
46911,
1143,
14,
24886,
8973,
8,
628,
220,
220,
220,
611,
18645,
62,
17561,
1756,
318,
64,
791,
23599,
49646,
560,
25559,
1756,
198,
220,
220,
220,
220,
220,
220,
220,
18645,
62,
17561,
1756,
796,
2393,
14692,
22355,
10640,
32624,
3672,
14,
46911,
1143,
14,
7784,
560,
62,
17561,
1756,
8973,
198,
220,
220,
220,
886,
628,
220,
220,
220,
36525,
796,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
2393,
14692,
22355,
10640,
32624,
3672,
14,
46911,
1143,
14,
521,
1063,
8973,
198,
220,
220,
220,
4929,
198,
220,
220,
220,
220,
220,
220,
220,
357,
45299,
1058,
11,
14373,
198,
220,
220,
220,
886,
628,
220,
220,
220,
318,
22366,
7,
25928,
8,
11405,
357,
25928,
796,
2393,
14692,
46911,
1143,
14,
25928,
8973,
8,
628,
220,
220,
220,
1303,
15161,
284,
9135,
611,
6159,
10959,
4249,
10706,
318,
7368,
198,
220,
220,
220,
10959,
796,
318,
22366,
7,
998,
5712,
495,
8,
5633,
357,
271,
22366,
7,
25928,
8,
5633,
9135,
3419,
1058,
17340,
942,
13,
998,
5712,
495,
7,
25928,
4008,
1058,
10959,
628,
220,
220,
220,
1303,
770,
815,
307,
4615,
287,
257,
1227,
393,
734,
357,
19,
14,
20,
14,
1238,
1828,
737,
198,
220,
220,
220,
10706,
796,
1949,
198,
220,
220,
220,
220,
220,
220,
220,
319,
62,
998,
5712,
495,
7,
998,
5712,
495,
11,
10706,
8,
198,
220,
220,
220,
4929,
11454,
1303,
45974,
11,
262,
10706,
468,
14496,
3163,
20477,
287,
340,
986,
198,
220,
220,
220,
220,
220,
220,
220,
611,
10706,
318,
64,
48599,
346,
259,
451,
41339,
1303,
356,
460,
1949,
986,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
399,
87,
796,
2393,
14692,
25928,
14,
45,
87,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
17735,
796,
2393,
14692,
25928,
14,
45,
88,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
399,
89,
796,
2393,
14692,
25928,
14,
45,
89,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
367,
87,
796,
2393,
14692,
25928,
14,
39,
87,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6707,
796,
2393,
14692,
25928,
14,
21217,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26109,
796,
2393,
14692,
25928,
14,
7399,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
157,
114,
254,
39611,
225,
39611,
225,
796,
2393,
14692,
25928,
14,
87,
157,
114,
254,
39611,
225,
39611,
225,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
331,
39611,
225,
157,
114,
254,
39611,
225,
796,
2393,
14692,
25928,
14,
88,
39611,
225,
157,
114,
254,
39611,
225,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1976,
39611,
225,
39611,
225,
157,
114,
254,
796,
2393,
14692,
25928,
14,
89,
39611,
225,
39611,
225,
157,
114,
254,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2124,
796,
2393,
14692,
25928,
14,
138,
242,
87,
157,
114,
254,
39611,
225,
39611,
225,
8973,
318,
64,
7913,
5633,
357,
87,
157,
114,
254,
39611,
225,
39611,
225,
58,
16,
4357,
2124,
157,
114,
254,
39611,
225,
39611,
225,
58,
45,
87,
10,
16,
12962,
1058,
2124,
157,
114,
254,
39611,
225,
39611,
225,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
331,
796,
2393,
14692,
25928,
14,
138,
242,
88,
39611,
225,
157,
114,
254,
39611,
225,
8973,
318,
64,
7913,
5633,
357,
88,
39611,
225,
157,
114,
254,
39611,
225,
58,
16,
4357,
331,
39611,
225,
157,
114,
254,
39611,
225,
58,
45,
88,
10,
16,
12962,
1058,
331,
39611,
225,
157,
114,
254,
39611,
225,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1976,
796,
2393,
14692,
25928,
14,
138,
242,
89,
39611,
225,
39611,
225,
157,
114,
254,
8973,
318,
64,
7913,
5633,
357,
89,
39611,
225,
39611,
225,
157,
114,
254,
58,
16,
4357,
1976,
39611,
225,
39611,
225,
157,
114,
254,
58,
45,
89,
10,
16,
12962,
1058,
1976,
39611,
225,
39611,
225,
157,
114,
254,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1353,
78,
796,
1353,
1435,
7,
25928,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
44048,
329,
21939,
15225,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7386,
796,
34441,
51,
29291,
19510,
25,
87,
11,
1058,
88,
11,
1058,
89,
38381,
72,
60,
5218,
357,
87,
11,
331,
11,
1976,
38381,
72,
60,
329,
1312,
28,
16,
25,
18,
611,
1353,
78,
58,
72,
60,
5145,
855,
21939,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2546,
796,
309,
29291,
19510,
45,
87,
11,
17735,
11,
399,
89,
38381,
72,
60,
329,
1312,
28,
16,
25,
18,
611,
1353,
78,
58,
72,
60,
5145,
855,
21939,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
289,
7335,
796,
309,
29291,
19510,
39,
87,
11,
6707,
11,
26109,
38381,
72,
60,
329,
1312,
28,
16,
25,
18,
611,
1353,
78,
58,
72,
60,
5145,
855,
21939,
8,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
48599,
346,
259,
451,
41339,
7,
998,
5712,
495,
26,
2546,
11,
289,
7335,
11,
1353,
1435,
28,
4852,
78,
11,
7386,
23029,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3714,
7,
8056,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1969,
7,
7753,
8,
628,
220,
220,
220,
44988,
11,
406,
56,
11,
406,
57,
796,
4067,
198,
220,
220,
220,
640,
62,
25076,
796,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
92,
7,
25928,
11,
1661,
26,
36525,
11,
18645,
62,
17561,
1756,
8,
628,
220,
220,
220,
900,
0,
7,
2435,
62,
25076,
11,
3108,
11,
1438,
8,
628,
220,
220,
220,
1441,
640,
62,
25076,
198,
437,
198,
198,
14881,
13,
8000,
7,
35594,
3712,
15878,
7575,
27996,
8,
796,
2560,
7,
35594,
13,
7890,
8,
198,
198,
8818,
7308,
13,
1136,
9630,
7,
35594,
3712,
818,
30871,
15878,
7575,
27996,
11,
299,
3712,
5317,
8,
198,
220,
220,
220,
10238,
62,
7890,
796,
1570,
7,
8000,
7,
35594,
828,
1058,
11,
1058,
11,
1058,
11,
299,
8,
220,
198,
220,
220,
220,
1366,
796,
11677,
62,
7890,
7,
4625,
3157,
62,
7890,
11,
277,
912,
13,
25928,
11,
4067,
7,
35594,
828,
277,
912,
13,
521,
1063,
8,
198,
220,
220,
220,
18645,
62,
17561,
1756,
796,
277,
912,
13,
7784,
560,
62,
17561,
1756,
198,
220,
220,
220,
36525,
796,
277,
912,
13,
521,
1063,
198,
220,
220,
220,
1441,
7663,
7,
24886,
7,
35594,
828,
277,
912,
13,
25928,
26,
1366,
11,
18645,
62,
17561,
1756,
11,
36525,
8,
198,
437,
198,
198,
4242,
2,
198,
4242,
2,
900,
0,
198,
4242,
2,
198,
198,
37811,
198,
220,
220,
220,
7663,
7,
24886,
11,
3108,
11,
1438,
11,
11629,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10706,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10959,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36525,
796,
357,
45299,
1058,
11,
1058,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18645,
62,
17561,
1756,
796,
2147,
8,
198,
198,
8912,
257,
2214,
1444,
4600,
3672,
63,
7448,
287,
257,
449,
11163,
17,
2393,
379,
4600,
6978,
63,
379,
4600,
2676,
63,
341,
13,
198,
28042,
7368,
11,
262,
4600,
25928,
63,
318,
9639,
422,
4600,
6978,
44646,
198,
37811,
198,
8818,
7663,
7,
24886,
11,
3108,
3712,
10100,
11,
1438,
3712,
10100,
11,
11629,
26,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10706,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10959,
796,
2147,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36525,
796,
357,
45299,
1058,
11,
1058,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18645,
62,
17561,
1756,
796,
2147,
8,
628,
220,
220,
220,
2393,
796,
474,
335,
9654,
7,
6978,
8,
628,
220,
220,
220,
1303,
15161,
284,
9135,
611,
6159,
10959,
4249,
10706,
318,
7368,
198,
220,
220,
220,
10959,
796,
318,
22366,
7,
998,
5712,
495,
8,
5633,
198,
220,
220,
220,
220,
220,
220,
220,
357,
271,
22366,
7,
25928,
8,
5633,
9135,
3419,
1058,
17340,
942,
13,
998,
5712,
495,
7,
25928,
4008,
1058,
198,
220,
220,
220,
220,
220,
220,
220,
10959,
628,
220,
220,
220,
10706,
796,
318,
22366,
7,
25928,
8,
5633,
198,
220,
220,
220,
220,
220,
220,
220,
319,
62,
998,
5712,
495,
7,
998,
5712,
495,
11,
2393,
14692,
46911,
1143,
14,
25928,
8973,
8,
1058,
10706,
628,
220,
220,
220,
8246,
62,
7890,
796,
3934,
62,
18747,
7,
998,
5712,
495,
11,
2393,
14692,
22355,
10640,
32624,
3672,
32624,
2676,
8973,
8,
628,
220,
220,
220,
1969,
7,
7753,
8,
628,
220,
220,
220,
1366,
796,
11677,
62,
7890,
7,
1831,
62,
7890,
11,
10706,
11,
4067,
11,
36525,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
1441,
7663,
7,
24886,
11,
10706,
26,
18645,
62,
17561,
1756,
11,
36525,
11,
1366,
8,
198,
437,
198,
198,
8818,
900,
0,
7,
2435,
62,
25076,
3712,
818,
30871,
15878,
7575,
27996,
11,
3108,
3712,
10100,
11,
1438,
3712,
10100,
8,
628,
220,
220,
220,
2393,
796,
474,
335,
9654,
7,
6978,
8,
198,
220,
220,
220,
2393,
62,
2676,
602,
796,
21136,
12195,
5317,
11,
8251,
7,
7753,
14692,
22355,
10640,
14,
83,
8973,
4008,
198,
220,
220,
220,
2393,
62,
22355,
796,
685,
7753,
14692,
22355,
10640,
14,
83,
32624,
72,
8973,
329,
1312,
287,
2393,
62,
2676,
602,
60,
198,
220,
220,
220,
1969,
7,
7753,
8,
628,
220,
220,
220,
329,
357,
77,
11,
640,
8,
287,
27056,
378,
7,
2435,
62,
25076,
13,
22355,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2393,
62,
9630,
796,
1064,
11085,
7,
83,
4613,
256,
15139,
230,
640,
11,
2393,
62,
22355,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2393,
62,
2676,
796,
2393,
62,
2676,
602,
58,
7753,
62,
9630,
60,
628,
220,
220,
220,
220,
220,
220,
220,
2214,
62,
77,
796,
7663,
7,
24886,
7,
2435,
62,
25076,
828,
3108,
11,
1438,
11,
2393,
62,
2676,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36525,
796,
640,
62,
25076,
13,
521,
1063,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18645,
62,
17561,
1756,
796,
640,
62,
25076,
13,
7784,
560,
62,
17561,
1756,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10706,
796,
640,
62,
25076,
13,
25928,
8,
628,
220,
220,
220,
220,
220,
220,
220,
900,
0,
7,
2435,
62,
25076,
58,
77,
4357,
2214,
62,
77,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
8818,
900,
0,
7,
35594,
3712,
15878,
7575,
27996,
11,
7032,
62,
31364,
3712,
23839,
38469,
90,
27,
25,
23839,
15878,
30072,
198,
220,
220,
220,
8246,
62,
7890,
796,
2560,
7,
35594,
8,
198,
220,
220,
220,
2393,
796,
474,
335,
9654,
7,
6978,
8,
628,
220,
220,
220,
329,
357,
77,
11,
2214,
8,
287,
27056,
378,
7,
25747,
62,
31364,
8,
198,
220,
220,
220,
220,
220,
220,
220,
8246,
62,
7890,
58,
45299,
1058,
11,
1058,
11,
299,
60,
764,
28,
2560,
7,
3245,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
1969,
7,
7753,
8,
628,
220,
220,
220,
1441,
2147,
198,
437,
198,
198,
8818,
11087,
7,
35594,
3712,
15878,
7575,
27996,
8,
198,
220,
220,
220,
1179,
796,
4067,
7,
35594,
8,
198,
220,
220,
220,
1353,
78,
796,
1353,
1435,
7,
35594,
13,
25928,
8,
198,
220,
220,
220,
264,
89,
796,
2546,
7,
35594,
13,
25928,
8,
198,
220,
220,
220,
289,
7335,
62,
82,
89,
796,
289,
7335,
62,
7857,
7,
35594,
13,
25928,
8,
628,
220,
220,
220,
1312,
62,
3849,
1504,
796,
11087,
62,
8000,
62,
521,
1063,
12195,
17946,
11,
1353,
78,
11,
264,
89,
11,
289,
7335,
62,
82,
89,
8,
628,
220,
220,
220,
36525,
796,
277,
912,
13,
521,
1063,
198,
220,
220,
220,
1312,
62,
1177,
796,
11087,
62,
1177,
62,
521,
1063,
12195,
521,
1063,
11,
1312,
62,
3849,
1504,
8,
628,
220,
220,
220,
1441,
1570,
7,
8000,
7,
35594,
828,
1312,
62,
1177,
986,
11,
14373,
198,
437,
198,
198,
3849,
1504,
7,
35594,
3712,
15878,
7575,
27996,
11,
314,
23029,
796,
1570,
7,
3849,
1504,
7,
35594,
828,
314,
23029,
198,
198,
521,
1063,
7,
35594,
3712,
15878,
7575,
27996,
8,
796,
277,
912,
13,
521,
1063,
198,
198,
4242,
2,
198,
4242,
2,
1550,
40961,
640,
2168,
274,
198,
4242,
2,
198,
198,
7249,
1550,
40961,
6601,
198,
220,
220,
220,
3108,
7904,
10903,
198,
220,
220,
220,
1438,
7904,
10903,
198,
437,
198,
198,
8818,
7663,
7575,
27996,
7,
6978,
11,
1438,
11,
30203,
3712,
2202,
40961,
26,
10959,
28,
22366,
11,
10706,
28,
22366,
8,
198,
220,
220,
220,
2393,
796,
474,
335,
9654,
7,
6978,
8,
628,
220,
220,
220,
611,
318,
22366,
7,
25928,
8,
198,
220,
220,
220,
220,
220,
220,
220,
10706,
796,
319,
62,
998,
5712,
495,
7,
998,
5712,
495,
11,
2393,
14692,
46911,
1143,
14,
25928,
8973,
8,
198,
220,
220,
220,
886,
628,
220,
220,
220,
34820,
796,
21136,
12195,
5317,
11,
8251,
7,
7753,
14692,
22355,
10640,
14,
83,
8973,
4008,
198,
220,
220,
220,
1661,
796,
685,
7753,
14692,
22355,
10640,
14,
83,
32624,
72,
8973,
329,
1312,
287,
34820,
60,
628,
220,
220,
220,
1366,
796,
1550,
40961,
6601,
7,
6978,
11,
1438,
8,
198,
220,
220,
220,
44988,
11,
406,
56,
11,
406,
57,
796,
2393,
14692,
22355,
10640,
32624,
3672,
14,
46911,
1143,
14,
24886,
8973,
198,
220,
220,
220,
275,
6359,
796,
2393,
14692,
22355,
10640,
32624,
3672,
14,
46911,
1143,
14,
7784,
560,
62,
17561,
1756,
8973,
198,
220,
220,
220,
36525,
796,
2393,
14692,
22355,
10640,
32624,
3672,
14,
46911,
1143,
14,
521,
1063,
8973,
628,
220,
220,
220,
1969,
7,
7753,
8,
628,
220,
220,
220,
1441,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
1550,
40961,
92,
7,
7890,
11,
10706,
11,
275,
6359,
11,
1661,
11,
36525,
8,
198,
437,
198,
198,
4242,
2,
198,
4242,
2,
25458,
198,
4242,
2,
198,
198,
2,
40348,
262,
640,
15793,
13,
198,
31,
45145,
7308,
13,
7857,
7,
35594,
3712,
15878,
7575,
27996,
8,
796,
357,
7857,
7,
24886,
7,
35594,
828,
277,
912,
13,
25928,
11,
277,
912,
13,
521,
1063,
26513,
11,
4129,
7,
35594,
13,
22355,
4008,
198,
198,
31,
22930,
37861,
62,
259,
65,
3733,
7308,
13,
1136,
9630,
7,
69,
3712,
15878,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
554,
30871,
5512,
1312,
11,
474,
11,
479,
11,
299,
8,
810,
1391,
43,
55,
11,
406,
56,
11,
406,
57,
92,
796,
277,
13,
7890,
58,
72,
11,
474,
11,
479,
11,
299,
60,
198,
198,
8818,
7308,
13,
1136,
9630,
7,
35594,
3712,
15878,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
1550,
40961,
5512,
299,
3712,
5317,
8,
810,
1391,
43,
55,
11,
406,
56,
11,
406,
57,
92,
198,
220,
220,
220,
1303,
8778,
1366,
198,
220,
220,
220,
3934,
796,
10959,
7,
35594,
8,
198,
220,
220,
220,
2393,
796,
474,
335,
9654,
7,
35594,
13,
7890,
13,
6978,
8,
198,
220,
220,
220,
11629,
796,
8251,
7,
7753,
14692,
22355,
10640,
14,
83,
8973,
38381,
77,
60,
198,
220,
220,
220,
8246,
62,
7890,
796,
3934,
62,
18747,
7,
998,
5712,
495,
7,
35594,
828,
2393,
14692,
22355,
10640,
32624,
7,
35594,
13,
7890,
13,
3672,
20679,
3,
2676,
8973,
8,
198,
220,
220,
220,
1969,
7,
7753,
8,
628,
220,
220,
220,
1303,
41028,
7663,
198,
220,
220,
220,
1179,
796,
357,
43,
55,
11,
406,
56,
11,
406,
57,
8,
198,
220,
220,
220,
2214,
62,
7890,
796,
11677,
62,
7890,
7,
1831,
62,
7890,
11,
277,
912,
13,
25928,
11,
1179,
11,
277,
912,
13,
521,
1063,
8,
628,
220,
220,
220,
1441,
7663,
7,
17946,
11,
277,
912,
13,
25928,
26,
36525,
28,
35594,
13,
521,
1063,
11,
18645,
62,
17561,
1756,
28,
35594,
13,
7784,
560,
62,
17561,
1756,
11,
1366,
28,
3245,
62,
7890,
8,
198,
437,
198,
198,
14881,
13,
2617,
9630,
0,
7,
35594,
3712,
15878,
7575,
27996,
11,
1188,
11,
773,
82,
23029,
796,
7308,
13,
2617,
9630,
0,
7,
35594,
13,
7890,
11,
1188,
11,
773,
82,
23029,
198,
14881,
13,
8000,
7,
35594,
3712,
15878,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
1550,
40961,
30072,
810,
1391,
43,
55,
11,
406,
56,
11,
406,
57,
92,
796,
2147,
198,
198,
4242,
2,
198,
4242,
2,
14392,
1104,
329,
20691,
198,
4242,
2,
198,
4242,
2,
16926,
46,
25,
1104,
329,
20691,
1973,
4808,
2435,
62,
357,
494,
618,
604,
18872,
230,
5391,
82,
8,
198,
4242,
2,
198,
198,
9979,
376,
4694,
796,
7663,
7575,
27996,
198,
198,
1640,
7741,
287,
357,
25,
16345,
11,
1058,
47033,
11,
1058,
39504,
11,
1058,
439,
11,
1058,
1092,
11,
1058,
1676,
67,
8,
198,
220,
220,
220,
7741,
0,
796,
38357,
7,
445,
8110,
11,
705,
0,
11537,
628,
220,
220,
220,
2488,
18206,
2221,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
1439,
27123,
198,
220,
220,
220,
220,
220,
220,
220,
2163,
7308,
48082,
7,
445,
8110,
5769,
69,
3712,
22203,
11,
277,
912,
3712,
37,
4694,
26,
5391,
82,
28,
45299,
479,
86,
23029,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
5391,
82,
318,
64,
14049,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
7308,
48082,
7,
445,
8110,
5769,
3,
7,
445,
8110,
5769,
69,
11,
277,
912,
58,
77,
11208,
479,
86,
23029,
329,
299,
287,
352,
25,
13664,
7,
35594,
13,
22355,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
309,
796,
6070,
4906,
7,
14881,
48082,
7,
445,
8110,
26290,
277,
912,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1179,
796,
44988,
11,
406,
56,
11,
406,
57,
796,
5322,
62,
24886,
7,
24886,
7,
35594,
1776,
5391,
82,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1661,
796,
277,
912,
13,
22355,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
374,
912,
796,
7663,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
92,
7,
25928,
11,
1661,
11,
309,
26,
36525,
28,
35594,
13,
521,
1063,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
7308,
48082,
7,
445,
8110,
0,
5769,
69,
11,
374,
912,
11,
277,
912,
26,
479,
86,
23029,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
7308,
48082,
7,
445,
8110,
5769,
35594,
3712,
37,
4694,
26,
479,
86,
23029,
796,
7308,
48082,
7,
445,
8110,
5769,
738,
414,
11,
277,
912,
26,
479,
86,
23029,
628,
220,
220,
220,
220,
220,
220,
220,
2163,
7308,
48082,
7,
445,
8110,
0,
5769,
69,
3712,
22203,
11,
81,
912,
3712,
37,
4694,
11,
277,
912,
3712,
37,
4694,
26,
5391,
82,
28,
45299,
479,
86,
23029,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5391,
82,
318,
64,
309,
29291,
11405,
604,
18872,
230,
5391,
82,
11405,
4049,
7203,
7738,
8110,
1973,
262,
640,
15793,
357,
27740,
28,
19,
8,
318,
407,
1865,
4855,
2474,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1661,
796,
374,
912,
13,
22355,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
299,
796,
352,
25,
13664,
7,
22355,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7308,
48082,
7,
445,
8110,
0,
5769,
69,
11,
374,
912,
58,
72,
4357,
277,
912,
58,
72,
11208,
5391,
82,
11,
479,
86,
23029,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
886,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
374,
912,
198,
220,
220,
220,
220,
220,
220,
220,
886,
628,
220,
220,
220,
220,
220,
220,
220,
7308,
48082,
7,
445,
8110,
0,
5769,
81,
912,
3712,
37,
4694,
11,
277,
912,
3712,
37,
4694,
26,
479,
86,
23029,
796,
7308,
48082,
7,
445,
8110,
0,
5769,
738,
414,
11,
374,
912,
11,
277,
912,
26,
479,
86,
23029,
198,
220,
220,
220,
886,
198,
437,
198,
198,
4242,
2,
198,
4242,
2,
5438,
5050,
198,
4242,
2,
198,
198,
1891,
437,
62,
2536,
7,
3712,
818,
30871,
8,
796,
366,
818,
30871,
1,
198,
1891,
437,
62,
2536,
7,
3712,
2202,
40961,
8,
796,
366,
2202,
40961,
1,
198,
198,
4242,
2,
198,
4242,
2,
905,
198,
4242,
2,
198,
198,
8818,
7308,
13,
49736,
7,
35594,
3712,
15878,
7575,
27996,
90,
43,
55,
11,
406,
56,
11,
406,
57,
11,
509,
30072,
810,
1391,
43,
55,
11,
406,
56,
11,
406,
57,
11,
509,
92,
198,
220,
220,
220,
3934,
796,
10959,
7,
35594,
8,
198,
220,
220,
220,
317,
796,
2099,
1659,
7,
998,
8,
198,
220,
220,
220,
1441,
4731,
7203,
3,
7,
22179,
7,
7857,
7,
35594,
828,
366,
12906,
48774,
7663,
7575,
27996,
90,
3,
7,
1891,
437,
62,
2536,
7,
42,
3419,
4008,
92,
5140,
379,
33172,
905,
62,
24886,
7,
35594,
828,
366,
319,
33172,
317,
8,
198,
437,
198,
198,
8818,
7308,
13,
12860,
7,
952,
3712,
9399,
11,
277,
912,
3712,
15878,
7575,
27996,
8,
198,
220,
220,
220,
21231,
796,
4731,
7,
49736,
7,
35594,
828,
705,
59,
77,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
6552,
250,
8418,
10706,
25,
33172,
10638,
7,
35594,
13,
25928,
828,
705,
59,
77,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
6552,
250,
8418,
36525,
25,
33172,
277,
912,
13,
521,
1063,
11,
705,
59,
77,
11537,
628,
220,
220,
220,
35488,
796,
4731,
7203,
6552,
242,
8418,
1366,
25,
33172,
10638,
7,
35594,
13,
7890,
828,
705,
59,
77,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
220,
220,
220,
13305,
242,
8418,
33172,
1366,
62,
49736,
7,
35594,
4008,
628,
220,
220,
220,
1441,
3601,
7,
952,
11,
21231,
11,
35488,
8,
198,
437,
198
] | 2.244909 | 5,647 |
module LightGraphsMatching
using LightGraphs
using SparseArrays: spzeros
using JuMP
using MathProgBase: AbstractMathProgSolver
import BlossomV # 'using BlossomV' leads to naming conflicts with JuMP
using Hungarian
export MatchingResult, maximum_weight_matching, maximum_weight_maximal_matching, minimum_weight_perfect_matching, HungarianAlgorithm, LPAlgorithm
"""
struct MatchingResult{U}
weight::U
mate::Vector{Int}
end
A type representing the result of a matching algorithm.
weight: total weight of the matching
mate: `mate[i] = j` if vertex `i` is matched to vertex `j`.
`mate[i] = -1` for unmatched vertices.
"""
struct MatchingResult{U<:Real}
weight::U
mate::Vector{Int}
end
include("lp.jl")
include("maximum_weight_matching.jl")
include("blossomv.jl")
include("hungarian.jl")
include("maximum_weight_maximal_matching.jl")
end # module
| [
21412,
4401,
37065,
82,
44,
19775,
198,
198,
3500,
4401,
37065,
82,
198,
198,
3500,
1338,
17208,
3163,
20477,
25,
599,
9107,
418,
198,
198,
3500,
12585,
7378,
198,
3500,
16320,
2964,
70,
14881,
25,
27741,
37372,
2964,
70,
50,
14375,
198,
11748,
35544,
53,
1303,
705,
3500,
35544,
53,
6,
220,
5983,
284,
19264,
12333,
351,
12585,
7378,
198,
3500,
27304,
198,
198,
39344,
13225,
278,
23004,
11,
5415,
62,
6551,
62,
15699,
278,
11,
5415,
62,
6551,
62,
9806,
4402,
62,
15699,
278,
11,
5288,
62,
6551,
62,
25833,
62,
15699,
278,
11,
27304,
2348,
42289,
11,
18470,
2348,
42289,
198,
198,
37811,
198,
220,
220,
220,
2878,
13225,
278,
23004,
90,
52,
92,
198,
220,
220,
220,
220,
220,
220,
220,
3463,
3712,
52,
198,
220,
220,
220,
220,
220,
220,
220,
16133,
3712,
38469,
90,
5317,
92,
198,
220,
220,
220,
886,
198,
198,
32,
2099,
10200,
262,
1255,
286,
257,
12336,
11862,
13,
628,
220,
220,
220,
3463,
25,
2472,
3463,
286,
262,
12336,
628,
220,
220,
220,
16133,
25,
220,
220,
220,
4600,
9830,
58,
72,
60,
796,
474,
63,
611,
37423,
4600,
72,
63,
318,
14451,
284,
37423,
4600,
73,
44646,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4600,
9830,
58,
72,
60,
796,
532,
16,
63,
329,
48621,
9421,
1063,
13,
198,
37811,
198,
7249,
13225,
278,
23004,
90,
52,
27,
25,
15633,
92,
198,
220,
220,
220,
3463,
3712,
52,
198,
220,
220,
220,
16133,
3712,
38469,
90,
5317,
92,
198,
437,
198,
198,
17256,
7203,
34431,
13,
20362,
4943,
198,
17256,
7203,
47033,
62,
6551,
62,
15699,
278,
13,
20362,
4943,
198,
17256,
7203,
2436,
25548,
85,
13,
20362,
4943,
198,
17256,
7203,
43274,
3699,
13,
20362,
4943,
198,
17256,
7203,
47033,
62,
6551,
62,
9806,
4402,
62,
15699,
278,
13,
20362,
4943,
198,
198,
437,
1303,
8265,
198
] | 2.88254 | 315 |