# This file is a part of AstroLib.jl. License is MIT "Expat".
# Copyright (C) 2016 Mosè Giordano.

"""
List of locations of North Magnetic Pole since 1590.

This is provided by World Magnetic Model
(https://www.ngdc.noaa.gov/geomag/data/poles/NP.xy).
"""
const POLELATLONG =
    try
        let
            local polelatlong, rows, floattype, temp
            polelatlong = readdlm(joinpath(dirname(@__FILE__),
                                           "..", "deps", "NP.xy"))
            rows = size(polelatlong, 1)
            floattype = typeof(polelatlong[1])
            temp = Dict{floattype, Tuple{floattype, floattype}}()
            for i = 1:rows
                merge!(temp, Dict(polelatlong[2rows + i]=>
                                  (polelatlong[rows + i],
                                   polelatlong[i])))
            end
            temp
        end
    catch
        warn("""Could not find file NP.xy, you will not be able to use
"geo2mag" and "mag2geo" functions.  Build again the package with
    Pkg.build("AstroLib")
then restart Julia session in order to fix this problem.""")
    end

const AU = 1.495978707e11 # Astronomical unit in meters
const J2000 = jdcnv(2000, 01, 01, 12) # 2451545
const JULIANYEAR = 365.25 # days in Julian year

# Constant used in ct2lst function, see Meeus, p.84.
const ct2lst_c  = (280.46061837, 360.98564736629, 0.000387933, 38710000.0)

# Used in "bprecess" and "jprecess".
const A_precess  = 1e-6*[-1.62557, -0.31919, -0.13843] # In radians
const A_dot_precess = 0.001*[1.244 , -1.579, -0.660] # In arc seconds per century

"""
List of observing sites.  The observatories have `Observatory` type.
"""
const observatories =
    Dict("mgio"=>Observatory("Mount Graham International Observatory",
                             (32,42,04.69), (-109,53,31.25), 3191.0, -7),
         "whitin"=>Observatory("Whitin Observatory, Wellesley College",
                               42.295, -71.305833, 32, -5),
         "fmo"=>Observatory("Fan Mountain Observatory",
                            (37,52,41), (-78,41,34), 556, -5),
         "lmo"=>Observatory("Leander McCormick Observatory",
                            (38,02,00), (-78,31,24), 264, -5),
         "holi"=>Observatory("Observatorium Hoher List (Universitaet Bonn) - Germany",
                             50.16276, 6.85, 541, 1),
         "ca"=>Observatory("Calar Alto Observatory",
                           (37,13,25), (-2,32,46.5), 2168, 1),
         "bgsuo"=>Observatory("Bowling Green State Univ Observatory",
                              (41,22,42), (-83,39,33), 225., -5),
         "irtf"=>Observatory("NASA Infrared Telescope Facility",
                             19.826218, -155.471999, 4168, -10),
         "rozhen"=>Observatory("National Astronomical Observatory Rozhen - Bulgaria",
                               (41,41,35), (24,44,38), 1759, 2),
         "bosque"=>Observatory("Estacion Astrofisica Bosque Alegre, Cordoba",
                               (-31,35,54), (-64,32,45), 1250, -3),
         "casleo"=>Observatory("Complejo Astronomico El Leoncito, San Juan",
                               (-31,47,57), (-69,18,00), 2552, -3),
         "saao"=>Observatory("South African Astronomical Observatory",
                             (-32,22,46), (20,48,38.5), 1798., 2),
         "lna"=>Observatory("Laboratorio Nacional de Astrofisica - Brazil",
                            (-22,32,04), -45.5825, 1864., -3),
         "oro"=>Observatory("Oak Ridge Observatory",
                            (42,30,18.94), (-71,33,29.32), 184., -5),
         "flwo"=>Observatory("Whipple Observatory",
                             (31,40,51.4), (-110,52,39), 2320., -7),
         "vbo"=>Observatory("Vainu Bappu Observatory",
                            12.57666, 78.8266, 725., 5.5),
         "lowell"=>Observatory("Lowell Observatory",
                               (35,05.8), (-111,32.1), 2198., -7),
         "apo"=>Observatory("Apache Point Observatory",
                            (32,46.8), (-105,49.2), 2798., -7),
         "loiano"=>Observatory("Bologna Astronomical Observatory, Loiano - Italy",
                               (44,15,33), (11,20,2), 785., 1),
         "ekar"=>Observatory("Mt. Ekar 182 cm. Telescope",
                             (45,50,54.92), (11,34,52.08), 1413.69, 1),
         "keck"=>Observatory("W. M. Keck Observatory",
                             (19,49.7), (-155,28.7), 4160., -10),
         "bao"=>Observatory("Beijing XingLong Observatory",
                            (40,23.6), (117,34.5), 950., 8),
         "bmo"=>Observatory("Black Moshannon Observatory",
                            (40,55.3), (-78,00.3), 738., -5),
         "nov"=>Observatory("National Observatory of Venezuela",
                            (8,47.4), (-70,52.0), 3610, -4),
         "mdm"=>Observatory("Michigan-Dartmouth-MIT Observatory",
                            (31,57.0), (-111,37.0), 1938.5, -7),
         "palomar"=>Observatory("The Hale Telescope",
                                (33,21,21.6), (-116,51,46.80), 1706., -8),
         # https://en.wikipedia.org/wiki/Tonantzintla_Observatory
         "tona"=>Observatory("Observatorio Astronomico Nacional, Tonantzintla",
                             (19,01,58), (-98,18,50), 2166., -6),
         "spm"=>Observatory("Observatorio Astronomico Nacional, San Pedro Martir",
                            (31,01,45), (-115,29,13), 2830., -7),
         "dao"=>Observatory("Dominion Astrophysical Observatory",
                            (48,31.3), (-123,25.0), 229., -8),
         "mtbigelow"=>Observatory("Catalina Observatory: 61 inch telescope",
                                  (32,25.0), (-110,43.9), 2510., -7),
         "lco"=>Observatory("Las Campanas Observatory",
                            (-29,0.2), (-70,42.1), 2282, -4),
         "mcdonald"=>Observatory("McDonald Observatory",
                                 30.6716667, -104.0216667, 2075, -6),
         "aao"=>Observatory("Anglo-Australian Observatory",
                            (-31,16,37.34), (149,3,57.91), 1164, 10),
         "sso"=>Observatory("Siding Spring Observatory",
                            (-31,16,24.10), (149,3,40.3), 1149, 10),
         "mso"=>Observatory("Mt. Stromlo Observatory",
                            (-35,19,14.34), (149,1,27.6), 767, 10),
         "lapalma"=>Observatory("Roque de los Muchachos, La Palma",
                                (28,45.5), (-17,52.8), 2327, 0),
         "cfht"=>Observatory("Canada-France-Hawaii Telescope",
                             (19,49.6), (-155,28.3), 4215., -10),
         "mmto"=>Observatory("MMT Observatory",
                             (31,41.3), (-110,53.1), 2600., -7),
         "lick"=>Observatory("Lick Observatory",
                             (37,20.6), (-121,38.2), 1290., -8),
         "eso"=>Observatory("European Southern Observatory",
                            (-29,15.4), (-70,43.8), 2347., -4),
         "ctio"=>Observatory("Cerro Tololo Interamerican Observatory",
                             -30.16527778, -70.815, 2215., -4),
         "kpno"=>Observatory("Kitt Peak National Observatory",
                             (31,57.8), (-111,36.0), 2120., -7))

"""
List of planets of the Solar System, from Mercury to Pluto.  The elements of the
list have `Planet` type.

Reference for most quantities is the Planetary Fact Sheet:
http://nssdc.gsfc.nasa.gov/planetary/factsheet/index.html
"""
const planets =
    Dict("mercury"=>Planet("mercury", 2439.7e3, 2439.7e3, 2439.7e3, 3.3011e23,
                           0.20563069, 57909050e3, 87.9691*86400),
         "venus"=>Planet("venus", 6051.8e3, 6051.8e3, 6051.8e3, 4.8675e24,
                         0.00677323, 108208000e3, 224.701*86400),
         "earth"=>Planet("earth", 6371e3, 6378.137e3,  6356.752e3, 5.97237e24,
                         0.0167086, 149598023e3, 365.256363004*86400),
         "mars"=>Planet("mars", 3389.5e3, 3396.2e3, 3376.2e3, 3.3011e23,
                        0.09341233, 57909050e3, 87.9691*86400),
         "jupiter"=>Planet("jupiter", 69911e3, 71492e3, 66854e3, 1898.19e24,
                           0.04839266, 5.20336301*AU, 4332.589*86400),
         "saturn"=>Planet("saturn", 58232e3, 60268e3, 54364e3, 568.34e23,
                          0.05415060, 9.53707032*AU, 10759.22*86400),
         "uranus"=>Planet("uranus", 25362e3, 25559e3, 24973e3, 86.813e24,
                          0.04716771, 19.19126393*AU, 30685.4*86400),
         "neptune"=>Planet("neptune", 24622e3, 24764e3, 24341e3, 102.413e24,
                           0.00858587, 30.06896348*AU, 60189*86400),
         "pluto"=>Planet("pluto", 1187e3, 1187e3, 1187e3, 0.01303e24,
                         0.24880766, 39.48168677*AU, 90560*86400))


import Pkg
Pkg.rm(["Grids", "GridGames"])
Pkg.develop(["Grids", "GridGames"])
using MuZero
using Base.Threads: @spawn
include("game.jl")
include("muzero_config.jl")
config = getconfig(Tac)
config.num_actors = Threads.nthreads() - 3
include("inference_tests.jl")
pv_tests = makepolicyvaluetests(Tac)
pv_tests.period = 100
learner = Learner(
    config;
    uuid="435c256d-1c60-4e07-ac03-a2430ae7b7bd",
    dir="~/.julia/dev/MuZeroModels/tictactoe/",
    tests=[pv_tests],
    schedule=tacschedule!
)
@spawn play!(learner)
res = @spawn fit!(learner; steps=1000000)


# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test, LinearAlgebra, SparseArrays
let ambig = detect_ambiguities(LinearAlgebra; recursive=true)
    @test_broken isempty(ambig)
    ambig = Set{Any}(((m1.sig, m2.sig) for (m1, m2) in ambig))
    expect = []

    push!(expect, (Tuple{typeof(\),Factorization{T},Union{Array{Complex{T},1}, Array{Complex{T},2}}} where T<:Union{Float32, Float64}, Tuple{typeof(\),Union{QR{TA,S} where S<:AbstractMatrix{TA}, LinearAlgebra.QRCompactWY{TA,M} where M<:AbstractMatrix{TA}, QRPivoted{TA,S} where S<:AbstractMatrix{TA}},AbstractVecOrMat{TB}} where TB where TA))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{T,var"#s843"} where var"#s843"<:(LU{T,var"#s842"} where var"#s842"<:(StridedMatrix{T} where T)),StridedVecOrMat{T}} where T<:Real, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{T,var"#s843"} where var"#s843"<:(LU{T,var"#s842"} where var"#s842"<:(StridedMatrix{T} where T)),StridedVecOrMat{T}} where T<:Real, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{T,var"#s843"} where var"#s843"<:(LU{T,var"#s842"} where var"#s842"<:(StridedMatrix{T} where T)),StridedVecOrMat{T}} where T<:Real, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{T,var"#s843"} where var"#s843"<:(LU{T,var"#s842"} where var"#s842"<:(StridedMatrix{T} where T)),StridedVecOrMat{T}} where T<:Real, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:Hessenberg where var"#s843",AbstractVecOrMat{T} where T}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(LowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:Hessenberg where var"#s843",AbstractVecOrMat{T} where T}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitLowerTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:Hessenberg where var"#s843",AbstractVecOrMat{T} where T}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UnitUpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:Hessenberg where var"#s843",AbstractVecOrMat{T} where T}, Tuple{typeof(ldiv!),Adjoint{var"#s806",var"#s805"} where var"#s805"<:(UpperTriangular{T,var"#s804"} where var"#s804"<:(StridedMatrix{T} where T)) where var"#s806",StridedVecOrMat{T}} where T<:Union{ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Adjoint{var"#s843",var"#s842"} where var"#s842"<:Hessenberg where var"#s843",AbstractVecOrMat{T} where T}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(Diagonal{T,V} where V<:AbstractVector{T}) where var"#s843",AbstractVecOrMat{T}} where T, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:(LU{var"#s841",var"#s840"} where var"#s840"<:(StridedMatrix{T} where T) where var"#s841") where var"#s843",StridedVecOrMat{T} where T}, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:LU{T,Tridiagonal{T,V}} where var"#s843",AbstractVecOrMat{T} where T} where V where T, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(LowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:LU{T,Tridiagonal{T,V}} where var"#s843",AbstractVecOrMat{T} where T} where V where T, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitLowerTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:LU{T,Tridiagonal{T,V}} where var"#s843",AbstractVecOrMat{T} where T} where V where T, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UnitUpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:LU{T,Tridiagonal{T,V}} where var"#s843",AbstractVecOrMat{T} where T} where V where T, Tuple{typeof(ldiv!),Transpose{var"#s812",var"#s811"} where var"#s811"<:(UpperTriangular{T,var"#s810"} where var"#s810"<:(StridedMatrix{T} where T)) where var"#s812",StridedVecOrMat{T}} where T<:Union{Float32, Float64, ComplexF32, ComplexF64}))
    push!(expect, (Tuple{typeof(ldiv!),Transpose{var"#s843",var"#s842"} where var"#s842"<:LU{T,Tridiagonal{T,V}} where var"#s843",AbstractVecOrMat{T} where T} where V where T, Tuple{typeof(ldiv!),Union{Adjoint{T,var"#s843"} where var"#s843"<:(UpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitUpperTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s843"} where var"#s843"<:(LowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Adjoint{T,var"#s841"} where var"#s841"<:(UnitLowerTriangular{T,var"#s840"} where var"#s840"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), LowerTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), Transpose{T,var"#s839"} where var"#s839"<:(UpperTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitUpperTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s839"} where var"#s839"<:(LowerTriangular{T,var"#s838"} where var"#s838"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), Transpose{T,var"#s837"} where var"#s837"<:(UnitLowerTriangular{T,var"#s836"} where var"#s836"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)), UnitLowerTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UnitUpperTriangular{T,var"#s842"} where var"#s842"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti), UpperTriangular{T,var"#s843"} where var"#s843"<:(Union{SparseArrays.AbstractSparseMatrixCSC{T,Ti}, SubArray{T,2,var"#s843",Tuple{Base.Slice{Base.OneTo{Int}},I},L} where L where var"#s843"<:SparseArrays.AbstractSparseMatrixCSC{T,Ti} where I<:AbstractUnitRange} where Ti)},StridedVecOrMat{T}} where T))

    good = true
    while !isempty(ambig)
        sigs = pop!(ambig)
        i = findfirst(==(sigs), expect)
        if i === nothing
            println(stderr, "push!(expect, (", sigs[1], ", ", sigs[2], "))")
            good = false
            continue
        end
        deleteat!(expect, i)
    end
    @test isempty(expect)
    @test good
end


# This file is a part of TextSearch.jl

export TextModel, VectorModel,
    TfWeighting, IdfWeighting, TpWeighting,
    FreqWeighting, BinaryLocalWeighting, BinaryGlobalWeighting,
    LocalWeighting, GlobalWeighting,
    fit, vectorize, vectorize_corpus, prune, prune_select_top

#####
##
## LocalWeighting
##
#####
"""
    LocalWeighting

Abstract type for local weighting
"""
abstract type LocalWeighting end

"""
    TfWeighting()

Term frequency weighting
"""
struct TfWeighting <: LocalWeighting end

"""
    TpWeighting()

Term probability weighting
"""
struct TpWeighting <: LocalWeighting end

"""
    FreqWeighting()

Frequency weighting
"""
struct FreqWeighting <: LocalWeighting end

"""
    BinaryLocalWeighting()

The weight is 1 for known tokens, 0 for out of vocabulary tokens
"""
struct BinaryLocalWeighting <: LocalWeighting end

#####
##
## GlobalWeighting
##
#####
"""
    GlobalWeighting

Abstract type for global weighting
"""
abstract type GlobalWeighting end

"""
    IdfWeighting()

Inverse document frequency weighting
"""
struct IdfWeighting <: GlobalWeighting end

"""
    BinaryGlobalWeighting()

The weight is 1 for known tokens, 0 for out of vocabulary tokens
"""
struct BinaryGlobalWeighting <: GlobalWeighting end

#####
##
## TextModels
##
#####
"""
    Model

An abstract type that represents a weighting model
"""
abstract type TextModel end

"""
    TokenStats(occs, ndocs)

Stores useful information for a token; i.e., the number of occurrences in the collection, the number of documents having that token
"""
struct TokenStats
    occs::Int32
    ndocs::Int32
    weight::Float32
end

const UnknownTokenStats = TokenStats(0, 0, 0f0)

const Vocabulary = Dict{UInt64, TokenStats}

mutable struct VectorModel{_G<:GlobalWeighting, _L<:LocalWeighting} <: TextModel
    global_weighting::_G
    local_weighting::_L
    tokens::Vocabulary
    maxfreq::Int
    m::Int  # vocabulary size
    n::Int  # training collection size
end

function Base.copy(
        e::VectorModel;
        local_weighting=e.local_weighting,
        global_weighting=e.global_weighting,
        tokens=e.tokens,
        maxfreq=e.maxfreq,
        m=e.m,
        n=e.n
    )
    VectorModel(global_weighting, local_weighting, tokens, maxfreq, m, n)
end

function create_vocabulary(corpus)
    V = Vocabulary()
    for tokenlist in corpus
        for (token, occs) in tokenlist
            s = get(V, token, UnknownTokenStats)
            V[token] = TokenStats(s.occs + occs, s.ndocs + 1, 0f0)
        end
    end

    V
end

"""
    VectorModel(global_weighting::GlobalWeighting, local_weighting::LocalWeighting, corpus; mindocs=1)

Creates a vector model using the input corpus.
"""
function VectorModel(global_weighting::GlobalWeighting, local_weighting::LocalWeighting, corpus; mindocs=1)
    tokens = Vocabulary()

    tokens = Vocabulary()
    maxfreq = 0
    for (t, s) in create_vocabulary(corpus)
        s.ndocs < mindocs && continue
        tokens[t] = TokenStats(s.occs, s.ndocs, 0.0f0)
        maxfreq = max(maxfreq, s.occs)
    end

    VectorModel(global_weighting, local_weighting, tokens, maxfreq, length(tokens), length(corpus))
end

Base.show(io::IO, model::VectorModel) = print(io, "{VectorModel global_weighting=$(model.global_weighting), local_weighting=$(model.local_weighting), train-voc=$(model.m), train-n=$(model.n), maxfreq=$(model.maxfreq)}")

"""
    prune(model::VectorModel, lowerweight::AbstractFloat)

Creates a new vector model without terms with smaller global weights than `lowerweight`.
"""
function prune(model::VectorModel, lowerweight::AbstractFloat)
    tokens = Vocabulary()
    for (token, s) in model.tokens
        if prune_global_weighting(model, s) >= lowerweight
            tokens[token] = TokenStats(s.occs, s.ndocs, s.weight)
        end
    end

    VectorModel(model.global_weighting, model.local_weighting, tokens, model.maxfreq, model.m, model.n)
end

"""
    prune_select_top(model::VectorModel, k::Integer)
    prune_select_top(model::VectorModel, ratio::AbstractFloat)

Creates a new vector model with the best `k` tokens from `model` based on global weighting.
`ratio` is a floating point between 0 and 1 indicating the ratio of the vocabulary to be kept
"""
function prune_select_top(model::VectorModel, k::Integer)
    w = [prune_global_weighting(model, s) for (token, s) in model.tokens]
    sort!(w, rev=true)
    prune(model, Float64(w[k]))
end

prune_select_top(model::VectorModel, ratio::AbstractFloat) = prune_select_top(model, floor(Int, length(model.tokens) * ratio))

"""
    vectorize(model::VectorModel, bow::BOW, maxfreq::Integer=maximum(bow); normalize=true) where Tv<:Real

Computes a weighted vector using the given bag of words and the specified weighting scheme.
"""
function vectorize(model::VectorModel{_G, _L}, bow::BOW; normalize=true) where {_L,_G}
    numtokens = 0.0
    if _L === TpWeighting
        for (token, freq) in bow
            numtokens += freq
        end
    end

    maxfreq = (_L === TfWeighting) ? maximum(bow) : 0.0
    vec = SVEC()

    for (token, freq) in bow
        s = get(model.tokens, token, nothing)
        s === nothing && continue

        w = local_weighting(model.local_weighting, freq, maxfreq, numtokens) * global_weighting(model, s)
        if w > 1e-9
            vec[token] = w
        end
    end

    if length(vec) == 0
        # error("empty final vector: the original vector has $(length(bow)) features")
        vec[0] = 1e-9
    end

    normalize && normalize!(vec)
    vec
end

function vectorize(tok::Tokenizer, model::VectorModel, text; bow=BOW(), normalize=true)
    compute_bow(tok, text, bow)
    v = vectorize(model, bow; normalize=normalize)
    # if length(v) == 1 && haskey(v, 0)
    #     @info "empty vector"
    # end
    v
end

function vectorize_corpus(tok::Tokenizer, model::VectorModel, corpus; bow=BOW(), normalize=true)
    V = Vector{SVEC}(undef, length(corpus))

    for (i, text) in enumerate(corpus)
        empty!(bow)
        V[i] = vectorize(tok, model, text; bow=bow, normalize=normalize)
    end

    V
end

function broadcastable(model::VectorModel)
    (model,)
end

# local weightings: TfWeighting, TpWeighting, FreqWeighting, BinaryLocalWeighting
# global weightings: IdfWeighting, BinaryGlobalWeighting

local_weighting(::TfWeighting, occs, maxfreq, numtokens) = occs / maxfreq
local_weighting(::FreqWeighting, occs, maxfreq, numtokens) = occs
local_weighting(::TpWeighting, occs, maxfreq, numtokens) = occs / numtokens
local_weighting(::BinaryLocalWeighting, occs, maxfreq, numtokens) = 1.0
global_weighting(m::VectorModel{IdfWeighting}, s::TokenStats) = log2(1 + m.n / s.ndocs)
global_weighting(m::VectorModel{BinaryGlobalWeighting}, s::TokenStats) = 1.0
prune_global_weighting(m::VectorModel, s) = global_weighting(m, s)
prune_global_weighting(m::VectorModel{BinaryGlobalWeighting}, s) = -s.ndocs