licenses
sequencelengths
1
3
version
stringclasses
677 values
tree_hash
stringlengths
40
40
path
stringclasses
1 value
type
stringclasses
2 values
size
stringlengths
2
8
text
stringlengths
25
67.1M
package_name
stringlengths
2
41
repo
stringlengths
33
86
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
1515
model, model0, q, q1, q2, state0, state1, tstep = test_config(); ## set up modeling operator S0 = jutulModeling(model0, tstep) S = jutulModeling(model, tstep) ## simulation x = log.(KtoTrans(CartesianMesh(model), model.K)) x0 = log.(KtoTrans(CartesianMesh(model0), model0.K)) ϕ = S.model.ϕ states = S(x, ϕ, q) misfit(x0, ϕ, q, states) = 0.5 * norm(S0(x0, ϕ, q) - states).^2 g = gradient(()->misfit(x0, ϕ, q, states), Flux.params(x0, ϕ)) dx = randn(MersenneTwister(2023), length(x0)) dx = dx/norm(dx) * norm(x0)/5.0 dϕ = randn(MersenneTwister(2023), length(ϕ)) ϕmask = ϕ .< 1 dϕ[.!ϕmask] .= 0 dϕ[ϕmask] = dϕ[ϕmask]/norm(dϕ[ϕmask]) * norm(ϕ[ϕmask]) dϕ = vec(dϕ) @testset "Taylor-series gradient test of jutulModeling with wells" begin grad_test(x0->misfit(x0, ϕ, q, states), x0, dx, g[x0]) grad_test(ϕ->misfit(x0, ϕ, q, states), ϕ, dϕ, g[ϕ]) end states1 = S(x, ϕ, q1) g1 = gradient(()->misfit(x0, ϕ, q1, states1), Flux.params(x0, ϕ)) @testset "Taylor-series gradient test of simple jutulModeling" begin grad_test(x0->misfit(x0, ϕ, q1, states1), x0, dx, g1[x0]) grad_test(ϕ->misfit(x0, ϕ, q1, states1), ϕ, dϕ, g1[ϕ]) end states2 = S(x, q2) g2 = gradient(()->misfit(x0, ϕ, q2, states2), Flux.params(x0, ϕ)) @testset "Taylor-series gradient test of jutulModeling with vertical wells" begin # This test is very brittle. There may be an issue here. grad_test(x0->misfit(x0, ϕ, q2, states2), x0, dx, g2[x0]) grad_test(ϕ->misfit(x0, ϕ, q2, states2), ϕ, dϕ, g2[ϕ]; unittest=:skip) end
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
378
@testset "Test jutulForce" begin d = (1.0, 20.0, 3.0) inj_loc = (3, 1, 9) .* d prod_loc = (28, 1, 9) .* d irate = rand() q = jutulForce(irate, [inj_loc, prod_loc]) q1 = jutulForce(irate, [inj_loc]) @test q != q1 @test q.irate == q1.irate @test q.loc[1] == q1.loc[1] @test q.name[1] == q1.name[1] @test q.name[2] == :Producer end
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
438
@testset "Test jutulModel" begin @info "set up model" n = (rand(3:5), rand(3:5), rand(3:5)) d = 10 .* (rand(), rand(), rand()) K = 200 * rand() * md * ones(n) ϕ = rand() model = jutulModel(n, d, ϕ, K1to3(K); pad=false) @test model.n == n @test model.d == d @test all(model.ϕ .== ϕ) @test model.K == K1to3(K) model1 = jutulModel(n, d, ϕ, K1to3(K); pad=false) @test model1 == model end
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
2215
model, model0, q, q1, q2, init_state, init_state1, tstep = test_config(); ## set up modeling operator S = jutulModeling(model, tstep) ## simulation x = log.(KtoTrans(CartesianMesh(model), model.K)) x0 = log.(KtoTrans(CartesianMesh(model0), model0.K)) @testset "Test mass conservation for well modeling" begin states = S(x, q) for i = 1:length(states.states) exist_co2 = sum(Saturations(states.states[i]) .* states.states[i].state[:Reservoir][:PhaseMassDensities][1,:] .* model.ϕ) * prod(model.d) inj_co2 = JutulDarcyRules.ρCO2 * q.irate * JutulDarcyRules.day * sum(tstep[1:i]) @test isapprox(exist_co2, inj_co2) rtol=1e-3 end end @testset "Test mass conservation for simple modeling" begin states = S(x, q1) for i = 1:length(states.states) exist_co2 = sum(Saturations(states.states[i]) .* states.states[i].state[:PhaseMassDensities][1,:] .* model.ϕ) * prod(model.d) inj_co2 = JutulDarcyRules.ρCO2 * q.irate * JutulDarcyRules.day * sum(S.tstep[1:i]) @test isapprox(exist_co2, inj_co2) rtol=1e-3 end end @testset "Test mass conservation for well modeling, different injection rates" begin states = S(x, q) pre_co2 = sum(Saturations(states.states[end]) .* states.states[end].state[:Reservoir][:PhaseMassDensities][1,:] .* model.ϕ) * prod(model.d) q2 = jutulForce(q.irate * 0.5, q.loc) S.tstep ./= 2 states_end = S(x, q2; state0=states) for i = 1:length(states_end.states) exist_co2 = sum(Saturations(states_end.states[i]) .* states_end.states[i].state[:Reservoir][:PhaseMassDensities][1,:] .* model.ϕ) * prod(model.d) inj_co2 = JutulDarcyRules.ρCO2 * q2.irate * JutulDarcyRules.day * sum(S.tstep[1:i]) @test isapprox(exist_co2-pre_co2, inj_co2) rtol=1e-3 end end @testset "Test mass conservation for vertical well modeling" begin states = S(x, q2) for i = 1:length(states.states) exist_co2 = sum(Saturations(states.states[i]) .* states.states[i].state[:Reservoir][:PhaseMassDensities][1,:] .* model.ϕ) * prod(model.d) inj_co2 = JutulDarcyRules.ρCO2 * q.irate * JutulDarcyRules.day * sum(tstep[1:i]) @test isapprox(exist_co2, inj_co2) rtol=1e-3 end end
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
379
@testset "Test jutulSource" begin d = (1.0, 20.0, 3.0) inj_loc = (3, 1, 9) .* d prod_loc = (28, 1, 9) .* d irate = rand() q = jutulForce(irate, [inj_loc, prod_loc]) q1 = jutulForce(irate, [inj_loc]) @test q != q1 @test q.irate == q1.irate @test q.loc[1] == q1.loc[1] @test q.name[1] == q1.name[1] @test q.name[2] == :Producer end
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
924
model, model0, q, q1, q2, init_state, init_state_simple, tstep = test_config(); @testset "Test jutulState" begin @info "length, size" @test size(init_state) == (length(init_state),) @test length(init_state) == length(vec(init_state)) @info "getindex, setindex!" rdm_idx = randperm(length(init_state))[1:5] rdm_num = rand(5) init_state[rdm_idx] = rdm_num @test init_state[rdm_idx] == rdm_num @test vec(init_state) == init_state[1:end] @info "test ==" init_state1 = deepcopy(init_state) init_state1[1] = 0.2 @test init_state1 != init_state init_state[1] = 0.2 @test init_state1 == init_state @info "test dict" dict(init_state) == init_state.state @info "test translation" half_init_state = init_state(vec(init_state) ./ 2) JutulDarcyRules.check_valid_state(half_init_state) @test vec(half_init_state) == 0.5 * vec(init_state) end
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
382
@testset "Test jutulVWell" begin d = (1.0, 20.0, 3.0) inj_loc = (3, 1) .* d[1:2] prod_loc = (28, 1) .* d[1:2] irate = rand() q = jutulVWell(irate, [inj_loc, prod_loc]) q1 = jutulVWell(irate, [inj_loc]) @test q != q1 @test q.irate == q1.irate @test q.loc[1] == q1.loc[1] @test q.name[1] == q1.name[1] @test q.name[2] == :Producer end
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
830
model, model0, q, q1, q2, init_state, init_state1, tstep = test_config(); @testset "Test parameters" begin visCO2 = 5e-5 visH2O = 3e-3 ρCO2 = 6e-7 ρH2O = 7e-4 jutul_model, parameters, state0, forces = JutulDarcyRules.setup_well_model(model, q, tstep; visCO2=visCO2, visH2O=visH2O, ρCO2=ρCO2, ρH2O=ρH2O) @test all(parameters[:Reservoir][:PhaseViscosities][1, :] .== visCO2) @test all(parameters[:Reservoir][:PhaseViscosities][2, :] .== visH2O) @test jutul_model.models.Reservoir.system.rho_ref[1] == ρCO2 @test jutul_model.models.Reservoir.system.rho_ref[2] == ρH2O @test jutul_model.models.Reservoir.secondary_variables[:PhaseMassDensities].reference_densities[1] == ρCO2 @test jutul_model.models.Reservoir.secondary_variables[:PhaseMassDensities].reference_densities[2] == ρH2O end
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
code
801
function test_config() n = (30, 1, 15) d = (30.0, 30.0, 30.0) ## permeability K0 = 40 * md * ones(n) ϕ = 0.25 K = deepcopy(K0) K[:,:,1:2:end] .*= 40 model0 = jutulModel(n, d, ϕ, K1to3(K0)) model = jutulModel(n, d, ϕ, K1to3(K)) ## simulation time steppings tstep = 50 * ones(10) ## injection & production inj_loc = (15, 1, 10) .* d prod_loc = (30, 1, 10) .* d irate = 5e-3 q = jutulForce(irate, inj_loc) q1 = jutulSource(irate, [inj_loc, prod_loc]) q2 = jutulVWell(irate, inj_loc[1:2]; startz = 9 * d[3], endz = 11 * d[3]) state0 = jutulState(JutulDarcyRules.setup_well_model(model, q, tstep)[3]) state1 = jutulSimpleState(model) return model, model0, q, q1, q2, state0, state1, tstep end include("grad_test.jl")
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
0.2.8
da37b282ff5919181ee4c1eae2ad7665e9af3702
docs
2614
<h1 align="center">JutulDarcyRules: auto-differentiable two-phase flow solvers based on Jutul and JutulDarcy</h1> [![][license-img]][license-status] [![][zenodo-img]][zenodo-status] Interoperate [Jutul.jl] and [JutulDarcy.jl] to other Julia packages via [ChainRules.jl] ## LICENSE The software used in this repository can be modified and redistributed according to [MIT license](LICENSE). ## Papers The following publications use [JutulDarcyRules.jl]: - **"Time-lapse full-waveform permeability inversion: a feasibility study"**, doi: [10.48550/arXiv.2403.04083](https://doi.org/10.48550/arXiv.2403.04083) - **"A Digital Twin for Geological Carbon Storage with Controlled Injectivity"**, doi: [10.48550/arXiv.2403.19819](https://doi.org/10.48550/arXiv.2403.19819) - **BEACON: Bayesian Experimental design Acceleration with Conditional Normalizing flows – a case study in optimal monitor well placement for CO2 sequestration**, doi: [10.48550/arXiv.2404.00075](https://doi.org/10.48550/arXiv.2404.00075) - **"Inference of CO2 flow patterns -- a feasibility study"**, doi: [10.48550/arXiv.2311.00290](https://doi.org/10.48550/arXiv.2311.00290) - **"Solving multiphysics-based inverse problems with learned surrogates and constraints"**, doi: [10.1186/s40323-023-00252-0](https://doi.org/10.1186/s40323-023-00252-0) - **"Learned multiphysics inversion with differentiable programming and machine learning"**, doi: [10.1190/tle42070474.1](https://library.seg.org/doi/10.1190/tle42070474.1) ## Reference If you use our software for your research, we appreciate it if you cite us following the bibtex in [CITATION.bib](CITATION.bib). ## Authors This repository is written by Ziyi Yin from the [Seismic Laboratory for Imaging and Modeling](https://slim.gatech.edu/) (SLIM) at the Georgia Institute of Technology. If you have any question, we welcome your contributions to our software by opening issue or pull request. SLIM Group @ Georgia Institute of Technology, [https://slim.gatech.edu](https://slim.gatech.edu/). SLIM public GitHub account, [https://github.com/slimgroup](https://github.com/slimgroup). [Jutul.jl]:https://github.com/sintefmath/Jutul.jl [JutulDarcy.jl]:https://github.com/sintefmath/JutulDarcy.jl [JutulDarcyRules.jl]:https://github.com/slimgroup/JutulDarcyRules.jl [ChainRules.jl]:https://github.com/JuliaDiff/ChainRules.jl [license-status]:LICENSE [license-img]:http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat?style=plastic [zenodo-status]:https://zenodo.org/badge/latestdoi/594128866 [zenodo-img]:https://zenodo.org/badge/594128866.svg?style=plastic
JutulDarcyRules
https://github.com/slimgroup/JutulDarcyRules.jl.git
[ "MIT" ]
1.2.1
d70afeec1ca9f432fa55157aa65790ea7abcb6db
code
246
module CavityTools import Random export Accumulator, CumSum, Cavity, cavity, cavity!, ExponentialQueue, ExponentialQueueDict, peekevent include("accumulator.jl") include("cumsum.jl") include("cavity.jl") include("exponentialqueue.jl") end
CavityTools
https://github.com/abraunst/CavityTools.jl.git
[ "MIT" ]
1.2.1
d70afeec1ca9f432fa55157aa65790ea7abcb6db
code
2579
""" An `a = Accumulator(v::AbstractVector; op=+, init=zero)` works as a replacement for `v` with extra tracking computation, such as `sum`. See also `CumSum` and `Cavity` ``` julia> a = Accumulator([1:10;]) 10-element Accumulator{Int64, +, zero}: 1 2 3 4 5 6 7 8 9 10 julia> sum(a) 55 julia> a[1]=0 0 julia> sum(a) 54 ``` """ struct Accumulator{T,op,init} <: AbstractVector{T} sums::Vector{Vector{T}} function Accumulator(vals::AbstractVector{T}; op=+, init=zero) where T a = new{T,op,init}([T[]]) for x in vals push!(a, x) end return a end end Accumulator() = Accumulator(Float64) Accumulator(::Type{T}) where T = Accumulator(T[]) Accumulator{T}() where {T} = Accumulator(T) Base.length(a::Accumulator) = length(a.sums[1]) Base.size(a::Accumulator) = tuple(length(a)) Base.lastindex(a::Accumulator) = lastindex(a.sums[1]) Base.:(==)(a::Accumulator, v::AbstractVector) = a.sums[1] == v Base.:(==)(v::AbstractVector, a::Accumulator) = a.sums[1] == v function Base.push!(a::Accumulator{T,op,init}, v) where {T, op, init} x = length(a) for s in a.sums length(s) == x && push!(s,init(T)) s[x + 1] = op(s[x + 1], v) x >>= 1 end if length(a.sums[end]) == 2 push!(a.sums, [op(a.sums[end][1], a.sums[end][2])]) end end function Base.pop!(a::Accumulator{T,op,init}) where {T, op, init} a[length(a)] = init(T) pop!(a.sums[1]) x = length(a) for k in 2:length(a.sums) x >>= 1 length(a.sums[k]) > x + 1 && pop!(a.sums[k]) end end function Base.setindex!(a::Accumulator{T,op,init},v,i::Integer) where {T,op,init} x = i - 1 r = promote_type(typeof(v), T)(v) for s in a.sums s[x + 1] = r left = (x & 1 == 0) x ⊻= 1 if x + 1 ∈ eachindex(s) r = left ? op(r, s[x + 1]) : op(s[x + 1], r) end x >>= 1 end end Base.:(==)(a::Accumulator, b::Accumulator) = first(a.sums) == first(b.sums) Base.getindex(a::Accumulator, i) = first(a.sums)[i] Base.sum(a::Accumulator{T,+,zero}) where T = only(last(a.sums)) Base.reduce(a::Accumulator{T,op,init}) where {T,op,init} = only(last(a.sums)) Base.isempty(a::Accumulator) = isempty(first(a.sums)) function Base.empty!(a::Accumulator) resize!(a.sums, 1) resize!(first(a.sums), 0) end function Base.show(io::IO, a::Accumulator{T,op,init}) where {T,op,init} print(io, "Accumulator(", a.sums[1], op !== (+) ? ", op=$op" : "", init !== zero ? ", init=$init" : "", ")") end
CavityTools
https://github.com/abraunst/CavityTools.jl.git
[ "MIT" ]
1.2.1
d70afeec1ca9f432fa55157aa65790ea7abcb6db
code
1726
struct Cavity{T, op, init} <: AbstractVector{T} acc::Accumulator{T, op, init} end Base.size(c::Cavity) = size(c.acc) Base.keys(c::Cavity) = keys(c.acc.sums[1]) function Base.getindex(c::Cavity{T,op,init}, i) where {T, op, init} @boundscheck checkbounds(c, i) a = c.acc s = init(T) i -= 1 @inbounds for ak in a.sums j = xor(i, 1) + 1 if j in eachindex(ak) s = op(s, ak[j]) end i >>= 1 end s end @inline function Base.iterate(c::Cavity{T, op, init}, (i,L,R) = (0, fill(init(T), length(c.acc.sums)), fill(init(T), length(c.acc.sums)))) where {T, op, init} i == length(c) && return nothing a = c.acc.sums k = i == 0 ? length(a) - 1 : count_ones(xor(i - 1, i)) for f in k:-1:1 j = xor(i >> (f-1), 1) + 1 l, r = L[f + 1], R[f + 1] L[f] = ( isodd(j) && j ∈ eachindex(a[f])) ? op(l, a[f][j]) : l R[f] = (iseven(j) && j ∈ eachindex(a[f])) ? op(a[f][j], r) : r end op(first(L), first(R)), (i + 1, L, R) end function cavity!(dest, source, op, init) @assert length(dest) == length(source) isempty(source) && return init if length(source) == 1 @inbounds dest[begin] = init return op(first(source), init) end accumulate!(op, dest, source) full = op(dest[end], init) right = init for (i,s)=zip(lastindex(dest):-1:firstindex(dest)+1,Iterators.reverse(source)) @inbounds dest[i] = op(dest[i-1], right); right = op(s, right); end @inbounds dest[begin] = right full end function cavity(source, op, init) dest = [init for _ in source] full = cavity!(dest, source, op, init) dest, full end
CavityTools
https://github.com/abraunst/CavityTools.jl.git
[ "MIT" ]
1.2.1
d70afeec1ca9f432fa55157aa65790ea7abcb6db
code
2238
""" An `CumSum(a::Accumulator)` gets updated each time that `a` does. The time for an update and retrieval is both `O(log(length(a)))`. It is normally constructed with `cumsum(a)`, which takes time `O(1)` ``` julia> a = Accumulator([1:10;]) 10-element Accumulator{Int64, +, zero}: 1 2 3 4 5 6 7 8 9 10 julia> c = cumsum(a) CumSum(Accumulator([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) julia> c[end] 55 julia> a[1] = 100 100 julia> c[end] 154 ``` """ struct CumSum{T,op,init} <: AbstractVector{T} acc::Accumulator{T,op,init} end function Base.cumsum(a::Accumulator) Base.require_one_based_indexing(a) CumSum(a) end Base.size(c::CumSum) = size(c.acc) Base.length(c::CumSum) = length(c.acc) Base.firstindex(c::CumSum) = firstindex(c.acc) Base.lastindex(c::CumSum) = lastindex(c.acc) Base.keys(c::CumSum) = keys(c.acc) Base.diff(c::CumSum) = @view c.acc[2:end] function Base.getindex(c::CumSum{T,op,init},i) where {T,op,init} a = c.acc m = init(T) K = length(a.sums) for k in K:-1:1 s = a.sums[k] if (i >> (k-1)) & 1 == 1 m = op(m, s[xor(i >> (k-1), 1) + 1]) end end return m end function Base.show(io::IO, c::CumSum{T,op,init}) where {T,op,init} print(io, "CumSum(", c.acc, op != (+) || init != zero ? "; op=$op, init=$init)" : ")") end Base.:(==)(c::CumSum, v::Vector) = v[1] == c.acc[1] && all(c.acc[i] == v[i] - v[i-1] for i=2:lastindex(v)) Base.:(==)(v::Vector, c::CumSum) = c == v function Base.searchsortedfirst(c::CumSum{T,op,init}, r; lt = isless, rev = false) where {T,op,init} a = c.acc x = 0 m = init(T) for k in length(a.sums):-1:1 s = a.sums[k] x + 1 > length(s) && return length(a) + 1 n = op(s[x + 1], m) if xor(rev, lt(n, r)) m = n x ⊻= 1 end x <<= 1 end return (x >>= 1) + 1 end @inline function Base.iterate(c::CumSum{T, op, init}, state = nothing) where {T, op, init} a = c.acc sums, i = isnothing(state) ? (fill(init(T), length(a.sums) + 1), 0) : state i == length(a) && return nothing k = count_ones(xor(i + 1, i)) sums[1:k] .= op(sums[k+1], a.sums[k][(i >> (k-1))+1]) first(sums), (sums, i + 1) end
CavityTools
https://github.com/abraunst/CavityTools.jl.git
[ "MIT" ]
1.2.1
d70afeec1ca9f432fa55157aa65790ea7abcb6db
code
5274
abstract type AbstractExponentialQueue{T} <: AbstractDict{T, Float64} end struct ExponentialQueue <: AbstractExponentialQueue{Int} acc::Accumulator{Float64,+,zero} sum::CumSum{Float64,+,zero} idx::Vector{Int} ridx::Vector{Int} end """ `ExponentialQueue()` keeps an updatable queue of up to `N` events with ids `1...N` and contant rates Q[1] ... Q[N]. This is intended for sampling in continuous time. julia> Q = ExponentialQueue() ExponentialQueue(Accumulator{Float64, +, zero}([Float64[]]), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0 … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], Int64[]) julia> Q[1] = 1.2 #updates rate of event 1 1.2 julia> Q[55] = 2.3 #updates rate of event 55 2.3 julia> i,t = pop!(Q) # gets time and id of next event and remove it from the queue (55, 0.37869716808319576) See also: `ExponentialQueueDict` """ function ExponentialQueue(v = []) ridx = Int[] R2 = Float64[] N = 0 for (i,ri) in v N = max(N, i) if ri > 0 push!(ridx, i) push!(R2, ri) end end idx = fill(0, N) for (j,i) in enumerate(ridx) idx[i] = j end acc = Accumulator(R2) ExponentialQueue(acc, cumsum(acc), idx, ridx) end @deprecate ExponentialQueue(N::Integer) ExponentialQueue() function Base.show(io::IO, Q::ExponentialQueue) print(io, "ExponentialQueue(", [i=>r for (i,r) in zip(Q.ridx, Q.acc.sums[1])], ")") end """ `ExponentialQueueDict{K}` keeps an updatable queue of elements of type `K` with contant rates Q[k]. This is intended for sampling in continuous time. julia> Q = ExponentialQueueDict{Int}() ExponentialQueueDict(Pair{Int64, Float64}[]) julia> Q[1] = 1.2 # updates rate of event 1 1.2 julia> Q[55] = 2.3 # updates rate of event 55 2.3 julia> i,t = pop!(Q) # gets time and id of next event and remove it from the queue (55, 0.37869716808319576) See also: `ExponentialQueue` for a slightly more efficient queue for the case `K == Int` """ struct ExponentialQueueDict{K} <: AbstractExponentialQueue{K} acc::Accumulator{Float64,+,zero} sum::CumSum{Float64,+,zero} idx::Dict{K,Int} ridx::Vector{K} end function Base.show(io::IO, Q::ExponentialQueueDict{K}) where K print(io, "ExponentialQueueDict(", Pair{K,Float64}[i=>Q.acc[Q.idx[i]] for i in eachindex(Q.idx)], ")") end function ExponentialQueueDict{K}() where K acc = Accumulator() ExponentialQueueDict(acc, cumsum(acc), Dict{K,Int}(), K[]) end function ExponentialQueueDict(v) acc = Accumulator([float(r) for (_,r) in v]) ExponentialQueueDict(acc, cumsum(acc), Dict(k=>i for (i,(k,_)) in enumerate(v)), [i for (i,_) in v]) end ExponentialQueueDict() = ExponentialQueueDict{Any}() function _addidx(e::ExponentialQueue, i) i <= 0 && throw(BoundsError(e, i)) i > length(e.idx) && append!(e.idx, fill(0, i - length(e.idx))) e.idx[i] = length(e.acc) end function _addidx(e::ExponentialQueueDict, i) e.idx[i] = length(e.acc) end function Base.setindex!(e::AbstractExponentialQueue, p, i) if p <= 0 # do not store null rates haskey(e, i) && delete!(e, i) return p end if haskey(e, i) e.acc[e.idx[i]] = p else push!(e.acc, p) _addidx(e, i) push!(e.ridx, i) end p end Base.haskey(e::ExponentialQueue, i) = i ∈ eachindex(e.idx) && !iszero(e.idx[i]) Base.haskey(e::ExponentialQueueDict, i) = haskey(e.idx, i) Base.getindex(e::AbstractExponentialQueue, i) = haskey(e, i) ? e.acc[e.idx[i]] : 0.0 _deleteidx!(e::ExponentialQueueDict, i) = delete!(e.idx, i) _deleteidx!(e::ExponentialQueue, i) = (e.idx[i] = 0) function Base.delete!(e::AbstractExponentialQueue, i) l, k = e.idx[i], e.ridx[length(e.acc)] e.acc[l] = e.acc.sums[1][end] e.idx[k], e.ridx[l] = l, k pop!(e.acc) pop!(e.ridx) _deleteidx!(e, i) e end """ k,t = peek(Q): Sample next event and time from the queue. """ function Base.peek(e::AbstractExponentialQueue; rng = Random.default_rng()) t = -log(rand(rng))/sum(e.acc) i = peekevent(e; rng) i => t end """ peekevent(Q; rng): Sample next event from the queue (with probability proportional to its rate) """ function peekevent(e::AbstractExponentialQueue; rng = Random.default_rng()) j = searchsortedfirst(e.sum, rand(rng) * sum(e.acc)) e.ridx[min(j, lastindex(e.ridx))] end """ k,t = pop!(Q): Sample next event and time from the queue and remove it from the queue. """ function Base.pop!(e::AbstractExponentialQueue; rng = Random.default_rng()) i, t = peek(e; rng) delete!(e, i) i => t end Base.isempty(e::AbstractExponentialQueue) = isempty(e.acc) function Base.empty!(e::ExponentialQueue) e.idx .= 0 empty!(e.ridx) empty!(e.acc) end function Base.empty!(e::ExponentialQueueDict) empty!(e.idx) empty!(e.ridx) empty!(e.acc) end Base.values(e::ExponentialQueueDict) = e.acc Base.keys(e::ExponentialQueueDict) = e.ridx Base.iterate(e::AbstractExponentialQueue, i = 1) = length(e.acc) < i ? nothing : ((e.ridx[i]=>e.acc[i]), i+1) Base.eltype(::AbstractExponentialQueue{T}) where T = Pair{T,Float64} Base.length(e::AbstractExponentialQueue) = length(e.acc) Base.:(==)(e1::AbstractExponentialQueue, e2::AbstractExponentialQueue) = (Dict(e1) == Dict(e2))
CavityTools
https://github.com/abraunst/CavityTools.jl.git
[ "MIT" ]
1.2.1
d70afeec1ca9f432fa55157aa65790ea7abcb6db
code
3183
using CavityTools using Test using Random v = rand(0:200, 20) a = Accumulator(v) c = cumsum(a) @testset "Accumulator" begin @test string(Accumulator()) == "Accumulator(Float64[])" @test Accumulator{Int}() == Accumulator(Int) @test a == v @test v == a @test a == Accumulator(v) @test sum(a) == sum(v) @test a.sums == Accumulator(v).sums a[3] = v[3] = 70 @test sum(a) == sum(v) @test a.sums == Accumulator(v).sums a[1] = v[1] = 55 @test sum(a) == sum(v) @test a.sums == Accumulator(v).sums a[10] = v[10] = 44 @test sum(a) == sum(v) @test a.sums == Accumulator(v).sums for i=5:15 a[i] = i v[i] = i @test sum(a) == sum(v) @test a.sums == Accumulator(v).sums end end @testset "Cumsum" begin @test string(CumSum(Accumulator([1]))) == "CumSum(Accumulator([1]))" c = cumsum(v) ca = cumsum(a) @test c == ca @test c == collect(ca) @test c == collect(c) @test diff(ca) == diff(c) @test keys(ca) == keys(v) @test length(ca) == length(v) @test firstindex(ca) == 1 for r in c[1]-0.5:0.5:c[end]+0.5 @test searchsortedfirst(c,r) == searchsortedfirst(ca,r) end end @testset "nonnumerical" begin v = string.('a':'z') a = Accumulator(v, op = *, init = _->"") c = cumsum(a) for i in eachindex(v) @test c[i] == prod(v[1:i]) end @test c[end] == prod(v) == reduce(a) a[2] = "X" @test c[5] == "aXcde" end @testset "Reproducibility" begin Q = ExponentialQueue(i=>i for i in 1:100) Qcp = ExponentialQueueDict(Q) x = pop!(Q; rng = MersenneTwister(0)) xcp = pop!(Qcp; rng = MersenneTwister(0)) @test x == xcp end @testset "cavity" begin x = rand(1:10^4,10^4+11); a = Accumulator(x); y = sum(x) .- x c = Cavity(a); @test keys(y) == keys(c) @test c == y @test all(c[i] == y[i] for i in eachindex(c)) @test cavity(x, +, 0) |> first == y @test cavity([1],+,0) == ([0], 1) end @testset "ExponentialQueue" begin e = ExponentialQueue([5=>10.0, 10=>0.0]) i,t = peek(e) @test i == 5 @test !isempty(e) i,t = pop!(e) @test i == 5 @test isempty(e) e[10] = 5 empty!(e) @test isempty(e) end @testset "ExponentialQueueDict" begin e = ExponentialQueueDict{String}() e["event1"] = 5 e["event1"] = 0 @test !haskey(e, "event1") e["event1"] = 10 @test e["event2"] == 0 @test !haskey(e, "event2") @test (e["event1"] = 10; e["event1"] == 10) i,t = peek(e) @test i == "event1" @test !isempty(e) i,t = pop!(e) @test i == "event1" @test isempty(e) e = ExponentialQueueDict{}() e[1000] = 10 empty!(e) @test isempty(e) e1 = ExponentialQueue() @test string(e1) == "ExponentialQueue(Pair{Int64, Float64}[])" events = Dict(1 => 1.0, 2 => 2.0, 3 => 3.0) for (k,r) in events e1[k] = r end e2 = ExponentialQueueDict(events) @test e1 == e2 @test string(e2) == "ExponentialQueueDict([2 => 2.0, 3 => 3.0, 1 => 1.0])" @test Set(keys(events)) == Set(keys(e2)) @test Set(values(events)) == Set(values(e2)) end nothing
CavityTools
https://github.com/abraunst/CavityTools.jl.git
[ "MIT" ]
1.2.1
d70afeec1ca9f432fa55157aa65790ea7abcb6db
docs
2867
# CavityTools [![Coverage](https://codecov.io/gh/abraunst/CavityTools.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/abraunst/CavityTools.jl) [![Build Status](https://github.com/abraunst/CavityTools.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/abraunst/CavityTools.jl/actions/workflows/CI.yml?query=branch%3Amain) This small package contains: * `cavity!` and `cavity`: Functions to compute the `N` all-but-one operations between `N` elements in time `O(N)`. The operation is arbitrary and needs only to be associative. This is equivalent to computing `[reduce(op, (src[j] for j in eachindex(src) if i != j); init) for i in eachindex(src)]` which however would need `N*(N-1)` evaluations of `op`. If `op` is commutative with exact inverse `invop`, you could obtain the same result of `cavity(src, op, init)`, also in time `O(N)`, with `invop.(reduce(op, src; init), src)`. * `Accumulator`: An `a = Accumulator(v::AbstractVector)` works as a replacement for `v` with extra tracking computations. * Construction of `a` requires time `O(N)` where `N == length(v)`. * `sum(a)` requires time `O(1)`. * `cumsum(a)`, `cavity(a)` require time `O(1)` and return respectively a `CumSum` and `Cavity` objects that are linked to `a`. * `c::CumSum(a::Accumulator)`: keeps a live-updated `cumsum` of `a`. * Create it with `c = cumsum(a::Accumulator)` * Retrieval `c[i]` takes time `O(log N)`. * `collect(c)` takes time `O(N)` * `searchsortedfirst(r, c)` takes time `O(log N)` * `c::Cavity(a::Accumulator)`: keeps a live-updated `cavity` of `a`. * Create it with `c = cavity(a::Accumulator)`. * Retrieval `c[i]` takes time `O(log N)`. * `collect(c)` takes time `O(N)` (but is slower than `cavity(v::Vector)`). * `Q::ExponentialQueueDict{K}()`: `Dict`-like interface to a collection of events with associated independent probability rates, intended for sampling on a Gillespie-like scheme. * Events are of type `K`. * Dict-like contruction `Q = ExponentialQueueDict([:a => 0.1, :b => 0.2, :c => 0.3])` is allowed * Rates can be queried by `getindex` (i.e. `r = Q[k]`) and updated via `setindex!` (i.e. `Q[k] = r`), both in time `O(log N)` where `N` is the number of stored events. * Next event type and time can extracted from the queue by `k,t = pop!(Q)` or `k,t = peek(Q)`. On `pop!`, event `k` is then removed from the collection. `pop!` and `peek` take time `O(log N)`. * If event time is unneeded, next event alone can be extracted with `k = peekevent(Q)` (taking also time `O(log N)`). * `Q::ExponentialQueue()`: Like `ExponentialQueue{Int}` but events are stored on a vector instead of a `Dict`, so it may be slightly more efficient. Event indices are positive integers (note that the memory space needed scales with the maximum index, so use ExponentialQueueDIct{Int} if you need very large indices).
CavityTools
https://github.com/abraunst/CavityTools.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
1690
prodir = realpath(joinpath(dirname(dirname(@__FILE__)))) srcdir = joinpath(prodir, "src") srcdir ∉ LOAD_PATH && push!(LOAD_PATH, srcdir) using Documenter using IntegerTriangles #UpdateDocs() makedocs( modules = [IntegerTriangles], sitename = "IntegerTriangles.jl", clean = true, checkdocs = :none, doctest = false, pages = [ "Introduction" => "introduction.md", "Library" => "index.md", "Modules" => "modules.md", "Aitken" => "Aitken.md", "Bessel1" => "Bessel1.md", "Binomial" => "Binomial.md", "Catalan" => "Catalan.md", "DArcais" => "DArcais.md", "Delannoy" => "Delannoy.md", "Euler" => "Euler.md", "EulerSec" => "EulerS.md", "EulerTan" => "EulerT.md", "Eulerian" => "Eulerian.md", "EulerianSO2" => "EulerianSO2.md", "FallingFact" => "FallingFact.md", "Fibonacci" => "Fibonacci.md", "Fine" => "Fine.md", "Fubini" => "Fubini.md", "Hermite" => "Hermite.md", "Laguerre" => "Laguerre.md", "Lah" => "Lah.md", "Motzkin" => "Motzkin.md", "Narayana" => "Narayana.md", "Rencontres" => "Rencontres.md", "RisingFact" => "RisingFact.md", "SchroederBig" => "SchroederB.md", "SchroederLittle" => "SchroederL.md", "StirlingCycle" => "StirlingCycle.md", "StirlingSet" => "StirlingSet.md", "Trinomial" => "Trinomial.md", "TTree" => "TTree.md", "Uni" => "Uni.md", "Worpitzky" => "Worpitzky.md" ] ) deploydocs( repo = "github.com/OpenLibMathSeq/IntegerTriangles.jl.git", target = "build" )
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
12861
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. # Builds the module IntegerTriangles, runtests and perftests from the src modules. # # The source files are scanned and the source modules are joined together, # not merely included. This architecture has three advantages: # * Source and test modules can be placed in the same file. # * A uniform layout of the source modules is enforced. # * The build can be easily customized by filtering source files. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module BuildTriangles using Dates, UUIDs export build_all cloudpath = "https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/src/" # Version information version() = v"0.3.0" print("IntegerTriangles version $(version())\n") pkgdir = dirname((@__DIR__)) @info("Package directory is: " * pkgdir) srcdir = dirname((@__FILE__)) cd(srcdir) @info("Working directory is: " * pwd()) tstdir = joinpath(pkgdir, "test") @info("Test files are in: " * tstdir) docdir = joinpath(pkgdir, "docs") @info("Docs directory is: " * docdir) docsrcdir = joinpath(docdir, "src") @info("Docs sources are in: " * docsrcdir) const exclude = [ "BuildTriangles.jl", "IntegerTriangles.jl", "TrianglesTypes.jl", "SequenceID.jl", "_EXPORT.jl", "_TEMP.jl", "_INDEX.jl", "_SINDEX.jl", "_IS.jl", "tempCodeRunnerFile.jl" ] # Plots fails const references = "Nemo, HTTP, DocStringExtensions, OrderedCollections, PrettyTables" function header(f) println(f, "# This file is part of IntegerTriangles.") println(f, "# Copyright Peter Luschny. License is MIT.") println(f) println(f, "# Version of: UTC ", Dates.format(now(), "yyyy-mm-dd HH:MM:SS")) println(f, "# ", UUIDs.uuid1()) println(f) println(f, "# Do not edit this file, it is generated from the modules and will be overwritten!") println(f, "# Edit the modules in the src directory and build this file with BuildTriangles.jl!") println(f) end function sortnames() index = open("_INDEX.jl", "r") sindex = open("_SINDEX.jl", "w") dict = Dict{Int64,Array{String}}() for l ∈ eachline(index, keep=true) i = 0 c = 2 if occursin(r"^[ACFGILMPRSTV][0-9]{6},$", l) c = 0 end if occursin(r"^is[0-9]{6},$", l) # || occursin(r"^TL[0-9]{6},$", l) # || occursin(r"^TF[0-9]{6},$", l) i = 2 c = 0 end c == 2 && (print(sindex, l); continue) Anum = l[1:end - 2] N = Meta.parse(Anum[2 + i:end - c]) if !haskey(dict, N) dict[N] = [Anum] else push!(dict[N], Anum) end end # We have to avoid the final comma in the export list K = sort(collect(keys(dict))) for key ∈ K[1:end - 1] for s ∈ dict[key] print(sindex, s * ",") end println(sindex) end E = dict[K[end]] for s ∈ E[1:end - 1] print(sindex, s * ",") end println(sindex, E[end]) close(index) close(sindex) end # Nota bene: we make use of the convention that an Triangles module # is closed by "end # module" (and not merely by "end")! function build_seq() tmp = open("_TEMP.jl", "w") exp = open("_EXPORT.jl", "w") seq_modules = filter!(s -> occursin(r"\.jl$", s), readdir(srcdir)) for filename ∈ seq_modules filename ∈ exclude && continue path = joinpath(srcdir, filename) mod = open(path, "r") println(" + ", filename) println(tmp, "# *** ", splitdir(path)[2], " ****************") doc = false mlcomment = false for l ∈ eachline(mod, keep=true) n = lstrip(l) if mlcomment && startswith(n, "=#") mlcomment = false continue end if mlcomment || startswith(n, "#=") mlcomment = true continue end startswith(n, "# START-TEST") && break startswith(n, "end # module") && break startswith(n, '#') && continue startswith(n, "using") && continue startswith(n, "module") && continue startswith(n, "(@__DIR__)") && continue startswith(n, "__precompile__") && continue startswith(n, "\"\"\"") && (doc = !doc) if doc print(tmp, l) continue end if startswith(n, "export") print(exp, n) continue end print(tmp, n) end close(mod) end flush(exp) close(exp) flush(tmp) close(tmp) sleep(0.1) exp = open("_EXPORT.jl", "r") sor = open("_INDEX.jl", "w") s = "" for l ∈ eachline(exp, keep=true) n = lstrip(l) if startswith(n, "export") n = n[7:end] end s *= n end R = replace(s, ',' => ' ') T = sort(split(R)) println(sor, "export ") for t ∈ T[1:end] println(sor, t, ",") end close(sor) close(exp) sleep(0.01) sortnames() tmp = open("_TEMP.jl", "r") sor = open("_SINDEX.jl", "r") target = joinpath(srcdir, "_IS.jl") olm = open(target, "w") header(olm) println(olm, "__precompile__()") println(olm, "module IntegerTriangles") println(olm, "using " * references) for l ∈ eachline(sor, keep=true) print(olm, l) end for l ∈ eachline(tmp, keep=true) print(olm, l) end print(olm, "end") close(sor) close(tmp) close(olm) end # Builds the file test/runtests.jl from the Triangles modules. # Nota bene: we make use of the convention that a Triangles module # has three functions: test(), demo() and perf(), in this order. function build_test() path = joinpath(tstdir, "runtests.jl") o = open(path, "w") header(o) println(o, "module runtests") println(o, "tstdir = realpath(joinpath(dirname(@__FILE__)))") println(o, "srcdir = joinpath(dirname(tstdir), \"src\")") println(o, "tstdir ∉ LOAD_PATH && push!(LOAD_PATH, tstdir)") println(o, "srcdir ∉ LOAD_PATH && push!(LOAD_PATH, srcdir)") println(o, "using Nemo, Test, IntegerTriangles, PrettyTables") path = joinpath(tstdir, "runtests.jl") i = open(path, "r") buff = Array{String,1}() for l ∈ eachline(i, keep=true) n = lstrip(l) startswith(n, '#') && continue startswith(n, "module") && continue startswith(n, "using") && continue startswith(n, "export") && continue push!(buff, n) end j = length(buff) while j > 0 && buff[j] == "" j -= 1 end for k ∈ 1:j - 1 print(o, buff[k]) end close(i) seq_modules = filter!(s -> occursin(r"\.jl$", s), readdir(srcdir)) for filename ∈ seq_modules filename ∈ exclude && continue path = joinpath(srcdir, filename) i = open(path, "r") inside = false println(o, "# *** ", splitdir(path)[2], " *********") buff = Array{String,1}() for l ∈ eachline(i, keep=true) n = lstrip(l) startswith(n, '#') && continue b = startswith(n, "function test") if b inside = true continue end if inside c = startswith(n, "function") && n[10] ≠ 't' if c break end push!(buff, n) end end j = length(buff) while j > 0 && buff[j] == "" j -= 1 end for k ∈ 1:j - 1 print(o, buff[k]) end close(i) end print(o, "end # module") close(o) end # Builds the file test/perftests.jl. function build_perf() path = joinpath(tstdir, "perftests.jl") o = open(path, "w") header(o) println(o, "tstdir = realpath(joinpath(dirname(@__FILE__)))") println(o, "srcdir = joinpath(dirname(tstdir), \"src\")") println(o, "tstdir ∉ LOAD_PATH && push!(LOAD_PATH, tstdir)") println(o, "srcdir ∉ LOAD_PATH && push!(LOAD_PATH, srcdir)") println(o, "module perftests") println(o, "using IntegerTriangles, Dates, InteractiveUtils") println(o, "InteractiveUtils.versioninfo()") println(o, "start = Dates.now()") seq_modules = filter!(s -> occursin(r"\.jl$", s), readdir(srcdir)) for filename ∈ seq_modules filename ∈ exclude && continue path = joinpath(srcdir, filename) i = open(path, "r") inside = false println(o, "# +++ ", filename, " +++") buff = Array{String,1}() s = "" for l ∈ eachline(i, keep=true) n = lstrip(l) b = startswith(n, "function perf()") if b inside = true continue end if inside c = startswith(n, "function main") if c break end startswith(n, '#') && continue if startswith(n, "@time") s = chomp(n[7:end]) * "\")\n" push!(buff, "println(\"\\nTEST: ", s) end push!(buff, n) end end j = length(buff) while j > 0 && buff[j] == "" j -= 1 end for k ∈ 1:j - 1 print(o, buff[k]) end close(i) end println(o, "stop = Dates.now()") println(o, "tdiff = stop - start") println(o, "println(\"\\nJulia version: \" * string(VERSION) )") println(o, "println(start)") println(o, "println(\"Total test time: \", tdiff)") println(o, "end # module") close(o) end # Builds the file index.md in docs/src. function make_index() path = joinpath(docsrcdir, "index.md") ind = open(path, "w") tind = open("_SINDEX.jl", "r") first = true for l ∈ eachline(tind, keep=false) if first first = false println(ind, "# Library") println(ind, "") continue end endswith(l, ',') && (l = chop(l)) for f ∈ split(l, ",") println(ind, "```@docs") println(ind, f) println(ind, "```") end end close(ind) close(tind) end function make_modules() mdpath = joinpath(docsrcdir, "modules.md") mod = open(mdpath, "w") seq_modules = filter!(s -> occursin(r"\.jl$", s), readdir(srcdir)) for filename ∈ seq_modules filename ∈ exclude && continue path = joinpath(srcdir, filename) src = open(path, "r") indoc = false for l ∈ eachline(src, keep=false) n = lstrip(l) if startswith(n, "\"\"\"") indoc && break indoc = true path = joinpath(cloudpath, filename) name = splitext(filename) println(mod, "\n##   🔶  ", '[', name[1], "](", path, ")\n") else n = replace(n, "\\\\" => "\\") indoc && println(mod, n) end end close(src) end close(mod) end function addsig(srcfile, docfile) nextline(srcfile) = !eof(srcfile) ? (return readline(srcfile)) : (return nothing) n = nextline(srcfile) while true n === nothing && return while !startswith(n, "\"\"\"") println(docfile, n) n = nextline(srcfile) n === nothing && return end if startswith(n, "\"\"\"") println(docfile, n) n = nextline(srcfile) n === nothing && return while !startswith(n, "\"\"\"") println(docfile, n) n = nextline(srcfile) n === nothing && return end nn = nextline(srcfile) # Do you want signatures? #if !startswith(nn, "const Module") # println(docfile, "\$(SIGNATURES)") #end println(docfile, n) n = nn end end end function build_all() @info("Uses the following external modules:") println(references) @info("The local modules included in IntegerTriangles.jl:") build_seq() srcdir = dirname(@__FILE__) srcfile = open(joinpath(srcdir, "_IS.jl"), "r") profile = open(joinpath(srcdir, "IntegerTriangles.jl"), "w") addsig(srcfile, profile) close(srcfile) close(profile) build_test() build_perf() make_index() make_modules() rm("_EXPORT.jl") rm("_INDEX.jl") rm("_IS.jl") rm("_SINDEX.jl") rm("_TEMP.jl") end build_all() end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
67620
# This file is part of IntegerTriangles. # Copyright Peter Luschny. License is MIT. # Version of: UTC 2021-05-06 12:01:36 # 0b91ade0-ae52-11eb-130f-67bb9017db3a # Do not edit this file, it is generated from the modules and will be overwritten! # Edit the modules in the src directory and build this file with BuildTriangles.jl! __precompile__() module IntegerTriangles using Nemo, HTTP, DocStringExtensions, OrderedCollections, PrettyTables export A046802Transform, A046802Triangle, AbstractSequence, AbstractTriangle, AitkenTriangle, AllPrettyTraits, AllTraitCards, AltSum, AssociatedTriangles, BernoulliPolynomial, Bessel1Transform, Bessel1Triangle, BinConv, Binomial, BinomialTransform, BinomialTriangle, Catalan, CatalanBallot, CatalanTransform, CatalanTriangle, Central, Coefficients, ConvSum, ConvTrans, ConvTri, Convolution, ConvolutionTransformation, ConvolutionTriangle, DArcaisTriangle, DelannoyTriangle, DelehamΔ, DiagSum, DiagTri, DiagonalTriangle, EgfExpansionCoeff, EgfExpansionPoly, EulerSecTriangle, EulerTanTriangle, EulerTriangle, EulerianSO2Triangle, EulerianTransform, EulerianTriangle, EulerianTriangle2, Evaluate, EvenSum, Explore, ExtCatalanTriangle, Factorial, FallingFactTriangle, FibonacciTransform, FibonacciTriangle, Fine, FineTriangle, Flat, FubiniTriangle, FubiniTriangle, GetSeqnum, GetSeqnumUri, HermiteTransform, HermiteTriangle, IBinConv, IBinomial, IBinomialTransform, IBinomialTriangle, Inspect, InvRev, Inverse, InverseTriangle, JacobsthalTransform, JacobsthalTriangle, Laguerre, LaguerreTransform, LaguerreTriangle, LahNumbers, LahTransform, LahTriangle, LeftSide, LinMap, MakeSeqUri, Middle, MotzkinTransform, MotzkinTriangle, NarayanaTransform, NarayanaTriangle, NegHalf, OddSum, OrthoPoly, PascalTriangle, PolyArray, PolyTri, PolyTriangle, PolyVal2, PolyVal3, PolyValue, Polynomial, PolynomialFunction, PosHalf, PrettyTraits, Print, Println, QInt, QPolyRing, QPolySeq, QSeq, QTri, RecTriangle, RencontresTriangle, RevInv, Reverse, ReversePolynomial, RightSide, RiordanSquare, RisingFactTriangle, SaveToCSV, SchroederBigTransform, SchroederBigTriangle, SchröderBTriangle, SchröderLTriangle, SeqToString, Show, StirlingCycleTransform, StirlingCycleTriangle, StirlingSetTransform, StirlingSetTriangle, SwingTriangle, TRAITS, TRIANGLES, TTreeTriangle, Telescope, TraitCard, Trans, TransAlts, TransNat0, TransNat1, TransSqrs, TransTraits, TransUnos, Triangles, TrinomialTransform, TrinomialTriangle, UniTriangle, UpdateDocs, WorpitzkyTriangle, ZInt, ZPolyRing, ZPolySeq, ZSeq, ZTri, csv_files, datapath, docsrcpath, oeis_notinstalled, oeis_search, profilespath, search_failed, ℚInt, ℚPolyRing, ℚPolySeq, ℚSeq, ℚTri, ℤInt, ℤPolyRing, ℤPolySeq, ℤSeq, ℤTri, V000111, A000166, I008279, T008279, A038048, I048993, T048993, I094587, T094587, I132393, T132393, I225478, T225478, I271703, T271703 # *** TrianglesBase.jl **************** import Base.sum """ Basic definitions used in the library IntegerTriangles. We consider the following traits of an triangle: ``` Flat, Reverse, Inverse, RevInv, InvRev, DiagTri, PolyTri, Sum, EvenSum, OddSum, AltSum, DiagSum, Middle, Central, LeftSide, RightSide, PosHalf, NegHalf, PolyVal2, PolyVal3, BinConv, IBinConv, TransSqrs, TransNat0, TransNat1 ``` """ const ModuleTrianglesBase = "" """ Supertype for sequences (or sequence-like types). """ abstract type AbstractSequence end """ Supertype for triangles (or triangles-like types). """ abstract type AbstractTriangle end const Seq{T} = Array{T,1} """ ℤInt is an alias for the type Nemo.fmpz. """ const ℤInt = Nemo.fmpz """ ℚInt is an alias for the type Nemo.fmpq. """ const ℚInt = Nemo.fmpq """ ℤSeq is an alias for the type Array{Nemo.fmpz, 1}. """ const ℤSeq = Seq{ℤInt} """ ℚSeq is an alias for the type Array{Nemo.fmpq, 1}. """ const ℚSeq = Seq{ℚInt} """ ℤTri is an alias for the type Array{Array{Nemo.fmpz, 1}, 1}. """ const ℤTri = Seq{ℤSeq} """ ℚTri is an alias for the type Array{Array{Nemo.fmpq, 1}, 1}. """ const ℚTri = Seq{ℚSeq} """ Constructor for an ℤSeq of length len. If a second parameter f is given the sequence is constructed as [ZZ(f(n)) for n in 0:len-1] """ ZSeq(len::Int) = ℤSeq(undef, len) ZSeq(len::Int, f::Function) = [ZZ(f(n)) for n = 0:len-1] """ Constructor for an ℚSeq of length len. If a second parameter f is given the sequence is constructed as [QQ(f(n)) for n in 0:len-1] """ QSeq(len::Int) = ℚSeq(undef, len) QSeq(len::Int, f::Function) = [QQ(f(n)) for n = 0:len-1] """ Constructor for ZTri. """ function ZTri(dim::Int; reg = false) reg ? ℤTri(ZSeq.(1:dim)) : ℤTri(undef, dim) end ZTri(dim, f::Function) = f.(0:dim-1) ZTri(T::AbstractTriangle) = [row for row ∈ T] """ Constructor for QTri. """ function QTri(dim::Int; reg = false) reg ? QSeq.(1:dim) : ℚTri(undef, dim) end """ ℤPoly is an alias for the type Nemo.fmpz_poly. """ const ℤPoly = Nemo.fmpz_poly """ ℚPoly is an alias for the type Nemo.fmpq_poly. """ const ℚPoly = Nemo.fmpq_poly """ ℤPolySeq is an alias for the type Array{Nemo.fmpz_poly, 1}. """ const ℤPolySeq = Seq{ℤPoly} """ ℚPolySeq is an alias for the type Array{Nemo.fmpq_poly, 1}. """ const ℚPolySeq = Seq{ℚPoly} """ ℤPolyTri is an alias for the type Array{Array{Nemo.fmpz_poly, 1}, 1}. """ const ℤPolyTri = Seq{ℤPolySeq} """ ℚPolyTri is an alias for the type Array{Array{Nemo.fmpq_poly, 1}, 1}. """ const ℚPolyTri = Seq{ℚPolySeq} """ (SIGNATURES) """ ZPolyRing(x) = PolynomialRing(ZZ, x) """ (SIGNATURES) """ QPolyRing(x) = PolynomialRing(QQ, x) const WARNING_ON_NOTINVERTIBLE = false """ Return the diagonal triangle T(n - k, k) where k in 0:n/2. ``` julia> Println.(DiagonalTriangle(MotzkinTriangle(8))) [1] [1] [2, 1] [4, 2] [9, 5, 1] [21, 12, 3] [51, 30, 9, 1] [127, 76, 25, 4] # A106489 ``` """ function DiagonalTriangle(T::ℤTri) dim = length(T) U = ZTri(dim) for n = 1:dim R = ZSeq(div(n + 1, 2)) for k = 0:div(n - 1, 2) R[k+1] = T[n-k][k+1] end U[n] = R end U end DiagTri(T::ℤTri) = DiagonalTriangle(T) function Convolution(S::ℤSeq, T::ℤSeq) L = length(S) if L != length(T) @warn "Incompatible lengths!" return [] end [sum(S[k+1] * T[n-k+1] for k = 0:n) for n = 0:L-1] end Convolution(S::ℤSeq) = Convolution(S, S) ConvSum(S::ℤSeq) = sum(Convolution(S)) """ Return the convolution triangle of T. ``` julia> T = [ℤInt[1], ℤInt[2, 3], ℤInt[4, 5, 6], ℤInt[7, 8, 9, 10]] Println.(ConvolutionTriangle(T)) [1] [4, 12] [16, 40, 73] [49, 112, 190, 284] ``` """ ConvolutionTriangle(T::ℤTri) = Convolution.(T) ConvTri(T::ℤTri) = ConvolutionTriangle(T) # alias """ The sum of a ℤTri is the sequence of the sum of the rows. """ Base.sum(T::ℤTri) = [sum(row) for row ∈ T] Base.sum(T::ℚTri) = [sum(row) for row ∈ T] """ The EvenSum of a ℤSeq is the sum of the even indexed terms, indexing starts with 0. ``` julia> EvenSum([0, 1, 2, 3, 4, 5]) 0 + 2 + 4 = 6 ``` """ EvenSum(A) = sum(A[1:2:end]) """ The OddSum of a ℤSeq is the sum of the odd indexed terms, indexing starts with 0. ``` julia> OddSum([0, 1, 2, 3, 4, 5]) 1 + 3 + 5 = 9 ``` """ OddSum(A) = sum(A[2:2:end]) """ The AltSum of a ℤSeq is the alternating sum. ``` julia> AltSum([0, 1, 2, 3, 4, 5]) + 0 - 1 + 2 - 3 + 4 - 5 = 6 - 9 = - 3 ``` """ AltSum(A) = EvenSum(A) - OddSum(A) """ The Middle of a ℤSeq A is the middle term, A[div(begin + end, 2)]. ``` julia> Middle([0, 1, 2, 3, 4, 5]) 3 ``` """ Middle(A) = A[div(begin + end, 2)] """ The LeftSide of a ℤSeq is the first term. ``` julia> LeftSide([0, 1, 2, 3, 4, 5]) 0 ``` """ LeftSide(A) = A[begin] """ The RightSide of a ℤSeq is the last term. ``` julia> RightSide([0, 1, 2, 3, 4, 5]) 5 ``` """ RightSide(A) = A[end] """ The EvenSum of a ℤTri is the sequence of the even sums of the rows. ``` EvenSum(T::ℤTri) = EvenSum.(T) ``` """ EvenSum(T::ℤTri) = EvenSum.(T) """ The OddSum of a ℤTri is the sequence of the odd sums of the rows. ``` OddSum(T::ℤTri) = OddSum.(T) ``` """ OddSum(T::ℤTri) = OddSum.(T) """ The AltSum of a ℤTri is the sequence of the alternating sums of the rows. ``` AltSum(T::ℤTri) = EvenSum(T) - OddSum(T) ``` """ AltSum(T::ℤTri) = EvenSum(T) - OddSum(T) """ The DiagSum of a ℤTri is the sum of the diagonal triangle. ``` DiagSum(T::ℤTri) = sum(DiagonalTriangle(T)) ``` """ DiagSum(T::ℤTri) = sum(DiagonalTriangle(T)) """ The Middle of a ℤTri is the sequence of the middle term in the rows. ``` Middle(T::ℤTri) = Middle.(T) ``` """ Middle(T::ℤTri) = Middle.(T) """ The Central of a ℤTri is the sequence of the middle term of the even indexed rows, indexing starts with 0. ``` Central(T::ℤTri) = Middle.(T[begin:2:end]) ``` """ Central(T::ℤTri) = Middle.(T[begin:2:end]) """ The LeftSide of a ℤTri is the sequence of the first term in the rows. ``` LeftSide(T::ℤTri) = LeftSide.(T) ``` """ LeftSide(T::ℤTri) = LeftSide.(T) """ The RightSide of a ℤTri is the sequence of the last term in the rows. ``` RightSide(T::ℤTri) = RightSide.(T) ``` """ RightSide(T::ℤTri) = RightSide.(T) """ Return the ℤ-polynomial whose coefficients are the terms of the sequence. ``` [1, 2, 3] -> 1 + 2*x + 3*x^2 ``` """ function Polynomial(S::ℤSeq) R, x = ZPolyRing("x") sum(c * x^(k - 1) for (k, c) ∈ enumerate(S)) end """ Return the sequence of ℤ-polynomials whose coefficients are the terms of the triangle. ``` Polynomial(T::ℤTri) = Polynomial.(T) ``` """ Polynomial(T::ℤTri) = Polynomial.(T) """ Return the ℤ-polynomial whose coefficients are the terms of the reversed sequence. ``` [1, 2, 3] -> x^2 + 2*x + 3 ``` """ ReversePolynomial(S::ℤSeq) = Polynomial(reverse(S)) """ Return the sequence of ℤ-polynomials whose coefficients are the terms of the reversed triangle. ``` ReversePolynomial(T::ℤTri) = ReversePolynomial.(T) ``` """ ReversePolynomial(T::ℤTri) = ReversePolynomial.(T) """ Return the polynomial function associated with the polynomial with coefficients given by the sequence S. A polynomial function evaluates to Float64 values. ``` p = PolynomialFunction([1, 2, 3]) julia> [p(r) for r in 0:3] 4-element Vector{Float64}: 1.0 6.0 17.0 34.0 ``` """ function PolynomialFunction(S) y -> sum(Float64(c) * y^(k - 1) for (k, c) ∈ enumerate(S)) end """ Return the sequence of polynomial functions associated to the polynomials with coefficients given by the triangle T. ``` PolynomialFunction(T::ℤTri) = PolynomialFunction.(T) ``` """ PolynomialFunction(T::ℤTri) = PolynomialFunction.(T) """ Return the value of the ℤ-polynomial p evaluated at x. ``` julia> R, x = ZPolyRing("x") p = 1 + 2*x + 3*x^2 Evaluate(p, 2) 17 ``` """ Evaluate(p::ℤPoly, x) = subst(p, x) Evaluate(p::ℚPoly, x) = subst(p, x) """ Return the sequence of values to which the sequence of ℤ-polynomials P evaluate at x. ``` julia> R, x = ZPolyRing("x") P = [sum(k * x^k for k in 0:n) for n in 0:9] Evaluate(P, 3) # A289399 ``` """ Evaluate(P::ℤPolySeq, x) = Evaluate.(P, x) Evaluate(P::ℚPolySeq, x) = Evaluate.(P, x) """ Return the list of coefficients of the polynomial p (ordered by ascending powers). ``` julia> R, x = ZPolyRing("x") p = 1 + 2*x + 3*x^2 Coefficients(p) ``` """ Coefficients(p, n = 0) = p == 0 ? ℤInt[0] : coeff.(p, 0:max(n, degree(p))) """ Return the sequence of list of coefficients of the polynomials P. """ Coefficients(P::AbstractArray) = Coefficients.(P) import Nemo.numerator numerator(T::ℚTri) = [numerator.(t) for t ∈ T] """ Return numerator(2^degree(p) * Evaluate(p, QQ(1, 2))). ``` julia> R, x = ZPolyRing("x") p = 1 + 2*x + 3*x^2 PosHalf(p) 11 ``` """ PosHalf(p) = p == 0 ? ZZ(0) : numerator(2^degree(p) * Evaluate(p, QQ(1, 2))) """ Return Numerator((-2)^degree(p) * Evaluate(p, QQ(-1, 2))) ``` julia> R, x = ZPolyRing("x") p = 1 + 2*x + 3*x^2 NegHalf(p) 3 ``` """ NegHalf(p) = p == 0 ? ZZ(0) : numerator((-2)^degree(p) * Evaluate(p, QQ(-1, 2))) """ Return the sequence generated by broadcasting PosHalf over the rows of the triangle interpreted as a polynomials. ``` julia> T = [[ZZ(k) for k in 0:n] for n in 1:5] PosHalf(Polynomial(T)) # A000295 5-element ℤSeq 1 4 11 26 57 ``` """ PosHalf(T::ℤTri) = PosHalf.(Polynomial(T)) """ Return the sequence generated by broadcasting NegHalf over the rows of the triangle interpreted as a polynomials. ``` NegHalf(T::ℤTri) = NegHalf.(Polynomial(T)) ``` """ NegHalf(T::ℤTri) = NegHalf.(Polynomial(T)) """ Return the sequence generated by broadcasting PosHalf over the sequence of polynomials. """ PosHalf(P::ℤPolySeq) = PosHalf.(P) """ Return the sequence generated by broadcasting NegHalf over the sequence of polynomials. """ NegHalf(P::ℤPolySeq) = NegHalf.(P) LinMap(M::ℤTri, V::ℤSeq, n) = sum(M[n][k] * V[k] for k = 1:n) """ LinMap(M::ℤTri, V::ℤSeq) returns the 'matrix times vector' product of M and V. Expands up to length(V) and we assume length(M) >= length(V). """ LinMap(M::ℤTri, V::ℤSeq) = (n -> LinMap(M, V, n)).(1:length(V)) LinMap(F::Function, V::ℤSeq, n) = sum(F(n - 1)[k] * V[k] for k = 1:n) """ LinMap(F::Function, V::ℤSeq) returns the 'matrix times vector' product of a matrix generated by F and V. ``` julia> L(n) = [ZZ(k) for k in 0:n] [LinMap(L, L(n)) for n in 0:9] 0 1 5 14 30 ... # A000330 ``` """ LinMap(F::Function, V::ℤSeq) = LinMap(F, V, length(V)) """ Transform a ℤSeq V by the matrix/vector product by applying LinMap to (M, V). Expands up to min(length(M), length(V)). """ Trans(M::ℤTri, V::ℤSeq) = (n -> LinMap(M, V, n)).(1:min(length(M), length(V))) """ TransAlts(T) = Trans(T, [(-1)^n * ZZ(1) for n = 0:length(T)]) Standard trait of T. """ TransAlts(T) = Trans(T, [(-1)^n * ZZ(1) for n = 0:length(T)]) """ TransSqrs(T) = Trans(T, [ZZ(n^2) for n = 0:length(T)]) Standard trait of T. """ TransSqrs(T) = Trans(T, [ZZ(n^2) for n = 0:length(T)]) """ TransNat0(T) = Trans(T, [ZZ(n) for n = 0:length(T)]) Standard trait of T. """ TransNat0(T) = Trans(T, [ZZ(n) for n = 0:length(T)]) """ TransNat1(T) = Trans(T, [ZZ(n) for n = 1:length(T)]) Standard trait of T. """ TransNat1(T) = Trans(T, [ZZ(n) for n = 1:length(T)]) """ Return an iterator expanding the given sequence to a regular triangle. ``` julia> T = Telescope(ℤInt[1, 2, 3, 4, 5, 6]) collect(T) [1] [1, 2] [1, 2, 3] [1, 2, 3, 4] [1, 2, 3, 4, 5] [1, 2, 3, 4, 5, 6] ``` """ Telescope(A::ℤSeq) = (A[1:k] for k = 1:size(A, 1)) """ Return an iterator expanding the sequence generated by the function f to a regular triangle. """ Telescope(len::Int, f::Function) = Telescope([ZZ(f(k)) for k = 0:len-1]) """ (SIGNATURES) """ Binomial(n, k) = Nemo.binomial(ZZ(n), ZZ(k)) Binomial(n) = [Binomial(n, k) for k = 0:n] Binomial(A::ℤSeq) = LinMap(Binomial, A) """ (SIGNATURES) """ BinomialTriangle(dim) = [Binomial(n) for n = 0:dim-1] """ (SIGNATURES) """ BinomialTransform(A::ℤSeq) = Binomial.(Telescope(A)) BinomialTransform(A::ℤTri) = Binomial.(A) BinConv(A::ℤTri) = BinomialTransform(A::ℤTri) IBinomial(n, k) = ZZ((-1)^(n - k)) * Binomial(n, k) IBinomial(n) = [IBinomial(n, k) for k = 0:n] IBinomial(A::ℤSeq) = LinMap(IBinomial, A) """ (SIGNATURES) """ IBinomialTriangle(dim) = [IBinomial(n) for n = 0:dim-1] """ (SIGNATURES) """ IBinomialTransform(A::ℤSeq) = IBinomial.(Telescope(A)) IBinomialTransform(A::ℤTri) = IBinomial.(A) IBinConv(A::ℤTri) = IBinomialTransform(A::ℤTri) """ Return the factorial ``n! = ∏(1, n)``. """ Factorial(n) = Nemo.factorial(ZZ(n)) """ (SIGNATURES) """ Laplace(s, k) = factorial(k) * coeff(s, k) """ Return the Laplace expansion of a bivariate exponential generating function as a power series, or, if 'coeff=true', as the coefficients of the series. """ function EgfExpansion(prec, gf::Function, coeff = true) R, x = QPolyRing("x") S, t = PowerSeriesRing(R, prec + 1, "t") ser = gf(x, t) P = Laplace.(ser, 0:prec-1) coeff ? Coefficients.(P) : P end """ Return the Laplace expansion of a bivariate exponential generating function as a power series. """ EgfExpansionCoeff(prec, gf::Function) = EgfExpansion(prec, gf, true) """ Return the Laplace expansion of a bivariate exponential generating function as a list of the coefficients of the power series. """ EgfExpansionPoly(prec, gf::Function) = EgfExpansion(prec, gf, false) function OrthoPoly(dim::Int, s::Function, t::Function) T = ZTri(dim, reg = true) # regular triangle for n ∈ 1:dim T[n][n] = 1 end for n ∈ 2:dim u(k) = k == 0 || k == n ? 0 : T[n-1][k] for k ∈ 1:n-1 T[n][k] = (u(k - 1) + s(k - 1) * u(k) + t(k) * u(k + 1)) end end T end """ (SIGNATURES) """ function DelehamΔ(dim::Int, s::Function, t::Function) T = ZTri(dim) R, x = ZPolyRing("x") A = [R(s(k) + x * t(k)) for k ∈ 0:dim-2] C = [R(1) for i ∈ 0:dim] C[1] = R(0) m = 1 for k ∈ 0:dim-1 for j ∈ k+1:-1:2 C[j] = C[j-1] + C[j+1] * A[j-1] end T[m] = [coeff(C[2], j) for j ∈ 0:k] m += 1 end T end """ (SIGNATURES) """ function RiordanSquare(dim::Int, s::Function) T = ZTri(dim, reg = true) for n ∈ 0:dim-1 T[n+1][1] = s(n) end for k ∈ 1:dim-1, m ∈ k:dim-1 T[m+1][k+1] = sum(T[j][k] * T[m-j+2][1] for j ∈ k:m) end T end """ (SIGNATURES) """ function ExpRiordanSquare(dim::Int, s::Function) R = RiordanSquare(dim, s) u = ZZ(1) for k ∈ 1:dim-1 u *= k for m ∈ 1:k j = (m == 1 ? u : div(j, m - 1)) R[k+1][m] *= j end end R end """ (SIGNATURES) """ function check(invM, dim) for n = 1:dim for k = 1:n if denominator(invM[n, k]) != 1 return false end end end return true end """ (SIGNATURES) """ function InverseTriangle(T) dim = length(T) M = zeros(QQ, dim, dim) for n = 1:dim, k = 1:n M[n, k] = QQ(T[n][k]) end S = MatrixSpace(QQ, dim, dim) invM = try inv(S(M)) catch e if isa(e, Exception) if WARNING_ON_NOTINVERTIBLE @warn("\n\n Not invertible!\n\n") end return ℤSeq[] end end if check(invM, dim) != true if WARNING_ON_NOTINVERTIBLE @warn("\n\n Inverse not in MatrixSpace(ZZ)!\n\n") end return ℤSeq[] end return [[numerator(invM[n, k]) for k = 1:n] for n = 1:dim] end """ Alias for InverseTriangle """ Inverse(T::ℤTri) = InverseTriangle(T) """ Return the row reversed triangle. """ Reverse(T::ℤTri) = reverse.(T) """ (SIGNATURES) """ function RevInv(T::ℤTri) I = Inverse(T) return I != [] ? Reverse(I) : ℤSeq[] end """ (SIGNATURES) """ InvRev(T::ℤTri) = Inverse(Reverse(T)) """ (SIGNATURES) """ function Flat(T::ℤTri) T === [] && return [] Empty(s) = isempty(s) ? [ZZ(0)] : s [z for t ∈ T for z ∈ Empty(t)] end """ Print the array without typeinfo. """ function Println(io, v::AbstractVector, newline = true) print(io, "[") for (i, el) ∈ enumerate(v) i > 1 && print(io, ", ") print(io, el) end newline ? println(io, "]") : print(io, "]") end Println(io, str::String) = println(io, str) Println(T::ℤSeq) = Println(IOContext(stdout), T) Println(T::ℤTri) = Println.(IOContext(stdout), T) Print(io, str::String) = print(io, str) Print(T::ℤSeq) = Println(IOContext(stdout), T, false) Print(T::ℤTri) = Println.(IOContext(stdout), T, false) """ A recursive triangle `RecTriangle` is a subtype of `AbstractTriangle`. The rows of the triangle are generated by a function `gen(n, k, prevrow)` defined for ``n ≥ 0`` and ``0 ≤ k ≤ n``. The function returns value of type ℤInt. The parameter prevrow is a function which returns the values of `row(n-1)` of the triangle and 0 if ``k < 0`` or ``k > n``. The function prevrow is provided by an instance of `RecTriangle` and must not be defined by the user. """ struct RecTriangle <: AbstractTriangle dim::Int A::ℤSeq gen::Function # generating function function RecTriangle(dim::Int, gen::Function) dim <= 0 && throw(ArgumentError("dim has to be a positive integer.")) new( dim, fill(ZZ(0), dim), (n::Int, k::Int, f::Function) -> gen(n, k, f)::ℤInt, ) end end function Base.iterate(T::RecTriangle) top = T.gen(0, 0, () -> undef) T.A[1] = ZZ(top) ([top], 1) end """ Return the next row of the triangle. """ function Base.iterate(T::RecTriangle, n) @inline prevrow(A, n) = (k) -> (k < 0 || k > n) ? ZZ(0) : A[k+1] n == T.dim && return nothing F(n, k) = T.gen(n, k, prevrow(T.A, n)) row = [F(n, k) for k ∈ 0:n] for k ∈ 1:n+1 T.A[k] = row[k] end (row, n + 1) end Base.length(R::RecTriangle) = R.dim Base.eltype(R::RecTriangle) = ℤInt function PolyArray(T::ℤTri) P = Polynomial(T) dim = length(T) U = ZTri(dim) for n = 1:dim p = P[n] eva = [Evaluate(p, k) for k = 0:dim-1] U[n] = numerator.(eva) end U end """ (SIGNATURES) """ function PolyTriangle(T::ℤTri) A = PolyArray(T) U = ZTri(length(T)) for n = 1:length(T) U[n] = [A[n-k][k+1] for k = 0:n-1] end U end PolyTri(T::ℤTri) = PolyTriangle(T) """ (SIGNATURES) """ function PolyValue(T::ℤTri, k::Int) P = PolyArray(T) [P[n][k+1] for n = 1:length(P)] end """ (SIGNATURES) """ PolyVal2(T::ℤTri) = PolyValue(T, 2) """ (SIGNATURES) """ PolyVal3(T::ℤTri) = PolyValue(T, 3) """ (SIGNATURES) """ const TRAITS = Function[ Flat, Reverse, Inverse, RevInv, InvRev, DiagTri, PolyTri, sum, EvenSum, OddSum, AltSum, DiagSum, Middle, Central, LeftSide, RightSide, PosHalf, NegHalf, PolyVal2, PolyVal3, BinConv, IBinConv, TransSqrs, TransNat0, TransNat1, ] # *** TrianglesExamples.jl **************** const CacheA000166 = Dict{Int,ℤInt}(0 => ZZ(1)) const CacheA038048 = Dict{Int,ℤInt}(0 => ZZ(0)) const CacheFine = Dict{Int,ℤInt}(0 => ZZ(1), 1 => ZZ(1), 2 => ZZ(0)) const CacheAndré = Dict{Tuple{Int,Int},fmpz}() const CacheBeta = Dict{Tuple{Int,Int},fmpz}() const CacheLah = Dict{Int,ℤSeq}([0 => [ZZ(1)]]) const CacheFubini = Dict{Int,ℤSeq}([0 => [ZZ(1)]]) const CacheDelannoy = Dict{Tuple{Int,Int},ℤInt}([ (0, 0) => ZZ(1), (1, 0) => ZZ(1), (1, 1) => ZZ(1), ]) const CacheAitken = Dict{Int,ℤSeq}([0 => [ZZ(1)]]) const CacheBallot = Dict{Tuple{Int,Int},ℤInt}() const CacheDArcais = Dict{Tuple{Int,Int},ℤInt}() const CacheWorpitzky = Dict{Tuple{Int,Int},ℤInt}() const CacheEulerianSO2 = Dict{Tuple{Int,Int},ℤInt}((0, 0) => ZZ(1)) const CacheSwing = Dict{Tuple{Int,Int},ℤInt}((0, 0) => ZZ(1)) const CacheEulerian = Dict{Tuple{Int,Int},ℤInt}() const CacheEulerianClassic = Dict{Tuple{Int,Int},fmpz}() const CacheNarayana = Dict{Tuple{Int,Int},fmpz}() const CacheLaguerre = Dict{Int,ℤSeq}(0 => [ZZ(1)]) """ Recurrences and iterations for some triangles. The examples given are: ``` Aitken, Bessel1, Binomial, Catalan, DArcais, Delannoy, Eulerian, EulerianSO2, EulerSec, EulerTan, Euler, FallingFact, Fibonacci, Fine, Fubini, Hermite, Laguerre, Lah, Motzkin, Narayana, Rencontres, RisingFact, SchröderB, SchröderL, StirlingCycle, StirlingSet, Trinomial, TTree, Uni, Worpitzky ``` """ const ModuleTrianglesExamples = "" function A000166(n::Int) n <= 1 && return ZZ(1 - n) haskey(CacheA000166, n) && return CacheA000166[n] a = (n - 1) * (A000166(n - 1) + A000166(n - 2)) return CacheA000166[n] = a end function A038048(n::Int) haskey(CacheA038048, n) && return CacheA038048[n] s = Factorial(n - 1) * divisor_sigma(n, 1) return CacheA038048[n] = s end function Fine(n::Int) haskey(CacheFine, n) && return CacheFine[n] s = div((7 * n - 12) * Fine(n - 1) + (4 * n - 6) * Fine(n - 2), 2 * n) CacheFine[n] = s end function André(m::Int, n::Int) haskey(CacheAndré, (m, n)) && return CacheAndré[(m, n)] n ≤ 0 && return ZZ(1) r = range(0, step = m, stop = n - 1) S = sum(binomial(ZZ(n), ZZ(k)) * André(m, k) for k ∈ r) return CacheAndré[(m, n)] = n % m == 0 ? -S : S end """ Return the up-down numbers (2-alternating permutations). """ V000111(n::Int) = abs(André(2, n)) function PrimeDivisors(n) n < 2 && return ℤInt[] sort!([p for (p, e) ∈ factor(ZZ(n))]) end Euler(n, k) = Binomial(n, k) * V000111(n - k) EulerTriangle(dim) = [[Euler(n, k) for k = 0:n] for n = 0:dim-1] Euler(A::ℤSeq) = LinMap(Euler, A, length(A)) EulerTransform(A::ℤSeq) = Euler.(Telescope(A)) """ https://oeis.org/wiki/User:Peter_Luschny/SwissKnifePolynomials """ function BetaPoly(n) function v(n, k) if haskey(CacheBeta, (n, k)) CacheBeta[(n, k)] else CacheBeta[(n, k)] = binomial(n, k) * subst(BetaPoly(k), 0) end end R, z = ZPolyRing("z") n == 0 && return R(1) R(sum(isodd(k) ? 0 : v(n, k) * (z - 1)^(n - k - 1) for k = 0:n-1)) end SECH(n) = isodd(n) ? 0 : subst(BetaPoly(n), 0) TANH(n) = iseven(n) ? 0 : subst(BetaPoly(n), 0) function SecPoly(n) R, z = ZPolyRing("z") R(sum(Binomial(n, k) * SECH(k) * z^(n - k) for k = 0:n)) end function TanPoly(n) R, z = ZPolyRing("z") n == 0 && return R(0) R(sum(Binomial(n, k) * TANH(n - k) * z^k for k = 0:n-1)) end function SwissKnifePoly(n, p, q) R, z = ZPolyRing("z") P = p == 0 ? 0 : SecPoly(n) Q = q == 0 ? 0 : TanPoly(n) p * P + q * Q end EulerTanTriangle(dim) = [Coefficients(TanPoly(n), n) for n = 0:dim-1] EulerSecTriangle(dim) = Coefficients([SecPoly(n) for n = 0:dim-1]) FineTriangle(dim::Int) = RiordanSquare(dim, Fine) TernaryTree(n::Int) = div(Binomial(ZZ(3 * n), n), ZZ(2 * n + 1)) TTreeTriangle(dim::Int) = RiordanSquare(dim, TernaryTree) """ (SIGNATURES) """ function LahNumbers(n::Int64) haskey(CacheLah, n) && return CacheLah[n] prevrow = LahNumbers(n - 1) row = ZSeq(n + 1) row[1] = 0 row[n+1] = 1 for k = 2:n row[k] = prevrow[k-1] + prevrow[k] * (n + k - 2) end CacheLah[n] = row end LahNumbers(n, k) = LahNumbers(n)[k+1] """ (SIGNATURES) """ function LahTriangle(size) length(CacheLah) < size && LahNumbers(size) [CacheLah[n] for n = 0:size-1] end LahNumbers(A::ℤSeq) = LinMap(LahNumbers, A, length(A)) LahTransform(A::ℤSeq) = LahNumbers.(Telescope(A)) """ (SIGNATURES) """ function FubiniNumbers(n::Int64) haskey(CacheFubini, n) && return CacheFubini[n] prevrow = FubiniNumbers(n - 1) row = ZSeq(n + 1) row[1] = 0 row[2] = 1 row[n+1] = n * prevrow[n] for k = 3:n row[k] = (k - 1) * (prevrow[k-1] + prevrow[k]) end CacheFubini[n] = row end FubiniNumbers(n, k) = FubiniNumbers(n)[k+1] """ (SIGNATURES) """ function FubiniTriangle(size) length(CacheFubini) < size && FubiniNumbers(size) [CacheFubini[n] for n = 0:size-1] end FubiniNumbers(A::ℤSeq) = LinMap(FubiniNumbers, A, length(A)) FubiniTransform(A::ℤSeq) = FubiniNumbers.(Telescope(A)) """ (SIGNATURES) """ function Delannoy(n::Int64, k::Int64) haskey(CacheDelannoy, (n, k)) && return CacheDelannoy[(n, k)] if n < 0 || k < 0 || k > n return CacheDelannoy[(n, k)] = 0 end CacheDelannoy[(n, k)] = Delannoy(n - 1, k - 1) + Delannoy(n - 2, k - 1) + Delannoy(n - 1, k) end Delannoy(n) = [Delannoy(n, k) for k ∈ 0:n] DelannoyTriangle(dim) = [Delannoy(n) for n = 0:dim-1] Delannoy(A::ℤSeq) = LinMap(Delannoy, A, length(A)) DelannoyTransform(A::ℤSeq) = Delannoy.(Telescope(A)) """ (SIGNATURES) """ function AitkenNumbers(n::Int64) haskey(CacheAitken, n) && return CacheAitken[n] prevrow = AitkenNumbers(n - 1) row = ZSeq(n + 1) row[1] = prevrow[n] for k = 2:n+1 row[k] = row[k-1] + prevrow[k-1] end CacheAitken[n] = row end AitkenNumbers(n, k) = AitkenNumbers(n)[k+1] """ (SIGNATURES) """ function AitkenTriangle(size) length(CacheAitken) < size && AitkenNumbers(size) [CacheAitken[n] for n = 0:size-1] end AitkenNumbers(A::ℤSeq) = LinMap(AitkenNumbers, A, length(A)) AitkenTransform(A::ℤSeq) = AitkenNumbers.(Telescope(A)) G271703(x, t) = exp(t * divexact(x, 1 - t)) T271703(dim) = EgfExpansionCoeff(dim, G271703) egfBernoulli(x, t) = divexact(t * exp(x * t), exp(t) - 1) BernoulliPolynomial(n) = EgfExpansionPoly(n, egfBernoulli) G278075(x, t) = divexact(1, 1 - x * (1 - exp(-t))) FubiniPolynomial(n) = EgfExpansionPoly(n, G278075) function MotzkinTriangle2(dim::Int) T = ZTri(dim) for n = 1:dim T[n][n] = 1 end for n = 2:dim u(k) = k == 0 || k == n ? 0 : T[n-1][k] for k = 1:n-1 T[n][k] = u(k - 1) + u(k) + u(k + 1) end end T end """ (SIGNATURES) """ MotzkinTriangle(dim) = OrthoPoly(dim, n -> 1, n -> 1) """ (SIGNATURES) """ Motzkin(n) = MotzkinTriangle(n + 1)[n+1] # TODO!! Motzkin(n, k) = Motzkin(n)[k+1] Motzkin(A::ℤSeq) = LinMap(Motzkin, A, length(A)) MotzkinTransform(A::ℤSeq) = Motzkin.(Telescope(A)) """ (SIGNATURES) """ CatalanTriangle(dim) = OrthoPoly(dim, n -> 0, n -> 1) Catalan(n) = CatalanTriangle(n + 1)[n+1] # TODO!! Catalan(n::Int, k::Int) = Catalan(n)[k+1] Catalan(A::ℤSeq) = LinMap(Catalan, A, length(A)) CatalanTransform(A::ℤSeq) = Catalan.(Telescope(A)) function CatalanBallot(n::Int, k::Int) haskey(CacheBallot, (n, k)) && return CacheBallot[(n, k)] (k > n || k < 0) && return ZZ(0) n == k && return ZZ(1) CacheBallot[(n, k)] = ( CatalanBallot(n - 1, k - 1) + CatalanBallot(n - 1, k + 1) + (iseven(n - k) ? 0 : CatalanBallot(n - 1, k)) ) end CatalanBallot(n) = [CatalanBallot(n, k) for k ∈ 0:n] ExtCatalanTriangle(dim) = [[CatalanBallot(n, k) for k = 0:n] for n = 0:dim-1] Rencontres(n, k) = A000166(n - k) * Binomial(n, k) RencontresTriangle(dim) = [[Rencontres(n, k) for k = 0:n] for n = 0:dim-1] Rencontres(A::ℤSeq) = LinMap(Rencontres, A, length(A)) RencontresTransform(A::ℤSeq) = Rencontres.(Telescope(A)) function DArcais(n, k) haskey(CacheDArcais, (n, k)) && return CacheDArcais[(n, k)] k == 0 && return ZZ(0^n) S = sum( Binomial(n - 1, j - 1) * A038048(j) * DArcais(n - j, k - 1) for j = 0:n-k+1 ) CacheDArcais[(n, k)] = S end DArcaisTriangle(dim) = [[DArcais(n, k) for k = 0:n] for n = 0:dim-1] DArcais(A::ℤSeq) = LinMap(DArcais, A, length(A)) DArcaisTransform(A::ℤSeq) = DArcais.(Telescope(A)) function Worpitzky(n, k) haskey(CacheWorpitzky, (n, k)) && return CacheWorpitzky[(n, k)] S = sum(Eulerian(n, j) * Binomial(n - j, n - k) for j = 0:n) CacheWorpitzky[(n, k)] = S end WorpitzkyTriangle(dim) = [[Worpitzky(n, k) for k = 0:n] for n = 0:dim-1] Worpitzky(A::ℤSeq) = LinMap(Worpitzky, A, length(A)) WorpitzkyTransform(A::ℤSeq) = Worpitzky.(Telescope(A)) """ Return the second order Eulerian number E2(n,k). """ function EulerianSO2(n, k) n < 0 && return ZZ(0) haskey(CacheEulerianSO2, (n, k)) && return CacheEulerianSO2[(n, k)] S = EulerianSO2(n - 1, k) * k + EulerianSO2(n - 1, k - 1) * (2 * n - k) CacheEulerianSO2[(n, k)] = S end EulerianSO2Triangle(dim) = [[EulerianSO2(n, k) for k = 0:n] for n = 0:dim-1] EulerianSO2(A::ℤSeq) = LinMap(EulerianSO2, A, length(A)) EulerianSO2Transform(A::ℤSeq) = EulerianSO2.(Telescope(A)) function Swing(n, k) haskey(CacheSwing, (n, k)) && return CacheSwing[(n, k)] p = ZZ(2)^n k == 0 && return p S = numerator(p * prod(QQ(2, j)^((-1)^(j)) for j = 1:k)) CacheSwing[(n, k)] = S end SwingTriangle(dim) = [[Swing(n, k) for k = 0:n] for n = 0:dim-1] Swing(A::ℤSeq) = LinMap(Swing, A, length(A)) SwingTransform(A::ℤSeq) = Swing.(Telescope(A)) Uni(n, k) = 1 UniTriangle(dim) = [[ZZ(1) for k = 0:n] for n = 0:dim-1] Uni(A::ℤSeq) = LinMap(Uni, A, length(A)) UniTransform(A::ℤSeq) = Uni.(Telescope(A)) function Bessel1(n, k) (k == 0) && return ZZ(k^n) div( Factorial(2 * n - k - 1), ((-2)^(n - k) * Factorial(k - 1) * Factorial(n - k)), ) end Bessel1Triangle(dim) = [[Bessel1(n, k) for k = 0:n] for n = 0:dim-1] Bessel1(A::ℤSeq) = LinMap(Bessel1, A, length(A)) Bessel1Transform(A::ℤSeq) = Bessel1.(Telescope(A)) function Hermite(n, k) isodd(n - k) && return ZZ(0) m = div(n - k, 2) div(Factorial(n), Factorial(k) * Factorial(m) * 2^m) end HermiteTriangle(dim) = [[Hermite(n, k) for k = 0:n] for n = 0:dim-1] Hermite(A::ℤSeq) = LinMap(Hermite, A, length(A)) HermiteTransform(A::ℤSeq) = Hermite.(Telescope(A)) function Trinomial(n, k) sum(Binomial(n, j) * Binomial(j, k - j) for j = 0:n) end TrinomialTriangle(dim) = [[Trinomial(n, k) for k = 0:n] for n = 0:dim-1] Trinomial(A::ℤSeq) = LinMap(Trinomial, A, length(A)) TrinomialTransform(A::ℤSeq) = Trinomial.(Telescope(A)) bs(n) = iszero(n) ? 0 : isodd(n) ? 2 : 1 SchröderBTriangle(dim) = DelehamΔ(dim, bs, n -> 0^n) ls(n) = isodd(n) ? 2 : 1 SchröderLTriangle(dim) = DelehamΔ(dim, ls, n -> 0^n) """ Recurrence for A132393, StirlingCycle numbers. """ function R132393(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) (n - 1) * prevrow(k) + prevrow(k - 1) end """ Recurrence for A048993, StirlingSet numbers. """ function R048993(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) k * prevrow(k) + prevrow(k - 1) end """ Recurrence for A271703, Lah numbers. """ function R271703(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) (k - 1 + n) * prevrow(k) + prevrow(k - 1) end """ Recurrence for A094587, (Rising factorials). """ function R094587(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) (n - k) * prevrow(k) + prevrow(k - 1) end """ Recurrence for A008279. Number of permutations of n things k at a time. (Falling factorials) """ function R008279(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) prevrow(k) + k * prevrow(k - 1) end """ xIterates over the first n rows of `A132393`. Triangle of unsigned Stirling numbers of the first kind. """ I132393(n) = RecTriangle(n, R132393) T132393(dim) = ZTri(I132393(dim)) """ (SIGNATURES) """ StirlingCycleTriangle(dim) = T132393(dim) StirlingCycle(n) = StirlingCycleTriangle(n + 1)[n+1] StirlingCycle(n, k) = StirlingCycle(n)[k+1] StirlingCycle(A::ℤSeq) = LinMap(StirlingCycle, A, length(A)) StirlingCycleTransform(A::ℤSeq) = StirlingCycle.(Telescope(A)) """ Iterates over the first n rows of `A048993`. Triangle of Stirling numbers of 2nd kind. """ I048993(n) = RecTriangle(n, R048993) T048993(dim) = ZTri(I048993(dim)) """ (SIGNATURES) """ StirlingSetTriangle(dim) = T048993(dim) StirlingSet(n) = StirlingSetTriangle(n + 1)[n+1] StirlingSet(n, k) = StirlingSet(n)[k+1] StirlingSet(A::ℤSeq) = LinMap(StirlingSet, A, length(A)) StirlingSetTransform(A::ℤSeq) = StirlingSet.(Telescope(A)) """ Iterates over the first n rows of `A094587`. """ I094587(n) = RecTriangle(n, R094587) T094587(dim) = ZTri(I094587(dim)) """ Iterates over the first n rows of `A008279`. """ I008279(n) = RecTriangle(n, R008279) T008279(dim) = ZTri(I008279(dim)) FallingFactTriangle(dim) = ZTri(I008279(dim)) PermCoeffsTriangle(dim) = ZTri(I008279(dim)) function R225478(n, k, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) 4 * prevrow(k - 1) + (4 * n - 1) * prevrow(k) end I225478(dim) = RecTriangle(dim, R225478) T225478(dim) = ZTri(I225478(dim)) function R007318(n, k, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) prevrow(k - 1) + prevrow(k) end I007318(dim) = RecTriangle(dim, R007318) PascalTriangle(dim) = ZTri(I007318(dim)) function SchroederBig(n, k) div( (k + 1) * sum(Binomial(n + 1, k + j + 1) * Binomial(n + j, j) for j = 0:(n-k)), n + 1, ) end function SchroederBigTriangle(dim) [[SchroederBig(n, k) for k = 0:n] for n = 0:dim-1] end SchroederBig(n) = SchroederBigTriangle(n + 1)[n+1] SchroederBig(A::ℤSeq) = LinMap(SchroederBig, A, length(A)) SchroederBigTransform(A::ℤSeq) = SchroederBig.(Telescope(A)) FJ(n, k) = n <= 2 ? 1 : FJ(n - 1, k) + k * FJ(n - 2, k) """ (SIGNATURES) """ JacobsthalTriangle(dim) = RiordanSquare(dim, n -> FJ(n, 2)) Jacobsthal(n) = JacobsthalTriangle(n + 1)[n+1] Jacobsthal(n, k) = Jacobsthal(n)[k+1] Jacobsthal(A::ℤSeq) = LinMap(Jacobsthal, A, length(A)) JacobsthalTransform(A::ℤSeq) = Jacobsthal.(Telescope(A)) """ (SIGNATURES) """ FibonacciTriangle(dim) = RiordanSquare(dim, n -> FJ(n, 1)) Fibonacci(n) = FibonacciTriangle(n + 1)[n+1] Fibonacci(n, k) = Fibonacci(n)[k+1] Fibonacci(A::ℤSeq) = LinMap(Fibonacci, A, length(A)) FibonacciTransform(A::ℤSeq) = Fibonacci.(Telescope(A)) function EulerianNumbers(n, k) haskey(CacheEulerian, (n, k)) && return CacheEulerian[(n, k)] CacheEulerian[(n, k)] = if (k == 0) && (n >= 0) ZZ(1) elseif (k < 0) || (k > n) ZZ(0) else (n - k) * EulerianNumbers(n - 1, k - 1) + (k + 1) * EulerianNumbers(n - 1, k) end end """ (SIGNATURES) """ EulerianTriangle(dim) = [[EulerianNumbers(n, k) for k = 0:n] for n = 0:dim-1] Eulerian(n) = EulerianTriangle(n + 1)[n+1] Eulerian(n, k) = Eulerian(n)[k+1] Eulerian(A::ℤSeq) = LinMap(Eulerian, A, length(A)) EulerianTransform(A::ℤSeq) = Eulerian.(Telescope(A)) function A046802(n, k) sum(Binomial(n, j) * Eulerian(j, j - k) for j = k:n) end A046802Triangle(dim) = [[A046802(n, k) for k = 0:n] for n = 0:dim-1] A046802(A::ℤSeq) = LinMap(A046802, A, length(A)) A046802Transform(A::ℤSeq) = A046802.(Telescope(A)) function EulerianNumbersClassic(n, k) haskey(CacheEulerianClassic, (n, k)) && return CacheEulerianClassic[(n, k)] CacheEulerianClassic[(n, k)] = if (k == n) ZZ(1) elseif (k <= 0) || (k > n) ZZ(0) else (n - k + 1) * EulerianNumbersClassic(n - 1, k - 1) + (k) * EulerianNumbersClassic(n - 1, k) end end EulerianTriangleClassic(dim) = [[EulerianNumbersClassic(n, k) for k = 0:n] for n = 0:dim-1] EulerianClassic(n) = EulerianTriangleClassic(n + 1)[n+1] EulerianClassic(n, k) = EulerianClassic(n)[k+1] EulerianClassic(A::ℤSeq) = LinMap(EulerianClassic, A, length(A)) EulerianTransform2(A::ℤSeq) = EulerianClassic.(Telescope(A)) function NarayanaNumbers(n::Int, k::Int) haskey(CacheNarayana, (n, k)) && return CacheNarayana[(n, k)] CacheNarayana[(n, k)] = if (k == n) ZZ(1) elseif k > n || k <= 0 ZZ(0) else div(Binomial(ZZ(n), n - k) * Binomial(ZZ(n - 1), n - k), ZZ(n - k + 1)) end end """ (SIGNATURES) """ NarayanaTriangle(dim) = [[NarayanaNumbers(n, k) for k = 0:n] for n = 0:dim] Narayana(n) = NarayanaTriangle(n + 1)[n+1] Narayana(n, k) = Narayana(n)[k+1] Narayana(A::ℤSeq) = LinMap(Narayana, A, length(A)) NarayanaTransform(A::ℤSeq) = Narayana.(Telescope(A)) """ (SIGNATURES) """ RisingFactTriangle(dim) = [[rising_factorial(ZZ(n), ZZ(k)) for k = 0:n] for n = 0:dim] RisingFact(n) = RisingFactTriangle(n + 1)[n+1] RisingFact(n, k) = RisingFact(n)[k+1] RisingFact(A::ℤSeq) = LinMap(RisingFact, A, length(A)) RisingFactTransform(A::ℤSeq) = RisingFact.(Telescope(A)) function Laguerre(n::Int) haskey(CacheLaguerre, n) && return CacheLaguerre[n] prevrow = Laguerre(n - 1) row = ZSeq(n + 1) row[n+1] = ZZ(1) for k ∈ 1:n row[k] = ( get(prevrow, k - 1, 0) + get(prevrow, k, 0) * (2 * k - 1) + get(prevrow, k + 1, 0) * k^2 ) end CacheLaguerre[n] = row end Laguerre(n::Int, k::Int) = Laguerre(n)[k+1] Laguerre(A::ℤSeq) = LinMap(Laguerre, A, length(A)) """ (SIGNATURES) """ function LaguerreTriangle(size::Int) length(CacheLaguerre) < size && Laguerre(size) [CacheLaguerre[n] for n = 0:size-1] end LaguerreTransform(A::ℤSeq) = Laguerre.(Telescope(A)) function transforms(trans) len = 18 println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") println(trans) println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") println() Unos = [ZZ(1) for n = 0:len] print("UNOS ") Println(Unos) trans(Unos) |> Println println() AltUnos = [(-1)^n * ZZ(1) for n = 0:len] println("ALTS ") Println(AltUnos) trans(AltUnos) |> Println println() Squares = [ZZ(n^2) for n = 0:len] println("SQRS ") Println(Squares) trans(Squares) |> Println println() Nat = [ZZ(n) for n = 0:len] println("N0TS ") Println(Nat) trans(Nat) |> Println println() Nut = [ZZ(n) for n = 1:len] println("NATS ") Println(Nut) trans(Nut) |> Println end const TRIANGLES = Function[ AitkenTriangle, Bessel1Triangle, BinomialTriangle, CatalanTriangle, DArcaisTriangle, DelannoyTriangle, EulerianTriangle, EulerianSO2Triangle, EulerSecTriangle, EulerTanTriangle, EulerTriangle, FallingFactTriangle, FibonacciTriangle, FineTriangle, FubiniTriangle, HermiteTriangle, LaguerreTriangle, LahTriangle, MotzkinTriangle, NarayanaTriangle, RencontresTriangle, RisingFactTriangle, SchröderBTriangle, SchröderLTriangle, StirlingCycleTriangle, StirlingSetTriangle, TrinomialTriangle, TTreeTriangle, UniTriangle, WorpitzkyTriangle, ] # *** TrianglesExplorer.jl **************** """ Explore integer triangles via their traits. The traits and their OEIS references will be saved as csv-files in the data directory. """ const ModuleTrianglesExplorer = "" const WARNING_ON_NOTFOUND = false const Kind = ["Std", "Rev", "Inv", "RevInv", "InvRev"] const Triangles = LittleDict{String,Function}( "Aitken" => AitkenTriangle, "Bessel1" => Bessel1Triangle, "Binomial" => BinomialTriangle, "Catalan" => CatalanTriangle, "DArcais" => DArcaisTriangle, "Delannoy" => DelannoyTriangle, "Euler" => EulerTriangle, "EulerS" => EulerSecTriangle, "EulerT" => EulerTanTriangle, "Eulerian" => EulerianTriangle, "EulerianSO2" => EulerianSO2Triangle, "FallingFact" => FallingFactTriangle, "Fibonacci" => FibonacciTriangle, "Fine" => FineTriangle, "Fubini" => FubiniTriangle, "Hermite" => HermiteTriangle, "Laguerre" => LaguerreTriangle, "Lah" => LahTriangle, "Motzkin" => MotzkinTriangle, "Narayana" => NarayanaTriangle, "RisingFact" => RisingFactTriangle, "SchroederB" => SchröderBTriangle, "SchroederL" => SchröderLTriangle, "StirlingCycle" => StirlingCycleTriangle, "StirlingSet" => StirlingSetTriangle, "Rencontres" => RencontresTriangle, "Trinomial" => TrinomialTriangle, "TTree" => TTreeTriangle, "Uni" => UniTriangle, "Worpitzky" => WorpitzkyTriangle, ) const TraitFunc = LittleDict{String,Function}( "Triangle" => Flat, "Reverse" => Reverse, "Inverse" => Inverse, "RevInv" => RevInv, "InvRev" => InvRev, "DiagTri" => DiagTri, "PolyTri" => PolyTri, "Sum" => sum, "EvenSum" => EvenSum, "OddSum" => OddSum, "AltSum" => AltSum, "DiagSum" => DiagSum, "Middle" => Middle, "Central" => Central, "LeftSide" => LeftSide, "RightSide" => RightSide, "PosHalf" => PosHalf, "NegHalf" => NegHalf, "PolyVal2" => PolyVal2, "PolyVal3" => PolyVal3, "BinConv" => BinomialTransform, "IBinConv" => IBinomialTransform, "TransSqrs" => TransSqrs, "TransNat0" => TransNat0, "TransNat1" => TransNat1, ) function Show(io, name, kind, trait, seq, savetofile = false) seq == [] && return [] if typeof(seq) === ℤTri seq = Flat(seq) end anum = GetSeqnum(seq, WARNING_ON_NOTFOUND) if savetofile print(".") print(io, anum, ",", name, ",", kind, ",", trait, ",") Println(io, SeqToString(seq, 10)) else print(anum, " ", name, " ", kind, " ", trait, " ") Println(IOContext(stdout), SeqToString(seq, 10)) end end function TriangleVariant(Tri, dim, kind = "Std") if !(kind in Kind) @warn("No valid kind!") return [] end M = Tri(dim) kind == "Std" && return M kind == "Rev" && return reverse.(M) kind == "InvRev" && (M = reverse.(M)) invM = InverseTriangle(M) (kind == "Inv" || kind == "InvRev" || invM == []) && return invM return reverse.(invM) end const LEN = 19 function Inspect(triangle, kind, trait, dim) T = TriangleVariant(Triangles[triangle], dim, kind) seq = TraitFunc[trait](T) seq == [] && return [] typeof(seq) === ℤTri && (seq = Flat(seq)) anum = GetSeqnum(seq, false) println(anum, " ", triangle, " ", kind, " ", trait) println(SeqToString(seq)) end """ (SIGNATURES) """ function Explore(triangle, kind, trait, dim) T = TriangleVariant(Triangles[triangle], dim, kind) seq = TraitFunc[trait](T) Show(stdout, triangle, kind, trait, seq) end function Explore(T::ℤTri, trait::Function) seq = trait(T) if seq == [] || seq === nothing return [] end typeof(seq) === ℤTri && (seq = Flat(seq)) println("$trait ") anum = GetSeqnumUri(seq) anum === nothing && (anum = "nothing") seqstr = string(seq[1:min(10, end)])[max(0, 11):max(0, end - 1)] String["$trait ", anum, seqstr] end """ """ function Explore(triangle, kind, trait) dim = 19 T = TriangleVariant(Triangles[triangle], dim, kind) seq = TraitFunc[trait](T) anum = GetSeqnum(seq) anum === nothing && (anum = "nothing") seqstr = string(seq[1:min(10, end)])[max(0, 11):max(0, end - 1)] String[anum, triangle, kind, trait, seqstr] end function Explore(trait::String, dim::Int) for (name, triangle) in Triangles for kind in Kind T = TriangleVariant(triangle, dim, kind) if T != [] seq = TraitFunc[trait](T) Show(stdout, name, kind, trait, seq) end end end end function Explore(savetofile::Bool) @warn "This will take several minutes and produce the file 'BIGLIST.csv' in the data directory." path = datapath("BIGLIST.csv") rm(path; force = true) open(path, "w") do io println(io, "Anumber,Triangle,Type,Trait,Sequence") for (name, triangle) in Triangles kind = "Std" T = TriangleVariant(triangle, LEN, kind) if T != [] for (trait, f) in TraitFunc Show(io, name, kind, trait, f(T), savetofile) end end end end end function SaveToCSV(name) T = Triangles[name](LEN) path = datapath(name * ".csv") rm(path; force = true) open(path, "w") do io println(io, "Trait,ANumber,Sequence") for (trait, f) in TraitFunc seq = f(T) seq == [] && continue if typeof(seq) === ℤTri seq = Flat(seq) end anum = GetSeqnum(seq) anum === nothing && (anum = "nothing") println(io, trait, ",", anum, ",", SeqToString(seq, 10)) end end end function SaveAllToCSV() @warn "This will take several minutes and produce the csv-files in the data directory." for (name, f) in Triangles println(name) SaveToCSV(name) end end # *** TrianglesPlot.jl **************** """ Plotting triangles. """ const ModuleTrianglesPlot = "" function PolyPlot(F, title) x = -2.0:0.05:1.0 plot(x, F[1], c = "black", linewidth = 1) plot!(x, F[2], c = "green", line = :dash) plot!(x, F[3], c = "blue", linewidth = 1) plot!(x, F[4], c = "red", line = :dash) plot!(x, F[5], c = "orange", linewidth = 1) plot!(x, F[6], c = "blue", line = :dash) plot!(x, F[7], c = "black", linewidth = 1) title!(title) xlabel!("x") ylabel!("p(x)") P = plot!(xlims = (-2.0, 1.0), ylims = (-5.0, 5.0)) display(P) end # *** TrianglesTables.jl **************** """ Pretty printing of triangles trait cards. | A-number | Triangle | Form | Function | Sequence | |----------|------------|------|-----------|---------------------------------------------| | A000302 | Binomial | Std | PolyVal3 | 1, 4, 16, 64, 256, 1024, 4096, 16384 | | A001333 | SchroederB | Inv | AltSum | 1, -1, 3, -7, 17, -41, 99, -239 | | A006012 | SchroederL | Inv | AltSum | 1, -2, 6, -20, 68, -232, 792, -2704 | | A026302 | Motzkin | Rev | Central | 1, 2, 9, 44, 230, 1242, 6853, 38376 | | A103194 | Laguerre | Std | TransNat0 | 0, 1, 6, 39, 292, 2505, 24306, 263431 | | A111884 | Lah | Std | TransAlts | 1, -1, -1, -1, 1, 19, 151, 1091 | | nothing | Laguerre | Rev | TransNat1 | 1, 3, 15, 97, 753, 6771, 68983, 783945 | """ const ModuleTrianglesTables = "" const CSS = [ "<style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;}", "td, th {border-bottom: 0; padding: 4px}", "tr:nth-child(odd) {background: #eee;}", "tr:nth-child(even) {background: #fff;}", "tr.header {background: orange !important; color: white; font-weight: bold;}", "tr.subheader {background: lightgray !important; color: black;}", "tr.headerLastRow {border-bottom: 2px solid black;}", "th.rowNumber, td.rowNumber {text-align: right;} </style><body>", ] function PrettyTraits(T, name) header = ["Trait", "ANumber", "Sequence"] mat = String[name "" ""] for tra in TRAITS s = Explore(T, tra) s == [] && continue mat = [mat; reshape(s, 1, 3)] end path = datapath(name * ".md") rm(path; force = true) open(path, "w") do io println(io, "```@raw html") for ln in CSS println(io, ln) end pretty_table( io, mat, header, backend = :html, standalone = false, alignment = [:l, :l, :l], ) println(io, "```") end end function AllPrettyTraits() for T in Triangles println("-- ", T[1]) PrettyTraits(Triangles[T[1]](32), T[1]) end end function AllCSVtoTable() header = ["ANumber", "Triangle", "Type", "Trait", "Sequence"] mat = String["" "" "" "" ""] inpath = datapath("BIGLIST.csv") open(inpath, "r") do csv for L ∈ eachline(csv, keep = false) mat = [mat; reshape(split(L, ","), 1, 5)] end end outpath = datapath("BIGLISTTEST.md") rm(outpath; force = true) open(outpath, "w") do html println(html, "```@raw html") for ln in CSS println(html, ln) end pretty_table( html, mat, header, backend = :html, standalone = false, alignment = [:l, :l, :l, :l, :l], ) println(html, "```") end end function CSVtoTable(name) header = ["Trait", "ANumber", "Sequence"] p = splitext(name)[begin] p = splitpath(p)[end] mat = String[p "" ""] firstline = true inpath = profilespath(name) open(inpath, "r") do csv for L ∈ eachline(csv, keep = false) firstline && (firstline = false; continue) s = split(L, ",") s[2] = MakeSeqUri(s[2], s[3]) mat = [mat; reshape(s, 1, 3)] end end outpath = docsrcpath(p * ".md") rm(outpath; force = true) open(outpath, "w") do html println(html, "```@raw html") for ln in CSS println(html, ln) end pretty_table( html, mat, header, backend = :html, standalone = false, alignment = [:l, :l, :l], ) println(html, "```") end end function UpdateDocs() csvfiles = csv_files() for filename ∈ csvfiles fulname = profilespath(filename) CSVtoTable(fulname) end end # *** TrianglesTraitCard.jl **************** """ Build the trait card of one or many triangles with Anums. ``` julia> TraitCard(LaguerreTriangle) Triangle: A021009 [1, 1, 1, 2, 4, 1, 6, 18, 9, 1] Reverse: A021010 [1, 1, 1, 1, 4, 2, 1, 9, 18, 6] Inverse: A021009 [1, -1, 1, 2, -4, 1, -6, 18, -9, 1] RevInv: A021010 [1, 1, -1, 1, -4, 2, 1, -9, 18, -6] Diagonal: A084950 [1, 1, 2, 1, 6, 4, 24, 18, 1, 120] Sum: A002720 [1, 2, 7, 34, 209, 1546, 13327, 130922, 1441729, 17572114] EvenSum: A331325 [1, 1, 3, 15, 97, 745, 6571, 65359, 723969, 8842257] OddSum: A331326 [0, 1, 4, 19, 112, 801, 6756, 65563, 717760, 8729857] AltSum: A009940 [1, 0, -1, -4, -15, -56, -185, -204, 6209, 112400] DiagSum: C001040 [1, 1, 3, 10, 43, 225, 1393, 9976, 81201, 740785] Central: A295383 [1, 4, 72, 2400, 117600, 7620480, 614718720, 59364264960] LeftSide: A000142 [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880] RightSide: A000012 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] PosHalf: A025167 [1, 3, 17, 139, 1473, 19091, 291793, 5129307, 101817089] NegHalf: A025166 [1, -1, 1, 7, -127, 1711, -23231, 334391, -5144063, 84149983] TransUnos: A002720 [1, 2, 7, 34, 209, 1546, 13327, 130922, 1441729, 17572114] TransSqrs: A105219 [0, 1, 8, 63, 544, 5225, 55656, 653023, 8379008, 116780049] TransNat0: A103194 [0, 1, 6, 39, 292, 2505, 24306, 263431, 3154824, 41368977] TransNat1: C000262 [1, 3, 13, 73, 501, 4051, 37633, 394353, 4596553, 58941091] PolyVal2: A087912 [1, 3, 14, 86, 648, 5752, 58576, 671568, 8546432, 119401856] PolyVal3: A277382 [1, 4, 23, 168, 1473, 14988, 173007, 2228544, 31636449] ``` """ const ModuleTrianglesTraitCard = "" const SEARCHONLINE = false # true function TraitCard(T::ℚTri, name) @warn "WRONG TYPE! Will not process!" end """ (SIGNATURES) """ function Traits(T::ℤTri, name, N, an = false) an = an && !oeis_notinstalled() sep = " " println("\n=================") println(name) println() P = Polynomial(T) len = max(N, min(N - 1, length(T))) len = len < 10 ? len : 10 S = Flat(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Triangle", sep, SeqToString(S, len)) R = Reverse(T) S = Flat(R) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Reverse", sep, SeqToString(S, len)) I = Inverse(T) if I != [] S = Flat(I) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Inverse", sep, SeqToString(S, len)) RI = Reverse(I) S = Flat(RI) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "RevInv", sep, SeqToString(S, len)) end IR = Inverse(R) if IR != [] S = Flat(IR) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "InvRev", sep, SeqToString(S, len)) end S = DiagonalTriangle(T) S = Flat(S) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "DiagTri", sep, SeqToString(S, len)) S = ConvolutionTriangle(T) S = Flat(S) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "ConvTri", sep, SeqToString(S, len)) S = PolyTriangle(T) S = Flat(S) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "PolyTri", sep, SeqToString(S, len)) S = sum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Sum", sep, SeqToString(S, len)) S = EvenSum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "EvenSum", sep, SeqToString(S, len)) S = OddSum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "OddSum", sep, SeqToString(S, len)) S = AltSum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "AltSum", sep, SeqToString(S, len)) S = DiagSum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "DiagSum", sep, SeqToString(S, len)) S = Central(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Central", sep, SeqToString(S, len)) S = LeftSide(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "LeftSide", sep, SeqToString(S, len)) S = RightSide(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "RightSide", sep, SeqToString(S, len)) S = PosHalf(P) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "PosHalf", sep, SeqToString(S, len)) S = NegHalf(P) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "NegHalf", sep, SeqToString(S, len)) S = BinConv(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "BinConv", sep, SeqToString(S, len)) S = IBinConv(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "IBinConv", sep, SeqToString(S, len)) S = Trans(T, [ZZ(n^2) for n = 0:19]) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "TransSqrs", sep, SeqToString(S, len)) S = Trans(T, [ZZ(n) for n = 0:19]) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "TransNat0", sep, SeqToString(S, len)) S = Trans(T, [ZZ(n) for n = 1:19]) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "TransNat1", sep, SeqToString(S, len)) S = PolyVal2(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "PolyVal2", sep, SeqToString(S, len)) S = PolyVal3(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "PolyVal3", sep, SeqToString(S, len)) end """ Print the standard traits generated by linear transformation. ``` julia> TransTraits(BinomialTriangle) BinomialTriangle TransSqrs: A001788 [0, 1, 6, 24, 80, 240, 672, 1792, 4608, 11520] TransNat0: A001787 [0, 1, 4, 12, 32, 80, 192, 448, 1024, 2304] TransNat1: A001792 [1, 3, 8, 20, 48, 112, 256, 576, 1280, 2816] ``` """ function TransTraits(triangle::Function) dim = 19 T = triangle(dim) println("$triangle ") len = min(10, min(dim - 1, length(T))) S = Trans(T, [ZZ(1) for n = 0:dim]) anum = GetSeqnum(S, false) print("TransUnos: ", anum, " ") S[1:len] |> Println S = Trans(T, [ZZ((-1)^n) for n = 0:dim]) anum = GetSeqnum(S, false) print("TransAlts: ", anum, " ") S[1:len] |> Println S = Trans(T, [ZZ(n^2) for n = 0:dim]) anum = GetSeqnum(S, false) print("TransSqrs: ", anum, " ") S[1:len] |> Println S = Trans(T, [ZZ(n) for n = 0:dim]) anum = GetSeqnum(S, false) print("TransNat0: ", anum, " ") S[1:len] |> Println S = Trans(T, [ZZ(n) for n = 1:dim]) anum = GetSeqnum(S, false) print("TransNat1: ", anum, " ") S[1:len] |> Println println() end """ (SIGNATURES) """ function AssociatedTriangles(T::ℤTri, N) len = max(N, min(N - 1, length(T))) println("\nTriangle:\n") for row in T[1:len] Println(row) end println() print("Flat triangle: ") S = Flat(T) S[1:len] |> Println println("\nInverse triangle:\n") S = InverseTriangle(T) if S != [] for row in S[1:len] Println(row) end println() S = Flat(S) print("Inverse: ") S[1:len] |> Println end println("\nDiagonal triangle:\n") S = DiagonalTriangle(T) Println.(S[1:len]) println() S = Flat(S) print("Diagonal: ") S[1:len] |> Println println("\nPolynomial values, array:\n") Println.(PolyArray(T)) println("\nPolynomial values, triangle:\n") S = PolyTriangle(T) Println.(S[1:len]) println() S = Flat(S) print("PolyVal: ") S[1:len] |> Println end """ Prints a list of traits of the triangle with Anums. """ function TraitCard(triangle::Function) dim = 19 T = triangle(dim) name = "$triangle" c = findfirst("Triangle", name) Traits(T, name[1:c[1]-1], dim, true) end """ Prints a list of traits of the triangle without Anums and, if assoc=true, also a list of associated triangles. """ function TraitCard(triangle::Function, dim, assoc = false) T = triangle(dim) name = "$triangle" c = findfirst("Triangle", name) Traits(T, name[1:c[1]-1], dim) AssociatedTriangles(T, dim) end function AllTraitCards() for T in TRIANGLES TraitCard(T) end end # *** TrianglesUtils.jl **************** """ * Search the OEIS for a sequence. * Save a file in the 'data' directory in json format. * Triangle in standard format (without typeinfo): ``` [1] [1, 1] [2, 4, 1] [6, 18, 9, 1] [24, 96, 72, 16, 1] [120, 600, 600, 200, 25, 1] [720, 4320, 5400, 2400, 450, 36, 1] ``` * Triangle as a nested array: ``` [[1], [1, 1], [2, 4, 1], [6, 18, 9, 1], [24, 96, 72, 16, 1], [120, 600, 600, 200, 25, 1], [720, 4320, 5400, 2400, 450, 36, 1]] ``` * Triangle in flattened format: ``` 1, 1, 1, 2, 4, 1, 6, 18, 9, 1, 24, 96, 72, 16, 1, 120, 600, 600, 200, 25, 1, 720, 4320, 5400, 2400, 450, 36, 1, ``` * Triangle in info format with sequence ID: ``` [A021009] 1, 1, 1, 2, 4, 1, 6, 18, 9, 1, 24, 96, 72, 16, 1, ... ``` * Triangle in mapped format: ``` 0 ↦ 1 1 ↦ 1 2 ↦ 1 3 ↦ 2 4 ↦ 4 5 ↦ 1 6 ↦ 6 7 ↦ 18 8 ↦ 9 9 ↦ 1 ``` """ const ModuleTrianglesUtils = "" const srcdir = realpath(joinpath(dirname(@__FILE__))) const ROOTDIR = dirname(srcdir) const datadir = joinpath(ROOTDIR, "data") const profilesdir = joinpath(ROOTDIR, "profiles") const docsdir = joinpath(ROOTDIR, "docs") const docsrcdir = joinpath(docsdir, "src") datapath(name) = joinpath(datadir, name) profilespath(name) = joinpath(profilesdir, name) docsrcpath(name) = joinpath(docsrcdir, name) oeis_file() = joinpath(datadir, "stripped") is_oeis_installed() = isfile(oeis_file()) csv_files() = filter!(s -> occursin(r"\.csv$", s), readdir(profilesdir)) function oeis_notinstalled() if !is_oeis_installed() @warn("OEIS data not installed! Download stripped.gz from oeis.org,") @warn("expand it and put it in the directory ../data.") return true end return false end function search_failed(name) for ln ∈ eachline(name) occursin("greeting", ln) && continue occursin("{", ln) && continue occursin("start", ln) && continue if occursin("\"results\": null", ln) return true end end false end """ Search the OEIS for a sequence. The file is saved in the 'data' directory in json format. """ function oeis_search(seq) seqstr = AbsSeqToString(seq[1:min(end, 12)]) filename = joinpath(datadir, seqstr[1:min(end, 12)] * ".json") uristr = "https://oeis.org/search?q=" * seqstr * "&go=Search&fmt=json" url = HTTP.URI(uristr) tries = 3 r = nothing for i = 1:tries try r = HTTP.get(url; readtimeout = 2) getfield(r, :status) == 200 && break getfield(r, :status) == 302 && break catch e @warn(e) end sleep(2) end if !(r === nothing) && getfield(r, :status) == 200 open(filename, "w") do f write(f, getfield(r, :body)) end @info("Dowloaded " * basename(filename) * " to " * datadir) else if r === nothing @warn("Search did not succeed, connection timed out.\n") else @warn( "Search did not succeed, $url\nStatus: $(getfield(r, :status))" ) end end filename end function AbsSeqToString(seq::ℤSeq, max = 100) separator = "," str = "" c = 1 for trm in seq str *= string(abs(trm)) * separator c += 1 c > max && break end str end function SeqToString(seq::ℤSeq, max = 100) separator = " " str = "[" c = 1 for trm in seq str *= string(trm) * separator c += 1 c > max && break end str * "]" end const minlen = 30 # fragil! do not reduce! function GetSeqnum(seq::ℤSeq) str = AbsSeqToString(seq) soff = 1 loff = 10 for ln ∈ eachline(oeis_file()) ln[1] == '#' && continue l = replace(ln, "-" => "") m = min(length(str), length(l)) len = min(length(str), length(l) - loff) - 1 len < minlen && continue cmp(str[soff:soff+len], l[loff:loff+len]) == 0 && return ln[1:7] end toff = findfirst(",", str)[1] + 1 for ln ∈ eachline(oeis_file()) ln[1] == '#' && continue l = replace(ln, "-" => "") len = min(length(str) - toff, length(l) - loff) - 1 len < minlen && continue cmp(str[toff:toff+len], l[loff:loff+len]) == 0 && return "A" * ln[2:7] end for ln ∈ eachline(oeis_file()) ln[1] == '#' && continue l = replace(ln, "-" => "") ff = findnext(",", l, 10) ff === nothing && continue loff = ff[1] + 1 soff = 1 len = min(length(str) - soff, length(l) - loff) - 1 len < minlen && continue cmp(str[soff:soff+len], l[loff:loff+len]) == 0 && return "A" * ln[2:7] len = min(length(str) - toff, length(l) - loff) - 1 len < minlen && continue cmp(str[toff:toff+len], l[loff:loff+len]) == 0 && return "A" * ln[2:7] end nothing end GetSeqnum(seq::ℤTri) = GetSeqnum(Flat(seq)) function GetSeqnum(seq, search = false) if seq === nothing || seq == [] return nothing end anum = GetSeqnum(seq) if search if anum === nothing filename = oeis_search(seq) if !search_failed(filename) println() Println(seq[1:min(18, end)]) @warn "Not found in the local base but possibly in the OEIS!" println() end end end anum end function GetSeqnumUri(seq::ℤSeq, len = 10) anum = GetSeqnum(seq) if anum === nothing return "<a href='" * "https://oeis.org/?q=" * SeqToString(seq, len) * "'>" * "nomatch</a>" end uri = joinpath("https://oeis.org/", anum) return "<a href='" * uri * "'>" * anum * "</a>" end function MakeSeqUri(anum, seq) if anum == "nothing" return "<a href='" * "https://oeis.org/?q=" * seq * "'>" * "nomatch</a>" end uri = joinpath("https://oeis.org/", anum) return "<a href='" * uri * "'>" * anum * "</a>" end function print_without_type(io, v::AbstractVector) print(io, "[") for (i, el) ∈ enumerate(v) i > 1 && print(io, ", ") print(io, el) end println(io, "]") end """ Print the array ``A`` in the format ``n ↦ A[n]`` for n in the given range. """ function MappedShow(A::Array, R::AbstractRange, offset = 0) for k ∈ R if isassigned(A, k) println(k + offset, " ↦ ", A[k]) else println(k + offset, " ↦ ", "undef") end end end """ Print an integer triangle without typeinfo. """ function Show(T::ℤTri, format = "std") if format == "std" # default for t in T[1:min(10, end)] print_without_type(IOContext(stdout), t) end elseif format == "nest" T |> println elseif format == "flat" for n in Flat(T) print(n, ", ") end elseif format == "map" offset = -1 # Julia is unfortunately 1-based. for n in T MappedShow(n, 1:length(n), offset) offset += length(n) end elseif format == "info" S = Flat(T) print("[", GetSeqnum(S), "] ") for t in T[1:min(5, end)], k in t print(k, ", ") end println("... ") end end end
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
23878
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module TrianglesBase using Nemo import Base.sum export AbstractSequence, AbstractTriangle export ℤInt, ℤSeq, ℤTri, ℚInt, ℚSeq, ℚTri export ℤPolySeq, ℚPolySeq, ℤPolyRing, ℚPolyRing export ZInt, ZSeq, ZTri, QInt, QSeq, QTri export ZPolySeq, QPolySeq, ZPolyRing, QPolyRing export Polynomial, Evaluate, PolyArray export PolyTriangle, PolyTri, DiagTri, DiagonalTriangle export OrthoPoly, DelehamΔ, RecTriangle export EgfExpansionCoeff, EgfExpansionPoly export InverseTriangle, Inverse, Reverse, InvRev, RevInv export PolynomialFunction, ReversePolynomial, PolyValue export PolyVal2, PolyVal3, Coefficients export RiordanSquare, Println, Print, Telescope, LinMap, Trans export EvenSum, OddSum, AltSum, DiagSum, Central, Middle export LeftSide, RightSide, PosHalf, NegHalf, Flat, Factorial export Binomial, BinomialTransform, BinConv, BinomialTriangle export IBinomial, IBinomialTransform, IBinConv, IBinomialTriangle export TransUnos, TransAlts, TransSqrs, TransNat0, TransNat1 export Convolution, ConvolutionTriangle, ConvolutionTransformation export ConvSum, ConvTri, ConvTrans export TRAITS """ Basic definitions used in the library IntegerTriangles. We consider the following traits of an triangle: ``` Flat, Reverse, Inverse, RevInv, InvRev, DiagTri, PolyTri, Sum, EvenSum, OddSum, AltSum, DiagSum, Middle, Central, LeftSide, RightSide, PosHalf, NegHalf, PolyVal2, PolyVal3, BinConv, IBinConv, TransSqrs, TransNat0, TransNat1 ``` """ const ModuleTrianglesBase = "" """ Supertype for sequences (or sequence-like types). """ abstract type AbstractSequence end """ Supertype for triangles (or triangles-like types). """ abstract type AbstractTriangle end const Seq{T} = Array{T,1} """ ℤInt is an alias for the type Nemo.fmpz. """ const ℤInt = Nemo.fmpz """ ℚInt is an alias for the type Nemo.fmpq. """ const ℚInt = Nemo.fmpq """ ℤSeq is an alias for the type Array{Nemo.fmpz, 1}. """ const ℤSeq = Seq{ℤInt} """ ℚSeq is an alias for the type Array{Nemo.fmpq, 1}. """ const ℚSeq = Seq{ℚInt} """ ℤTri is an alias for the type Array{Array{Nemo.fmpz, 1}, 1}. """ const ℤTri = Seq{ℤSeq} """ ℚTri is an alias for the type Array{Array{Nemo.fmpq, 1}, 1}. """ const ℚTri = Seq{ℚSeq} # ------------- # ZZ(n) # (constructor for fmpz, defined in Nemo) # QQ(n, k) # (constructor for fmpq, defined in Nemo) """ Constructor for an ℤSeq of length len. If a second parameter f is given the sequence is constructed as [ZZ(f(n)) for n in 0:len-1] """ ZSeq(len::Int) = ℤSeq(undef, len) ZSeq(len::Int, f::Function) = [ZZ(f(n)) for n in 0:len-1] """ Constructor for an ℚSeq of length len. If a second parameter f is given the sequence is constructed as [QQ(f(n)) for n in 0:len-1] """ QSeq(len::Int) = ℚSeq(undef, len) QSeq(len::Int, f::Function) = [QQ(f(n)) for n in 0:len-1] """ Constructor for ZTri. """ function ZTri(dim::Int; reg=false) reg ? ℤTri(ZSeq.(1:dim)) : ℤTri(undef, dim) end ZTri(dim, f::Function) = f.(0:dim-1) ZTri(T::AbstractTriangle) = [row for row ∈ T] """ Constructor for QTri. """ function QTri(dim::Int; reg=false) reg ? QSeq.(1:dim) : ℚTri(undef, dim) end # --------------- """ ℤPoly is an alias for the type Nemo.fmpz_poly. """ const ℤPoly = Nemo.fmpz_poly """ ℚPoly is an alias for the type Nemo.fmpq_poly. """ const ℚPoly = Nemo.fmpq_poly """ ℤPolySeq is an alias for the type Array{Nemo.fmpz_poly, 1}. """ const ℤPolySeq = Seq{ℤPoly} """ ℚPolySeq is an alias for the type Array{Nemo.fmpq_poly, 1}. """ const ℚPolySeq = Seq{ℚPoly} """ ℤPolyTri is an alias for the type Array{Array{Nemo.fmpz_poly, 1}, 1}. """ const ℤPolyTri = Seq{ℤPolySeq} """ ℚPolyTri is an alias for the type Array{Array{Nemo.fmpq_poly, 1}, 1}. """ const ℚPolyTri = Seq{ℚPolySeq} # --------------- """ (SIGNATURES) """ ZPolyRing(x) = PolynomialRing(ZZ, x) """ (SIGNATURES) """ QPolyRing(x) = PolynomialRing(QQ, x) const WARNING_ON_NOTINVERTIBLE = false """ Return the diagonal triangle T(n - k, k) where k in 0:n/2. ``` julia> Println.(DiagonalTriangle(MotzkinTriangle(8))) [1] [1] [2, 1] [4, 2] [9, 5, 1] [21, 12, 3] [51, 30, 9, 1] [127, 76, 25, 4] # A106489 ``` """ function DiagonalTriangle(T::ℤTri) dim = length(T) U = ZTri(dim) for n = 1:dim R = ZSeq(div(n + 1, 2)) for k = 0:div(n - 1, 2) R[k + 1] = T[n - k][k + 1] end U[n] = R end U end DiagTri(T::ℤTri) = DiagonalTriangle(T) # -------------------------------------------------- function Convolution(S::ℤSeq, T::ℤSeq) L = length(S); if L != length(T) @warn "Incompatible lengths!" return [] end [sum(S[k + 1] * T[n - k + 1] for k in 0:n) for n in 0:L-1] end Convolution(S::ℤSeq) = Convolution(S, S) ConvSum(S::ℤSeq) = sum(Convolution(S)) """ Return the convolution triangle of T. ``` julia> T = [ℤInt[1], ℤInt[2, 3], ℤInt[4, 5, 6], ℤInt[7, 8, 9, 10]] Println.(ConvolutionTriangle(T)) [1] [4, 12] [16, 40, 73] [49, 112, 190, 284] ``` """ ConvolutionTriangle(T::ℤTri) = Convolution.(T) ConvTri(T::ℤTri) = ConvolutionTriangle(T) # alias #= -------------------------------------------------- """ ``` julia> Println.(ConvolutionTransformation(T)) [1, 16, 129, 635] ``` """ ConvolutionTransformation(T::ℤTri) = sum.(Convolution.(T)) ConvTrans(T::ℤTri) = ConvolutionTransformation(T::ℤTri) # alias function BinomialConvolution(S::ℤSeq, T::ℤSeq) L = length(S); L != length(T) && return [] [sum(Binomial(n,k)*S[k + 1] * T[n - k + 1] for k in 0:n) for n in 0:L-1] end BinomialConvolution(S::ℤSeq) = BinomialConvolution(S, S) BinConvSum(S::ℤSeq) = sum(BinomialConvolution(S)) """ Return the binomial convolution triangle of T. """ BinomialConvolutionTriangle(T::ℤTri) = BinomialConvolution.(T) BinConvTri(T::ℤTri) = BinomialConvolutionTriangle(T) # alias BinomialConvolutionTransformation(T::ℤTri) = sum.(BinomialConvolution.(T)) BinConvTrans(T::ℤTri) = BinomialConvolutionTransformation(T::ℤTri) # alias =# #-------------------------------------------------- """ The sum of a ℤTri is the sequence of the sum of the rows. """ Base.sum(T::ℤTri) = [sum(row) for row ∈ T] Base.sum(T::ℚTri) = [sum(row) for row ∈ T] """ The EvenSum of a ℤSeq is the sum of the even indexed terms, indexing starts with 0. ``` julia> EvenSum([0, 1, 2, 3, 4, 5]) 0 + 2 + 4 = 6 ``` """ EvenSum(A) = sum(A[1:2:end]) """ The OddSum of a ℤSeq is the sum of the odd indexed terms, indexing starts with 0. ``` julia> OddSum([0, 1, 2, 3, 4, 5]) 1 + 3 + 5 = 9 ``` """ OddSum(A) = sum(A[2:2:end]) """ The AltSum of a ℤSeq is the alternating sum. ``` julia> AltSum([0, 1, 2, 3, 4, 5]) + 0 - 1 + 2 - 3 + 4 - 5 = 6 - 9 = - 3 ``` """ AltSum(A) = EvenSum(A) - OddSum(A) """ The Middle of a ℤSeq A is the middle term, A[div(begin + end, 2)]. ``` julia> Middle([0, 1, 2, 3, 4, 5]) 3 ``` """ Middle(A) = A[div(begin + end, 2)] """ The LeftSide of a ℤSeq is the first term. ``` julia> LeftSide([0, 1, 2, 3, 4, 5]) 0 ``` """ LeftSide(A) = A[begin] """ The RightSide of a ℤSeq is the last term. ``` julia> RightSide([0, 1, 2, 3, 4, 5]) 5 ``` """ RightSide(A) = A[end] """ The EvenSum of a ℤTri is the sequence of the even sums of the rows. ``` EvenSum(T::ℤTri) = EvenSum.(T) ``` """ EvenSum(T::ℤTri) = EvenSum.(T) """ The OddSum of a ℤTri is the sequence of the odd sums of the rows. ``` OddSum(T::ℤTri) = OddSum.(T) ``` """ OddSum(T::ℤTri) = OddSum.(T) """ The AltSum of a ℤTri is the sequence of the alternating sums of the rows. ``` AltSum(T::ℤTri) = EvenSum(T) - OddSum(T) ``` """ AltSum(T::ℤTri) = EvenSum(T) - OddSum(T) """ The DiagSum of a ℤTri is the sum of the diagonal triangle. ``` DiagSum(T::ℤTri) = sum(DiagonalTriangle(T)) ``` """ DiagSum(T::ℤTri) = sum(DiagonalTriangle(T)) """ The Middle of a ℤTri is the sequence of the middle term in the rows. ``` Middle(T::ℤTri) = Middle.(T) ``` """ Middle(T::ℤTri) = Middle.(T) """ The Central of a ℤTri is the sequence of the middle term of the even indexed rows, indexing starts with 0. ``` Central(T::ℤTri) = Middle.(T[begin:2:end]) ``` """ Central(T::ℤTri) = Middle.(T[begin:2:end]) """ The LeftSide of a ℤTri is the sequence of the first term in the rows. ``` LeftSide(T::ℤTri) = LeftSide.(T) ``` """ LeftSide(T::ℤTri) = LeftSide.(T) """ The RightSide of a ℤTri is the sequence of the last term in the rows. ``` RightSide(T::ℤTri) = RightSide.(T) ``` """ RightSide(T::ℤTri) = RightSide.(T) """ Return the ℤ-polynomial whose coefficients are the terms of the sequence. ``` [1, 2, 3] -> 1 + 2*x + 3*x^2 ``` """ function Polynomial(S::ℤSeq) R, x = ZPolyRing("x") sum(c * x^(k - 1) for (k, c) ∈ enumerate(S)) end """ Return the sequence of ℤ-polynomials whose coefficients are the terms of the triangle. ``` Polynomial(T::ℤTri) = Polynomial.(T) ``` """ Polynomial(T::ℤTri) = Polynomial.(T) """ Return the ℤ-polynomial whose coefficients are the terms of the reversed sequence. ``` [1, 2, 3] -> x^2 + 2*x + 3 ``` """ ReversePolynomial(S::ℤSeq) = Polynomial(reverse(S)) """ Return the sequence of ℤ-polynomials whose coefficients are the terms of the reversed triangle. ``` ReversePolynomial(T::ℤTri) = ReversePolynomial.(T) ``` """ ReversePolynomial(T::ℤTri) = ReversePolynomial.(T) """ Return the polynomial function associated with the polynomial with coefficients given by the sequence S. A polynomial function evaluates to Float64 values. ``` p = PolynomialFunction([1, 2, 3]) julia> [p(r) for r in 0:3] 4-element Vector{Float64}: 1.0 6.0 17.0 34.0 ``` """ function PolynomialFunction(S) y -> sum(Float64(c) * y^(k - 1) for (k, c) ∈ enumerate(S)) end """ Return the sequence of polynomial functions associated to the polynomials with coefficients given by the triangle T. ``` PolynomialFunction(T::ℤTri) = PolynomialFunction.(T) ``` """ PolynomialFunction(T::ℤTri) = PolynomialFunction.(T) """ Return the value of the ℤ-polynomial p evaluated at x. ``` julia> R, x = ZPolyRing("x") p = 1 + 2*x + 3*x^2 Evaluate(p, 2) 17 ``` """ Evaluate(p::ℤPoly, x) = subst(p, x) Evaluate(p::ℚPoly, x) = subst(p, x) """ Return the sequence of values to which the sequence of ℤ-polynomials P evaluate at x. ``` julia> R, x = ZPolyRing("x") P = [sum(k * x^k for k in 0:n) for n in 0:9] Evaluate(P, 3) # A289399 ``` """ Evaluate(P::ℤPolySeq, x) = Evaluate.(P, x) Evaluate(P::ℚPolySeq, x) = Evaluate.(P, x) """ Return the list of coefficients of the polynomial p (ordered by ascending powers). ``` julia> R, x = ZPolyRing("x") p = 1 + 2*x + 3*x^2 Coefficients(p) ``` """ Coefficients(p, n=0) = p == 0 ? ℤInt[0] : coeff.(p, 0:max(n,degree(p))) """ Return the sequence of list of coefficients of the polynomials P. """ Coefficients(P::AbstractArray) = Coefficients.(P) import Nemo.numerator numerator(T::ℚTri) = [numerator.(t) for t ∈ T] """ Return numerator(2^degree(p) * Evaluate(p, QQ(1, 2))). ``` julia> R, x = ZPolyRing("x") p = 1 + 2*x + 3*x^2 PosHalf(p) 11 ``` """ PosHalf(p) = p == 0 ? ZZ(0) : numerator(2^degree(p) * Evaluate(p, QQ(1, 2))) """ Return Numerator((-2)^degree(p) * Evaluate(p, QQ(-1, 2))) ``` julia> R, x = ZPolyRing("x") p = 1 + 2*x + 3*x^2 NegHalf(p) 3 ``` """ NegHalf(p) = p == 0 ? ZZ(0) : numerator((-2)^degree(p) * Evaluate(p, QQ(-1, 2))) """ Return the sequence generated by broadcasting PosHalf over the rows of the triangle interpreted as a polynomials. ``` julia> T = [[ZZ(k) for k in 0:n] for n in 1:5] PosHalf(Polynomial(T)) # A000295 5-element ℤSeq 1 4 11 26 57 ``` """ PosHalf(T::ℤTri) = PosHalf.(Polynomial(T)) """ Return the sequence generated by broadcasting NegHalf over the rows of the triangle interpreted as a polynomials. ``` NegHalf(T::ℤTri) = NegHalf.(Polynomial(T)) ``` """ NegHalf(T::ℤTri) = NegHalf.(Polynomial(T)) """ Return the sequence generated by broadcasting PosHalf over the sequence of polynomials. """ PosHalf(P::ℤPolySeq) = PosHalf.(P) """ Return the sequence generated by broadcasting NegHalf over the sequence of polynomials. """ NegHalf(P::ℤPolySeq) = NegHalf.(P) # ------------------------------------------------------- LinMap(M::ℤTri, V::ℤSeq, n) = sum(M[n][k] * V[k] for k = 1:n) """ LinMap(M::ℤTri, V::ℤSeq) returns the 'matrix times vector' product of M and V. Expands up to length(V) and we assume length(M) >= length(V). """ LinMap(M::ℤTri, V::ℤSeq) = (n -> LinMap(M, V, n)).(1:length(V)) LinMap(F::Function, V::ℤSeq, n) = sum(F(n - 1)[k] * V[k] for k = 1:n) """ LinMap(F::Function, V::ℤSeq) returns the 'matrix times vector' product of a matrix generated by F and V. ``` julia> L(n) = [ZZ(k) for k in 0:n] [LinMap(L, L(n)) for n in 0:9] 0 1 5 14 30 ... # A000330 ``` """ LinMap(F::Function, V::ℤSeq) = LinMap(F, V, length(V)) """ Transform a ℤSeq V by the matrix/vector product by applying LinMap to (M, V). Expands up to min(length(M), length(V)). """ Trans(M::ℤTri, V::ℤSeq) = (n -> LinMap(M, V, n)).(1:min(length(M), length(V))) # ------------------------------------------------------- #""" --- same as sum #TransUnos(T) = Trans(T, [ZZ(1) for n = 0:length(T)]) # #Standard trait of T. #""" #TransUnos(T) = Trans(T, [ZZ(1) for n = 0:length(T)]) """ TransAlts(T) = Trans(T, [(-1)^n * ZZ(1) for n = 0:length(T)]) Standard trait of T. """ TransAlts(T) = Trans(T, [(-1)^n * ZZ(1) for n = 0:length(T)]) """ TransSqrs(T) = Trans(T, [ZZ(n^2) for n = 0:length(T)]) Standard trait of T. """ TransSqrs(T) = Trans(T, [ZZ(n^2) for n = 0:length(T)]) """ TransNat0(T) = Trans(T, [ZZ(n) for n = 0:length(T)]) Standard trait of T. """ TransNat0(T) = Trans(T, [ZZ(n) for n = 0:length(T)]) """ TransNat1(T) = Trans(T, [ZZ(n) for n = 1:length(T)]) Standard trait of T. """ TransNat1(T) = Trans(T, [ZZ(n) for n = 1:length(T)]) """ Return an iterator expanding the given sequence to a regular triangle. ``` julia> T = Telescope(ℤInt[1, 2, 3, 4, 5, 6]) collect(T) [1] [1, 2] [1, 2, 3] [1, 2, 3, 4] [1, 2, 3, 4, 5] [1, 2, 3, 4, 5, 6] ``` """ Telescope(A::ℤSeq) = (A[1:k] for k = 1:size(A, 1)) """ Return an iterator expanding the sequence generated by the function f to a regular triangle. """ Telescope(len::Int, f::Function) = Telescope([ZZ(f(k)) for k = 0:len - 1]) # -------------------------------------------------- """ (SIGNATURES) """ Binomial(n, k) = Nemo.binomial(ZZ(n), ZZ(k)) Binomial(n) = [Binomial(n, k) for k = 0:n] Binomial(A::ℤSeq) = LinMap(Binomial, A) """ (SIGNATURES) """ BinomialTriangle(dim) = [Binomial(n) for n = 0:dim - 1] """ (SIGNATURES) """ BinomialTransform(A::ℤSeq) = Binomial.(Telescope(A)) BinomialTransform(A::ℤTri) = Binomial.(A) # Alias BinConv(A::ℤTri) = BinomialTransform(A::ℤTri) # -------------------------------------------------- IBinomial(n, k) = ZZ((-1)^(n-k))*Binomial(n, k) IBinomial(n) = [IBinomial(n, k) for k = 0:n] IBinomial(A::ℤSeq) = LinMap(IBinomial, A) """ (SIGNATURES) """ IBinomialTriangle(dim) = [IBinomial(n) for n = 0:dim - 1] """ (SIGNATURES) """ IBinomialTransform(A::ℤSeq) = IBinomial.(Telescope(A)) IBinomialTransform(A::ℤTri) = IBinomial.(A) # Alias IBinConv(A::ℤTri) = IBinomialTransform(A::ℤTri) # -------------------------------------------------- """ Return the factorial ``n! = ∏(1, n)``. """ Factorial(n) = Nemo.factorial(ZZ(n)) """ (SIGNATURES) """ Laplace(s, k) = factorial(k) * coeff(s, k) """ Return the Laplace expansion of a bivariate exponential generating function as a power series, or, if 'coeff=true', as the coefficients of the series. """ function EgfExpansion(prec, gf::Function, coeff=true) R, x = QPolyRing("x") S, t = PowerSeriesRing(R, prec + 1, "t") ser = gf(x, t) P = Laplace.(ser, 0:prec - 1) coeff ? Coefficients.(P) : P end """ Return the Laplace expansion of a bivariate exponential generating function as a power series. """ EgfExpansionCoeff(prec, gf::Function) = EgfExpansion(prec, gf, true) """ Return the Laplace expansion of a bivariate exponential generating function as a list of the coefficients of the power series. """ EgfExpansionPoly(prec, gf::Function) = EgfExpansion(prec, gf, false) function OrthoPoly(dim::Int, s::Function, t::Function) T = ZTri(dim, reg=true) # regular triangle for n ∈ 1:dim T[n][n] = 1 end for n ∈ 2:dim u(k) = k == 0 || k == n ? 0 : T[n - 1][k] for k ∈ 1:n - 1 T[n][k] = (u(k - 1) + s(k - 1) * u(k) + t(k) * u(k + 1)) end end T end """ (SIGNATURES) """ function DelehamΔ(dim::Int, s::Function, t::Function) T = ZTri(dim) R, x = ZPolyRing("x") A = [R(s(k) + x * t(k)) for k ∈ 0:dim - 2] C = [R(1) for i ∈ 0:dim] C[1] = R(0) m = 1 for k ∈ 0:dim - 1 for j ∈ k + 1:-1:2 C[j] = C[j - 1] + C[j + 1] * A[j - 1] end T[m] = [coeff(C[2], j) for j ∈ 0:k] m += 1 end T end # -------------------------------------------------- """ (SIGNATURES) """ function RiordanSquare(dim::Int, s::Function) T = ZTri(dim, reg=true) for n ∈ 0:dim - 1 T[n + 1][1] = s(n) end for k ∈ 1:dim - 1, m ∈ k:dim - 1 T[m + 1][k + 1] = sum(T[j][k] * T[m - j + 2][1] for j ∈ k:m) end T end """ (SIGNATURES) """ function ExpRiordanSquare(dim::Int, s::Function) R = RiordanSquare(dim, s) u = ZZ(1) for k ∈ 1:dim - 1 u *= k for m ∈ 1:k j = (m == 1 ? u : div(j, m - 1)) R[k + 1][m] *= j end end R end # -------------------------------------------------- """ (SIGNATURES) """ function check(invM, dim) for n = 1:dim for k = 1:n if denominator(invM[n, k]) != 1 return false end end end return true end """ (SIGNATURES) """ function InverseTriangle(T) dim = length(T) M = zeros(QQ, dim, dim) for n in 1:dim, k in 1:n M[n, k] = QQ(T[n][k]) end S = MatrixSpace(QQ, dim, dim) invM = try inv(S(M)) catch e if isa(e, Exception) if WARNING_ON_NOTINVERTIBLE @warn("\n\n Not invertible!\n\n") end return ℤSeq[] end end # check if all entries are integer. if check(invM, dim) != true if WARNING_ON_NOTINVERTIBLE @warn("\n\n Inverse not in MatrixSpace(ZZ)!\n\n") end return ℤSeq[] end return [[numerator(invM[n, k]) for k = 1:n] for n = 1:dim] end """ Alias for InverseTriangle """ Inverse(T::ℤTri) = InverseTriangle(T) """ Return the row reversed triangle. """ Reverse(T::ℤTri) = reverse.(T) """ (SIGNATURES) """ function RevInv(T::ℤTri) I = Inverse(T) return I != [] ? Reverse(I) : ℤSeq[] end """ (SIGNATURES) """ InvRev(T::ℤTri) = Inverse(Reverse(T)) """ (SIGNATURES) """ function Flat(T::ℤTri) T === [] && return [] Empty(s) = isempty(s) ? [ZZ(0)] : s [z for t ∈ T for z ∈ Empty(t)] end """ Print the array without typeinfo. """ function Println(io, v::AbstractVector, newline=true) print(io, "[") for (i, el) ∈ enumerate(v) i > 1 && print(io, ", ") print(io, el) end newline ? println(io, "]") : print(io, "]") end # TransformTriangle(Trans::Function, dim::Int, f::Function) = ℤTri(dim, n -> Trans(n+1, x -> f(x, n))) # Print the array without typeinfo. Println(io, str::String) = println(io, str) Println(T::ℤSeq) = Println(IOContext(stdout), T) Println(T::ℤTri) = Println.(IOContext(stdout), T) Print(io, str::String) = print(io, str) Print(T::ℤSeq) = Println(IOContext(stdout), T, false) Print(T::ℤTri) = Println.(IOContext(stdout), T, false) """ A recursive triangle `RecTriangle` is a subtype of `AbstractTriangle`. The rows of the triangle are generated by a function `gen(n, k, prevrow)` defined for ``n ≥ 0`` and ``0 ≤ k ≤ n``. The function returns value of type ℤInt. The parameter prevrow is a function which returns the values of `row(n-1)` of the triangle and 0 if ``k < 0`` or ``k > n``. The function prevrow is provided by an instance of `RecTriangle` and must not be defined by the user. """ struct RecTriangle <: AbstractTriangle dim::Int A::ℤSeq gen::Function # generating function function RecTriangle(dim::Int, gen::Function) dim <= 0 && throw(ArgumentError("dim has to be a positive integer.")) new( dim, fill(ZZ(0), dim), (n::Int, k::Int, f::Function) -> gen(n, k, f)::ℤInt, ) end end function Base.iterate(T::RecTriangle) top = T.gen(0, 0, () -> undef) T.A[1] = ZZ(top) ([top], 1) end """ Return the next row of the triangle. """ function Base.iterate(T::RecTriangle, n) @inline prevrow(A, n) = (k) -> (k < 0 || k > n) ? ZZ(0) : A[k + 1] n == T.dim && return nothing F(n, k) = T.gen(n, k, prevrow(T.A, n)) row = [F(n, k) for k ∈ 0:n] for k ∈ 1:n + 1 T.A[k] = row[k] end (row, n + 1) end Base.length(R::RecTriangle) = R.dim Base.eltype(R::RecTriangle) = ℤInt function PolyArray(T::ℤTri) P = Polynomial(T) # P = ReversePolynomial(T) dim = length(T) U = ZTri(dim) for n = 1:dim p = P[n] eva = [Evaluate(p, k) for k in 0:dim - 1] # Make sure that all denominators are 1. # @assert all(d -> d == ZZ(1), denominator.(eva)) "is not an integer" U[n] = numerator.(eva) end U end """ (SIGNATURES) """ function PolyTriangle(T::ℤTri) A = PolyArray(T) U = ZTri(length(T)) for n = 1:length(T) U[n] = [A[n - k][k + 1] for k = 0:n - 1] end U end PolyTri(T::ℤTri) = PolyTriangle(T) """ (SIGNATURES) """ function PolyValue(T::ℤTri, k::Int) P = PolyArray(T) [P[n][k + 1] for n = 1:length(P)] end """ (SIGNATURES) """ PolyVal2(T::ℤTri) = PolyValue(T, 2) """ (SIGNATURES) """ PolyVal3(T::ℤTri) = PolyValue(T, 3) """ (SIGNATURES) """ const TRAITS = Function[ Flat, Reverse, Inverse, RevInv, InvRev, DiagTri, PolyTri, sum, EvenSum, OddSum, AltSum, DiagSum, Middle, Central, LeftSide, RightSide, PosHalf, NegHalf, PolyVal2, PolyVal3, BinConv, IBinConv, TransSqrs, TransNat0, TransNat1 ] # START-TEST-######################################################## # using Test function test() end function demo() Apery = ℤInt[ 1, 5, 73, 1445, 33001, 819005, 21460825, 584307365, ] BinomialTransform(Apery) |> println Binomial(Apery) |> println typeof(Apery) |> println println(typeof(Apery) === ℤSeq) typeof(Binomial(Apery)) |> println T = ℤSeq[ ℤInt[1], ℤInt[1, 1], ℤInt[2, 4, 1], ℤInt[6, 18, 9, 1], ℤInt[24, 96, 72, 16, 1], ℤInt[120, 600, 600, 200, 25, 1], ℤInt[720, 4320, 5400, 2400, 450, 36, 1] ] println("Trans") Trans(T, [ZZ(1) for n = 0:33]) |> println DiagonalTriangle(T) |> println println(ZTri(3, reg=true)) println(ZTri(3)) q = QQ(3, 4) q |> println typeof(q) |> println K(n) = [ZZ(1) for _ in 0:n] [LinMap(K, K(n)) for n in 0:9] |> println L(n) = [ZZ(k) for k in 0:n] [LinMap(L, L(n)) for n in 0:9] |> println t = Telescope(ℤInt[1,2,3,4,5]) typeof(t) |> println collect(t) |> println egfBernoulli(x, t) = divexact(t * exp(x * t), 1 - exp(-t)) BernoulliPolynomials(n) = EgfExpansionPoly(n, egfBernoulli) BernoulliPolynomials(6) |> println CatalanTriangle(dim) = OrthoPoly(dim, n -> 0, n -> 1) CatalanTriangle(7) |> println DiagonalTriangle(CatalanTriangle(9)) |> println P = Polynomial(T) p = P[3] p |> println typeof(p) |> println s = subst(p, 2) s |> println s = subst(p, QQ(1, 3)) s |> println T = Telescope(6, n -> ZZ(n)) println(isa(collect(T), ℤTri)) end function perf() end function main() test() demo() perf() end main() end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
25419
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module TrianglesExamples using Nemo, TrianglesBase export LahNumbers, LahTriangle, LahTransform, SchröderBTriangle, SchröderLTriangle, MotzkinTriangle export Catalan, CatalanTriangle, CatalanTransform, CatalanBallot, ExtCatalanTriangle export BernoulliPolynomial, PascalTriangle, SchroederBigTriangle, AitkenTriangle export EulerianTriangle, EulerianTriangle2, NarayanaTriangle, NarayanaTransform export EulerTriangle, EulerTanTriangle, EulerSecTriangle, UniTriangle export EulerianTransform, MotzkinTransform, SchroederBigTransform, FubiniTriangle export Laguerre, LaguerreTriangle, LaguerreTransform, TrinomialTriangle, TrinomialTransform export JacobsthalTriangle, JacobsthalTransform, FibonacciTriangle, FibonacciTransform export StirlingSetTriangle, StirlingCycleTriangle, FallingFactTriangle, RisingFactTriangle export StirlingSetTransform, StirlingCycleTransform, FubiniTriangle, RencontresTriangle export DArcaisTriangle, WorpitzkyTriangle, EulerianSO2Triangle, SwingTriangle, DelannoyTriangle export Bessel1Triangle, Bessel1Transform, HermiteTriangle, HermiteTransform export I132393, I048993, I271703, I094587, I008279, I225478, T132393, T048993 export T094587, T008279, T225478, T271703, FineTriangle, TTreeTriangle export A046802Triangle, A046802Transform export A000166, A038048, V000111, Fine export TRIANGLES #function __init__() const CacheA000166 = Dict{Int,ℤInt}(0 => ZZ(1)) const CacheA038048 = Dict{Int,ℤInt}(0 => ZZ(0)) const CacheFine = Dict{Int,ℤInt}(0 => ZZ(1), 1 => ZZ(1), 2 => ZZ(0)) const CacheAndré = Dict{Tuple{Int,Int},fmpz}() const CacheBeta = Dict{Tuple{Int,Int},fmpz}() const CacheLah = Dict{Int,ℤSeq}([0 => [ZZ(1)]]) const CacheFubini = Dict{Int,ℤSeq}([0 => [ZZ(1)]]) const CacheDelannoy = Dict{Tuple{Int,Int},ℤInt}([(0,0) => ZZ(1), (1,0) => ZZ(1), (1,1) => ZZ(1)]) const CacheAitken = Dict{Int,ℤSeq}([0 => [ZZ(1)]]) const CacheBallot = Dict{Tuple{Int,Int},ℤInt}() const CacheDArcais = Dict{Tuple{Int,Int},ℤInt}() const CacheWorpitzky = Dict{Tuple{Int,Int},ℤInt}() const CacheEulerianSO2 = Dict{Tuple{Int,Int},ℤInt}((0,0) => ZZ(1)) const CacheSwing = Dict{Tuple{Int,Int},ℤInt}((0,0) => ZZ(1)) const CacheEulerian = Dict{Tuple{Int,Int},ℤInt}() const CacheEulerianClassic = Dict{Tuple{Int,Int},fmpz}() const CacheNarayana = Dict{Tuple{Int,Int},fmpz}() const CacheLaguerre = Dict{Int,ℤSeq}(0 => [ZZ(1)]) #end """ Recurrences and iterations for some triangles. The examples given are: ``` Aitken, Bessel1, Binomial, Catalan, DArcais, Delannoy, Eulerian, EulerianSO2, EulerSec, EulerTan, Euler, FallingFact, Fibonacci, Fine, Fubini, Hermite, Laguerre, Lah, Motzkin, Narayana, Rencontres, RisingFact, SchröderB, SchröderL, StirlingCycle, StirlingSet, Trinomial, TTree, Uni, Worpitzky ``` """ const ModuleTrianglesExamples = "" # ------------------------------------------------ function A000166(n::Int) n <= 1 && return ZZ(1 - n) haskey(CacheA000166, n) && return CacheA000166[n] a = (n - 1) * (A000166(n - 1) + A000166(n - 2)) return CacheA000166[n] = a end function A038048(n::Int) haskey(CacheA038048, n) && return CacheA038048[n] s = Factorial(n - 1) * divisor_sigma(n, 1) return CacheA038048[n] = s end function Fine(n::Int) haskey(CacheFine, n) && return CacheFine[n] s = div((7*n - 12)*Fine(n-1) + (4*n - 6)*Fine(n-2), 2*n) CacheFine[n] = s end function André(m::Int, n::Int) haskey(CacheAndré, (m, n)) && return CacheAndré[(m, n)] n ≤ 0 && return ZZ(1) r = range(0, step = m, stop = n - 1) S = sum(binomial(ZZ(n), ZZ(k)) * André(m, k) for k ∈ r) return CacheAndré[(m, n)] = n % m == 0 ? -S : S end """ Return the up-down numbers (2-alternating permutations). """ V000111(n::Int) = abs(André(2, n)) function PrimeDivisors(n) n < 2 && return ℤInt[] sort!([p for (p, e) ∈ factor(ZZ(n))]) end # ------------------------------------------------ Euler(n, k) = Binomial(n, k) * V000111(n - k) EulerTriangle(dim) = [[Euler(n, k) for k = 0:n] for n = 0:dim - 1] Euler(A::ℤSeq) = LinMap(Euler, A, length(A)) EulerTransform(A::ℤSeq) = Euler.(Telescope(A)) # ------------------------------------------------ """ https://oeis.org/wiki/User:Peter_Luschny/SwissKnifePolynomials """ function BetaPoly(n) function v(n, k) if haskey(CacheBeta, (n, k)) CacheBeta[(n, k)] else CacheBeta[(n, k)] = binomial(n, k)*subst(BetaPoly(k), 0) end end R, z = ZPolyRing("z") n == 0 && return R(1) R(sum(isodd(k) ? 0 : v(n, k)*(z - 1)^(n - k - 1) for k in 0:n-1)) end SECH(n) = isodd(n) ? 0 : subst(BetaPoly(n), 0) TANH(n) = iseven(n) ? 0 : subst(BetaPoly(n), 0) function SecPoly(n) R, z = ZPolyRing("z") R(sum(Binomial(n, k)*SECH(k)*z^(n-k) for k in 0:n)) end function TanPoly(n) R, z = ZPolyRing("z") n == 0 && return R(0) R(sum(Binomial(n, k)*TANH(n - k)*z^k for k in 0:n-1)) end function SwissKnifePoly(n, p, q) R, z = ZPolyRing("z") P = p == 0 ? 0 : SecPoly(n) Q = q == 0 ? 0 : TanPoly(n) p*P + q*Q end EulerTanTriangle(dim) = [Coefficients(TanPoly(n), n) for n in 0:dim-1] EulerSecTriangle(dim) = Coefficients([SecPoly(n) for n in 0:dim-1]) # ------------------------------------------------ FineTriangle(dim::Int) = RiordanSquare(dim, Fine) TernaryTree(n::Int) = div(Binomial(ZZ(3*n), n), ZZ(2*n + 1)) TTreeTriangle(dim::Int) = RiordanSquare(dim, TernaryTree) # ------------------------------------------------ """ (SIGNATURES) """ function LahNumbers(n::Int64) haskey(CacheLah, n) && return CacheLah[n] prevrow = LahNumbers(n - 1) row = ZSeq(n + 1) row[1] = 0 row[n + 1] = 1 for k = 2:n row[k] = prevrow[k - 1] + prevrow[k] * (n + k - 2) end CacheLah[n] = row end LahNumbers(n, k) = LahNumbers(n)[k + 1] """ (SIGNATURES) """ function LahTriangle(size) length(CacheLah) < size && LahNumbers(size) [CacheLah[n] for n = 0:size - 1] end LahNumbers(A::ℤSeq) = LinMap(LahNumbers, A, length(A)) LahTransform(A::ℤSeq) = LahNumbers.(Telescope(A)) # ------------------------------------------------ """ (SIGNATURES) """ function FubiniNumbers(n::Int64) haskey(CacheFubini, n) && return CacheFubini[n] prevrow = FubiniNumbers(n - 1) row = ZSeq(n + 1) row[1] = 0 row[2] = 1 row[n + 1] = n * prevrow[n] for k = 3:n row[k] = (k - 1)*(prevrow[k - 1] + prevrow[k]) end CacheFubini[n] = row end FubiniNumbers(n, k) = FubiniNumbers(n)[k + 1] """ (SIGNATURES) """ function FubiniTriangle(size) length(CacheFubini) < size && FubiniNumbers(size) [CacheFubini[n] for n = 0:size - 1] end FubiniNumbers(A::ℤSeq) = LinMap(FubiniNumbers, A, length(A)) FubiniTransform(A::ℤSeq) = FubiniNumbers.(Telescope(A)) # ------------------------------------------------ """ (SIGNATURES) """ function Delannoy(n::Int64, k::Int64) haskey(CacheDelannoy, (n, k)) && return CacheDelannoy[(n, k)] if n < 0 || k < 0 || k > n return CacheDelannoy[(n,k)] = 0 end CacheDelannoy[(n,k)] = Delannoy(n-1, k-1) + Delannoy(n-2, k-1) + Delannoy(n-1, k) end Delannoy(n) = [Delannoy(n, k) for k ∈ 0:n] DelannoyTriangle(dim) = [Delannoy(n) for n = 0:dim - 1] Delannoy(A::ℤSeq) = LinMap(Delannoy, A, length(A)) DelannoyTransform(A::ℤSeq) = Delannoy.(Telescope(A)) # ------------------------------------------------ """ (SIGNATURES) """ function AitkenNumbers(n::Int64) haskey(CacheAitken, n) && return CacheAitken[n] prevrow = AitkenNumbers(n - 1) row = ZSeq(n + 1) row[1] = prevrow[n] for k = 2:n + 1 row[k] = row[k-1] + prevrow[k - 1] end CacheAitken[n] = row end AitkenNumbers(n, k) = AitkenNumbers(n)[k + 1] """ (SIGNATURES) """ function AitkenTriangle(size) length(CacheAitken) < size && AitkenNumbers(size) [CacheAitken[n] for n = 0:size - 1] end AitkenNumbers(A::ℤSeq) = LinMap(AitkenNumbers, A, length(A)) AitkenTransform(A::ℤSeq) = AitkenNumbers.(Telescope(A)) # ------------------------------------------------ #row[k] = ( get(prevrow, k - 1, 0) #+ get(prevrow, k, 0) * (2 * k - 1) #+ get(prevrow, k + 1, 0) * k^2 ) #A011971 := proc(n, k) option remember; if n=0 and k=0 then 1 elif k=0 #then A011971(n-1, n-1) else A011971(n, k-1) + A011971(n-1, k-1); fi: end; G271703(x, t) = exp(t * divexact(x, 1 - t)) T271703(dim) = EgfExpansionCoeff(dim, G271703) egfBernoulli(x, t) = divexact(t * exp(x * t), exp(t) - 1) BernoulliPolynomial(n) = EgfExpansionPoly(n, egfBernoulli) G278075(x, t) = divexact(1, 1 - x * (1 - exp(-t))) FubiniPolynomial(n) = EgfExpansionPoly(n, G278075) function MotzkinTriangle2(dim::Int) T = ZTri(dim) for n = 1:dim T[n][n] = 1 end for n = 2:dim u(k) = k == 0 || k == n ? 0 : T[n - 1][k] for k = 1:n - 1 T[n][k] = u(k - 1) + u(k) + u(k + 1) end end T end # ------------------------------------------------ """ (SIGNATURES) """ MotzkinTriangle(dim) = OrthoPoly(dim, n -> 1, n -> 1) """ (SIGNATURES) """ Motzkin(n) = MotzkinTriangle(n + 1)[n + 1] # TODO!! Motzkin(n, k) = Motzkin(n)[k + 1] Motzkin(A::ℤSeq) = LinMap(Motzkin, A, length(A)) MotzkinTransform(A::ℤSeq) = Motzkin.(Telescope(A)) # ------------------------------------------------ """ (SIGNATURES) """ CatalanTriangle(dim) = OrthoPoly(dim, n -> 0, n -> 1) Catalan(n) = CatalanTriangle(n + 1)[n + 1] # TODO!! Catalan(n::Int, k::Int) = Catalan(n)[k + 1] Catalan(A::ℤSeq) = LinMap(Catalan, A, length(A)) CatalanTransform(A::ℤSeq) = Catalan.(Telescope(A)) function CatalanBallot(n::Int, k::Int) haskey(CacheBallot, (n, k)) && return CacheBallot[(n, k)] (k > n || k < 0) && return ZZ(0) n == k && return ZZ(1) CacheBallot[(n, k)] = ( CatalanBallot(n - 1, k - 1) + CatalanBallot(n - 1, k + 1) + (iseven(n - k) ? 0 : CatalanBallot(n - 1, k)) ) end CatalanBallot(n) = [CatalanBallot(n, k) for k ∈ 0:n] ExtCatalanTriangle(dim) = [[CatalanBallot(n, k) for k = 0:n] for n = 0:dim - 1] # ------------------------------------------------ Rencontres(n, k) = A000166(n - k)*Binomial(n, k) RencontresTriangle(dim) = [[Rencontres(n, k) for k = 0:n] for n = 0:dim - 1] #A008290(n) = A008290Triangle(n + 1)[n + 1] #A008290(n, k) = A008290(n)[k + 1] Rencontres(A::ℤSeq) = LinMap(Rencontres, A, length(A)) RencontresTransform(A::ℤSeq) = Rencontres.(Telescope(A)) # ------------------------------------------------ function DArcais(n, k) haskey(CacheDArcais, (n, k)) && return CacheDArcais[(n, k)] k == 0 && return ZZ(0^n) S = sum(Binomial(n-1, j-1)*A038048(j)*DArcais(n-j, k-1) for j in 0:n-k+1) CacheDArcais[(n, k)] = S end DArcaisTriangle(dim) = [[DArcais(n, k) for k = 0:n] for n = 0:dim - 1] DArcais(A::ℤSeq) = LinMap(DArcais, A, length(A)) DArcaisTransform(A::ℤSeq) = DArcais.(Telescope(A)) # ------------------------------------------------ function Worpitzky(n, k) haskey(CacheWorpitzky, (n, k)) && return CacheWorpitzky[(n, k)] S = sum(Eulerian(n, j)*Binomial(n-j, n-k) for j in 0:n) CacheWorpitzky[(n, k)] = S end WorpitzkyTriangle(dim) = [[Worpitzky(n, k) for k = 0:n] for n = 0:dim - 1] Worpitzky(A::ℤSeq) = LinMap(Worpitzky, A, length(A)) WorpitzkyTransform(A::ℤSeq) = Worpitzky.(Telescope(A)) # ------------------------------------------------ """ Return the second order Eulerian number E2(n,k). """ function EulerianSO2(n, k) n < 0 && return ZZ(0) haskey(CacheEulerianSO2, (n, k)) && return CacheEulerianSO2[(n, k)] S = EulerianSO2(n-1, k)*k + EulerianSO2(n-1, k-1)*(2*n - k) CacheEulerianSO2[(n, k)] = S end EulerianSO2Triangle(dim) = [[EulerianSO2(n, k) for k = 0:n] for n = 0:dim - 1] EulerianSO2(A::ℤSeq) = LinMap(EulerianSO2, A, length(A)) EulerianSO2Transform(A::ℤSeq) = EulerianSO2.(Telescope(A)) # ------------------------------------------------ function Swing(n, k) haskey(CacheSwing, (n, k)) && return CacheSwing[(n, k)] p = ZZ(2)^n k == 0 && return p S = numerator(p*prod(QQ(2,j)^((-1)^(j )) for j in 1:k)) CacheSwing[(n, k)] = S end SwingTriangle(dim) = [[Swing(n, k) for k = 0:n] for n = 0:dim - 1] Swing(A::ℤSeq) = LinMap(Swing, A, length(A)) SwingTransform(A::ℤSeq) = Swing.(Telescope(A)) # ------------------------------------------------ Uni(n, k) = 1 UniTriangle(dim) = [[ZZ(1) for k = 0:n] for n = 0:dim - 1] Uni(A::ℤSeq) = LinMap(Uni, A, length(A)) UniTransform(A::ℤSeq) = Uni.(Telescope(A)) # ------------------------------------------------ function Bessel1(n, k) (k == 0) && return ZZ(k^n) div(Factorial(2*n - k - 1),((-2)^(n - k)*Factorial(k - 1)*Factorial(n - k))) end Bessel1Triangle(dim) = [[Bessel1(n, k) for k = 0:n] for n = 0:dim - 1] Bessel1(A::ℤSeq) = LinMap(Bessel1, A, length(A)) Bessel1Transform(A::ℤSeq) = Bessel1.(Telescope(A)) # ------------------------------------------------ function Hermite(n, k) isodd(n - k) && return ZZ(0) m = div(n - k, 2) div(Factorial(n), Factorial(k)*Factorial(m)*2^m) end HermiteTriangle(dim) = [[Hermite(n, k) for k = 0:n] for n = 0:dim - 1] Hermite(A::ℤSeq) = LinMap(Hermite, A, length(A)) HermiteTransform(A::ℤSeq) = Hermite.(Telescope(A)) # ------------------------------------------------ function Trinomial(n, k) sum(Binomial(n, j) * Binomial(j, k-j) for j in 0:n) end TrinomialTriangle(dim) = [[Trinomial(n, k) for k = 0:n] for n = 0:dim - 1] Trinomial(A::ℤSeq) = LinMap(Trinomial, A, length(A)) TrinomialTransform(A::ℤSeq) = Trinomial.(Telescope(A)) # ------------------------------------------------ bs(n) = iszero(n) ? 0 : isodd(n) ? 2 : 1 SchröderBTriangle(dim) = DelehamΔ(dim, bs, n -> 0^n) ls(n) = isodd(n) ? 2 : 1 SchröderLTriangle(dim) = DelehamΔ(dim, ls, n -> 0^n) """ Recurrence for A132393, StirlingCycle numbers. """ function R132393(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) (n - 1) * prevrow(k) + prevrow(k - 1) end """ Recurrence for A048993, StirlingSet numbers. """ function R048993(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) k * prevrow(k) + prevrow(k - 1) end """ Recurrence for A271703, Lah numbers. """ function R271703(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) (k - 1 + n) * prevrow(k) + prevrow(k - 1) end """ Recurrence for A094587, (Rising factorials). """ function R094587(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) (n - k) * prevrow(k) + prevrow(k - 1) end """ Recurrence for A008279. Number of permutations of n things k at a time. (Falling factorials) """ function R008279(n::Int, k::Int, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) prevrow(k) + k * prevrow(k - 1) end """ xIterates over the first n rows of `A132393`. Triangle of unsigned Stirling numbers of the first kind. """ I132393(n) = RecTriangle(n, R132393) T132393(dim) = ZTri(I132393(dim)) """ (SIGNATURES) """ StirlingCycleTriangle(dim) = T132393(dim) StirlingCycle(n) = StirlingCycleTriangle(n + 1)[n + 1] StirlingCycle(n, k) = StirlingCycle(n)[k + 1] StirlingCycle(A::ℤSeq) = LinMap(StirlingCycle, A, length(A)) StirlingCycleTransform(A::ℤSeq) = StirlingCycle.(Telescope(A)) """ Iterates over the first n rows of `A048993`. Triangle of Stirling numbers of 2nd kind. """ I048993(n) = RecTriangle(n, R048993) T048993(dim) = ZTri(I048993(dim)) """ (SIGNATURES) """ StirlingSetTriangle(dim) = T048993(dim) StirlingSet(n) = StirlingSetTriangle(n + 1)[n + 1] StirlingSet(n, k) = StirlingSet(n)[k + 1] StirlingSet(A::ℤSeq) = LinMap(StirlingSet, A, length(A)) StirlingSetTransform(A::ℤSeq) = StirlingSet.(Telescope(A)) # """ # Iterates over the first n rows of `A271703`. # """ # Alternative definition already given above via EgfExpansion. # I271703(n) = RecTriangle(n, R271703) # T271703(dim) = ZTri(I271703(dim)) """ Iterates over the first n rows of `A094587`. """ I094587(n) = RecTriangle(n, R094587) T094587(dim) = ZTri(I094587(dim)) # T094587(dim) = Reverse(ZTri(I008279(dim))) """ Iterates over the first n rows of `A008279`. """ I008279(n) = RecTriangle(n, R008279) T008279(dim) = ZTri(I008279(dim)) # Alias FallingFactTriangle(dim) = ZTri(I008279(dim)) PermCoeffsTriangle(dim) = ZTri(I008279(dim)) function R225478(n, k, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) 4 * prevrow(k - 1) + (4 * n - 1) * prevrow(k) end I225478(dim) = RecTriangle(dim, R225478) T225478(dim) = ZTri(I225478(dim)) function R007318(n, k, prevrow::Function) (k == 0 && n == 0) && return ZZ(1) prevrow(k - 1) + prevrow(k) end I007318(dim) = RecTriangle(dim, R007318) PascalTriangle(dim) = ZTri(I007318(dim)) function SchroederBig(n, k) div( (k + 1) * sum(Binomial(n + 1, k + j + 1) * Binomial(n + j, j) for j = 0:(n - k)), n + 1 ) end function SchroederBigTriangle(dim) [[SchroederBig(n, k) for k = 0:n] for n = 0:dim - 1] end SchroederBig(n) = SchroederBigTriangle(n + 1)[n + 1] SchroederBig(A::ℤSeq) = LinMap(SchroederBig, A, length(A)) SchroederBigTransform(A::ℤSeq) = SchroederBig.(Telescope(A)) FJ(n, k) = n <= 2 ? 1 : FJ(n - 1, k) + k * FJ(n - 2, k) """ (SIGNATURES) """ JacobsthalTriangle(dim) = RiordanSquare(dim, n -> FJ(n, 2)) Jacobsthal(n) = JacobsthalTriangle(n + 1)[n + 1] Jacobsthal(n, k) = Jacobsthal(n)[k + 1] Jacobsthal(A::ℤSeq) = LinMap(Jacobsthal, A, length(A)) JacobsthalTransform(A::ℤSeq) = Jacobsthal.(Telescope(A)) """ (SIGNATURES) """ FibonacciTriangle(dim) = RiordanSquare(dim, n -> FJ(n, 1)) Fibonacci(n) = FibonacciTriangle(n + 1)[n + 1] Fibonacci(n, k) = Fibonacci(n)[k + 1] Fibonacci(A::ℤSeq) = LinMap(Fibonacci, A, length(A)) FibonacciTransform(A::ℤSeq) = Fibonacci.(Telescope(A)) function EulerianNumbers(n, k) haskey(CacheEulerian, (n, k)) && return CacheEulerian[(n, k)] CacheEulerian[(n, k)] = if (k == 0) && (n >= 0) ZZ(1) elseif (k < 0) || (k > n) ZZ(0) else (n - k) * EulerianNumbers(n - 1, k - 1) + (k + 1) * EulerianNumbers(n - 1, k) end end """ (SIGNATURES) """ EulerianTriangle(dim) = [[EulerianNumbers(n, k) for k = 0:n] for n = 0:dim - 1] Eulerian(n) = EulerianTriangle(n + 1)[n + 1] Eulerian(n, k) = Eulerian(n)[k + 1] Eulerian(A::ℤSeq) = LinMap(Eulerian, A, length(A)) EulerianTransform(A::ℤSeq) = Eulerian.(Telescope(A)) # ------------------------------------------------ function A046802(n, k) sum(Binomial(n, j) * Eulerian(j, j-k) for j in k:n) end A046802Triangle(dim) = [[A046802(n, k) for k = 0:n] for n = 0:dim - 1] A046802(A::ℤSeq) = LinMap(A046802, A, length(A)) A046802Transform(A::ℤSeq) = A046802.(Telescope(A)) # ------------------------------------------------ function EulerianNumbersClassic(n, k) haskey(CacheEulerianClassic, (n, k)) && return CacheEulerianClassic[(n, k)] CacheEulerianClassic[(n, k)] = if (k == n) ZZ(1) elseif (k <= 0) || (k > n) ZZ(0) else (n - k + 1) * EulerianNumbersClassic(n - 1, k - 1) + (k) * EulerianNumbersClassic(n - 1, k) end end EulerianTriangleClassic(dim) = [[EulerianNumbersClassic(n, k) for k = 0:n] for n = 0:dim - 1] EulerianClassic(n) = EulerianTriangleClassic(n + 1)[n + 1] EulerianClassic(n, k) = EulerianClassic(n)[k + 1] EulerianClassic(A::ℤSeq) = LinMap(EulerianClassic, A, length(A)) EulerianTransform2(A::ℤSeq) = EulerianClassic.(Telescope(A)) function NarayanaNumbers(n::Int, k::Int) haskey(CacheNarayana, (n, k)) && return CacheNarayana[(n, k)] CacheNarayana[(n, k)] = if (k == n) ZZ(1) elseif k > n || k <= 0 ZZ(0) else div( Binomial(ZZ(n), n - k) * Binomial(ZZ(n - 1), n - k), ZZ(n - k + 1) ) end end """ (SIGNATURES) """ NarayanaTriangle(dim) = [[NarayanaNumbers(n, k) for k = 0:n] for n = 0:dim] Narayana(n) = NarayanaTriangle(n + 1)[n + 1] Narayana(n, k) = Narayana(n)[k + 1] Narayana(A::ℤSeq) = LinMap(Narayana, A, length(A)) NarayanaTransform(A::ℤSeq) = Narayana.(Telescope(A)) """ (SIGNATURES) """ RisingFactTriangle(dim) = [[rising_factorial(ZZ(n), ZZ(k)) for k = 0:n] for n = 0:dim] RisingFact(n) = RisingFactTriangle(n + 1)[n + 1] RisingFact(n, k) = RisingFact(n)[k + 1] RisingFact(A::ℤSeq) = LinMap(RisingFact, A, length(A)) RisingFactTransform(A::ℤSeq) = RisingFact.(Telescope(A)) function Laguerre(n::Int) haskey(CacheLaguerre, n) && return CacheLaguerre[n] prevrow = Laguerre(n - 1) row = ZSeq(n + 1) row[n + 1] = ZZ(1) for k ∈ 1:n row[k] = ( get(prevrow, k - 1, 0) + get(prevrow, k, 0) * (2 * k - 1) + get(prevrow, k + 1, 0) * k^2 ) end # println(row) CacheLaguerre[n] = row end Laguerre(n::Int, k::Int) = Laguerre(n)[k + 1] Laguerre(A::ℤSeq) = LinMap(Laguerre, A, length(A)) """ (SIGNATURES) """ function LaguerreTriangle(size::Int) length(CacheLaguerre) < size && Laguerre(size) [CacheLaguerre[n] for n in 0:size - 1] end LaguerreTransform(A::ℤSeq) = Laguerre.(Telescope(A)) function transforms(trans) len = 18 println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") println(trans) println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") println() Unos = [ZZ(1) for n = 0:len] print("UNOS ") Println(Unos) trans(Unos) |> Println println() AltUnos = [(-1)^n * ZZ(1) for n = 0:len] println("ALTS ") Println(AltUnos) trans(AltUnos) |> Println println() Squares = [ZZ(n^2) for n = 0:len] println("SQRS ") Println(Squares) trans(Squares) |> Println println() Nat = [ZZ(n) for n = 0:len] println("N0TS ") Println(Nat) trans(Nat) |> Println println() Nut = [ZZ(n) for n = 1:len] println("NATS ") Println(Nut) trans(Nut) |> Println end const TRIANGLES = Function[ AitkenTriangle, Bessel1Triangle, BinomialTriangle, CatalanTriangle, DArcaisTriangle, DelannoyTriangle, EulerianTriangle, EulerianSO2Triangle, EulerSecTriangle, EulerTanTriangle, EulerTriangle, FallingFactTriangle, FibonacciTriangle, FineTriangle, FubiniTriangle, HermiteTriangle, LaguerreTriangle, LahTriangle, MotzkinTriangle, NarayanaTriangle, RencontresTriangle, RisingFactTriangle, SchröderBTriangle, SchröderLTriangle, StirlingCycleTriangle, StirlingSetTriangle, TrinomialTriangle, TTreeTriangle, UniTriangle, WorpitzkyTriangle ] # START-TEST-######################################################## using Test function test() @testset "Laguerre" begin A = ℤInt[0, 1, 6, 39, 292, 2505, 24306, 263431] @test Laguerre(0) == ℤInt[1] @test Laguerre(3) == ℤInt[6, 18, 9, 1] @test Laguerre(5) == ℤInt[120, 600, 600, 200, 25, 1] @test Laguerre(6, 1) == ZZ(4320) @test [Laguerre(7, k) for k in 0:7] == Laguerre(7) @test Laguerre(ℤInt[0, 1, 2, 3, 4, 5]) == ZZ(2505) @test Laguerre(ℤInt[0, 1, 4, 9, 16, 25]) == ZZ(5225) @test LaguerreTransform([ZZ(n) for n in 0:7]) == A # Test types @test typeof(Laguerre(3, 3)) === fmpz # ℤInt @test typeof(Laguerre(5)) === Array{fmpz,1} # ℤSeq @test typeof(Laguerre(A)) === fmpz # ℤInt @test typeof(LaguerreTriangle(5)) === Array{Array{fmpz,1},1} # ℤTri @test typeof(LaguerreTransform(A)) === Array{fmpz,1} # ℤSeq end end function demo() # isa(PascalTriangle(6), ℤTri) |> println FubiniPolynomial(6) |> println BernoulliPolynomial(6) |> println SchroederBigTriangle(8) |> println transforms(BinomialTransform) transforms(LahTransform) transforms(MotzkinTransform) transforms(SchroederBigTransform) Println.(JacobsthalTriangle(8)) transforms(JacobsthalTransform) Println.(FibonacciTriangle(8)) transforms(FibonacciTransform) Println.(StirlingSetTriangle(8)) transforms(StirlingSetTransform) Println.(StirlingCycleTriangle(8)) transforms(StirlingCycleTransform) Println.(LaguerreTriangle(8)) transforms(LaguerreTransform) Println.(EulerianTriangle(8)) #Println.(EulerianTriangle2(8)) transforms(EulerianTransform) # Println.(Inverse(EulerianTriangle2(8))) Println.(NarayanaTriangle(8)) transforms(NarayanaTransform) CatalanBallot.(0:6) |> println Println.(Reverse(DiagonalTriangle(FallingFactTriangle(10)))) Println.(Reverse(FallingFactTriangle(10))) Println.(RisingFactTriangle(10)) Println.(Inverse(RisingFactTriangle(10))) Println.(Reverse(RisingFactTriangle(10))) Println.(Inverse(Reverse(RisingFactTriangle(10)))) for n in 0:7 BetaPoly(n) |> println end for n in 0:7 SecPoly(n) |> println end for n in 0:7 TanPoly(n) |> println end end function perf() # display(@benchmark LaguerreTriangle(1000)) # display(@benchmark PolyArray(LaguerreTriangle(100))) # @time LaguerreTriangle(1000) # @time PolyArray(LaguerreTriangle(100)) T = LaguerreTriangle(8) Println.(PolyTriangle(T)) Println.(PolyArray(T)) Println.(Inverse(PolyTriangle(T))) Println.(FubiniTriangle(8)) Println.(DArcaisTriangle(8)) end function main() test() demo() perf() end main() end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
7399
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module TrianglesExplorer using Nemo, OrderedCollections using TrianglesBase, TrianglesExamples, TrianglesUtils export Explore, Triangles, SaveToCSV, Inspect """ Explore integer triangles via their traits. The traits and their OEIS references will be saved as csv-files in the data directory. """ const ModuleTrianglesExplorer = "" const WARNING_ON_NOTFOUND = false const Kind = ["Std", "Rev", "Inv", "RevInv", "InvRev"] const Triangles = LittleDict{String, Function}( "Aitken" => AitkenTriangle, "Bessel1" => Bessel1Triangle, "Binomial" => BinomialTriangle, "Catalan" => CatalanTriangle, "DArcais" => DArcaisTriangle, "Delannoy" => DelannoyTriangle, "Euler" => EulerTriangle, "EulerS" => EulerSecTriangle, "EulerT" => EulerTanTriangle, "Eulerian" => EulerianTriangle, "EulerianSO2" => EulerianSO2Triangle, "FallingFact" => FallingFactTriangle, "Fibonacci" => FibonacciTriangle, "Fine" => FineTriangle, "Fubini" => FubiniTriangle, "Hermite" => HermiteTriangle, "Laguerre" => LaguerreTriangle, "Lah" => LahTriangle, "Motzkin" => MotzkinTriangle, "Narayana" => NarayanaTriangle, "RisingFact" => RisingFactTriangle, "SchroederB" => SchröderBTriangle, "SchroederL" => SchröderLTriangle, "StirlingCycle" => StirlingCycleTriangle, "StirlingSet" => StirlingSetTriangle, "Rencontres" => RencontresTriangle, "Trinomial" => TrinomialTriangle, "TTree" => TTreeTriangle, "Uni" => UniTriangle, "Worpitzky" => WorpitzkyTriangle ) const TraitFunc = LittleDict{String, Function}( "Triangle" => Flat, "Reverse" => Reverse, "Inverse" => Inverse, "RevInv" => RevInv, "InvRev" => InvRev, "DiagTri" => DiagTri, "PolyTri" => PolyTri, "Sum" => sum, "EvenSum" => EvenSum, "OddSum" => OddSum, "AltSum" => AltSum, "DiagSum" => DiagSum, "Middle" => Middle, "Central" => Central, "LeftSide" => LeftSide, "RightSide" => RightSide, "PosHalf" => PosHalf, "NegHalf" => NegHalf, "PolyVal2" => PolyVal2, "PolyVal3" => PolyVal3, "BinConv" => BinomialTransform, "IBinConv" => IBinomialTransform, "TransSqrs" => TransSqrs, "TransNat0" => TransNat0, "TransNat1" => TransNat1 ) function Show(io, name, kind, trait, seq, savetofile=false) seq == [] && return [] if typeof(seq) === ℤTri seq = Flat(seq) end anum = GetSeqnum(seq, WARNING_ON_NOTFOUND) if savetofile print(".") print(io, anum, ",", name, ",", kind, ",", trait, ",") Println(io, SeqToString(seq, 10)) else print(anum, " ", name, " ", kind, " ", trait, " ") Println(IOContext(stdout), SeqToString(seq, 10)) end end function TriangleVariant(Tri, dim, kind="Std") if ! (kind in Kind) @warn("No valid kind!") return [] end M = Tri(dim) kind == "Std" && return M kind == "Rev" && return reverse.(M) kind == "InvRev" && (M = reverse.(M)) invM = InverseTriangle(M) (kind == "Inv" || kind == "InvRev" || invM == []) && return invM return reverse.(invM) end const LEN = 19 # Prints full sequence function Inspect(triangle, kind, trait, dim) T = TriangleVariant(Triangles[triangle], dim, kind) seq = TraitFunc[trait](T) seq == [] && return [] typeof(seq) === ℤTri && (seq = Flat(seq)) anum = GetSeqnum(seq, false) println(anum, " ", triangle, " ", kind, " ", trait) println(SeqToString(seq)) end """ (SIGNATURES) """ function Explore(triangle, kind, trait, dim) T = TriangleVariant(Triangles[triangle], dim, kind) seq = TraitFunc[trait](T) Show(stdout, triangle, kind, trait, seq) end function Explore(T::ℤTri, trait::Function) seq = trait(T) if seq == [] || seq === nothing return [] end typeof(seq) === ℤTri && (seq = Flat(seq)) println("$trait ") anum = GetSeqnumUri(seq) anum === nothing && (anum = "nothing") seqstr = string(seq[1:min(10, end)])[max(0,11):max(0,end-1)] String["$trait ", anum, seqstr] end """ """ function Explore(triangle, kind, trait) dim = 19 T = TriangleVariant(Triangles[triangle], dim, kind) seq = TraitFunc[trait](T) anum = GetSeqnum(seq) anum === nothing && (anum = "nothing") seqstr = string(seq[1:min(10, end)])[max(0,11):max(0,end-1)] String[anum, triangle, kind, trait, seqstr] end function Explore(trait::String, dim::Int) for (name, triangle) in Triangles for kind in Kind T = TriangleVariant(triangle, dim, kind) if T != [] seq = TraitFunc[trait](T) Show(stdout, name, kind, trait, seq) end end end end # The BIG LIST goes to data/profile.txt. function Explore(savetofile::Bool) @warn "This will take several minutes and produce the file 'BIGLIST.csv' in the data directory." path = datapath("BIGLIST.csv") rm(path; force=true) open(path, "w") do io println(io, "Anumber,Triangle,Type,Trait,Sequence") for (name, triangle) in Triangles #for kind in Kind kind = "Std" T = TriangleVariant(triangle, LEN, kind) if T != [] for (trait, f) in TraitFunc Show(io, name, kind, trait, f(T), savetofile) end end #end end end end function SaveToCSV(name) T = Triangles[name](LEN) path = datapath(name * ".csv") rm(path; force=true) open(path, "w") do io println(io, "Trait,ANumber,Sequence") for (trait, f) in TraitFunc seq = f(T) seq == [] && continue if typeof(seq) === ℤTri seq = Flat(seq) end anum = GetSeqnum(seq) anum === nothing && (anum = "nothing") println(io, trait, ",", anum, ",", SeqToString(seq, 10)) end end end function SaveAllToCSV() @warn "This will take several minutes and produce the csv-files in the data directory." for (name, f) in Triangles println(name) SaveToCSV(name) end end # START-TEST-############################################## function test() TLEN = 19 Explore("SchroederB", "Inv", "AltSum", TLEN) end function demo() TLEN = 19 Explore("Binomial", "Std", "PolyVal3", TLEN) Explore("SchroederB", "Inv", "AltSum", TLEN) Explore("SchroederL", "Inv", "AltSum", TLEN) Explore("Motzkin", "Rev", "Central", TLEN) Explore("Laguerre", "Std", "PosHalf", TLEN) Explore("Laguerre", "Std", "TransNat0", TLEN) Explore("Laguerre", "Std", "TransNat1", TLEN) Explore("Lah", "Std", "TransSqrs", TLEN) Inspect("Lah", "Std", "TransSqrs", TLEN) println() end function perf() #Explore(true) #SaveToCSV("Laguerre") #SaveAllToCSV() end function main() test() demo() perf() end main() end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
1748
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module TrianglesPlot """ Plotting triangles. """ const ModuleTrianglesPlot = "" using TrianglesBase, TrianglesExamples using Plots; gr() function PolyPlot(F, title) x = -2.0:0.05:1.0 plot(x, F[1], c="black", linewidth=1) plot!(x, F[2], c="green", line=:dash) plot!(x, F[3], c="blue", linewidth=1) plot!(x, F[4], c="red", line=:dash) plot!(x, F[5], c="orange", linewidth=1) plot!(x, F[6], c="blue", line=:dash) plot!(x, F[7], c="black", linewidth=1) title!(title) xlabel!("x") ylabel!("p(x)") # axis limit P = plot!(xlims=(-2.0, 1.0), ylims=(-5.0, 5.0)) display(P) end # START-TEST-######################################################## function test() end function demo() # P = PolynomialFunction(LahTriangle(7)) # PolyPlot(P, "Lah polynomials") # P = PolynomialFunction(EulerianTriangle(7)) # PolyPlot(P, "Eulerian polynomials") # P = PolynomialFunction(LaguerreTriangle(7)) # PolyPlot(P, "Laguerre polynomials") # P = PolynomialFunction(CatalanTriangle(7)) # PolyPlot(P, "Catalan polynomials") # P = PolynomialFunction(MotzkinTriangle(7)) # PolyPlot(P, "Motzkin polynomials") P = PolynomialFunction(NarayanaTriangle(7)) PolyPlot(P, "Narayana polynomials") # P = PolynomialFunction(JacobsthalTriangle(7)) # PolyPlot(P, "Jacobsthal polynomials") # P = PolynomialFunction(FibonacciTriangle(7)) # PolyPlot(P, "Fibonacci polynomials") end function perf() end function main() test() # this might take a while demo() perf() end main() end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
5196
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module TrianglesTables using PrettyTables, TrianglesExplorer using TrianglesBase, TrianglesExamples, TrianglesTraitCard, TrianglesUtils export PrettyTraits, AllPrettyTraits, UpdateDocs """ Pretty printing of triangles trait cards. | A-number | Triangle | Form | Function | Sequence | |----------|------------|------|-----------|---------------------------------------------| | A000302 | Binomial | Std | PolyVal3 | 1, 4, 16, 64, 256, 1024, 4096, 16384 | | A001333 | SchroederB | Inv | AltSum | 1, -1, 3, -7, 17, -41, 99, -239 | | A006012 | SchroederL | Inv | AltSum | 1, -2, 6, -20, 68, -232, 792, -2704 | | A026302 | Motzkin | Rev | Central | 1, 2, 9, 44, 230, 1242, 6853, 38376 | | A103194 | Laguerre | Std | TransNat0 | 0, 1, 6, 39, 292, 2505, 24306, 263431 | | A111884 | Lah | Std | TransAlts | 1, -1, -1, -1, 1, 19, 151, 1091 | | nothing | Laguerre | Rev | TransNat1 | 1, 3, 15, 97, 753, 6771, 68983, 783945 | """ const ModuleTrianglesTables = "" const CSS = ["<style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;}", "td, th {border-bottom: 0; padding: 4px}", "tr:nth-child(odd) {background: #eee;}", "tr:nth-child(even) {background: #fff;}", "tr.header {background: orange !important; color: white; font-weight: bold;}", "tr.subheader {background: lightgray !important; color: black;}", "tr.headerLastRow {border-bottom: 2px solid black;}", "th.rowNumber, td.rowNumber {text-align: right;} </style><body>"] function PrettyTraits(T, name) header = [ "Trait", "ANumber", "Sequence" ] mat = String[name "" ""] for tra in TRAITS s = Explore(T, tra) s == [] && continue mat = [mat; reshape(s, 1, 3)] end path = datapath(name * ".md") rm(path; force=true) open(path, "w") do io println(io, "```@raw html") for ln in CSS println(io, ln) end pretty_table(io, mat, header, backend = :html, standalone= false, alignment=[:l,:l,:l]) println(io, "```") end end function AllPrettyTraits() for T in Triangles println("-- ", T[1]) PrettyTraits(Triangles[T[1]](32), T[1]) end end function AllCSVtoTable() header = ["ANumber", "Triangle", "Type", "Trait", "Sequence"] mat = String["" "" "" "" ""] inpath = datapath("BIGLIST.csv") open(inpath, "r") do csv for L ∈ eachline(csv, keep=false) mat = [mat; reshape(split(L, ","), 1, 5)] end end outpath = datapath("BIGLISTTEST.md") rm(outpath; force=true) open(outpath, "w") do html println(html, "```@raw html") for ln in CSS println(html, ln) end pretty_table(html, mat, header, backend = :html, standalone= false, alignment=[:l,:l,:l,:l,:l]) println(html, "```") end end function CSVtoTable(name) header = ["Trait", "ANumber", "Sequence"] # Depending on the number of csv data: #mat = String["" "" "" "" ""] #mat = [mat; reshape(split(L, ","), 1, 5)] #alignment=[:l,:l,:l,:l,:l]) p = splitext(name)[begin] p = splitpath(p)[end] mat = String[p "" ""] firstline = true inpath = profilespath(name) open(inpath, "r") do csv for L ∈ eachline(csv, keep=false) firstline && (firstline = false; continue) s = split(L, ",") s[2] = MakeSeqUri(s[2], s[3]) mat = [mat; reshape(s, 1, 3)] end end outpath = docsrcpath(p * ".md") rm(outpath; force=true) open(outpath, "w") do html println(html, "```@raw html") for ln in CSS println(html, ln) end pretty_table(html, mat, header, backend = :html, standalone= false, alignment=[:l,:l,:l]) println(html, "```") end end function UpdateDocs() csvfiles = csv_files() for filename ∈ csvfiles fulname = profilespath(filename) CSVtoTable(fulname) end end # START-TEST-######################################################## function test() header = ["A-number", "Triangle", "Form", "Function", "Sequence"] mat = [ # Type Matrix{String}, or Array{String,2} "A000302" "Binomial" "Std" "PolyVal3" "1, 4, 16, 64, 256, 1024, 4096, 16384" ; ] S = String["A111884" "Lah" "Std" "TransAlts" "1, -1, -1, -1, 1, 19, 151, 1091"] mat = [mat; S] L = String["A111884", "Lah", "Std", "TransAlts", "1, -1, -1, -1, 1, 19, 151, 1091"] mat = [mat; reshape(L, 1, 5)] L = Explore("Laguerre", "Rev", "TransNat1") mat = [mat; reshape(L, 1, 5)] pretty_table(mat, header, alignment=[:l,:l,:l,:l,:l]) mat end function demo() PrettyTraits(LahTriangle(32), "Lah") PrettyTraits(A046802Triangle(32), "A046802") end function perf() #AllPrettyTraits() #AllCSVtoTable() #UpdateDocs() end function main() test() #demo() #perf() end main() end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
9454
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module TrianglesTraitCard using Nemo, TrianglesBase, TrianglesExamples, TrianglesUtils export TraitCard, TransTraits, AssociatedTriangles, AllTraitCards """ Build the trait card of one or many triangles with Anums. ``` julia> TraitCard(LaguerreTriangle) Triangle: A021009 [1, 1, 1, 2, 4, 1, 6, 18, 9, 1] Reverse: A021010 [1, 1, 1, 1, 4, 2, 1, 9, 18, 6] Inverse: A021009 [1, -1, 1, 2, -4, 1, -6, 18, -9, 1] RevInv: A021010 [1, 1, -1, 1, -4, 2, 1, -9, 18, -6] Diagonal: A084950 [1, 1, 2, 1, 6, 4, 24, 18, 1, 120] Sum: A002720 [1, 2, 7, 34, 209, 1546, 13327, 130922, 1441729, 17572114] EvenSum: A331325 [1, 1, 3, 15, 97, 745, 6571, 65359, 723969, 8842257] OddSum: A331326 [0, 1, 4, 19, 112, 801, 6756, 65563, 717760, 8729857] AltSum: A009940 [1, 0, -1, -4, -15, -56, -185, -204, 6209, 112400] DiagSum: C001040 [1, 1, 3, 10, 43, 225, 1393, 9976, 81201, 740785] Central: A295383 [1, 4, 72, 2400, 117600, 7620480, 614718720, 59364264960] LeftSide: A000142 [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880] RightSide: A000012 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] PosHalf: A025167 [1, 3, 17, 139, 1473, 19091, 291793, 5129307, 101817089] NegHalf: A025166 [1, -1, 1, 7, -127, 1711, -23231, 334391, -5144063, 84149983] TransUnos: A002720 [1, 2, 7, 34, 209, 1546, 13327, 130922, 1441729, 17572114] TransSqrs: A105219 [0, 1, 8, 63, 544, 5225, 55656, 653023, 8379008, 116780049] TransNat0: A103194 [0, 1, 6, 39, 292, 2505, 24306, 263431, 3154824, 41368977] TransNat1: C000262 [1, 3, 13, 73, 501, 4051, 37633, 394353, 4596553, 58941091] PolyVal2: A087912 [1, 3, 14, 86, 648, 5752, 58576, 671568, 8546432, 119401856] PolyVal3: A277382 [1, 4, 23, 168, 1473, 14988, 173007, 2228544, 31636449] ``` """ const ModuleTrianglesTraitCard = "" const SEARCHONLINE = false # true function TraitCard(T::ℚTri, name) @warn "WRONG TYPE! Will not process!" end """ (SIGNATURES) """ function Traits(T::ℤTri, name, N, an=false) an = an && ! oeis_notinstalled() sep = " " println("\n=================") println(name) println() P = Polynomial(T) len = max(N, min(N - 1, length(T))) len = len < 10 ? len : 10 S = Flat(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Triangle", sep, SeqToString(S, len)) R = Reverse(T); S = Flat(R) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Reverse", sep, SeqToString(S, len)) I = Inverse(T) if I != [] S = Flat(I); anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Inverse", sep, SeqToString(S, len)) RI = Reverse(I); S = Flat(RI); anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "RevInv", sep, SeqToString(S, len)) end IR = Inverse(R) if IR != [] S = Flat(IR); anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "InvRev", sep, SeqToString(S, len)) end S = DiagonalTriangle(T); S = Flat(S) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "DiagTri", sep, SeqToString(S, len)) S = ConvolutionTriangle(T); S = Flat(S) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "ConvTri", sep, SeqToString(S, len)) S = PolyTriangle(T); S = Flat(S) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "PolyTri", sep, SeqToString(S, len)) S = sum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Sum", sep, SeqToString(S, len)) S = EvenSum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "EvenSum", sep, SeqToString(S, len)) S = OddSum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "OddSum", sep, SeqToString(S, len)) S = AltSum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "AltSum", sep, SeqToString(S, len)) S = DiagSum(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "DiagSum", sep, SeqToString(S, len)) S = Central(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "Central", sep, SeqToString(S, len)) S = LeftSide(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "LeftSide", sep, SeqToString(S, len)) S = RightSide(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "RightSide", sep, SeqToString(S, len)) S = PosHalf(P) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "PosHalf", sep, SeqToString(S, len)) S = NegHalf(P) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "NegHalf", sep, SeqToString(S, len)) S = BinConv(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "BinConv", sep, SeqToString(S, len)) S = IBinConv(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "IBinConv", sep, SeqToString(S, len)) S = Trans(T, [ZZ(n^2) for n = 0:19]) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "TransSqrs", sep, SeqToString(S, len)) S = Trans(T, [ZZ(n) for n = 0:19]) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "TransNat0", sep, SeqToString(S, len)) S = Trans(T, [ZZ(n) for n = 1:19]) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "TransNat1", sep, SeqToString(S, len)) S = PolyVal2(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "PolyVal2", sep, SeqToString(S, len)) S = PolyVal3(T) anum = an ? GetSeqnum(S, SEARCHONLINE) : "" println(anum, sep, name, sep, "PolyVal3", sep, SeqToString(S, len)) end """ Print the standard traits generated by linear transformation. ``` julia> TransTraits(BinomialTriangle) BinomialTriangle TransSqrs: A001788 [0, 1, 6, 24, 80, 240, 672, 1792, 4608, 11520] TransNat0: A001787 [0, 1, 4, 12, 32, 80, 192, 448, 1024, 2304] TransNat1: A001792 [1, 3, 8, 20, 48, 112, 256, 576, 1280, 2816] ``` """ function TransTraits(triangle::Function) dim = 19 T = triangle(dim) println("$triangle ") len = min(10, min(dim - 1, length(T))) S = Trans(T, [ZZ(1) for n = 0:dim]); anum = GetSeqnum(S, false) print("TransUnos: ", anum, " "); S[1:len] |> Println S = Trans(T, [ZZ((-1)^n) for n = 0:dim]); anum = GetSeqnum(S, false) print("TransAlts: ", anum, " "); S[1:len] |> Println S = Trans(T, [ZZ(n^2) for n = 0:dim]); anum = GetSeqnum(S, false) print("TransSqrs: ", anum, " "); S[1:len] |> Println S = Trans(T, [ZZ(n) for n = 0:dim]); anum = GetSeqnum(S, false) print("TransNat0: ", anum, " "); S[1:len] |> Println S = Trans(T, [ZZ(n) for n = 1:dim]); anum = GetSeqnum(S, false) print("TransNat1: ", anum, " "); S[1:len] |> Println println() end """ (SIGNATURES) """ function AssociatedTriangles(T::ℤTri, N) len = max(N, min(N - 1, length(T))) println("\nTriangle:\n") for row in T[1:len] Println(row) end println() print("Flat triangle: "); S = Flat(T); S[1:len] |> Println println("\nInverse triangle:\n") S = InverseTriangle(T) if S != [] for row in S[1:len] Println(row) end println() S = Flat(S); print("Inverse: "); S[1:len] |> Println end println("\nDiagonal triangle:\n") S = DiagonalTriangle(T) Println.(S[1:len]) println() S = Flat(S); print("Diagonal: "); S[1:len] |> Println println("\nPolynomial values, array:\n") Println.(PolyArray(T)) println("\nPolynomial values, triangle:\n") S = PolyTriangle(T) Println.(S[1:len]) println() S = Flat(S); print("PolyVal: "); S[1:len] |> Println end """ Prints a list of traits of the triangle with Anums. """ function TraitCard(triangle::Function) dim = 19 T = triangle(dim) name = "$triangle" c = findfirst("Triangle", name) Traits(T, name[1:c[1]-1], dim, true) end """ Prints a list of traits of the triangle without Anums and, if assoc=true, also a list of associated triangles. """ function TraitCard(triangle::Function, dim, assoc=false) T = triangle(dim) name = "$triangle" c = findfirst("Triangle", name) Traits(T, name[1:c[1]-1], dim) AssociatedTriangles(T, dim) end function AllTraitCards() for T in TRIANGLES TraitCard(T) end end # START-TEST-######################################################## using TrianglesExamples function test() dim = 8 TraitCard(BinomialTriangle, dim) TraitCard(LaguerreTriangle, dim) TraitCard(LahTriangle, dim) TraitCard(CatalanTriangle, dim) TraitCard(MotzkinTriangle, dim) TraitCard(NarayanaTriangle, dim) TraitCard(SchroederBigTriangle, dim) TraitCard(JacobsthalTriangle, dim) TraitCard(FibonacciTriangle, dim) TraitCard(EulerianTriangle, dim) TraitCard(UniTriangle, dim) end function demo() TransTraits(BinomialTriangle) TraitCard(LaguerreTriangle) end function perf() #AllTraitCards() end function main() test() demo() perf() end main() end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
10471
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module TrianglesUtils using Nemo, TrianglesBase, HTTP export Show, GetSeqnum, GetSeqnumUri, MakeSeqUri, SeqToString export profilespath, datapath, docsrcpath, csv_files export oeis_notinstalled, oeis_search, search_failed """ * Search the OEIS for a sequence. * Save a file in the 'data' directory in json format. * Triangle in standard format (without typeinfo): ``` [1] [1, 1] [2, 4, 1] [6, 18, 9, 1] [24, 96, 72, 16, 1] [120, 600, 600, 200, 25, 1] [720, 4320, 5400, 2400, 450, 36, 1] ``` * Triangle as a nested array: ``` [[1], [1, 1], [2, 4, 1], [6, 18, 9, 1], [24, 96, 72, 16, 1], [120, 600, 600, 200, 25, 1], [720, 4320, 5400, 2400, 450, 36, 1]] ``` * Triangle in flattened format: ``` 1, 1, 1, 2, 4, 1, 6, 18, 9, 1, 24, 96, 72, 16, 1, 120, 600, 600, 200, 25, 1, 720, 4320, 5400, 2400, 450, 36, 1, ``` * Triangle in info format with sequence ID: ``` [A021009] 1, 1, 1, 2, 4, 1, 6, 18, 9, 1, 24, 96, 72, 16, 1, ... ``` * Triangle in mapped format: ``` 0 ↦ 1 1 ↦ 1 2 ↦ 1 3 ↦ 2 4 ↦ 4 5 ↦ 1 6 ↦ 6 7 ↦ 18 8 ↦ 9 9 ↦ 1 ``` """ const ModuleTrianglesUtils = "" const srcdir = realpath(joinpath(dirname(@__FILE__))) const ROOTDIR = dirname(srcdir) const datadir = joinpath(ROOTDIR, "data") const profilesdir = joinpath(ROOTDIR, "profiles") const docsdir = joinpath(ROOTDIR, "docs") const docsrcdir = joinpath(docsdir, "src") datapath(name) = joinpath(datadir, name) profilespath(name) = joinpath(profilesdir, name) docsrcpath(name) = joinpath(docsrcdir, name) oeis_file() = joinpath(datadir, "stripped") is_oeis_installed() = isfile(oeis_file()) csv_files() = filter!(s -> occursin(r"\.csv$", s), readdir(profilesdir)) function oeis_notinstalled() if !is_oeis_installed() @warn("OEIS data not installed! Download stripped.gz from oeis.org,") @warn("expand it and put it in the directory ../data.") return true end return false end function search_failed(name) for ln ∈ eachline(name) occursin("greeting", ln) && continue occursin("{", ln) && continue occursin("start", ln) && continue if occursin("\"results\": null", ln) return true end end false end """ Search the OEIS for a sequence. The file is saved in the 'data' directory in json format. """ function oeis_search(seq) seqstr = AbsSeqToString(seq[1:min(end,12)]) filename = joinpath(datadir, seqstr[1:min(end,12)] * ".json") uristr = "https://oeis.org/search?q=" * seqstr * "&go=Search&fmt=json" url = HTTP.URI(uristr) tries = 3 r = nothing for i = 1:tries try r = HTTP.get(url; readtimeout = 2) getfield(r, :status) == 200 && break getfield(r, :status) == 302 && break catch e @warn(e) end sleep(2) end if !(r === nothing) && getfield(r, :status) == 200 open(filename, "w") do f write(f, getfield(r, :body)) end @info("Dowloaded " * basename(filename) * " to " * datadir) else if r === nothing @warn("Search did not succeed, connection timed out.\n") else @warn("Search did not succeed, $url\nStatus: $(getfield(r, :status))") end end filename end function AbsSeqToString(seq::ℤSeq, max=100) separator = "," str = "" c = 1 for trm in seq str *= string(abs(trm)) * separator c += 1 c > max && break end str end function SeqToString(seq::ℤSeq, max=100) separator = " " str = "[" c = 1 for trm in seq str *= string(trm) * separator c += 1 c > max && break end str * "]" end # increases accuracy and prevents premature matches const minlen = 30 # fragil! do not reduce! function GetSeqnum(seq::ℤSeq) str = AbsSeqToString(seq) soff = 1; loff = 10 #println(seq) #println(str) for ln ∈ eachline(oeis_file()) ln[1] == '#' && continue l = replace(ln, "-" => "") m = min(length(str), length(l)) len = min(length(str), length(l)-loff) - 1 len < minlen && continue cmp(str[soff:soff+len], l[loff:loff+len]) == 0 && return ln[1:7] end toff = findfirst(",", str)[1] + 1 for ln ∈ eachline(oeis_file()) ln[1] == '#' && continue l = replace(ln, "-" => "") len = min(length(str)-toff, length(l)-loff) - 1 len < minlen && continue cmp(str[toff:toff+len], l[loff:loff+len]) == 0 && return "A" * ln[2:7] end for ln ∈ eachline(oeis_file()) ln[1] == '#' && continue l = replace(ln, "-" => "") ff = findnext(",", l, 10) ff === nothing && continue loff = ff[1] + 1; soff = 1 len = min(length(str)-soff, length(l)-loff) - 1 len < minlen && continue cmp(str[soff:soff+len], l[loff:loff+len]) == 0 && return "A" * ln[2:7] len = min(length(str)-toff, length(l)-loff) - 1 len < minlen && continue cmp(str[toff:toff+len], l[loff:loff+len]) == 0 && return "A" * ln[2:7] end nothing end GetSeqnum(seq::ℤTri) = GetSeqnum(Flat(seq)) function GetSeqnum(seq, search=false) if seq === nothing || seq == [] return nothing end anum = GetSeqnum(seq) if search if anum === nothing filename = oeis_search(seq) if ! search_failed(filename) println() Println(seq[1:min(18, end)]) @warn "Not found in the local base but possibly in the OEIS!" println() end end end anum end function GetSeqnumUri(seq::ℤSeq, len=10) anum = GetSeqnum(seq) if anum === nothing return "<a href='" * "https://oeis.org/?q=" * SeqToString(seq, len) * "'>" * "nomatch</a>" end uri = joinpath("https://oeis.org/", anum) return "<a href='" * uri * "'>" * anum * "</a>" end function MakeSeqUri(anum, seq) if anum == "nothing" return "<a href='" * "https://oeis.org/?q=" * seq * "'>" * "nomatch</a>" end uri = joinpath("https://oeis.org/", anum) return "<a href='" * uri * "'>" * anum * "</a>" end function print_without_type(io, v::AbstractVector) print(io, "[") for (i, el) ∈ enumerate(v) i > 1 && print(io, ", ") print(io, el) end println(io, "]") end """ Print the array ``A`` in the format ``n ↦ A[n]`` for n in the given range. """ function MappedShow(A::Array, R::AbstractRange, offset=0) for k ∈ R if isassigned(A, k) println(k + offset, " ↦ ", A[k]) else println(k + offset, " ↦ ", "undef") end end end """ Print an integer triangle without typeinfo. """ function Show(T::ℤTri, format="std") if format == "std" # default for t in T[1:min(10, end)] print_without_type(IOContext(stdout), t) end elseif format == "nest" T |> println elseif format == "flat" for n in Flat(T) print(n, ", ") end elseif format == "map" offset = -1 # Julia is unfortunately 1-based. for n in T MappedShow(n, 1:length(n), offset) offset += length(n) end elseif format == "info" S = Flat(T) print("[", GetSeqnum(S), "] ") for t in T[1:min(5, end)], k in t print(k, ", ") end println("... ") end end # START-TEST-######################################################## using TrianglesExamples function test() T = LaguerreTriangle(7) println("\nThe $Laguerre triangle in different formats:") println("\nTriangle in standard format:\n") Show(T) println("\nTriangle as a nested array:\n") Show(T, "nest") println("\n\nTriangle in flattened format:\n") Show(T, "flat") println("\n\nTriangle in info format with sequence ID:\n") Show(T, "info") println("\nTriangle in mapped format:\n") Show(T, "map") end function demo() N = 7 println("\nTriangle in standard format:\n") Show(LaguerreTriangle(N)) println("\nTriangle as a nested array:\n") Show(LaguerreTriangle(N), "nest") println("\n\nTriangle in flattened format:\n") Show(LaguerreTriangle(N), "flat") println("\n\nTriangle in mapped format:\n") Show(LaguerreTriangle(N), "map") println("\nTriangle transform of the squares:\n") LaguerreTransform([ZZ(k^2) for k in 0:N - 1]) |> println println("\nTriangle transform of the IN:\n") LaguerreTransform([ZZ(k) for k in 0:N]) |> println LaguerreTransform([ZZ(k) for k in 1:N + 1]) |> println println() T = LaguerreTriangle(9) PosHalf(T) |> println NegHalf(T) |> println println() P = Polynomial(T) println.(P) E = Evaluate(P, ZZ(3)) println(E) println() Println.(PolyTriangle(T)) println() Println.(PolyArray(T)) println() end function perf() GetSeqnum(ℤInt[1, 1, -2, 3, -3, 3, -5, 7, -6, 6, -10, 12, -11, 13, -17, 20, -21, 21, -27, 34, -33, 36, -46, 51, -53, 58, -68, 78, -82, 89, -104]) |> println GetSeqnum(ℤInt[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52]) |> println GetSeqnum(ℤInt[1, 1, 7, 37, 241, 2101, 18271, 201097, 2270017, 29668681, 410815351, 6238931821, 101560835377, 1765092183037, 32838929702671, 644215775792401]) |> println GetSeqnum(ℤInt[1, 1, 1, 7, 37, 241, 2101, 18271, 201097, 2270017, 29668681, 410815351, 6238931821, 101560835377, 1765092183037, 32838929702671, 644215775792401]) |> println GetSeqnum(ℤInt[0, 1, 2, 7, 44, 361, 3654, 44207, 622552, 10005041, 180713290, 3624270839, 79914671748, 1921576392793, 50040900884366, 1403066801155039, 42142044935535536]) |> println GetSeqnum(ℤInt[0, 70, 3783, 338475, 40565585, 6061961733, 1083852977811, 225615988054171, 53595807366038234, 14308700593468127485, 4241390625289880226714]) |> println GetSeqnumUri(ℤInt[1, 1, 7, 37, 241, 2101, 18271, 201097, 2270017, 29668681, 410815351, 6238931821, 101560835377, 1765092183037, 32838929702671, 644215775792401]) |> println end function main() test() demo() perf() end main() end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
514
# This file is part of IntegerTriangles.jl. # Copyright Peter Luschny. License is MIT. (@__DIR__) ∉ LOAD_PATH && push!(LOAD_PATH, (@__DIR__)) module AnumTester using IntegerTriangles TLEN = 19 #Inspect("Aitken", "Std", "DiagTri", TLEN) #Inspect("Aitken", "Std", "PolyTri", TLEN) #Inspect("Aitken", "Std", "EvenSum", TLEN) #Inspect("Aitken", "Std", "OddSum", TLEN) #Inspect("Aitken", "Std", "AltSum", TLEN) #Inspect("Laguerre", "Std", "IBinConv", TLEN) Inspect("Laguerre", "Std", "Middle", TLEN) end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
2372
# This file is part of IntegerTriangles. # Copyright Peter Luschny. License is MIT. # Version of: UTC 2021-05-06 12:01:36 # 0b949410-ae52-11eb-0427-376cef549a70 # Do not edit this file, it is generated from the modules and will be overwritten! # Edit the modules in the src directory and build this file with BuildTriangles.jl! tstdir = realpath(joinpath(dirname(@__FILE__))) srcdir = joinpath(dirname(tstdir), "src") tstdir ∉ LOAD_PATH && push!(LOAD_PATH, tstdir) srcdir ∉ LOAD_PATH && push!(LOAD_PATH, srcdir) module perftests using IntegerTriangles, Dates, InteractiveUtils InteractiveUtils.versioninfo() start = Dates.now() # +++ TrianglesBase.jl +++ # +++ TrianglesExamples.jl +++ T = LaguerreTriangle(8) Println.(PolyTriangle(T)) Println.(PolyArray(T)) Println.(Inverse(PolyTriangle(T))) Println.(FubiniTriangle(8)) Println.(DArcaisTriangle(8)) # +++ TrianglesExplorer.jl +++ # +++ TrianglesPlot.jl +++ # +++ TrianglesTables.jl +++ # +++ TrianglesTraitCard.jl +++ # +++ TrianglesUtils.jl +++ GetSeqnum(ℤInt[1, 1, -2, 3, -3, 3, -5, 7, -6, 6, -10, 12, -11, 13, -17, 20, -21, 21, -27, 34, -33, 36, -46, 51, -53, 58, -68, 78, -82, 89, -104]) |> println GetSeqnum(ℤInt[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52]) |> println GetSeqnum(ℤInt[1, 1, 7, 37, 241, 2101, 18271, 201097, 2270017, 29668681, 410815351, 6238931821, 101560835377, 1765092183037, 32838929702671, 644215775792401]) |> println GetSeqnum(ℤInt[1, 1, 1, 7, 37, 241, 2101, 18271, 201097, 2270017, 29668681, 410815351, 6238931821, 101560835377, 1765092183037, 32838929702671, 644215775792401]) |> println GetSeqnum(ℤInt[0, 1, 2, 7, 44, 361, 3654, 44207, 622552, 10005041, 180713290, 3624270839, 79914671748, 1921576392793, 50040900884366, 1403066801155039, 42142044935535536]) |> println GetSeqnum(ℤInt[0, 70, 3783, 338475, 40565585, 6061961733, 1083852977811, 225615988054171, 53595807366038234, 14308700593468127485, 4241390625289880226714]) |> println GetSeqnumUri(ℤInt[1, 1, 7, 37, 241, 2101, 18271, 201097, 2270017, 29668681, 410815351, 6238931821, 101560835377, 1765092183037, 32838929702671, 644215775792401]) |> println stop = Dates.now() tdiff = stop - start println("\nJulia version: " * string(VERSION) ) println(start) println("Total test time: ", tdiff) end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
code
2975
# This file is part of IntegerTriangles. # Copyright Peter Luschny. License is MIT. # Version of: UTC 2021-05-06 12:01:36 # 0b949410-ae52-11eb-10dd-b977ed9ce129 # Do not edit this file, it is generated from the modules and will be overwritten! # Edit the modules in the src directory and build this file with BuildTriangles.jl! module runtests tstdir = realpath(joinpath(dirname(@__FILE__))) srcdir = joinpath(dirname(tstdir), "src") tstdir ∉ LOAD_PATH && push!(LOAD_PATH, tstdir) srcdir ∉ LOAD_PATH && push!(LOAD_PATH, srcdir) using Nemo, Test, IntegerTriangles, PrettyTables # *** TrianglesBase.jl ********* # *** TrianglesExamples.jl ********* @testset "Laguerre" begin A = ℤInt[0, 1, 6, 39, 292, 2505, 24306, 263431] @test Laguerre(0) == ℤInt[1] @test Laguerre(3) == ℤInt[6, 18, 9, 1] @test Laguerre(5) == ℤInt[120, 600, 600, 200, 25, 1] @test Laguerre(6, 1) == ZZ(4320) @test [Laguerre(7, k) for k in 0:7] == Laguerre(7) @test Laguerre(ℤInt[0, 1, 2, 3, 4, 5]) == ZZ(2505) @test Laguerre(ℤInt[0, 1, 4, 9, 16, 25]) == ZZ(5225) @test LaguerreTransform([ZZ(n) for n in 0:7]) == A @test typeof(Laguerre(3, 3)) === fmpz # ℤInt @test typeof(Laguerre(5)) === Array{fmpz,1} # ℤSeq @test typeof(Laguerre(A)) === fmpz # ℤInt @test typeof(LaguerreTriangle(5)) === Array{Array{fmpz,1},1} # ℤTri @test typeof(LaguerreTransform(A)) === Array{fmpz,1} # ℤSeq end # *** TrianglesExplorer.jl ********* TLEN = 19 Explore("SchroederB", "Inv", "AltSum", TLEN) # *** TrianglesPlot.jl ********* # *** TrianglesTables.jl ********* header = ["A-number", "Triangle", "Form", "Function", "Sequence"] mat = [ # Type Matrix{String}, or Array{String,2} "A000302" "Binomial" "Std" "PolyVal3" "1, 4, 16, 64, 256, 1024, 4096, 16384" ; ] S = String["A111884" "Lah" "Std" "TransAlts" "1, -1, -1, -1, 1, 19, 151, 1091"] mat = [mat; S] L = String["A111884", "Lah", "Std", "TransAlts", "1, -1, -1, -1, 1, 19, 151, 1091"] mat = [mat; reshape(L, 1, 5)] L = Explore("Laguerre", "Rev", "TransNat1") mat = [mat; reshape(L, 1, 5)] pretty_table(mat, header, alignment=[:l,:l,:l,:l,:l]) mat # *** TrianglesTraitCard.jl ********* dim = 8 TraitCard(BinomialTriangle, dim) TraitCard(LaguerreTriangle, dim) TraitCard(LahTriangle, dim) TraitCard(CatalanTriangle, dim) TraitCard(MotzkinTriangle, dim) TraitCard(NarayanaTriangle, dim) TraitCard(SchroederBigTriangle, dim) TraitCard(JacobsthalTriangle, dim) TraitCard(FibonacciTriangle, dim) TraitCard(EulerianTriangle, dim) TraitCard(UniTriangle, dim) # *** TrianglesUtils.jl ********* T = LaguerreTriangle(7) println("\nThe $Laguerre triangle in different formats:") println("\nTriangle in standard format:\n") Show(T) println("\nTriangle as a nested array:\n") Show(T, "nest") println("\n\nTriangle in flattened format:\n") Show(T, "flat") println("\n\nTriangle in info format with sequence ID:\n") Show(T, "info") println("\nTriangle in mapped format:\n") Show(T, "map") end # module
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
2687
<img src="https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/docs/src/TrianglesLogo.png"> [![Build status](https://travis-ci.org/OpenLibMathSeq/IntegerTriangles.jl.svg?branch=master)](https://travis-ci.org/OpenLibMathSeq/IntegerTriangles.jl) [![Docs dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://openlibmathseq.github.io/IntegerTriangles.jl/dev/introduction/) -- The package is tested against Julia >= 1.6.0 on Linux, macOS, and Windows64. Very early in the development cycle. ## Julia implementations of integer triangles. We give a framework for computing mathematical integer triangles and use it to create so called "Integer Triangle Trait Cards". A trait card is a compilation of the essential characteristics of an integer triangle, whereby we understand the characteristics of a triangle to be integer sequences that can be obtained from the triangle by elementary transformations. To see what you can expect start by executing using IntegerTriangles TraitCard(BinomialTriangle, 8) Overview tables can be automatically generated for a variety of triangles and traits. | A-Number | Triangle | Form | Function | Sequence | | -------- | ---------- | ---- | --------- | ------------------------------------------- | | A000302 | Binomial | Std | PolyVal3 | 1, 4, 16, 64, 256, 1024, 4096, 16384 | | A001333 | SchroederB | Inv | AltSum | 1, -1, 3, -7, 17, -41, 99, -239 | | A006012 | SchroederL | Inv | AltSum | 1, -2, 6, -20, 68, -232, 792, -2704 | | A026302 | Motzkin | Rev | Central | 1, 2, 9, 44, 230, 1242, 6853, 38376 | | A103194 | Laguerre | Std | TransNat0 | 0, 1, 6, 39, 292, 2505, 24306, 263431 | | nothing | Laguerre | Rev | TransNat1 | 1, 3, 15, 97, 753, 6771, 68983, 783945 | Important: Note that we assume all sequences to start at offset = 0. Also note that all references to A-numbers are approximativ only, i.e. the first few terms of the sequence may differ and the OEIS-'offset' is always disregarded. To use this feature you have to download the file [stripped.gz](http://oeis.org/stripped.gz) from oeis.org, expand it and put it in the directory ../data. You can also look at the demo [notebook](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/demos/IntegerTriangles.ipynb). An introduction to the project can be found in: * [Tutorial part 1](http://luschny.de/julia/triangles/TutorialTrianglesPart1.html) * [Tutorial part 2](http://luschny.de/julia/triangles/TutorialTrianglesPart2.html) * [Tutorial part 3](http://luschny.de/julia/triangles/TutorialTrianglesPart3.html)
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
213
Download the file https://oeis.org/stripped.gz from the OEIS and expand it here. Then you can get the numerical data of a sequence from this local copy with the function 'oeis_local()' in the module 'OEISUtils'.
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
1590
┌──────────┬────────────┬──────┬───────────┬────────────────────────────────────────────────────────────┐ │ A-number │ Triangle │ Form │ Function │ Sequence │ ├──────────┼────────────┼──────┼───────────┼────────────────────────────────────────────────────────────┤ │ A000302 │ Binomial │ Std │ PolyVal3 │ 1, 4, 16, 64, 256, 1024, 4096, 16384 │ │ A001333 │ SchroederB │ Inv │ AltSum │ 1, -1, 3, -7, 17, -41, 99, -239 │ │ A006012 │ SchroederL │ Inv │ AltSum │ 1, -2, 6, -20, 68, -232, 792, -2704 │ │ A026302 │ Motzkin │ Rev │ Central │ 1, 2, 9, 44, 230, 1242, 6853, 38376 │ │ A025167 │ Laguerre │ Std │ PosHalf │ 1, 3, 17, 139, 1473, 19091, 291793, 5129307 │ │ A103194 │ Laguerre │ Std │ TransNat0 │ 0, 1, 6, 39, 292, 2505, 24306, 263431 │ │ C000262 │ Laguerre │ Std │ TransNat1 │ 1, 3, 13, 73, 501, 4051, 37633, 394353 │ │ A103194 │ Lah │ Std │ TransSqrs │ 0, 1, 6, 39, 292, 2505, 24306, 263431 │ │ A111884 │ Lah │ Std │ TransAlts │ 1, -1, -1, -1, 1, 19, 151, 1091 │ │ A111884 │ Lah │ Std │ TransAlts │ 1, -1, -1, -1, 1, 19, 151, 1091 │ │ nothing │ Laguerre │ Rev │ TransNat1 │ 1, 3, 15, 97, 753, 6771, 68983, 783945, 9820737, 134352163 │ └──────────┴────────────┴──────┴───────────┴────────────────────────────────────────────────────────────┘
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6452
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Aitken</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A011971'>A011971</a></td> <td style = "text-align: left;">[1 1 2 2 3 5 5 7 10 15 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A123346'>A123346</a></td> <td style = "text-align: left;">[1 2 1 5 3 2 15 10 7 5 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 2 5 3 15 7 5 52 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 2 5 3 15 7 5 52 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 2 3 1 5 10 5 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 2 3 1 5 10 5 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A005493'>A005493</a></td> <td style = "text-align: left;">[1 3 10 37 151 674 3263 17007 94828 562595 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 7 15 94 290 1925 7541 54217 254189 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 7 15 94 290 1925 7541 54217 254189 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 2 3 22 57 384 1338 9466 40611 308406 ]'>nomatch</a></td> <td style = "text-align: left;">[0 2 3 22 57 384 1338 9466 40611 308406 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 4 -7 37 -94 587 -1925 13606 -54217 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 4 -7 37 -94 587 -1925 13606 -54217 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 4 8 27 82 312 1256 5708 28059 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 4 8 27 82 312 1256 5708 28059 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A216078'>A216078</a></td> <td style = "text-align: left;">[1 1 3 7 27 87 409 1657 9089 43833 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A094577'>A094577</a></td> <td style = "text-align: left;">[1 3 27 409 9089 272947 10515147 501178937 28773452321 1949230218691 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000110'>A000110</a></td> <td style = "text-align: left;">[1 1 2 5 15 52 203 877 4140 21147 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000110'>A000110</a></td> <td style = "text-align: left;">[1 2 5 15 52 203 877 4140 21147 115975 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 19 103 634 4393 33893 288158 2674849 26888251 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 19 103 634 4393 33893 288158 2674849 26888251 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 7 -17 166 -931 8333 -67902 668341 -6733957 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 7 -17 166 -931 8333 -67902 668341 -6733957 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A095676'>A095676</a></td> <td style = "text-align: left;">[1 5 28 179 1291 10358 91337 876289 9070546 100596161 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 7 56 521 5529 65674 860387 12290251 189680754 3139572183 ]'>nomatch</a></td> <td style = "text-align: left;">[1 7 56 521 5529 65674 860387 12290251 189680754 3139572183 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A126390'>A126390</a></td> <td style = "text-align: left;">[1 3 13 71 457 3355 27509 248127 2434129 25741939 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 2 23 182 1293 8932 62014 439442 3202127 24081458 ]'>nomatch</a></td> <td style = "text-align: left;">[0 2 23 182 1293 8932 62014 439442 3202127 24081458 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 2 13 72 393 2202 12850 78488 502327 3366648 ]'>nomatch</a></td> <td style = "text-align: left;">[0 2 13 72 393 2202 12850 78488 502327 3366648 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A278677'>A278677</a></td> <td style = "text-align: left;">[1 5 23 109 544 2876 16113 95495 597155 3929243 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6874
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Bessel1</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A122850'>A122850</a></td> <td style = "text-align: left;">[1 0 1 0 -1 1 0 3 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A104548'>A104548</a></td> <td style = "text-align: left;">[1 1 0 1 -1 0 1 -3 3 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A122848'>A122848</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 0 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A144299'>A144299</a></td> <td style = "text-align: left;">[1 1 0 1 1 0 1 3 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 1 0 -1 0 3 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 1 0 -1 0 3 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 1 1 0 0 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 0 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000806'>A000806</a></td> <td style = "text-align: left;">[1 1 0 1 -5 36 -329 3655 -47844 721315 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 -3 16 -115 1051 -11676 152839 -2304261 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 -3 16 -115 1051 -11676 152839 -2304261 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A025164'>A025164</a></td> <td style = "text-align: left;">[0 1 -1 4 -21 151 -1380 15331 -200683 3025576 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A144301'>A144301</a></td> <td style = "text-align: left;">[1 -1 2 -7 37 -266 2431 -27007 353522 -5329837 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 -1 4 -18 121 -1056 11386 -145960 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 -1 4 -18 121 -1056 11386 -145960 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -1 3 15 -105 -420 4725 17325 -270270 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -1 3 15 -105 -420 4725 17325 -270270 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 15 -420 17325 -945945 64324260 -5237832600 496939367925 -53835098191875 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 15 -420 17325 -945945 64324260 -5237832600 496939367925 -53835098191875 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A002119'>A002119</a></td> <td style = "text-align: left;">[1 1 -1 7 -71 1001 -18089 398959 -10391023 312129649 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A080893'>A080893</a></td> <td style = "text-align: left;">[1 1 3 19 193 2721 49171 1084483 28245729 848456353 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 2 2 -2 22 -206 2354 -31426 480806 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 2 2 -2 22 -206 2354 -31426 480806 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 6 9 9 18 -81 1053 -14418 225747 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 6 9 9 18 -81 1053 -14418 225747 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -1 1 7 -124 1591 -19991 256691 -3335228 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -1 1 7 -124 1591 -19991 256691 -3335228 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 3 19 175 2076 29911 505093 9757539 211883500 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 3 19 175 2076 29911 505093 9757539 211883500 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 3 0 7 -45 396 -4277 54825 -813348 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 3 0 7 -45 396 -4277 54825 -813348 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 1 0 1 -5 36 -329 3655 -47844 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 1 0 1 -5 36 -329 3655 -47844 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A231622'>A231622</a></td> <td style = "text-align: left;">[1 2 1 1 -4 31 -293 3326 -44189 673471 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6424
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Binomial</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A007318'>A007318</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 3 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A007318'>A007318</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 3 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A007318'>A007318</a></td> <td style = "text-align: left;">[1 -1 1 1 -2 1 -1 3 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A007318'>A007318</a></td> <td style = "text-align: left;">[1 1 -1 1 -2 1 1 -3 3 -1 ]</td> </tr> <tr> <td style = "text-align: left;">InvRev</td> <td style = "text-align: left;"><a href='https://oeis.org/A007318'>A007318</a></td> <td style = "text-align: left;">[1 -1 1 1 -2 1 -1 3 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A011973'>A011973</a></td> <td style = "text-align: left;">[1 1 1 1 1 2 1 3 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A009998'>A009998</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 4 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000079'>A000079</a></td> <td style = "text-align: left;">[1 2 4 8 16 32 64 128 256 512 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A011782'>A011782</a></td> <td style = "text-align: left;">[1 1 2 4 8 16 32 64 128 256 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A131577'>A131577</a></td> <td style = "text-align: left;">[0 1 2 4 8 16 32 64 128 256 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000045'>A000045</a></td> <td style = "text-align: left;">[1 1 2 3 5 8 13 21 34 55 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A001405'>A001405</a></td> <td style = "text-align: left;">[1 1 2 3 6 10 20 35 70 126 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A000984'>A000984</a></td> <td style = "text-align: left;">[1 2 6 20 70 252 924 3432 12870 48620 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A000244'>A000244</a></td> <td style = "text-align: left;">[1 3 9 27 81 243 729 2187 6561 19683 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 -1 1 -1 1 -1 1 -1 1 -1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A000244'>A000244</a></td> <td style = "text-align: left;">[1 3 9 27 81 243 729 2187 6561 19683 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A000302'>A000302</a></td> <td style = "text-align: left;">[1 4 16 64 256 1024 4096 16384 65536 262144 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A000984'>A000984</a></td> <td style = "text-align: left;">[1 2 6 20 70 252 924 3432 12870 48620 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A126869'>A126869</a></td> <td style = "text-align: left;">[1 0 -2 0 6 0 -20 0 70 0 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A001788'>A001788</a></td> <td style = "text-align: left;">[0 1 6 24 80 240 672 1792 4608 11520 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A001787'>A001787</a></td> <td style = "text-align: left;">[0 1 4 12 32 80 192 448 1024 2304 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A001792'>A001792</a></td> <td style = "text-align: left;">[1 3 8 20 48 112 256 576 1280 2816 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6364
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Catalan</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A053121'>A053121</a></td> <td style = "text-align: left;">[1 0 1 1 0 1 0 2 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A052173'>A052173</a></td> <td style = "text-align: left;">[1 1 0 1 0 1 1 0 2 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A049310'>A049310</a></td> <td style = "text-align: left;">[1 0 1 -1 0 1 0 -2 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A053119'>A053119</a></td> <td style = "text-align: left;">[1 1 0 1 0 -1 1 0 -2 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 0 0 2 2 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 0 0 2 2 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 1 1 0 2 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 1 1 0 2 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001405'>A001405</a></td> <td style = "text-align: left;">[1 1 2 3 6 10 20 35 70 126 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A126869'>A126869</a></td> <td style = "text-align: left;">[1 0 2 0 6 0 20 0 70 0 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A138364'>A138364</a></td> <td style = "text-align: left;">[0 1 0 3 0 10 0 35 0 126 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001405'>A001405</a></td> <td style = "text-align: left;">[1 -1 2 -3 6 -10 20 -35 70 -126 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 2 0 5 0 14 0 42 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 2 0 5 0 14 0 42 0 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 2 3 0 0 14 20 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 2 3 0 0 14 20 0 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 3 0 20 0 154 0 1260 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 3 0 20 0 154 0 1260 0 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A126120'>A126120</a></td> <td style = "text-align: left;">[1 0 1 0 2 0 5 0 14 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A121724'>A121724</a></td> <td style = "text-align: left;">[1 1 5 9 45 97 485 1145 5725 14289 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A121724'>A121724</a></td> <td style = "text-align: left;">[1 1 5 9 45 97 485 1145 5725 14289 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A054341'>A054341</a></td> <td style = "text-align: left;">[1 2 5 12 30 74 185 460 1150 2868 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A126931'>A126931</a></td> <td style = "text-align: left;">[1 3 10 33 110 366 1220 4065 13550 45162 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 7 21 66 216 715 2395 8101 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 7 21 66 216 715 2395 8101 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 7 21 66 216 715 2395 8101 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 7 21 66 216 715 2395 8101 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 4 11 28 66 152 339 748 1622 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 4 11 28 66 152 339 748 1622 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A045621'>A045621</a></td> <td style = "text-align: left;">[0 1 2 5 10 22 44 93 186 386 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A000079'>A000079</a></td> <td style = "text-align: left;">[1 2 4 8 16 32 64 128 256 512 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
7191
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">DArcais</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A078521'>A078521</a></td> <td style = "text-align: left;">[1 0 1 0 3 1 0 8 9 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 3 0 1 9 8 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 3 0 1 9 8 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 -3 1 0 19 -9 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 -3 1 0 19 -9 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 -3 0 1 -9 19 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 -3 0 1 -9 19 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 1 0 3 0 8 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 1 0 3 0 8 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 1 1 0 4 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 4 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A053529'>A053529</a></td> <td style = "text-align: left;">[1 1 4 18 120 840 7920 75600 887040 10886400 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 9 60 480 3960 40320 443520 5443200 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 9 60 480 3960 40320 443520 5443200 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 3 9 60 360 3960 35280 443520 5443200 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 3 9 60 360 3960 35280 443520 5443200 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A293140'>A293140</a></td> <td style = "text-align: left;">[1 -1 -2 0 0 120 0 5040 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 3 9 51 204 1908 9370 109017 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 3 9 51 204 1908 9370 109017 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 3 8 59 450 2475 28294 147889 2341332 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 3 8 59 450 2475 28294 147889 2341332 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 59 2475 147889 11744775 1163220575 137914387611 19052174174033 3005469776175867 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 59 2475 147889 11744775 1163220575 137914387611 19052174174033 3005469776175867 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 7 51 609 6825 122535 1890315 41928705 884551185 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 7 51 609 6825 122535 1890315 41928705 884551185 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -5 15 -135 -495 -9405 -237825 363825 -42652575 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -5 15 -135 -495 -9405 -237825 363825 -42652575 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 10 60 480 4320 46800 554400 7459200 108864000 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 10 60 480 4320 46800 554400 7459200 108864000 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 18 132 1224 12960 159120 2162160 32659200 536699520 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 18 132 1224 12960 159120 2162160 32659200 536699520 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 7 52 595 7521 117796 2033004 39834159 852065323 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 7 52 595 7521 117796 2033004 39834159 852065323 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -5 -2 115 -1779 976 79668 -2574417 32044003 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -5 -2 115 -1779 976 79668 -2574417 32044003 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 7 53 456 4384 47492 566516 7457384 106329384 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 7 53 456 4384 47492 566516 7457384 106329384 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A057623'>A057623</a></td> <td style = "text-align: left;">[0 1 5 29 218 1814 18144 196356 2427312 32304240 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 9 47 338 2654 26064 271956 3314352 43190640 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 9 47 338 2654 26064 271956 3314352 43190640 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6664
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Delannoy</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A008288'>A008288</a></td> <td style = "text-align: left;">[1 1 1 1 3 1 1 5 5 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A008288'>A008288</a></td> <td style = "text-align: left;">[1 1 1 1 3 1 1 5 5 1 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A103136'>A103136</a></td> <td style = "text-align: left;">[1 -1 1 2 -3 1 -6 10 -5 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A033878'>A033878</a></td> <td style = "text-align: left;">[1 1 -1 1 -3 2 1 -5 10 -6 ]</td> </tr> <tr> <td style = "text-align: left;">InvRev</td> <td style = "text-align: left;"><a href='https://oeis.org/A103136'>A103136</a></td> <td style = "text-align: left;">[1 -1 1 2 -3 1 -6 10 -5 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 1 3 1 5 1 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 1 3 1 5 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 1 1 5 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 5 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A077985'>A077985</a></td> <td style = "text-align: left;">[1 2 5 12 29 70 169 408 985 2378 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A116404'>A116404</a></td> <td style = "text-align: left;">[1 1 2 6 15 35 84 204 493 1189 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 3 6 14 35 85 204 492 1189 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 3 6 14 35 85 204 492 1189 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A014581'>A014581</a></td> <td style = "text-align: left;">[1 0 -1 0 1 0 -1 0 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 4 7 13 24 44 81 149 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 4 7 13 24 44 81 149 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A026003'>A026003</a></td> <td style = "text-align: left;">[1 1 3 5 13 25 63 129 321 681 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A001850'>A001850</a></td> <td style = "text-align: left;">[1 3 13 63 321 1683 8989 48639 265729 1462563 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A007482'>A007482</a></td> <td style = "text-align: left;">[1 3 11 39 139 495 1763 6279 22363 79647 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A077020'>A077020</a></td> <td style = "text-align: left;">[1 -1 -1 3 -1 -5 7 3 -17 11 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A007482'>A007482</a></td> <td style = "text-align: left;">[1 3 11 39 139 495 1763 6279 22363 79647 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A015530'>A015530</a></td> <td style = "text-align: left;">[1 4 19 88 409 1900 8827 41008 190513 885076 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A006139'>A006139</a></td> <td style = "text-align: left;">[1 2 8 32 136 592 2624 11776 53344 243392 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -4 0 24 0 -160 0 1120 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -4 0 24 0 -160 0 1120 0 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 7 34 138 503 1709 5524 17204 52061 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 7 34 138 503 1709 5524 17204 52061 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 5 18 58 175 507 1428 3940 10701 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 5 18 58 175 507 1428 3940 10701 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A026937'>A026937</a></td> <td style = "text-align: left;">[1 3 10 30 87 245 676 1836 4925 13079 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6652
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Euler</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A109449'>A109449</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 2 3 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 1 1 3 3 2 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 3 3 2 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A109449'>A109449</a></td> <td style = "text-align: left;">[1 -1 1 1 -2 1 -2 3 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -1 1 -2 1 1 -3 3 -2 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -1 1 -2 1 1 -3 3 -2 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 2 5 3 1 16 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 2 5 3 1 16 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 1 2 4 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 2 4 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000667'>A000667</a></td> <td style = "text-align: left;">[1 2 4 9 24 77 294 1309 6664 38177 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A062272'>A062272</a></td> <td style = "text-align: left;">[1 1 2 5 12 41 152 685 3472 19921 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A062161'>A062161</a></td> <td style = "text-align: left;">[0 1 2 4 12 36 142 624 3192 18256 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A062162'>A062162</a></td> <td style = "text-align: left;">[1 0 0 1 0 5 10 61 280 1665 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 4 9 27 93 392 1898 10493 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 4 9 27 93 392 1898 10493 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 3 6 20 40 175 350 2016 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 3 6 20 40 175 350 2016 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 6 40 350 4032 56364 933504 17824950 385848320 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 6 40 350 4032 56364 933504 17824950 385848320 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000111'>A000111</a></td> <td style = "text-align: left;">[1 1 1 2 5 16 61 272 1385 7936 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A000834'>A000834</a></td> <td style = "text-align: left;">[1 3 9 35 177 1123 8569 76355 777697 8911683 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 1 -9 33 -241 1761 -15929 161473 -1853281 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 1 -9 33 -241 1761 -15929 161473 -1853281 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A000752'>A000752</a></td> <td style = "text-align: left;">[1 3 9 28 93 338 1369 6238 31993 183618 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A307878'>A307878</a></td> <td style = "text-align: left;">[1 4 16 65 272 1189 5506 27365 147512 868129 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 6 21 90 467 2824 19383 148414 1251935 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 6 21 90 467 2824 19383 148414 1251935 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -2 -1 -6 -15 0 -271 574 -5379 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -2 -1 -6 -15 0 -271 574 -5379 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 6 24 84 300 1182 5292 26936 154224 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 6 24 84 300 1182 5292 26936 154224 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A231179'>A231179</a></td> <td style = "text-align: left;">[0 1 4 12 36 120 462 2058 10472 59976 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A000737'>A000737</a></td> <td style = "text-align: left;">[1 3 8 21 60 197 756 3367 17136 98153 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6492
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">EulerS</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A119879'>A119879</a></td> <td style = "text-align: left;">[1 0 1 -1 0 1 0 -3 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 0 -1 1 0 -3 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 0 -1 1 0 -3 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A119467'>A119467</a></td> <td style = "text-align: left;">[1 0 1 1 0 1 0 3 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A141665'>A141665</a></td> <td style = "text-align: left;">[1 1 0 1 0 1 1 0 3 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -1 1 0 0 5 -3 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -1 1 0 0 5 -3 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A247498'>A247498</a></td> <td style = "text-align: left;">[1 0 1 -1 1 1 0 0 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A009006'>A009006</a></td> <td style = "text-align: left;">[1 1 0 -2 0 16 0 -272 0 7936 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A009006'>A009006</a></td> <td style = "text-align: left;">[0 1 0 -2 0 16 0 -272 0 7936 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A009006'>A009006</a></td> <td style = "text-align: left;">[1 -1 0 2 0 -16 0 272 0 -7936 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 0 3 0 -41 0 1024 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 0 3 0 -41 0 1024 0 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 -3 -6 0 0 175 350 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 -3 -6 0 0 175 350 0 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -6 0 350 0 -56364 0 17824950 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -6 0 350 0 -56364 0 17824950 0 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A122045'>A122045</a></td> <td style = "text-align: left;">[1 0 -1 0 5 0 -61 0 1385 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A001586'>A001586</a></td> <td style = "text-align: left;">[1 1 -3 -11 57 361 -2763 -24611 250737 2873041 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A001586'>A001586</a></td> <td style = "text-align: left;">[1 1 -3 -11 57 361 -2763 -24611 250737 2873041 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A119880'>A119880</a></td> <td style = "text-align: left;">[1 2 3 2 -3 2 63 2 -1383 2 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A119881'>A119881</a></td> <td style = "text-align: left;">[1 3 8 18 32 48 128 528 512 -6912 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 -8 -30 26 840 2696 -22722 -240146 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 -8 -30 26 840 2696 -22722 -240146 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 -8 -30 26 840 2696 -22722 -240146 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 -8 -30 26 840 2696 -22722 -240146 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 4 6 -8 -40 96 672 -2176 -19584 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 4 6 -8 -40 96 672 -2176 -19584 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A109573'>A109573</a></td> <td style = "text-align: left;">[0 1 2 0 -8 0 96 0 -2176 0 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 2 -2 -8 16 96 -272 -2176 7936 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 2 -2 -8 16 96 -272 -2176 7936 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6266
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">EulerT</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A162660'>A162660</a></td> <td style = "text-align: left;">[0 1 0 0 2 0 -2 0 3 0 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 0 1 0 2 0 0 3 0 -2 ]'>nomatch</a></td> <td style = "text-align: left;">[0 0 1 0 2 0 0 3 0 -2 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 0 0 -2 2 0 0 0 16 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 0 0 -2 2 0 0 0 16 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 0 0 1 0 -2 2 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 0 0 1 0 -2 2 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A009832'>A009832</a></td> <td style = "text-align: left;">[0 1 2 1 -4 1 62 1 -1384 1 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000035'>A000035</a></td> <td style = "text-align: left;">[0 1 0 1 0 1 0 1 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 0 2 0 -4 0 62 0 -1384 0 ]'>nomatch</a></td> <td style = "text-align: left;">[0 0 2 0 -4 0 62 0 -1384 0 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A009832'>A009832</a></td> <td style = "text-align: left;">[0 1 -2 1 4 1 -62 1 1384 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 0 0 0 11 0 -192 0 6061 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 0 0 0 11 0 -192 0 6061 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 2 0 0 -20 -40 0 0 2016 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 2 0 0 -20 -40 0 0 2016 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A214447'>A214447</a></td> <td style = "text-align: left;">[0 2 0 -40 0 4032 0 -933504 0 385848320 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A009006'>A009006</a></td> <td style = "text-align: left;">[0 1 0 -2 0 16 0 -272 0 7936 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000004'>A000004</a></td> <td style = "text-align: left;">[0 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 2 -5 -28 181 1382 -12305 -125368 1436521 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 2 -5 -28 181 1382 -12305 -125368 1436521 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 2 -5 -28 181 1382 -12305 -125368 1436521 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 2 -5 -28 181 1382 -12305 -125368 1436521 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 4 10 16 16 64 400 256 -7424 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 4 10 16 16 64 400 256 -7424 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 6 25 84 241 666 2185 7944 19681 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 6 25 84 241 666 2185 7944 19681 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 4 7 -16 -159 -188 4383 26560 -104591 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 4 7 -16 -159 -188 4383 26560 -104591 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 -1 -4 -7 16 159 188 -4383 -26560 104591 ]'>nomatch</a></td> <td style = "text-align: left;">[0 -1 -4 -7 16 159 188 -4383 -26560 104591 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 0 2 12 28 0 -114 476 3480 -12384 ]'>nomatch</a></td> <td style = "text-align: left;">[0 0 2 12 28 0 -114 476 3480 -12384 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 0 2 6 4 -20 6 434 8 -12456 ]'>nomatch</a></td> <td style = "text-align: left;">[0 0 2 6 4 -20 6 434 8 -12456 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 4 7 0 -19 68 435 -1376 -12455 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 4 7 0 -19 68 435 -1376 -12455 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6279
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Eulerian</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A173018'>A173018</a></td> <td style = "text-align: left;">[1 1 0 1 1 0 1 4 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A123125'>A123125</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 1 4 1 ]</td> </tr> <tr> <td style = "text-align: left;">InvRev</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 -1 1 0 3 -4 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 -1 1 0 3 -4 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 0 1 1 1 4 0 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 0 1 1 1 4 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A332700'>A332700</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 2 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A128103'>A128103</a></td> <td style = "text-align: left;">[1 1 1 2 12 68 360 2384 20160 185408 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A262745'>A262745</a></td> <td style = "text-align: left;">[0 0 1 4 12 52 360 2656 20160 177472 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A009006'>A009006</a></td> <td style = "text-align: left;">[1 1 0 -2 0 16 0 -272 0 7936 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000800'>A000800</a></td> <td style = "text-align: left;">[1 1 1 2 5 13 38 125 449 1742 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A006551'>A006551</a></td> <td style = "text-align: left;">[1 1 1 4 11 66 302 2416 15619 156190 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A180056'>A180056</a></td> <td style = "text-align: left;">[1 1 11 302 15619 1310354 162512286 27971176092 6382798925475 1865385657780650 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A000670'>A000670</a></td> <td style = "text-align: left;">[1 1 3 13 75 541 4683 47293 545835 7087261 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A087674'>A087674</a></td> <td style = "text-align: left;">[1 1 -1 -3 15 21 -441 477 19935 -101979 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A000670'>A000670</a></td> <td style = "text-align: left;">[1 1 3 13 75 541 4683 47293 545835 7087261 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A122704'>A122704</a></td> <td style = "text-align: left;">[1 1 4 22 160 1456 15904 202672 2951680 48361216 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A011818'>A011818</a></td> <td style = "text-align: left;">[1 1 3 16 115 1056 11774 154624 2337507 39984640 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 -1 8 19 -276 -1002 21216 103395 -2881180 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 -1 8 19 -276 -1002 21216 103395 -2881180 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 0 1 8 64 540 4920 48720 524160 6108480 ]'>nomatch</a></td> <td style = "text-align: left;">[0 0 1 8 64 540 4920 48720 524160 6108480 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A180119'>A180119</a></td> <td style = "text-align: left;">[0 0 1 6 36 240 1800 15120 141120 1451520 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A001710'>A001710</a></td> <td style = "text-align: left;">[1 1 3 12 60 360 2520 20160 181440 1814400 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6615
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">EulerianSO2</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A340556'>A340556</a></td> <td style = "text-align: left;">[1 0 1 0 1 2 0 1 8 6 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A163936'>A163936</a></td> <td style = "text-align: left;">[1 1 0 2 1 0 6 8 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 1 0 1 0 1 2 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 1 0 1 0 1 2 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 1 1 0 3 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 3 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001147'>A001147</a></td> <td style = "text-align: left;">[1 1 3 15 105 945 10395 135135 2027025 34459425 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 2 8 46 496 5234 66344 1021918 17237488 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 2 8 46 496 5234 66344 1021918 17237488 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 1 7 59 449 5161 68791 1005107 17221937 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 1 7 59 449 5161 68791 1005107 17221937 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001662'>A001662</a></td> <td style = "text-align: left;">[1 -1 1 1 -13 47 73 -2447 16811 15551 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 3 9 29 111 467 2137 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 3 9 29 111 467 2137 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 22 52 1452 5610 195800 1062500 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 22 52 1452 5610 195800 1062500 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 22 1452 195800 44765000 15548960784 7634832149392 5036317938475648 4297211671488276816 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 22 1452 195800 44765000 15548960784 7634832149392 5036317938475648 4297211671488276816 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A000311'>A000311</a></td> <td style = "text-align: left;">[1 1 4 26 236 2752 39208 660032 12818912 282137824 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A341106'>A341106</a></td> <td style = "text-align: left;">[1 1 0 -6 -12 144 1080 -5184 -127008 -95904 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A112487'>A112487</a></td> <td style = "text-align: left;">[1 2 10 82 938 13778 247210 5240338 128149802 3551246162 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 21 237 3711 74451 1822557 52680189 1755990327 66313036227 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 21 237 3711 74451 1822557 52680189 1755990327 66313036227 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 4 33 392 6145 119724 2789465 75660080 2341894185 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 4 33 392 6145 119724 2789465 75660080 2341894185 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 -15 -80 665 17136 55209 -4162752 -83069415 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 -15 -80 665 17136 55209 -4162752 -83069415 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 9 87 995 13265 202545 3489255 66981915 1418241825 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 9 87 995 13265 202545 3489255 66981915 1418241825 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A051577'>A051577</a></td> <td style = "text-align: left;">[0 1 5 35 315 3465 45045 675675 11486475 218243025 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 8 50 420 4410 55440 810810 13513500 252702450 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 8 50 420 4410 55440 810810 13513500 252702450 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6282
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">FallingFact</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A008279'>A008279</a></td> <td style = "text-align: left;">[1 1 1 1 2 2 1 3 6 6 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A094587'>A094587</a></td> <td style = "text-align: left;">[1 1 1 2 2 1 6 6 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">InvRev</td> <td style = "text-align: left;"><a href='https://oeis.org/A128229'>A128229</a></td> <td style = "text-align: left;">[1 -1 1 0 -2 1 0 0 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 1 2 1 3 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 1 2 1 3 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 1 1 5 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 5 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000522'>A000522</a></td> <td style = "text-align: left;">[1 2 5 16 65 326 1957 13700 109601 986410 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A087208'>A087208</a></td> <td style = "text-align: left;">[1 1 3 7 37 141 1111 5923 62217 426457 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A002747'>A002747</a></td> <td style = "text-align: left;">[0 1 2 9 28 185 846 7777 47384 559953 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000166'>A000166</a></td> <td style = "text-align: left;">[1 0 1 -2 9 -44 265 -1854 14833 -133496 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A122852'>A122852</a></td> <td style = "text-align: left;">[1 1 2 3 6 11 24 51 122 291 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A205825'>A205825</a></td> <td style = "text-align: left;">[1 1 2 3 12 20 120 210 1680 3024 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A001813'>A001813</a></td> <td style = "text-align: left;">[1 2 12 120 1680 30240 665280 17297280 518918400 17643225600 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A010842'>A010842</a></td> <td style = "text-align: left;">[1 3 10 38 168 872 5296 37200 297856 2681216 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A000023'>A000023</a></td> <td style = "text-align: left;">[1 -1 2 -2 8 8 112 656 5504 49024 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A010844'>A010844</a></td> <td style = "text-align: left;">[1 3 13 79 633 6331 75973 1063623 17017969 306323443 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A010845'>A010845</a></td> <td style = "text-align: left;">[1 4 25 226 2713 40696 732529 15383110 369194641 9968255308 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A002720'>A002720</a></td> <td style = "text-align: left;">[1 2 7 34 209 1546 13327 130922 1441729 17572114 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A009940'>A009940</a></td> <td style = "text-align: left;">[1 0 -1 -4 -15 -56 -185 -204 6209 112400 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 10 81 652 5545 50886 506905 5480056 64116657 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 10 81 652 5545 50886 506905 5480056 64116657 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A093964'>A093964</a></td> <td style = "text-align: left;">[0 1 6 33 196 1305 9786 82201 767208 7891281 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A001339'>A001339</a></td> <td style = "text-align: left;">[1 3 11 49 261 1631 11743 95901 876809 8877691 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6479
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Fibonacci</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A193737'>A193737</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 2 4 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A193736'>A193736</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 3 4 2 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 1 1 -2 1 -1 2 -3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 1 1 -2 1 -1 2 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -1 1 -2 1 1 -3 2 -1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -1 1 -2 1 1 -3 2 -1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A119473'>A119473</a></td> <td style = "text-align: left;">[1 1 1 1 2 2 3 4 1 5 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 1 2 4 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 2 4 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A052542'>A052542</a></td> <td style = "text-align: left;">[1 2 4 10 24 58 140 338 816 1970 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A215928'>A215928</a></td> <td style = "text-align: left;">[1 1 2 5 12 29 70 169 408 985 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000129'>A000129</a></td> <td style = "text-align: left;">[0 1 2 5 12 29 70 169 408 985 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A011782'>A011782</a></td> <td style = "text-align: left;">[1 1 2 4 8 16 32 64 128 256 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 4 8 19 36 91 170 446 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 4 8 19 36 91 170 446 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A330793'>A330793</a></td> <td style = "text-align: left;">[1 2 8 36 170 826 4088 20496 103752 529100 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A274163'>A274163</a></td> <td style = "text-align: left;">[1 1 1 2 3 5 8 13 21 34 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A330795'>A330795</a></td> <td style = "text-align: left;">[1 3 9 39 153 615 2457 9831 39321 157287 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A006131'>A006131</a></td> <td style = "text-align: left;">[1 -1 1 -5 9 -29 65 -181 441 -1165 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A052906'>A052906</a></td> <td style = "text-align: left;">[1 3 9 30 99 327 1080 3567 11781 38910 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 16 68 288 1220 5168 21892 92736 392836 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 16 68 288 1220 5168 21892 92736 392836 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 6 24 100 426 1848 8120 36018 160940 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 6 24 100 426 1848 8120 36018 160940 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -2 2 4 -14 0 58 -78 -162 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -2 2 4 -14 0 58 -78 -162 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 6 25 92 313 1010 3137 9464 27905 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 6 25 92 313 1010 3137 9464 27905 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A119915'>A119915</a></td> <td style = "text-align: left;">[0 1 4 13 40 117 332 921 2512 6761 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A331321'>A331321</a></td> <td style = "text-align: left;">[1 3 8 23 64 175 472 1259 3328 8731 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6681
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Fine</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A321622'>A321622</a></td> <td style = "text-align: left;">[1 1 1 0 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 1 0 1 1 1 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 1 0 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 1 1 -1 1 -1 0 -1 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 1 1 -1 1 -1 0 -1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -1 1 -1 1 1 -1 0 -1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -1 1 -1 1 1 -1 0 -1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 1 1 2 1 1 6 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 1 1 2 1 1 6 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 0 2 1 1 2 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 0 2 1 1 2 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A002420'>A002420</a></td> <td style = "text-align: left;">[1 2 2 4 10 28 84 264 858 2860 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A115140'>A115140</a></td> <td style = "text-align: left;">[1 1 1 2 5 14 42 132 429 1430 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000108'>A000108</a></td> <td style = "text-align: left;">[0 1 1 2 5 14 42 132 429 1430 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 2 4 11 31 96 306 1010 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 2 4 11 31 96 306 1010 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 7 10 29 40 136 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 7 10 29 40 136 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 10 40 181 812 3732 17280 80740 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 10 40 181 812 3732 17280 80740 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A064310'>A064310</a></td> <td style = "text-align: left;">[1 1 0 1 2 6 18 57 186 622 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 3 15 75 423 2547 16047 104475 697335 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 3 15 75 423 2547 16047 104475 697335 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 -1 -5 7 -77 399 -2661 17175 -115517 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 -1 -5 7 -77 399 -2661 17175 -115517 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 6 15 42 126 396 1287 4290 14586 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 6 15 42 126 396 1287 4290 14586 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A100320'>A100320</a></td> <td style = "text-align: left;">[1 4 12 40 140 504 1848 6864 25740 97240 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 3 8 35 162 756 3600 17451 85670 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 3 8 35 162 756 3600 17451 85670 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -1 0 -5 0 -28 0 -165 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -1 0 -5 0 -28 0 -165 0 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 5 14 37 106 322 1020 3333 11154 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 5 14 37 106 322 1020 3333 11154 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 3 6 15 42 126 396 1287 4290 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 3 6 15 42 126 396 1287 4290 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 5 10 25 70 210 660 2145 7150 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 5 10 25 70 210 660 2145 7150 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6144
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Fubini</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A131689'>A131689</a></td> <td style = "text-align: left;">[1 0 1 0 1 2 0 1 6 6 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 2 1 0 6 6 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 2 1 0 6 6 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 1 0 1 0 1 2 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 1 0 1 0 1 2 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 1 1 0 3 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 3 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000670'>A000670</a></td> <td style = "text-align: left;">[1 1 3 13 75 541 4683 47293 545835 7087261 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A052841'>A052841</a></td> <td style = "text-align: left;">[1 0 2 6 38 270 2342 23646 272918 3543630 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A089677'>A089677</a></td> <td style = "text-align: left;">[0 1 1 7 37 271 2341 23647 272917 3543631 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 -1 1 -1 1 -1 1 -1 1 -1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A105795'>A105795</a></td> <td style = "text-align: left;">[1 0 1 1 3 7 21 67 237 907 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 14 30 540 1806 40824 186480 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 14 30 540 1806 40824 186480 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A210029'>A210029</a></td> <td style = "text-align: left;">[1 1 14 540 40824 5103000 953029440 248619571200 86355926616960 38528927611574400 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A122704'>A122704</a></td> <td style = "text-align: left;">[1 1 4 22 160 1456 15904 202672 2951680 48361216 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A009006'>A009006</a></td> <td style = "text-align: left;">[1 1 0 -2 0 16 0 -272 0 7936 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A004123'>A004123</a></td> <td style = "text-align: left;">[1 2 10 74 730 9002 133210 2299754 45375130 1007179562 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A032033'>A032033</a></td> <td style = "text-align: left;">[1 3 21 219 3045 52923 1103781 26857659 746870565 23365498683 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A000312'>A000312</a></td> <td style = "text-align: left;">[1 1 4 27 256 3125 46656 823543 16777216 387420489 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 -9 -40 125 3444 18571 -241872 -5796711 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 -9 -40 125 3444 18571 -241872 -5796711 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A083411'>A083411</a></td> <td style = "text-align: left;">[0 1 9 79 765 8311 100989 1362439 20246445 328972471 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A069321'>A069321</a></td> <td style = "text-align: left;">[0 1 5 31 233 2071 21305 249271 3270713 47580151 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A005649'>A005649</a></td> <td style = "text-align: left;">[1 2 8 44 308 2612 25988 296564 3816548 54667412 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6497
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Hermite</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A066325'>A066325</a></td> <td style = "text-align: left;">[1 0 1 1 0 1 0 3 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A073278'>A073278</a></td> <td style = "text-align: left;">[1 1 0 1 0 1 1 0 3 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A066325'>A066325</a></td> <td style = "text-align: left;">[1 0 1 -1 0 1 0 -3 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A073278'>A073278</a></td> <td style = "text-align: left;">[1 1 0 1 0 -1 1 0 -3 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 0 0 3 3 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 0 0 3 3 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 1 1 0 2 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 1 1 0 2 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000085'>A000085</a></td> <td style = "text-align: left;">[1 1 2 4 10 26 76 232 764 2620 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 2 0 10 0 76 0 764 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 2 0 10 0 76 0 764 0 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 0 4 0 26 0 232 0 2620 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 0 4 0 26 0 232 0 2620 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000085'>A000085</a></td> <td style = "text-align: left;">[1 -1 2 -4 10 -26 76 -232 764 -2620 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 2 0 7 0 37 0 266 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 2 0 7 0 37 0 266 0 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 3 6 0 0 105 210 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 3 6 0 0 105 210 0 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 6 0 210 0 13860 0 1351350 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 6 0 210 0 13860 0 1351350 0 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A123023'>A123023</a></td> <td style = "text-align: left;">[1 0 1 0 3 0 15 0 105 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A115329'>A115329</a></td> <td style = "text-align: left;">[1 1 5 13 73 281 1741 8485 57233 328753 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A115329'>A115329</a></td> <td style = "text-align: left;">[1 1 5 13 73 281 1741 8485 57233 328753 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A005425'>A005425</a></td> <td style = "text-align: left;">[1 2 5 14 43 142 499 1850 7193 29186 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A202834'>A202834</a></td> <td style = "text-align: left;">[1 3 10 36 138 558 2364 10440 47868 227124 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 10 40 176 916 4852 27350 163270 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 10 40 176 916 4852 27350 163270 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 10 40 176 916 4852 27350 163270 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 10 40 176 916 4852 27350 163270 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 4 12 40 130 456 1624 6112 23580 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 4 12 40 130 456 1624 6112 23580 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A013989'>A013989</a></td> <td style = "text-align: left;">[0 1 2 6 16 50 156 532 1856 6876 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A000085'>A000085</a></td> <td style = "text-align: left;">[1 2 4 10 26 76 232 764 2620 9496 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6550
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Laguerre</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A021009'>A021009</a></td> <td style = "text-align: left;">[1 1 1 2 4 1 6 18 9 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A021010'>A021010</a></td> <td style = "text-align: left;">[1 1 1 1 4 2 1 9 18 6 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A021009'>A021009</a></td> <td style = "text-align: left;">[1 -1 1 2 -4 1 -6 18 -9 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A021010'>A021010</a></td> <td style = "text-align: left;">[1 1 -1 1 -4 2 1 -9 18 -6 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A084950'>A084950</a></td> <td style = "text-align: left;">[1 1 2 1 6 4 24 18 1 120 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 2 2 1 6 7 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 2 2 1 6 7 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A002720'>A002720</a></td> <td style = "text-align: left;">[1 2 7 34 209 1546 13327 130922 1441729 17572114 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A331325'>A331325</a></td> <td style = "text-align: left;">[1 1 3 15 97 745 6571 65359 723969 8842257 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A331326'>A331326</a></td> <td style = "text-align: left;">[0 1 4 19 112 801 6756 65563 717760 8729857 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A009940'>A009940</a></td> <td style = "text-align: left;">[1 0 -1 -4 -15 -56 -185 -204 6209 112400 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001040'>A001040</a></td> <td style = "text-align: left;">[1 1 3 10 43 225 1393 9976 81201 740785 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A343580'>A343580</a></td> <td style = "text-align: left;">[1 1 4 18 72 600 2400 29400 117600 1905120 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A295383'>A295383</a></td> <td style = "text-align: left;">[1 4 72 2400 117600 7620480 614718720 59364264960 6678479808000 857813628672000 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A025167'>A025167</a></td> <td style = "text-align: left;">[1 3 17 139 1473 19091 291793 5129307 101817089 2250495523 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A025166'>A025166</a></td> <td style = "text-align: left;">[1 -1 1 7 -127 1711 -23231 334391 -5144063 84149983 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A087912'>A087912</a></td> <td style = "text-align: left;">[1 3 14 86 648 5752 58576 671568 8546432 119401856 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A277382'>A277382</a></td> <td style = "text-align: left;">[1 4 23 168 1473 14988 173007 2228544 31636449 490102164 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A216831'>A216831</a></td> <td style = "text-align: left;">[1 2 11 88 905 11246 162607 2668436 48830273 983353690 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A343840'>A343840</a></td> <td style = "text-align: left;">[1 0 -5 22 9 -1244 14335 -79470 -586943 25131304 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A105219'>A105219</a></td> <td style = "text-align: left;">[0 1 8 63 544 5225 55656 653023 8379008 116780049 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A103194'>A103194</a></td> <td style = "text-align: left;">[0 1 6 39 292 2505 24306 263431 3154824 41368977 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A000262'>A000262</a></td> <td style = "text-align: left;">[1 3 13 73 501 4051 37633 394353 4596553 58941091 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6610
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Lah</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A111596'>A111596</a></td> <td style = "text-align: left;">[1 0 1 0 2 1 0 6 6 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 2 0 1 6 6 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 2 0 1 6 6 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A111596'>A111596</a></td> <td style = "text-align: left;">[1 0 1 0 -2 1 0 6 -6 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 -2 0 1 -6 6 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 -2 0 1 -6 6 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A330609'>A330609</a></td> <td style = "text-align: left;">[1 0 0 1 0 2 0 6 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A253286'>A253286</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 3 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000262'>A000262</a></td> <td style = "text-align: left;">[1 1 3 13 73 501 4051 37633 394353 4596553 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A088312'>A088312</a></td> <td style = "text-align: left;">[1 0 1 6 37 260 2101 19362 201097 2326536 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A088313'>A088313</a></td> <td style = "text-align: left;">[0 1 2 7 36 241 1950 18271 193256 2270017 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A111884'>A111884</a></td> <td style = "text-align: left;">[1 -1 -1 -1 1 19 151 1091 7841 56519 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001053'>A001053</a></td> <td style = "text-align: left;">[1 0 1 2 7 30 157 972 6961 56660 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 2 6 36 240 1200 12600 58800 846720 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 2 6 36 240 1200 12600 58800 846720 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A187535'>A187535</a></td> <td style = "text-align: left;">[1 2 36 1200 58800 3810240 307359360 29682132480 3339239904000 428906814336000 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A025168'>A025168</a></td> <td style = "text-align: left;">[1 1 5 37 361 4361 62701 1044205 19748177 417787921 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A318223'>A318223</a></td> <td style = "text-align: left;">[1 1 -3 13 -71 441 -2699 9157 206193 -8443151 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A052897'>A052897</a></td> <td style = "text-align: left;">[1 2 8 44 304 2512 24064 261536 3173888 42483968 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A255806'>A255806</a></td> <td style = "text-align: left;">[1 3 15 99 801 7623 83079 1017495 13808097 205374123 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 5 37 361 4301 60001 954325 16984577 333572041 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 5 37 361 4301 60001 954325 16984577 333572041 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -3 1 73 -699 3001 24697 -783999 10946233 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -3 1 73 -699 3001 24697 -783999 10946233 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A103194'>A103194</a></td> <td style = "text-align: left;">[0 1 6 39 292 2505 24306 263431 3154824 41368977 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A052852'>A052852</a></td> <td style = "text-align: left;">[0 1 4 21 136 1045 9276 93289 1047376 12975561 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A002720'>A002720</a></td> <td style = "text-align: left;">[1 2 7 34 209 1546 13327 130922 1441729 17572114 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6481
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Motzkin</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A064189'>A064189</a></td> <td style = "text-align: left;">[1 1 1 2 2 1 4 5 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A026300'>A026300</a></td> <td style = "text-align: left;">[1 1 1 1 2 2 1 3 5 4 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A101950'>A101950</a></td> <td style = "text-align: left;">[1 -1 1 0 -2 1 1 1 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -1 1 -2 0 1 -3 1 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -1 1 -2 0 1 -3 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A106489'>A106489</a></td> <td style = "text-align: left;">[1 1 2 1 4 2 9 5 1 21 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A330792'>A330792</a></td> <td style = "text-align: left;">[1 1 1 2 2 1 4 5 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A005773'>A005773</a></td> <td style = "text-align: left;">[1 2 5 13 35 96 267 750 2123 6046 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A002426'>A002426</a></td> <td style = "text-align: left;">[1 1 3 7 19 51 141 393 1107 3139 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A005717'>A005717</a></td> <td style = "text-align: left;">[0 1 2 6 16 45 126 357 1016 2907 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A005043'>A005043</a></td> <td style = "text-align: left;">[1 0 1 1 3 6 15 36 91 232 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A342912'>A342912</a></td> <td style = "text-align: left;">[1 1 3 6 15 36 91 232 603 1585 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 5 9 25 44 133 230 726 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 5 9 25 44 133 230 726 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A026302'>A026302</a></td> <td style = "text-align: left;">[1 2 9 44 230 1242 6853 38376 217242 1239980 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A001006'>A001006</a></td> <td style = "text-align: left;">[1 1 2 4 9 21 51 127 323 835 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A330799'>A330799</a></td> <td style = "text-align: left;">[1 3 13 59 285 1419 7245 37659 198589 1059371 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A330800'>A330800</a></td> <td style = "text-align: left;">[1 -1 5 -17 77 -345 1653 -8097 40733 -208553 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A059738'>A059738</a></td> <td style = "text-align: left;">[1 3 10 34 117 405 1407 4899 17083 59629 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 17 73 315 1362 5895 25528 110579 479068 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 17 73 315 1362 5895 25528 110579 479068 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 7 29 128 587 2759 13190 63844 311948 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 7 29 128 587 2759 13190 63844 311948 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -1 3 0 -5 15 0 -28 84 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -1 3 0 -5 15 0 -28 84 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 6 26 100 361 1254 4245 14108 46247 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 6 26 100 361 1254 4245 14108 46247 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A330796'>A330796</a></td> <td style = "text-align: left;">[0 1 4 14 46 147 462 1437 4438 13637 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A000244'>A000244</a></td> <td style = "text-align: left;">[1 3 9 27 81 243 729 2187 6561 19683 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6457
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Narayana</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A090181'>A090181</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 1 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A131198'>A131198</a></td> <td style = "text-align: left;">[1 1 0 1 1 0 1 3 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 -1 1 0 2 -3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 -1 1 0 2 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 -1 0 1 -3 2 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 -1 0 1 -3 2 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 1 0 1 0 1 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 1 0 1 0 1 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 1 1 0 2 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 2 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000108'>A000108</a></td> <td style = "text-align: left;">[1 1 2 5 14 42 132 429 1430 4862 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A071688'>A071688</a></td> <td style = "text-align: left;">[1 0 1 3 7 20 66 217 715 2424 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A071684'>A071684</a></td> <td style = "text-align: left;">[0 1 1 2 7 22 66 212 715 2438 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A090192'>A090192</a></td> <td style = "text-align: left;">[1 -1 0 1 0 -2 0 5 0 -14 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 2 4 8 17 37 82 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 2 4 8 17 37 82 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 6 10 50 105 490 1176 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 6 10 50 105 490 1176 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A125558'>A125558</a></td> <td style = "text-align: left;">[1 1 6 50 490 5292 60984 736164 9202050 118195220 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A001003'>A001003</a></td> <td style = "text-align: left;">[1 1 3 11 45 197 903 4279 20793 103049 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A154825'>A154825</a></td> <td style = "text-align: left;">[1 1 -1 -1 5 -3 -21 51 41 -391 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A006318'>A006318</a></td> <td style = "text-align: left;">[1 2 6 22 90 394 1806 8558 41586 206098 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A047891'>A047891</a></td> <td style = "text-align: left;">[1 3 12 57 300 1686 9912 60213 374988 2381322 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 3 13 65 356 2072 12601 79221 511174 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 3 13 65 356 2072 12601 79221 511174 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -1 -5 9 56 -120 -825 1925 14014 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -1 -5 9 56 -120 -825 1925 14014 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A141222'>A141222</a></td> <td style = "text-align: left;">[0 1 5 22 95 406 1722 7260 30459 127270 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A001700'>A001700</a></td> <td style = "text-align: left;">[0 1 3 10 35 126 462 1716 6435 24310 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A189176'>A189176</a></td> <td style = "text-align: left;">[1 2 5 15 49 168 594 2145 7865 29172 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6642
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Rencontres</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A008290'>A008290</a></td> <td style = "text-align: left;">[1 0 1 1 0 1 2 3 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A098825'>A098825</a></td> <td style = "text-align: left;">[1 1 0 1 0 1 1 0 3 2 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A055137'>A055137</a></td> <td style = "text-align: left;">[1 0 1 -1 0 1 -2 -3 0 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 0 -1 1 0 -3 -2 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 0 -1 1 0 -3 -2 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 2 0 9 3 1 44 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 2 0 9 3 1 44 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 1 1 2 2 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 1 1 2 2 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A062282'>A062282</a></td> <td style = "text-align: left;">[1 0 2 2 16 64 416 2848 22912 205952 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A063083'>A063083</a></td> <td style = "text-align: left;">[0 1 0 4 8 56 304 2192 17408 156928 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000023'>A000023</a></td> <td style = "text-align: left;">[1 -1 2 -2 8 8 112 656 5504 49024 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 2 2 13 52 317 2138 16834 149292 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 2 2 13 52 317 2138 16834 149292 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 3 6 20 40 315 630 5544 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 3 6 20 40 315 630 5544 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A281262'>A281262</a></td> <td style = "text-align: left;">[1 0 6 40 630 11088 244860 6362928 190900710 6490575520 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000166'>A000166</a></td> <td style = "text-align: left;">[1 0 1 2 9 44 265 1854 14833 133496 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A000354'>A000354</a></td> <td style = "text-align: left;">[1 1 5 29 233 2329 27949 391285 6260561 112690097 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 5 -3 105 -807 10413 -143595 2304081 -41453775 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 5 -3 105 -807 10413 -143595 2304081 -41453775 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A000522'>A000522</a></td> <td style = "text-align: left;">[1 2 5 16 65 326 1957 13700 109601 986410 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A010842'>A010842</a></td> <td style = "text-align: left;">[1 3 10 38 168 872 5296 37200 297856 2681216 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 12 78 570 4900 48160 530390 6464430 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 12 78 570 4900 48160 530390 6464430 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 8 14 82 132 744 4566 -33442 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 8 14 82 132 744 4566 -33442 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 4 12 48 240 1440 10080 80640 725760 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 4 12 48 240 1440 10080 80640 725760 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[0 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A098558'>A098558</a></td> <td style = "text-align: left;">[1 2 4 12 48 240 1440 10080 80640 725760 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
7263
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">RisingFact</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A124320'>A124320</a></td> <td style = "text-align: left;">[1 1 1 1 2 6 1 3 12 60 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 6 2 1 60 12 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 6 2 1 60 12 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">InvRev</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 1 -4 -2 1 -36 -6 -3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 1 -4 -2 1 -36 -6 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 1 2 1 3 6 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 1 2 1 3 6 1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 1 1 9 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 9 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A123680'>A123680</a></td> <td style = "text-align: left;">[1 2 9 76 985 17046 366289 9374968 278095761 9375293170 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 7 13 861 1711 335707 670377 260702713 521092531 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 7 13 861 1711 335707 670377 260702713 521092531 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 2 63 124 15335 30582 8704591 17393048 8854200639 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 2 63 124 15335 30582 8704591 17393048 8854200639 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 5 -50 737 -13624 305125 -8034214 243309665 -8333108108 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 5 -50 737 -13624 305125 -8034214 243309665 -8333108108 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 3 10 17 86 157 1100 2081 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 3 10 17 86 157 1100 2081 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 3 20 30 336 504 7920 11880 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 3 20 30 336 504 7920 11880 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 20 336 7920 240240 8910720 390700800 19769460480 1133836704000 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 20 336 7920 240240 8910720 390700800 19769460480 1133836704000 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000407'>A000407</a></td> <td style = "text-align: left;">[1 1 6 60 840 15120 332640 8648640 259459200 8821612800 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 14 104 1208 19672 408832 10251712 299911808 10009405376 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 14 104 1208 19672 408832 10251712 299911808 10009405376 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 6 40 664 12408 282112 7506112 229153920 7898352832 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 6 40 664 12408 282112 7506112 229153920 7898352832 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 29 535 14489 512531 22307893 1151462831 68717854385 4653803729899 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 29 535 14489 512531 22307893 1151462831 68717854385 4653803729899 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 61 1738 71473 3816196 250097293 19413459094 1741065412993 177112972757008 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 61 1738 71473 3816196 250097293 19413459094 1741065412993 177112972757008 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A278070'>A278070</a></td> <td style = "text-align: left;">[1 2 11 106 1457 25946 566827 14665106 438351041 14862109042 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A278069'>A278069</a></td> <td style = "text-align: left;">[1 0 3 32 465 8544 190435 4996032 150869313 5155334720 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 26 591 14604 406895 12782622 449204847 17499943736 749432500119 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 26 591 14604 406895 12782622 449204847 17499943736 749432500119 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 14 207 3764 83015 2160234 64831151 2204676872 83786685039 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 14 207 3764 83015 2160234 64831151 2204676872 83786685039 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 23 283 4749 100061 2526523 74206119 2482772633 93161978209 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 23 283 4749 100061 2526523 74206119 2482772633 93161978209 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6553
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">SchroederB</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A122538'>A122538</a></td> <td style = "text-align: left;">[1 0 1 0 2 1 0 6 4 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 0 1 2 0 1 4 6 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 0 1 2 0 1 4 6 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A122542'>A122542</a></td> <td style = "text-align: left;">[1 0 1 0 -2 1 0 2 -4 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A266213'>A266213</a></td> <td style = "text-align: left;">[1 1 0 1 -2 0 1 -4 2 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 1 0 2 0 6 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 1 0 2 0 6 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 1 1 0 3 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 3 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001003'>A001003</a></td> <td style = "text-align: left;">[1 1 3 11 45 197 903 4279 20793 103049 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 4 17 76 353 1688 8257 41128 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 4 17 76 353 1688 8257 41128 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A010683'>A010683</a></td> <td style = "text-align: left;">[0 1 2 7 28 121 550 2591 12536 61921 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001003'>A001003</a></td> <td style = "text-align: left;">[1 -1 -1 -3 -11 -45 -197 -903 -4279 -20793 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 2 7 26 107 468 2141 10124 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 2 7 26 107 468 2141 10124 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 2 6 16 68 146 714 1408 7432 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 2 6 16 68 146 714 1408 7432 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A103885'>A103885</a></td> <td style = "text-align: left;">[1 2 16 146 1408 14002 142000 1459810 15158272 158611106 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A330802'>A330802</a></td> <td style = "text-align: left;">[1 1 5 33 253 2121 18853 174609 1667021 16290969 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A330803'>A330803</a></td> <td style = "text-align: left;">[1 1 -3 17 -123 1001 -8739 79969 -756939 7349657 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A109980'>A109980</a></td> <td style = "text-align: left;">[1 2 8 36 172 852 4324 22332 116876 618084 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 15 81 453 2583 14907 86733 507561 2982987 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 15 81 453 2583 14907 86733 507561 2982987 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A178792'>A178792</a></td> <td style = "text-align: left;">[1 1 5 31 209 1471 10625 78079 580865 4361215 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A255047'>A255047</a></td> <td style = "text-align: left;">[1 1 -3 7 -15 31 -63 127 -255 511 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A065096'>A065096</a></td> <td style = "text-align: left;">[0 1 6 31 156 785 3978 20335 104856 545073 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A239204'>A239204</a></td> <td style = "text-align: left;">[0 1 4 17 76 353 1688 8257 41128 207905 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A010683'>A010683</a></td> <td style = "text-align: left;">[1 2 7 28 121 550 2591 12536 61921 310954 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6967
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">SchroederL</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A172094'>A172094</a></td> <td style = "text-align: left;">[1 1 1 3 4 1 11 17 7 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 4 3 1 7 17 11 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 4 3 1 7 17 11 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A331969'>A331969</a></td> <td style = "text-align: left;">[1 -1 1 1 -4 1 -1 11 -7 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -1 1 -4 1 1 -7 11 -1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -1 1 -4 1 1 -7 11 -1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 3 1 11 4 45 17 1 197 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 3 1 11 4 45 17 1 197 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 3 2 1 11 8 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 3 2 1 11 8 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A109980'>A109980</a></td> <td style = "text-align: left;">[1 2 8 36 172 852 4324 22332 116876 618084 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A225887'>A225887</a></td> <td style = "text-align: left;">[1 1 4 18 86 426 2162 11166 58438 309042 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A225887'>A225887</a></td> <td style = "text-align: left;">[0 1 4 18 86 426 2162 11166 58438 309042 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 4 15 63 280 1297 6193 30268 150687 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 4 15 63 280 1297 6193 30268 150687 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 4 17 40 216 458 2745 5558 35318 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 4 17 40 216 458 2745 5558 35318 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 40 458 5558 69660 891154 11563214 151605142 2003523032 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 40 458 5558 69660 891154 11563214 151605142 2003523032 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A001003'>A001003</a></td> <td style = "text-align: left;">[1 1 3 11 45 197 903 4279 20793 103049 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A331328'>A331328</a></td> <td style = "text-align: left;">[1 3 21 171 1509 13995 134277 1320651 13237221 134682219 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A330802'>A330802</a></td> <td style = "text-align: left;">[1 -1 5 -33 253 -2121 18853 -174609 1667021 -16290969 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 15 81 453 2583 14907 86733 507561 2982987 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 15 81 453 2583 14907 86733 507561 2982987 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 24 152 984 6440 42408 280312 1857336 12326792 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 24 152 984 6440 42408 280312 1857336 12326792 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 12 84 630 4908 39158 317544 2605590 21571500 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 12 84 630 4908 39158 317544 2605590 21571500 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -4 20 -58 64 390 -2948 10934 -20320 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -4 20 -58 64 390 -2948 10934 -20320 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 8 54 342 2098 12634 75190 443934 2606330 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 8 54 342 2098 12634 75190 443934 2606330 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 6 34 190 1058 5890 32822 183158 1023658 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 6 34 190 1058 5890 32822 183158 1023658 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 14 70 362 1910 10214 55154 300034 1641742 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 14 70 362 1910 10214 55154 300034 1641742 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6462
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">StirlingCycle</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A048994'>A048994</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 2 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A054654'>A054654</a></td> <td style = "text-align: left;">[1 1 0 1 1 0 1 3 2 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A048993'>A048993</a></td> <td style = "text-align: left;">[1 0 1 0 -1 1 0 1 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A106800'>A106800</a></td> <td style = "text-align: left;">[1 1 0 1 -1 0 1 -3 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A331327'>A331327</a></td> <td style = "text-align: left;">[1 0 0 1 0 1 0 2 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 0 1 1 0 2 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 2 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A105752'>A105752</a></td> <td style = "text-align: left;">[1 0 1 3 12 60 360 2520 20160 181440 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001710'>A001710</a></td> <td style = "text-align: left;">[0 1 1 3 12 60 360 2520 20160 181440 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A014028'>A014028</a></td> <td style = "text-align: left;">[1 -1 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 3 9 36 176 1030 7039 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 3 9 36 176 1030 7039 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A154415'>A154415</a></td> <td style = "text-align: left;">[1 0 1 2 11 50 225 1624 6769 67284 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A187646'>A187646</a></td> <td style = "text-align: left;">[1 1 11 225 6769 269325 13339535 790943153 54631129553 4308105301929 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A001147'>A001147</a></td> <td style = "text-align: left;">[1 1 3 15 105 945 10395 135135 2027025 34459425 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A330797'>A330797</a></td> <td style = "text-align: left;">[1 1 -1 3 -15 105 -945 10395 -135135 2027025 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 2 6 24 120 720 5040 40320 362880 3628800 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 12 60 360 2520 20160 181440 1814400 19958400 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 12 60 360 2520 20160 181440 1814400 19958400 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A211210'>A211210</a></td> <td style = "text-align: left;">[1 1 3 16 115 1021 10696 128472 1734447 25937683 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A317274'>A317274</a></td> <td style = "text-align: left;">[1 1 -1 -2 19 -79 76 2640 -36945 329371 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A151881'>A151881</a></td> <td style = "text-align: left;">[0 1 5 23 120 724 5012 39332 345832 3371976 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A000254'>A000254</a></td> <td style = "text-align: left;">[0 1 3 11 50 274 1764 13068 109584 1026576 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A000774'>A000774</a></td> <td style = "text-align: left;">[1 2 5 17 74 394 2484 18108 149904 1389456 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6388
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">StirlingSet</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A048993'>A048993</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 1 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A106800'>A106800</a></td> <td style = "text-align: left;">[1 1 0 1 1 0 1 3 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A048994'>A048994</a></td> <td style = "text-align: left;">[1 0 1 0 -1 1 0 2 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A054654'>A054654</a></td> <td style = "text-align: left;">[1 1 0 1 -1 0 1 -3 2 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 1 0 1 0 1 1 0 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 1 0 1 0 1 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A189233'>A189233</a></td> <td style = "text-align: left;">[1 0 1 0 1 1 0 2 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000110'>A000110</a></td> <td style = "text-align: left;">[1 1 2 5 15 52 203 877 4140 21147 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A024430'>A024430</a></td> <td style = "text-align: left;">[1 0 1 3 8 25 97 434 2095 10707 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A024429'>A024429</a></td> <td style = "text-align: left;">[0 1 1 2 7 27 106 443 2045 10440 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000587'>A000587</a></td> <td style = "text-align: left;">[1 -1 0 1 1 -2 -9 -9 50 267 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A171367'>A171367</a></td> <td style = "text-align: left;">[1 0 1 1 2 4 9 22 58 164 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 1 1 7 15 90 301 1701 7770 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 1 1 7 15 90 301 1701 7770 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A007820'>A007820</a></td> <td style = "text-align: left;">[1 1 7 90 1701 42525 1323652 49329280 2141764053 106175395755 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A004211'>A004211</a></td> <td style = "text-align: left;">[1 1 3 11 49 257 1539 10299 75905 609441 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A009235'>A009235</a></td> <td style = "text-align: left;">[1 1 -1 -1 9 -23 -25 583 -3087 4401 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A001861'>A001861</a></td> <td style = "text-align: left;">[1 2 6 22 94 454 2430 14214 89918 610182 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A027710'>A027710</a></td> <td style = "text-align: left;">[1 3 12 57 309 1866 12351 88563 681870 5597643 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A122455'>A122455</a></td> <td style = "text-align: left;">[1 1 3 13 71 456 3337 27203 243203 2357356 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 -1 -5 15 56 -455 -237 16947 -64220 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 -1 -5 15 56 -455 -237 16947 -64220 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A033452'>A033452</a></td> <td style = "text-align: left;">[0 1 5 22 99 471 2386 12867 73681 446620 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A005493'>A005493</a></td> <td style = "text-align: left;">[0 1 3 10 37 151 674 3263 17007 94828 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A000110'>A000110</a></td> <td style = "text-align: left;">[1 2 5 15 52 203 877 4140 21147 115975 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6974
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">TTree</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A109956'>A109956</a></td> <td style = "text-align: left;">[1 1 1 3 4 1 12 18 7 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 4 3 1 7 18 12 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 4 3 1 7 18 12 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A109955'>A109955</a></td> <td style = "text-align: left;">[1 -1 1 1 -4 1 -1 10 -7 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A193636'>A193636</a></td> <td style = "text-align: left;">[1 1 -1 1 -4 1 1 -7 10 -1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 3 1 12 4 55 18 1 273 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 3 1 12 4 55 18 1 273 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 3 2 1 12 8 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 3 2 1 12 8 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A047098'>A047098</a></td> <td style = "text-align: left;">[1 2 8 38 196 1062 5948 34120 199316 1181126 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A047099'>A047099</a></td> <td style = "text-align: left;">[1 1 4 19 98 531 2974 17060 99658 590563 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A047099'>A047099</a></td> <td style = "text-align: left;">[0 1 4 19 98 531 2974 17060 99658 590563 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A109957'>A109957</a></td> <td style = "text-align: left;">[1 1 4 16 74 368 1926 10455 58333 332489 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 4 18 42 245 510 3325 6578 45630 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 4 18 42 245 510 3325 6578 45630 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 42 510 6578 87696 1193808 16486756 230090850 3237004680 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 42 510 6578 87696 1193808 16486756 230090850 3237004680 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A001764'>A001764</a></td> <td style = "text-align: left;">[1 1 3 12 55 273 1428 7752 43263 246675 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 21 183 1773 18303 197157 2189799 24891741 288132303 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 21 183 1773 18303 197157 2189799 24891741 288132303 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 5 -37 325 -3141 32261 -345605 3818501 -43197445 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 5 -37 325 -3141 32261 -345605 3818501 -43197445 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A005809'>A005809</a></td> <td style = "text-align: left;">[1 3 15 84 495 3003 18564 116280 735471 4686825 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 24 156 1048 7164 49488 344208 2405496 16868604 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 24 156 1048 7164 49488 344208 2405496 16868604 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 2 12 88 700 5814 49588 430560 3786588 33622600 ]'>nomatch</a></td> <td style = "text-align: left;">[1 2 12 88 700 5814 49588 430560 3786588 33622600 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -4 22 -84 238 -380 -828 10556 -56144 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -4 22 -84 238 -380 -828 10556 -56144 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 8 55 362 2343 15058 96500 617930 3957847 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 8 55 362 2343 15058 96500 617930 3957847 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 6 35 206 1227 7388 44900 275046 1696331 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 6 35 206 1227 7388 44900 275046 1696331 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 14 73 402 2289 13336 79020 474362 2877457 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 14 73 402 2289 13336 79020 474362 2877457 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6522
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Trinomial</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A111808'>A111808</a></td> <td style = "text-align: left;">[1 1 1 1 2 3 1 3 6 7 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A094531'>A094531</a></td> <td style = "text-align: left;">[1 1 1 3 2 1 7 6 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">InvRev</td> <td style = "text-align: left;"><a href='https://oeis.org/A102587'>A102587</a></td> <td style = "text-align: left;">[1 -1 1 -1 -2 1 2 0 -3 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 1 2 1 3 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 1 2 1 3 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 1 1 6 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 6 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A027914'>A027914</a></td> <td style = "text-align: left;">[1 2 6 17 50 147 435 1290 3834 11411 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 4 7 30 61 253 547 2194 4921 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 4 7 30 61 253 547 2194 4921 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 2 10 20 86 182 743 1640 6490 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 2 10 20 86 182 743 1640 6490 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A246437'>A246437</a></td> <td style = "text-align: left;">[1 0 2 -3 10 -25 71 -196 554 -1569 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 2 3 7 11 23 38 78 132 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 2 3 7 11 23 38 78 132 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A027913'>A027913</a></td> <td style = "text-align: left;">[1 1 2 3 10 15 50 77 266 414 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A027908'>A027908</a></td> <td style = "text-align: left;">[1 2 10 50 266 1452 8074 45474 258570 1481108 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A002426'>A002426</a></td> <td style = "text-align: left;">[1 1 3 7 19 51 141 393 1107 3139 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 11 39 139 493 1745 6163 21731 76521 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 11 39 139 493 1745 6163 21731 76521 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 -1 3 -1 11 9 57 111 387 989 ]'>nomatch</a></td> <td style = "text-align: left;">[1 -1 3 -1 11 9 57 111 387 989 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 17 87 481 2663 14993 84983 485057 2782023 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 17 87 481 2663 14993 84983 485057 2782023 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 4 34 253 2074 16999 142255 1199776 10203946 87281983 ]'>nomatch</a></td> <td style = "text-align: left;">[1 4 34 253 2074 16999 142255 1199776 10203946 87281983 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A082759'>A082759</a></td> <td style = "text-align: left;">[1 2 8 35 160 752 3599 17446 85376 420884 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 0 -3 0 0 15 0 0 -84 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 0 -3 0 0 15 0 0 -84 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 14 90 492 2330 10206 42147 166872 639414 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 14 90 492 2330 10206 42147 166872 639414 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 8 36 148 560 2034 7161 24672 83592 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 8 36 148 560 2034 7161 24672 83592 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 3 14 53 198 707 2469 8451 28506 95003 ]'>nomatch</a></td> <td style = "text-align: left;">[1 3 14 53 198 707 2469 8451 28506 95003 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6349
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Uni</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">Inverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A097806'>A097806</a></td> <td style = "text-align: left;">[1 -1 1 0 -1 1 0 0 -1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RevInv</td> <td style = "text-align: left;"><a href='https://oeis.org/A103451'>A103451</a></td> <td style = "text-align: left;">[1 1 -1 1 -1 0 1 -1 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">InvRev</td> <td style = "text-align: left;"><a href='https://oeis.org/A097806'>A097806</a></td> <td style = "text-align: left;">[1 -1 1 0 -1 1 0 0 -1 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/A104878'>A104878</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 3 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000027'>A000027</a></td> <td style = "text-align: left;">[1 2 3 4 5 6 7 8 9 10 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A008619'>A008619</a></td> <td style = "text-align: left;">[1 1 2 2 3 3 4 4 5 5 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A001057'>A001057</a></td> <td style = "text-align: left;">[0 1 1 2 2 3 3 4 4 5 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A014581'>A014581</a></td> <td style = "text-align: left;">[1 0 1 0 1 0 1 0 1 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A008619'>A008619</a></td> <td style = "text-align: left;">[1 1 2 2 3 3 4 4 5 5 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 1 1 1 1 1 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A126646'>A126646</a></td> <td style = "text-align: left;">[1 3 7 15 31 63 127 255 511 1023 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A077925'>A077925</a></td> <td style = "text-align: left;">[1 -1 3 -5 11 -21 43 -85 171 -341 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A126646'>A126646</a></td> <td style = "text-align: left;">[1 3 7 15 31 63 127 255 511 1023 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A003462'>A003462</a></td> <td style = "text-align: left;">[1 4 13 40 121 364 1093 3280 9841 29524 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A000079'>A000079</a></td> <td style = "text-align: left;">[1 2 4 8 16 32 64 128 256 512 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/A000330'>A000330</a></td> <td style = "text-align: left;">[0 1 5 14 30 55 91 140 204 285 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/A000217'>A000217</a></td> <td style = "text-align: left;">[0 1 3 6 10 15 21 28 36 45 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A025747'>A025747</a></td> <td style = "text-align: left;">[1 3 6 10 15 21 28 36 45 55 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
6492
```@raw html <style> table, td, th {border-collapse: collapse; font-family: sans-serif; color: blue;} td, th {border-bottom: 0; padding: 4px} tr:nth-child(odd) {background: #eee;} tr:nth-child(even) {background: #fff;} tr.header {background: orange !important; color: white; font-weight: bold;} tr.subheader {background: lightgray !important; color: black;} tr.headerLastRow {border-bottom: 2px solid black;} th.rowNumber, td.rowNumber {text-align: right;} </style><body> <table> <tr class = "header headerLastRow"> <th style = "text-align: left;">Trait</th> <th style = "text-align: left;">ANumber</th> <th style = "text-align: left;">Sequence</th> </tr> <tr> <td style = "text-align: left;">Worpitzky</td> <td style = "text-align: left;"></td> <td style = "text-align: left;"></td> </tr> <tr> <td style = "text-align: left;">Triangle</td> <td style = "text-align: left;"><a href='https://oeis.org/A028246'>A028246</a></td> <td style = "text-align: left;">[1 1 1 1 3 2 1 7 12 6 ]</td> </tr> <tr> <td style = "text-align: left;">Reverse</td> <td style = "text-align: left;"><a href='https://oeis.org/A075263'>A075263</a></td> <td style = "text-align: left;">[1 1 1 2 3 1 6 12 7 1 ]</td> </tr> <tr> <td style = "text-align: left;">InvRev</td> <td style = "text-align: left;"><a href='https://oeis.org/A106340'>A106340</a></td> <td style = "text-align: left;">[1 -1 1 1 -3 1 -1 9 -7 1 ]</td> </tr> <tr> <td style = "text-align: left;">DiagTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 1 3 1 7 2 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 1 3 1 7 2 1 ]</td> </tr> <tr> <td style = "text-align: left;">PolyTri</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 1 1 2 1 1 6 3 1 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 1 1 2 1 1 6 3 1 ]</td> </tr> <tr> <td style = "text-align: left;">Sum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000629'>A000629</a></td> <td style = "text-align: left;">[1 2 6 26 150 1082 9366 94586 1091670 14174522 ]</td> </tr> <tr> <td style = "text-align: left;">EvenSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000670'>A000670</a></td> <td style = "text-align: left;">[1 1 3 13 75 541 4683 47293 545835 7087261 ]</td> </tr> <tr> <td style = "text-align: left;">OddSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000670'>A000670</a></td> <td style = "text-align: left;">[0 1 3 13 75 541 4683 47293 545835 7087261 ]</td> </tr> <tr> <td style = "text-align: left;">AltSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A000007'>A000007</a></td> <td style = "text-align: left;">[1 0 0 0 0 0 0 0 0 0 ]</td> </tr> <tr> <td style = "text-align: left;">DiagSum</td> <td style = "text-align: left;"><a href='https://oeis.org/A229046'>A229046</a></td> <td style = "text-align: left;">[1 1 2 4 10 28 88 304 1144 4648 ]</td> </tr> <tr> <td style = "text-align: left;">Middle</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 1 3 7 50 180 2100 10206 166824 1020600 ]'>nomatch</a></td> <td style = "text-align: left;">[1 1 3 7 50 180 2100 10206 166824 1020600 ]</td> </tr> <tr> <td style = "text-align: left;">Central</td> <td style = "text-align: left;"><a href='https://oeis.org/A185157'>A185157</a></td> <td style = "text-align: left;">[1 3 50 2100 166824 21538440 4115105280 1091804313600 384202115256960 173201547619900800 ]</td> </tr> <tr> <td style = "text-align: left;">LeftSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000012'>A000012</a></td> <td style = "text-align: left;">[1 1 1 1 1 1 1 1 1 1 ]</td> </tr> <tr> <td style = "text-align: left;">RightSide</td> <td style = "text-align: left;"><a href='https://oeis.org/A000142'>A000142</a></td> <td style = "text-align: left;">[1 1 2 6 24 120 720 5040 40320 362880 ]</td> </tr> <tr> <td style = "text-align: left;">PosHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A123227'>A123227</a></td> <td style = "text-align: left;">[1 3 12 66 480 4368 47712 608016 8855040 145083648 ]</td> </tr> <tr> <td style = "text-align: left;">NegHalf</td> <td style = "text-align: left;"><a href='https://oeis.org/A009006'>A009006</a></td> <td style = "text-align: left;">[1 -1 0 2 0 -16 0 272 0 -7936 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal2</td> <td style = "text-align: left;"><a href='https://oeis.org/A201339'>A201339</a></td> <td style = "text-align: left;">[1 3 15 111 1095 13503 199815 3449631 68062695 1510769343 ]</td> </tr> <tr> <td style = "text-align: left;">PolyVal3</td> <td style = "text-align: left;"><a href='https://oeis.org/A201354'>A201354</a></td> <td style = "text-align: left;">[1 4 28 292 4060 70564 1471708 35810212 995827420 31153998244 ]</td> </tr> <tr> <td style = "text-align: left;">BinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/A000169'>A000169</a></td> <td style = "text-align: left;">[1 2 9 64 625 7776 117649 2097152 43046721 1000000000 ]</td> </tr> <tr> <td style = "text-align: left;">IBinConv</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[1 0 -3 -10 25 574 2653 -30234 -644079 -2438722 ]'>nomatch</a></td> <td style = "text-align: left;">[1 0 -3 -10 25 574 2653 -30234 -644079 -2438722 ]</td> </tr> <tr> <td style = "text-align: left;">TransSqrs</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 11 109 1139 13021 164051 2273629 34497299 569871901 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 11 109 1139 13021 164051 2273629 34497299 569871901 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat0</td> <td style = "text-align: left;"><a href='https://oeis.org/?q=[0 1 7 49 391 3601 37927 451249 5995591 88073041 ]'>nomatch</a></td> <td style = "text-align: left;">[0 1 7 49 391 3601 37927 451249 5995591 88073041 ]</td> </tr> <tr> <td style = "text-align: left;">TransNat1</td> <td style = "text-align: left;"><a href='https://oeis.org/A000670'>A000670</a></td> <td style = "text-align: left;">[1 3 13 75 541 4683 47293 545835 7087261 102247563 ]</td> </tr> </table> ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
4549
# Library ```@docs A046802Transform ``` ```@docs A046802Triangle ``` ```@docs AbstractSequence ``` ```@docs AbstractTriangle ``` ```@docs AitkenTriangle ``` ```@docs AllPrettyTraits ``` ```@docs AllTraitCards ``` ```@docs AltSum ``` ```@docs AssociatedTriangles ``` ```@docs BernoulliPolynomial ``` ```@docs Bessel1Transform ``` ```@docs Bessel1Triangle ``` ```@docs BinConv ``` ```@docs Binomial ``` ```@docs BinomialTransform ``` ```@docs BinomialTriangle ``` ```@docs Catalan ``` ```@docs CatalanBallot ``` ```@docs CatalanTransform ``` ```@docs CatalanTriangle ``` ```@docs Central ``` ```@docs Coefficients ``` ```@docs ConvSum ``` ```@docs ConvTrans ``` ```@docs ConvTri ``` ```@docs Convolution ``` ```@docs ConvolutionTransformation ``` ```@docs ConvolutionTriangle ``` ```@docs DArcaisTriangle ``` ```@docs DelannoyTriangle ``` ```@docs DelehamΔ ``` ```@docs DiagSum ``` ```@docs DiagTri ``` ```@docs DiagonalTriangle ``` ```@docs EgfExpansionCoeff ``` ```@docs EgfExpansionPoly ``` ```@docs EulerSecTriangle ``` ```@docs EulerTanTriangle ``` ```@docs EulerTriangle ``` ```@docs EulerianSO2Triangle ``` ```@docs EulerianTransform ``` ```@docs EulerianTriangle ``` ```@docs EulerianTriangle2 ``` ```@docs Evaluate ``` ```@docs EvenSum ``` ```@docs Explore ``` ```@docs ExtCatalanTriangle ``` ```@docs Factorial ``` ```@docs FallingFactTriangle ``` ```@docs FibonacciTransform ``` ```@docs FibonacciTriangle ``` ```@docs Fine ``` ```@docs FineTriangle ``` ```@docs Flat ``` ```@docs FubiniTriangle ``` ```@docs FubiniTriangle ``` ```@docs GetSeqnum ``` ```@docs GetSeqnumUri ``` ```@docs HermiteTransform ``` ```@docs HermiteTriangle ``` ```@docs IBinConv ``` ```@docs IBinomial ``` ```@docs IBinomialTransform ``` ```@docs IBinomialTriangle ``` ```@docs Inspect ``` ```@docs InvRev ``` ```@docs Inverse ``` ```@docs InverseTriangle ``` ```@docs JacobsthalTransform ``` ```@docs JacobsthalTriangle ``` ```@docs Laguerre ``` ```@docs LaguerreTransform ``` ```@docs LaguerreTriangle ``` ```@docs LahNumbers ``` ```@docs LahTransform ``` ```@docs LahTriangle ``` ```@docs LeftSide ``` ```@docs LinMap ``` ```@docs MakeSeqUri ``` ```@docs Middle ``` ```@docs MotzkinTransform ``` ```@docs MotzkinTriangle ``` ```@docs NarayanaTransform ``` ```@docs NarayanaTriangle ``` ```@docs NegHalf ``` ```@docs OddSum ``` ```@docs OrthoPoly ``` ```@docs PascalTriangle ``` ```@docs PolyArray ``` ```@docs PolyTri ``` ```@docs PolyTriangle ``` ```@docs PolyVal2 ``` ```@docs PolyVal3 ``` ```@docs PolyValue ``` ```@docs Polynomial ``` ```@docs PolynomialFunction ``` ```@docs PosHalf ``` ```@docs PrettyTraits ``` ```@docs Print ``` ```@docs Println ``` ```@docs QInt ``` ```@docs QPolyRing ``` ```@docs QPolySeq ``` ```@docs QSeq ``` ```@docs QTri ``` ```@docs RecTriangle ``` ```@docs RencontresTriangle ``` ```@docs RevInv ``` ```@docs Reverse ``` ```@docs ReversePolynomial ``` ```@docs RightSide ``` ```@docs RiordanSquare ``` ```@docs RisingFactTriangle ``` ```@docs SaveToCSV ``` ```@docs SchroederBigTransform ``` ```@docs SchroederBigTriangle ``` ```@docs SchröderBTriangle ``` ```@docs SchröderLTriangle ``` ```@docs SeqToString ``` ```@docs Show ``` ```@docs StirlingCycleTransform ``` ```@docs StirlingCycleTriangle ``` ```@docs StirlingSetTransform ``` ```@docs StirlingSetTriangle ``` ```@docs SwingTriangle ``` ```@docs TRAITS ``` ```@docs TRIANGLES ``` ```@docs TTreeTriangle ``` ```@docs Telescope ``` ```@docs TraitCard ``` ```@docs Trans ``` ```@docs TransAlts ``` ```@docs TransNat0 ``` ```@docs TransNat1 ``` ```@docs TransSqrs ``` ```@docs TransTraits ``` ```@docs TransUnos ``` ```@docs Triangles ``` ```@docs TrinomialTransform ``` ```@docs TrinomialTriangle ``` ```@docs UniTriangle ``` ```@docs UpdateDocs ``` ```@docs WorpitzkyTriangle ``` ```@docs ZInt ``` ```@docs ZPolyRing ``` ```@docs ZPolySeq ``` ```@docs ZSeq ``` ```@docs ZTri ``` ```@docs csv_files ``` ```@docs datapath ``` ```@docs docsrcpath ``` ```@docs oeis_notinstalled ``` ```@docs oeis_search ``` ```@docs profilespath ``` ```@docs search_failed ``` ```@docs ℚInt ``` ```@docs ℚPolyRing ``` ```@docs ℚPolySeq ``` ```@docs ℚSeq ``` ```@docs ℚTri ``` ```@docs ℤInt ``` ```@docs ℤPolyRing ``` ```@docs ℤPolySeq ``` ```@docs ℤSeq ``` ```@docs ℤTri ``` ```@docs V000111 ``` ```@docs A000166 ``` ```@docs I008279 ``` ```@docs T008279 ``` ```@docs A038048 ``` ```@docs I048993 ``` ```@docs T048993 ``` ```@docs I094587 ``` ```@docs T094587 ``` ```@docs I132393 ``` ```@docs T132393 ``` ```@docs I225478 ``` ```@docs T225478 ``` ```@docs I271703 ``` ```@docs T271703 ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
2287
![IntegerTriangles](TrianglesLogo.png) # Julia implementations of integer triangles. We give a framework for computing mathematical integer triangles and use it to create so called "Trait Cards". A trait card is a compilation of the essential characteristics of an integer triangle, whereby we understand the characteristics of a triangle to be integer sequences that can be obtained from the triangle by elementary transformations. Overview tables can be automatically generated for a variety of triangles and traits. | A-Number | Triangle | Form | Function | Sequence | |:--------:|:---------- |:----:|:--------- |:------------------------------------------- | | A000302 | Binomial | Std | PolyVal3 | 1, 4, 16, 64, 256, 1024, 4096, 16384 | | A001333 | SchroederB | Inv | AltSum | 1, -1, 3, -7, 17, -41, 99, -239 | | A006012 | SchroederL | Inv | AltSum | 1, -2, 6, -20, 68, -232, 792, -2704 | | A026302 | Motzkin | Rev | Central | 1, 2, 9, 44, 230, 1242, 6853, 38376 | | A103194 | Laguerre | Std | TransNat0 | 0, 1, 6, 39, 292, 2505, 24306, 263431 | | A111884 | Lah | Std | TransAlts | 1, -1, -1, -1, 1, 19, 151, 1091 | | nothing | Laguerre | Rev | TransNat1 | 1, 3, 15, 97, 753, 6771, 68983, 783945 | Important: Note that we assume all sequences to start at offset = 0. Also note that all references to A-numbers are approximativ only, i.e. the first few terms of the sequence may differ and the OEIS-'offset' is always disregarded. To use this feature you have to download the file [stripped.gz](http://oeis.org/stripped.gz) from oeis.org, expand it and put it in the 'data' directory. To see what you can expect start by executing using IntegerTriangles TraitCard(BinomialTriangle, 8) You can also look at the demo [notebook](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/demos/IntegerTriangles.ipynb). An introduction to the project can be found in: * [Tutorial part 1](http://luschny.de/julia/triangles/TutorialTrianglesPart1.html) * [Tutorial part 2](http://luschny.de/julia/triangles/TutorialTrianglesPart2.html) * [Tutorial part 3](http://luschny.de/julia/triangles/TutorialTrianglesPart3.html)
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
ee4f79aaf02af5bc74e84443a0b677bc42a09bee
docs
4922
##   🔶  [TrianglesBase](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/src/TrianglesBase.jl) Basic definitions used in the library IntegerTriangles. We consider the following traits of an triangle: ``` Flat, Reverse, Inverse, RevInv, InvRev, DiagTri, PolyTri, Sum, EvenSum, OddSum, AltSum, DiagSum, Middle, Central, LeftSide, RightSide, PosHalf, NegHalf, PolyVal2, PolyVal3, BinConv, IBinConv, TransSqrs, TransNat0, TransNat1 ``` ##   🔶  [TrianglesExamples](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/src/TrianglesExamples.jl) Recurrences and iterations for some triangles. The examples given are: ``` Aitken, Bessel1, Binomial, Catalan, DArcais, Delannoy, Eulerian, EulerianSO2, EulerSec, EulerTan, Euler, FallingFact, Fibonacci, Fine, Fubini, Hermite, Laguerre, Lah, Motzkin, Narayana, Rencontres, RisingFact, SchröderB, SchröderL, StirlingCycle, StirlingSet, Trinomial, TTree, Uni, Worpitzky ``` ##   🔶  [TrianglesExplorer](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/src/TrianglesExplorer.jl) Explore integer triangles via their traits. The traits and their OEIS references will be saved as csv-files in the data directory. ##   🔶  [TrianglesPlot](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/src/TrianglesPlot.jl) Plotting triangles. ##   🔶  [TrianglesTables](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/src/TrianglesTables.jl) Pretty printing of triangles trait cards. | A-number | Triangle | Form | Function | Sequence | |----------|------------|------|-----------|---------------------------------------------| | A000302 | Binomial | Std | PolyVal3 | 1, 4, 16, 64, 256, 1024, 4096, 16384 | | A001333 | SchroederB | Inv | AltSum | 1, -1, 3, -7, 17, -41, 99, -239 | | A006012 | SchroederL | Inv | AltSum | 1, -2, 6, -20, 68, -232, 792, -2704 | | A026302 | Motzkin | Rev | Central | 1, 2, 9, 44, 230, 1242, 6853, 38376 | | A103194 | Laguerre | Std | TransNat0 | 0, 1, 6, 39, 292, 2505, 24306, 263431 | | A111884 | Lah | Std | TransAlts | 1, -1, -1, -1, 1, 19, 151, 1091 | | nothing | Laguerre | Rev | TransNat1 | 1, 3, 15, 97, 753, 6771, 68983, 783945 | ##   🔶  [TrianglesTraitCard](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/src/TrianglesTraitCard.jl) Build the trait card of one or many triangles with Anums. ``` julia> TraitCard(LaguerreTriangle) Triangle: A021009 [1, 1, 1, 2, 4, 1, 6, 18, 9, 1] Reverse: A021010 [1, 1, 1, 1, 4, 2, 1, 9, 18, 6] Inverse: A021009 [1, -1, 1, 2, -4, 1, -6, 18, -9, 1] RevInv: A021010 [1, 1, -1, 1, -4, 2, 1, -9, 18, -6] Diagonal: A084950 [1, 1, 2, 1, 6, 4, 24, 18, 1, 120] Sum: A002720 [1, 2, 7, 34, 209, 1546, 13327, 130922, 1441729, 17572114] EvenSum: A331325 [1, 1, 3, 15, 97, 745, 6571, 65359, 723969, 8842257] OddSum: A331326 [0, 1, 4, 19, 112, 801, 6756, 65563, 717760, 8729857] AltSum: A009940 [1, 0, -1, -4, -15, -56, -185, -204, 6209, 112400] DiagSum: C001040 [1, 1, 3, 10, 43, 225, 1393, 9976, 81201, 740785] Central: A295383 [1, 4, 72, 2400, 117600, 7620480, 614718720, 59364264960] LeftSide: A000142 [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880] RightSide: A000012 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] PosHalf: A025167 [1, 3, 17, 139, 1473, 19091, 291793, 5129307, 101817089] NegHalf: A025166 [1, -1, 1, 7, -127, 1711, -23231, 334391, -5144063, 84149983] TransUnos: A002720 [1, 2, 7, 34, 209, 1546, 13327, 130922, 1441729, 17572114] TransSqrs: A105219 [0, 1, 8, 63, 544, 5225, 55656, 653023, 8379008, 116780049] TransNat0: A103194 [0, 1, 6, 39, 292, 2505, 24306, 263431, 3154824, 41368977] TransNat1: C000262 [1, 3, 13, 73, 501, 4051, 37633, 394353, 4596553, 58941091] PolyVal2: A087912 [1, 3, 14, 86, 648, 5752, 58576, 671568, 8546432, 119401856] PolyVal3: A277382 [1, 4, 23, 168, 1473, 14988, 173007, 2228544, 31636449] ``` ##   🔶  [TrianglesUtils](https://github.com/OpenLibMathSeq/IntegerTriangles.jl/blob/master/src/TrianglesUtils.jl) * Search the OEIS for a sequence. * Save a file in the 'data' directory in json format. * Triangle in standard format (without typeinfo): ``` [1] [1, 1] [2, 4, 1] [6, 18, 9, 1] [24, 96, 72, 16, 1] [120, 600, 600, 200, 25, 1] [720, 4320, 5400, 2400, 450, 36, 1] ``` * Triangle as a nested array: ``` [[1], [1, 1], [2, 4, 1], [6, 18, 9, 1], [24, 96, 72, 16, 1], [120, 600, 600, 200, 25, 1], [720, 4320, 5400, 2400, 450, 36, 1]] ``` * Triangle in flattened format: ``` 1, 1, 1, 2, 4, 1, 6, 18, 9, 1, 24, 96, 72, 16, 1, 120, 600, 600, 200, 25, 1, 720, 4320, 5400, 2400, 450, 36, 1, ``` * Triangle in info format with sequence ID: ``` [A021009] 1, 1, 1, 2, 4, 1, 6, 18, 9, 1, 24, 96, 72, 16, 1, ... ``` * Triangle in mapped format: ``` 0 ↦ 1 1 ↦ 1 2 ↦ 1 3 ↦ 2 4 ↦ 4 5 ↦ 1 6 ↦ 6 7 ↦ 18 8 ↦ 9 9 ↦ 1 ```
IntegerTriangles
https://github.com/OpenLibMathSeq/IntegerTriangles.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
code
287
module TensorRules using ChainRulesCore using LinearAlgebra using MacroTools using TensorOperations export rrule, frule, NoTangent, Thunk, InplaceableThunk, ProjectTo export I export @tensor, @tensoropt export @∇ include("parser.jl") include("generator.jl") include("macro.jl") end
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
code
5569
function genfunc( funcname::Symbol, args::Vector{Symbol}, lhsind::Vector{Any}, rhs::Expr, opt::Ref{Expr} ) ex = if isempty(lhsind) :($funcname[] := $rhs) else :($funcname[$(lhsind...)] := $rhs) end if isassigned(opt) return :(@inline $funcname($(args...)) = @tensoropt $(opt[]) $ex) else return :(@inline $funcname($(args...)) = @tensor $ex) end end function genfrule( funcname::Symbol, args::Vector{Symbol}, lhsind::Vector{Any}, rhs::Expr, opt::Ref{Expr} ) ȧrgs, ṙhss = Symbol[], Expr[] for arg in args @gensym ȧrg ṙhs = make_scalar_first(make_only_product(rhs, arg)) ṙhs = MacroTools.prewalk(ṙhs) do x # assume to match only once @capture(x, $arg) ? ȧrg : x end push!(ȧrgs, ȧrg) push!(ṙhss, ṙhs) end ṙhs = :(+$(ṙhss...)) @gensym val v̇al lhs = isempty(lhsind) ? :($v̇al[]) : :($v̇al[$(lhsind...)]) pushbody = if isassigned(opt) :(@tensoropt $(opt[]) $lhs := $ṙhs) else :(@tensor $lhs := $ṙhs) end return quote function ChainRulesCore.frule((_, $(ȧrgs...)), ::typeof($funcname), $(args...)) ($(ȧrgs...),) = ChainRulesCore.unthunk.(($(ȧrgs...),)) $val = $(funcname)($(args...)) $pushbody return ($val, $v̇al::typeof($val)) end end end function genrrule( funcname::Symbol, args::Vector{Symbol}, lhsind::Vector{Any}, rhs::Expr, opt::Ref{Expr}, isconjs::Vector{Bool}, indsall::Vector{Union{Symbol,Expr}}, ) indsall = [lhsind; indsall] @gensym Δlhs Δlhsex = isempty(lhsind) ? :(first($Δlhs)) : :($Δlhs[$(lhsind...)]) projargs, projargexs = Symbol[], Expr[] ∂args, ∂argexs, ∂argdefs = Symbol[], Expr[], Expr[] for (arg, isconj) in zip(args, isconjs) @gensym ∂arg projarg push!(∂args, ∂arg) push!(projargs, projarg) push!(projargexs, :(ProjectTo($arg))) rhsarg = make_scalar_first(make_only_product(rhs, arg)) ind = Ref{Vector{Any}}() ∂exrhs = MacroTools.prewalk(rhsarg) do x # assume to match only once if @capture(x, $arg[_ind__]) ind[] = _ind isconj ? Δlhsex : :(conj($Δlhsex)) elseif @capture(x, $arg) isconj ? Δlhsex : :(conj($Δlhsex)) else x end end @assert (isassigned(ind) && !isempty(ind[])) || !isassigned(ind) istensor = isassigned(ind) shouldtr = istensor ? ind[] ≠ unique(ind[]) : false indtr = Union{Symbol,Expr}[] if shouldtr δs = Expr[] for (k, i) in enumerate(ind[]) if i ∉ indtr push!(indtr, i) else j = Expr(Symbol("'"), i) while j ∈ [indsall; indtr] j = Expr(Symbol("'"), j) end push!(indtr, j) push!( δs, :(Array{eltype($arg)}(I, size($arg, $k), size($arg, $k))[$i, $j]), ) end end ∂exrhs = :(*($∂exrhs, $(δs...))) elseif istensor append!(indtr, ind[]) end ∂exrhs = isconj ? ∂exrhs : :(conj($∂exrhs)) @gensym ∂fn ∂exdef = if istensor if isassigned(opt) :(function $∂fn($Δlhs, $(args...)) @tensoropt $(opt[]) _[$(indtr...)] := $∂exrhs end) else :($∂fn($Δlhs, $(args...)) = @tensor _[$(indtr...)] := $∂exrhs) end else if isassigned(opt) :(function $∂fn($Δlhs, $(args...)) return first(@tensoropt $(opt[]) _[] := $∂exrhs) end) else :($∂fn($Δlhs, $(args...)) = first(@tensor _[] := $∂exrhs)) end end push!(∂argdefs, ∂exdef) if istensor @gensym ∂fnadd!! inplaced ∂exadd! = if isassigned(opt) :(function $∂fnadd!!($inplaced, $Δlhs, $(args...)) @tensoropt $(opt[]) $inplaced[$(indtr...)] += $∂exrhs end) else :(function $∂fnadd!!($inplaced, $Δlhs, $(args...)) @tensor $inplaced[$(indtr...)] += $∂exrhs end) end push!(∂argdefs, ∂exadd!) end ∂exarg = if istensor :( $∂arg = InplaceableThunk( $inplaced -> $∂fnadd!!($inplaced, $Δlhs, $(args...)), Thunk(() -> $projarg($∂fn($Δlhs, $(args...)))), ) ) else :($∂arg = Thunk(() -> $∂fn($Δlhs, $(args...)))) end push!(∂argexs, ∂exarg) end @gensym lhs pullback return quote function ChainRulesCore.rrule(::typeof($funcname), $(args...)) $lhs = $(funcname)($(args...)) ($(projargs...),) = ($(projargexs...),) function $(pullback)($Δlhs) return $(Expr( :block, :($Δlhs = Array(ChainRulesCore.unthunk($Δlhs))), ∂argdefs..., ∂argexs..., :(return (ChainRulesCore.NoTangent(), $(∂args...))), )) end return ($lhs, $pullback) end end end
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
code
2936
function _nabla(ex::Expr; mod) def = splitdef(ex) symfuncs, exfuncs, exrules = Symbol[], Expr[], Expr[] def[:body] = MacroTools.postwalk(def[:body]) do x lhs, lhsind, rhs = Ref{Symbol}(), Ref{Vector{Any}}(), Ref{Expr}() which, opt = Ref{Symbol}(), Ref{Expr}() if @capture(x, @tensor _lhs_[_lhsind__] := _rhs_) || @capture(x, @tensoropt _lhs_[_lhsind__] := _rhs_) lhs[], lhsind[], rhs[] = _lhs, _lhsind, _rhs which[] = :assign elseif @capture(x, @tensor _lhs_[_lhsind__] += _rhs_) || @capture(x, @tensoropt _lhs_[_lhsind__] += _rhs_) lhs[], lhsind[], rhs[] = _lhs, _lhsind, _rhs which[] = :pluseq elseif @capture(x, @tensor _lhs_[_lhsind__] -= _rhs_) || @capture(x, @tensoropt _lhs_[_lhsind__] -= _rhs_) lhs[], lhsind[], rhs[] = _lhs, _lhsind, _rhs which[] = :subteq elseif @capture(x, @tensoropt _opt_ _lhs_[_lhsind__] := _rhs_) lhs[], lhsind[], rhs[] = _lhs, _lhsind, _rhs which[], opt[] = :assign, _opt elseif @capture(x, @tensoropt _opt_ _lhs_[_lhsind__] += _rhs_) lhs[], lhsind[], rhs[] = _lhs, _lhsind, _rhs which[], opt[] = :pluseq, _opt elseif @capture(x, @tensoropt _opt_ _lhs_[_lhsind__] -= _rhs_) lhs[], lhsind[], rhs[] = _lhs, _lhsind, _rhs which[], opt[] = :subteq, _opt elseif @capture(x, @tensor _[__] = _) || @capture(x, @tensoropt _[__] = _) || @capture(x, @tensoropt _ _[__] = _) error("use assignment with `:=` instead of inplace operation with `=`") else return x end lhs, lhsind, rhs, which = lhs[], lhsind[], rhs[], which[] rhsreplace, argsorig, argsdummy, isconjs, indsall = rhs_to_args(rhs) @gensym symfunc push!(symfuncs, symfunc) genargs = (symfunc, argsdummy, lhsind, rhsreplace, opt) exfunc = genfunc(genargs...) exfrule = genfrule(genargs...) exrrule = genrrule(genargs..., isconjs, indsall) @eval mod $(macroexpand(TensorOperations, exfunc)) @eval mod $(macroexpand(TensorOperations, exfrule)) @eval mod $(macroexpand(TensorOperations, exrrule)) if which == :assign return :($lhs = $(Core.eval(mod, symfunc))($(argsorig...))) elseif which == :pluseq # use x += y instead of x .+= y for Zygote return :($lhs += $(Core.eval(mod, symfunc))($(argsorig...))) elseif which == :subteq # use x -= y instead of x .-= y for Zygote return :($lhs -= $(Core.eval(mod, symfunc))($(argsorig...))) end end return esc(MacroTools.combinedef(def)), symfuncs end macro ∇(ex) ex, _ = _nabla(ex; mod=@__MODULE__) return ex end macro fn∇(i, ex) _, fn = _nabla(ex; mod=@__MODULE__) return fn[i] end
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
code
2850
function rhs_to_args(ex::Expr) indsall = Union{Symbol,Expr}[] symorig, symgend, isconjs = Union{Symbol,Expr}[], Symbol[], Bool[] function exparse(x, isconj) if x isa Number x elseif @capture(x, -(rhs__)) y = exparse.(rhs, isconj) :(-($(y...))) elseif @capture(x, +(rhs__)) y = exparse.(rhs, isconj) :(+($(y...))) elseif @capture(x, *(rhs__)) y = exparse.(rhs, isconj) :(*($(y...))) elseif @capture(x, conj(rhs_)) y = exparse(rhs, !isconj) :(conj($y)) elseif @capture(x, sym_[ind__]) any(x -> isa(x, Integer), ind) && error("NCON style is unsupported") @gensym new push!(symorig, sym) push!(symgend, new) push!(isconjs, isconj) append!(indsall, ind) :($new[$(ind...)]) else @gensym new push!(symorig, x) push!(symgend, new) push!(isconjs, isconj) new end end exreplaced = exparse(ex, false) return exreplaced, symorig, symgend, isconjs, indsall end function make_only_product(ex::Expr, sym::Symbol) hassym(x) = if @capture(x, -(y__) | +(y__) | *(y__)) any(hassym.(y)) elseif @capture(x, conj(y_)) hassym(y) elseif @capture(x, $sym) || @capture(x, $sym[__]) true else false end return MacroTools.postwalk(ex) do x if @capture(x, -(y__)) @assert 1 ≤ length(y) ≤ 2 if length(y) == 1 x elseif hassym(first(y)) first(y) elseif hassym(last(y)) :(-$(last(y))) else x end elseif @capture(x, +(y__)) @assert 1 ≤ length(y) y = filter(hassym, y) @assert length(y) ≤ 1 length(y) == 1 ? first(y) : x else x end end end function make_scalar_first(ex::Expr) return MacroTools.postwalk(ex) do x if @capture(x, *(y__)) tensors = Expr[] notensors = Union{Expr,Symbol,Number}[] for z in y if @capture(z, _[__]) || @capture(z, conj(_[__])) push!(tensors, z) else push!(notensors, z) end end isempty(tensors) && return x if isempty(notensors) return x elseif length(notensors) == 1 return :(*($(notensors[1]), $(tensors...))) else return :(*(*($(notensors...)), $(tensors...))) end else return x end end end
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
code
1713
@testset "RHS parse" begin ex = quote (a[1:end, :][1, 2][a, b'] + sin(cos(B))[b', (a')']) * (C * D + E)[(a')', a] * 3 * 2 + α * a[a, a] * K[1, 2, 3][a, a] - (((L[a, b] * P.P[b, c]) * (M[c, d] * N[d, e]) * Z[e, f]) * D[f, a]) * π end @test rhs_to_args(ex)[2] == [ :(a[1:end, :][1, 2]), :(sin(cos(B))), :(C * D + E), :α, :a, :(K[1, 2, 3]), :L, :(P.P), :M, :N, :Z, :D, :π, ] ex = :(-a * (-b + (c + d) + (-e) - f - (g * h)) * i + j) @test make_only_product(ex, :a) == :(-a * (-b + (c + d) + (-e) - f - (g * h)) * i) @test make_only_product(ex, :b) == :(-a * -b * i) @test make_only_product(ex, :c) == :(-a * c * i) @test make_only_product(ex, :d) == :(-a * d * i) @test make_only_product(ex, :e) == :(-a * -e * i) @test make_only_product(ex, :f) == :(-a * -f * i) @test make_only_product(ex, :g) == :(-a * -(g * h) * i) @test make_only_product(ex, :h) == :(-a * -(g * h) * i) @test make_only_product(ex, :i) == :(-a * (-b + (c + d) + (-e) - f - (g * h)) * i) @test make_only_product(ex, :j) == :j ex = :(-a * (-conj(conj(b)) + conj(conj(c + d * e) + f) + -g)) @test make_only_product(ex, :a) == :(-a * (-conj(conj(b)) + conj(conj(c + d * e) + f) + -g)) @test make_only_product(ex, :b) == :(-a * -conj(conj(b))) @test make_only_product(ex, :c) == :(-a * conj(conj(c))) @test make_only_product(ex, :d) == :(-a * conj(conj(d * e))) @test make_only_product(ex, :e) == :(-a * conj(conj(d * e))) @test make_only_product(ex, :f) == :(-a * conj(f)) @test make_only_product(ex, :g) == :(-a * -(g)) end
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
code
6349
@testset "rules" begin @testset "einsum" begin _esum = @fn∇ 1 function (b, c, d) @tensor a[B, A] := conj(b[A, C]) * c[C, D] * d[B, D] end for T in (ComplexF64, Float64) b = randn(T, 3, 5) c = randn(T, 5, 4) d = randn(T, 4, 4) test_rrule(_esum, b, c, d) test_frule(_esum, b, c, d) end end @testset "tensoropt" begin _opt1 = @fn∇ 1 function (b, c, d) @tensoropt (A => 1, C => χ) a[B, A] := b[A, C] * c[C, D] * d[B, D] end _opt2 = @fn∇ 1 function (b, c, d) @tensoropt !(A, C) a[B, A] := b[A, C] * c[C, D] * d[B, D] end _opt3 = @fn∇ 1 function (b, c, d) @tensoropt (A, C) a[B, A] := b[A, C] * c[C, D] * d[B, D] end for T in (ComplexF64, Float64) b = randn(T, 3, 5) c = randn(T, 5, 4) d = randn(T, 4, 4) test_rrule(_opt1, b, c, d) test_rrule(_opt2, b, c, d) test_rrule(_opt3, b, c, d) test_frule(_opt1, b, c, d) test_frule(_opt2, b, c, d) test_frule(_opt3, b, c, d) end end @testset "scalar in rhs" begin _scar = @fn∇ 1 function (α, b, c) @tensor a[B, A] := α * conj(b[A, C]) * c[C, B] end for T in (ComplexF64, Float64) b = randn(T, 3, 5) c = randn(T, 5, 4) α = randn(T) test_rrule(_scar, α, b, c) test_frule(_scar, α, b, c) end end @testset "add" begin _add = @fn∇ 1 function (α, b, c, β, d, e, f) @tensor a[B, A] := -α * conj(b[A, C]) * c[C, B] + conj(β) * d[A, C] * (-e[C, B] + 2 * f[C, B]) end for T in (ComplexF64, Float64) α = randn(T) b = randn(T, 3, 5) c = randn(T, 5, 4) β = randn(T) d = randn(T, 3, 5) e = randn(T, 5, 4) f = randn(T, 5, 4) test_rrule(_add, α, b, c, β, d, e, f) test_frule(_add, α, b, c, β, d, e, f) end end @testset "trace" begin _tr1 = @fn∇ 1 function (b, c) @tensor a[C] := b[A, B, B', B', B] * c[A, A', A', C] end _tr2 = @fn∇ 1 function (b, c) @tensor a[c] := b[a, b, bb, bb, b] * c[a, aa, aa, c] end for T in (ComplexF64, Float64) b = randn(T, 3, 2, 3, 3, 2) c = randn(T, 3, 3, 3, 2) test_rrule(_tr1, b, c) test_rrule(_tr2, b, c) test_frule(_tr1, b, c) test_frule(_tr2, b, c) end end @testset "lhs is scalar" begin _scal = @fn∇ 1 function (b, c, d) @tensor a[] := b[A, B] * c[B, C] * d[C, A] end for T in (ComplexF64, Float64) b = randn(T, 3, 2) c = randn(T, 2, 4) d = randn(T, 4, 3) test_rrule(_scal, b, c, d) test_frule(_scal, b, c, d) end end @testset "conj" begin _co1 = @fn∇ 1 function (b, c, d) @tensor a[B, A] := conj(b[A, C]) * conj(c[C, D] * d[B, D]) end _co2 = @fn∇ 1 function (b, c, d) @tensor a[B, A] := conj(b[A, C] * c[C, D] * d[B, D]) end _co3 = @fn∇ 1 function (b, c, d) @tensor a[B, A] := conj( 1.23 * conj(conj(conj(b[A, C]))) * conj(c[C, D] * d[B, D]) ) end for T in (ComplexF64, Float64) b = randn(T, 3, 5) c = randn(T, 5, 4) d = randn(T, 4, 4) α = randn(T) β = randn(T) test_rrule(_co1, b, c, d) test_rrule(_co2, b, c, d) test_rrule(_co3, b, c, d) test_frule(_co1, b, c, d) test_frule(_co2, b, c, d) test_frule(_co3, b, c, d) end _co4 = @fn∇ 1 function (α, b, c, β, d, e, f) @tensor a[B, A] := -α * conj(conj(b[A, C]) * c[C, B] + conj(β) * d[A, C] * (-e[C, B] + 2 * f[C, B])) end for T in (ComplexF64, Float64) α = randn(T) b = randn(T, 3, 5) c = randn(T, 5, 4) β = randn(T) d = randn(T, 3, 5) e = randn(T, 5, 4) f = randn(T, 5, 4) test_rrule(_co4, α, b, c, β, d, e, f) test_frule(_co4, α, b, c, β, d, e, f) end end @testset "more" begin T = ComplexF64 _tn1 = @fn∇ 1 function (x, ar, H) return @tensoropt !(p, p1, p2) l[l, p, r] := x[l, p1, X] * ar[X, p2, Y] * conj(ar[r, p2', Y]) * H[p, p2', p1, p2] end _tn2 = @fn∇ 1 function (x, al, H) return @tensoropt !(p, p1, p2) r[l, p, r] := conj(al[X, p1', l]) * al[X, p1, Y] * x[Y, p2, r] * H[p1', p, p1, p2] end a1 = randn(T, 3, 2, 3) a2 = randn(T, 3, 2, 3) x = randn(T, 3, 2, 3) H = randn(T, 2, 2, 2, 2) r = randn(T, 3, 2, 3) test_rrule(_tn1, x, a1, a2, H) test_rrule(_tn2, a1, a2, x, H) test_frule(_tn1, x, a1, a2, H) test_frule(_tn2, a1, a2, x, H) _tn3 = @fn∇ 1 function (λ, o, a, b=a) return @tensoropt !(p1, p2) _[l, r] := λ * conj(b[1][X, p1', Y']) * conj(b[2][Y', p2', l]) * a[1][X, p1, Y] * a[2][Y, p2, r] * o[p1', p2', p1, p2] end _tn4 = @fn∇ 1 function (x, o, a, b=a) return @tensoropt !(p1, p2) _[l, r] := a[1][l, p1, X] * a[2][X, p2, Y] * x[Y, Y'] * conj(b[1][r, p1', X']) * conj(b[2][X', p2', Y']) * o[p1', p2', p1, p2] end a1 = randn(T, 3, 2, 3) a2 = randn(T, 3, 2, 3) b1 = randn(T, 3, 2, 3) b2 = randn(T, 3, 2, 3) x = randn(T, 3, 3) λ = randn(T) H = randn(T, 2, 2, 2, 2) r = randn(T, 3, 3) test_rrule(_tn3, λ, b1, b2, a1, a2, H) test_rrule(_tn4, a1, a2, x, b1, b2, H) test_frule(_tn3, λ, b1, b2, a1, a2, H) test_frule(_tn4, a1, a2, x, b1, b2, H) end end
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
code
309
using ChainRulesTestUtils using FiniteDifferences using Random using TensorRules using Test using Zygote import TensorRules: @fn∇, rhs_to_args, make_only_product Random.seed!(42) Zygote.refresh() @testset "TensorRules" begin include("rhsparse.jl") include("rules.jl") include("zygote.jl") end
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
code
1587
@testset "with Zygote" begin k = 1 function foo_(a, b, c, d, e, f) @tensoropt !C x[A, B] := k * conj(a[A, C]) * (-sin.(b)[C, D] * c.d[D, B] - c.d[C, B]) @tensor x[A, B] -= d * conj(e[1])[A, (B')', B', B', (B')', B] x = x + f * k @tensor x[A, B] += (@tensor _[A, C] := a[A, B] * a[B, C])[A, C] * (a * a)[C, B] return x end @∇ function foo(a, b, c, d, e, f) @tensoropt !C x[a, b] := k * conj(a[a, c]) * (-sin.(b)[c, d] * c.d[d, b] - c.d[c, b]) @tensor x[A, B] -= d * conj(e[1])[A, (B')', B', B', (B')', B] x = x + f * k @tensor x[A, B] += (@tensor _[A, C] := a[A, B] * a[B, C])[A, C] * (a * a)[C, B] return x end T = ComplexF64 a = randn(T, 3, 3) b = randn(T, 3, 3) c = (d=randn(T, 3, 3),) d = randn(T) e = [randn(T, 3, 2, 1, 1, 2, 3) for i in 1:2] f = randn(T, 3, 3) @test foo(a, b, c, d, e, f) ≈ foo_(a, b, c, d, e, f) for F in [angle ∘ first, angle ∘ sum, real ∘ sum] ad = gradient((a, b, c, d, e, f) -> F(foo(a, b, c, d, e, f)), (a, b, c, d, e, f)...) fd = grad( central_fdm(5, 1), (a, b, c, d, e, f) -> F(foo(a, b, c, d, e, f)), (a, b, c, d, e, f)..., ) @test ad[1] ≈ fd[1] atol = cbrt(eps()) @test ad[2] ≈ fd[2] atol = cbrt(eps()) @test ad[3].d ≈ fd[3].d atol = cbrt(eps()) @test ad[4] ≈ fd[4] atol = cbrt(eps()) @test ad[5][1] ≈ fd[5][1] atol = cbrt(eps()) @test ad[6] ≈ fd[6] atol = cbrt(eps()) end end
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.3.0
70191091d6a47e332502ce7adeab534491e1fefa
docs
5543
# TensorRules.jl [![Build Status](https://github.com/ho-oto/TensorRules.jl/workflows/CI/badge.svg)](https://github.com/ho-oto/TensorRules.jl/actions) [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) `TensorRules.jl` provides a macro `@∇` (you can type `∇` by `\nabla<tab>`), which enable us to use automatic differentiation (AD) libraries (e.g., [`Zygote.jl`](https://github.com/FluxML/Zygote.jl), [`Diffractor.jl`](https://github.com/JuliaDiff/Diffractor.jl)) with `@tensor` and `@tensoropt` macros in [`TensorOperations.jl`](https://github.com/Jutho/TensorOperations.jl). `TensorRules.jl` uses [`ChainRulesCore.jl`](https://github.com/JuliaDiff/ChainRulesCore.jl) to define custom adjoints. So, you can use any AD libraries which supports `ChainRulesCore.jl`. ## How to use ```julia julia> using TensorOperations, TensorRules, Zygote; julia> function foo(a, b, c) # define function with Einstein summation # d_F = \sum_{A,B,C,D} a_{A,B,C} b_{C,D,E,F} c_{A,B,D,E} @tensor d[F] := a[A, B, C] * b[C, D, E, F] * c[A, B, D, E] return d[1] end; julia> a, b, c = randn(3, 4, 5), randn(5, 6, 7, 8), randn(3, 4, 6, 7); julia> gradient(foo, a, b, c); # try to obtain gradient of `foo` by Zygote ERROR: this intrinsic must be compiled to be called Stacktrace: ... julia> @∇ function foo(a, b, c) # use @∇ @tensor d[F] := a[A, B, C] * b[C, D, E, F] * c[A, B, D, E] return d[1] end; julia> gradient(foo, a, b, c); # it works! ``` ## How it works The strategy of `TensorRules.jl` are very similar to [`TensorGrad.jl`](https://github.com/mcabbott/TensorGrad.jl). `@∇` converts functions which contains `@tensor` or `@tensoropt` macro. First, `@∇` detects `@tensor` or `@tensoropt` expressions in function definition and convert them to inlined functions. Then, `@∇` define custom adjoint rules for the generated functions. For example, the following definition ```julia @∇ function foo(a, b, c, d, e, f) @tensoropt !C x[A, B] := conj(a[A, C]) * sin.(b)[C, D] * c.d[D, B] + d * e[1, 2][A, B] x = x + f @tensor x[A, B] += a[A, C] * (a * a)[C, B] return x end ``` will be converted to a code equivalent to ```julia function foo(a, b, c, d, e, f) x = _foo_1(a, sin.(a), c.d, d, e[1, 2]) x = x + f x += _foo_2(a, a * a) return x end @inline _foo_1(x1, x2, x3, x4, x5) = @tensoropt !C _[A, B] := conj(x1[A, C]) * x2[C, D] * x3[D, B] + x4 * x5[A, B] @inline _foo_2(x1, x2) = @tensor _[A, B] := x1[A, C] * x2[C, B] function rrule(::typeof(_foo_1), x1, x2, x3, x4, x5) f = _foo_1(x1, x2, x3, x4, x5) Px1, Px2, Px3, Px4, Px5 = ProjectTo(x1), ProjectTo(x2), ProjectTo(x3), ProjectTo(x4), ProjectTo(x5) function _foo_1_pullback(Δf) fnΔx1(Δf, x1, x2, x3, x4, x5) = @tensoropt !C _[A, C] := conj(Δf[A, B]) * x2[C, D] * x3[D, B] fnΔx1add!!(x, Δf, x1, x2, x3, x4, x5) = @tensoropt !C x[A, C] += conj(Δf[A, B]) * x2[C, D] * x3[D, B] fnΔx2(Δf, x1, x2, x3, x4, x5) = @tensoropt !C _[C, D] := conj(conj(x1[A, C]) * conj(Δf[A, B]) * x3[D, B]) fnΔx2add!!(x, Δf, x1, x2, x3, x4, x5) = @tensoropt !C x[C, D] += conj(conj(x1[A, C]) * conj(Δf[A, B]) * x3[D, B]) fnΔx3(Δf, x1, x2, x3, x4, x5) = @tensoropt !C _[D, B] := conj(conj(x1[A, C]) * x2[C, D] * conj(Δf[A, B])) fnΔx3add!!(x, Δf, x1, x2, x3, x4, x5) = @tensoropt !C x[D, B] += conj(conj(x1[A, C]) * x2[C, D] * conj(Δf[A, B])) fnΔx4(Δf, x1, x2, x3, x4, x5) = first(@tensoropt !C _[] := conj(conj(Δf[A, B]) * x5[A, B])) fnΔx5(Δf, x1, x2, x3, x4, x5) = @tensoropt !C _[A, B] := conj(x4 * conj(Δf[A, B])) fnΔx5add!!(x, Δf, x1, x2, x3, x4, x5) = @tensoropt !C x[A, B] += conj(x4 * conj(Δf[A, B])) Δx1 = InplaceableThunk( Thunk(() -> Px1(fnΔx1(Δf, x1, x2, x3, x4, x5))), x -> fnΔx1add!!(x, Δf, x1, x2, x3, x4, x5) ) Δx2 = InplaceableThunk( Thunk(() -> Px2(fnΔx2(Δf, x1, x2, x3, x4, x5))), x -> fnΔx2add!!(x, Δf, x1, x2, x3, x4, x5) ) Δx3 = InplaceableThunk( Thunk(() -> Px3(fnΔx3(Δf, x1, x2, x3, x4, x5))), x -> fnΔx3add!!(x, Δf, x1, x2, x3, x4, x5) ) Δx4 = Thunk(() -> fnΔx4(Δf, x1, x2, x3, x4, x5)) Δx5 = InplaceableThunk( Thunk(() -> Px5(fnΔx5(Δf, x1, x2, x3, x4, x5))), x -> fnΔx5add!!(x, Δf, x1, x2, x3, x4, x5) ) return (NoTangent(), Δx1, Δx2, Δx3, Δx4, Δx5) end return f, _foo_1_pullback end function rrule(::typeof(_foo_2), x1, x2) ... end ``` By using `Thunk` and `InplaceableThunk` properly, adjoints will be evaluated only if they are needed. ## unsupported features - `@∇` uses `@capture` macro defined in [`MacroTools.jl`](https://github.com/FluxML/MacroTools.jl) to parse `Expr`. Because of the limitation of `@capture` macro, index notations based on `:typed_vcat` and `:typed_hcat` (`A[a; b], A[a b]`) are unsupported. Please use `A[a, b]` style. - Designations of contraction order based on `ord=(...)` or NCON style are unsupported. Please use `@tensoropt` and specify costs of each bonds. - Since `Zygote.jl` does not support inplace operations, we cannot use `@tensor A[] = ...` in the expression. Please use `:=`, `+=` and `-=` instead. ## TODO - [ ] support `@tensor` block (`@tensor begin ... end`) - [ ] support higher order differentiation (by applying `@∇` to `rrule` and `frule` recursively) - [ ] better support of `InplaceableThunk`
TensorRules
https://github.com/ho-oto/TensorRules.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
603
using NormalizingFlows using Documenter DocMeta.setdocmeta!( NormalizingFlows, :DocTestSetup, :(using NormalizingFlows); recursive=true ) makedocs(; modules=[NormalizingFlows], repo="https://github.com/TuringLang/NormalizingFlows.jl/blob/{commit}{path}#{line}", sitename="NormalizingFlows.jl", format=Documenter.HTML(), pages=[ "Home" => "index.md", "API" => "api.md", "Example" => "example.md", "Customize your own flow layer" => "customized_layer.md", ], ) deploydocs(; repo="github.com/TuringLang/NormalizingFlows.jl", devbranch="main")
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
1293
using Random, Distributions, LinearAlgebra, Bijectors # accessing the trained flow by looking at the first 2 dimensions function compare_trained_and_untrained_flow( flow_trained::Bijectors.MultivariateTransformed, flow_untrained::Bijectors.MultivariateTransformed, true_dist::ContinuousMultivariateDistribution, n_samples::Int; kwargs..., ) samples_trained = rand(flow_trained, n_samples) samples_untrained = rand(flow_untrained, n_samples) samples_true = rand(true_dist, n_samples) p = scatter( samples_true[1, :], samples_true[2, :]; label="True Distribution", color=:blue, markersize=2, alpha=0.5, ) scatter!( p, samples_untrained[1, :], samples_untrained[2, :]; label="Untrained Flow", color=:red, markersize=2, alpha=0.5, ) scatter!( p, samples_trained[1, :], samples_trained[2, :]; label="Trained Flow", color=:green, markersize=2, alpha=0.5, ) plot!(; kwargs...) xlabel!(p, "X") ylabel!(p, "Y") title!(p, "Comparison of Trained and Untrained Flow") return p end function create_flow(Ls, q₀) ts = fchain(Ls) return transformed(q₀, ts) end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
3575
using Flux using Functors using Bijectors using Bijectors: partition, PartitionMask """ Neural Rational quadratic Spline layer # References [1] Durkan, C., Bekasov, A., Murray, I., & Papamakarios, G., Neural Spline Flows, CoRR, arXiv:1906.04032 [stat.ML], (2019). """ struct NeuralSplineLayer{T1,T2,A<:AbstractVecOrMat{T1}} <: Bijectors.Bijector dim::Int mask::Bijectors.PartitionMask w::A # width h::A # height d::A # derivative of the knots B::T2 # bound of the knots end function MLP_3layer(input_dim::Int, hdims::Int, output_dim::Int; activation=Flux.leakyrelu) return Chain( Flux.Dense(input_dim, hdims, activation), Flux.Dense(hdims, hdims, activation), Flux.Dense(hdims, output_dim), ) end function NeuralSplineLayer( dim::Int, # dimension of input hdims::Int, # dimension of hidden units for s and t K::Int, # number of knots mask_idx::AbstractVector{<:Int}, # index of dimensione that one wants to apply transformations on B::T2, # bound of the knots ) where {T2<:Real} num_of_transformed_dims = length(mask_idx) input_dims = dim - num_of_transformed_dims w = [MLP_3layer(input_dims, hdims, K) for i in 1:num_of_transformed_dims] h = [MLP_3layer(input_dims, hdims, K) for i in 1:num_of_transformed_dims] d = [MLP_3layer(input_dims, hdims, K - 1) for i in 1:num_of_transformed_dims] mask = Bijectors.PartitionMask(D, mask_idx) return NeuralSplineLayer(D, mask, w, h, d, B) end @functor NeuralSplineLayer (w, h, d) # define forward and inverse transformation function instantiate_rqs(nsl::NeuralSplineLayer{<:Vector{<:Flux.Chain}}, x::AbstractVector) # instantiate rqs knots and derivatives ws = permutedims(reduce(hcat, [w(x) for w in nsl.w])) hs = permutedims(reduce(hcat, [h(x) for h in nsl.h])) ds = permutedims(reduce(hcat, [d(x) for d in nsl.d])) return Bijectors.RationalQuadraticSpline(ws, hs, ds, nsl.B) end function Bijectors.transform( nsl::NeuralSplineLayer{<:Vector{<:Flux.Chain}}, x::AbstractVector ) x_1, x_2, x_3 = Bijectors.partition(nsl.mask, x) # instantiate rqs knots and derivatives rqs = instantiate_rqs(nsl, x_2) y_1 = transform(rqs, x_1) return Bijectors.combine(nsl.mask, y_1, x_2, x_3) end function Bijectors.transform( insl::Inverse{<:NeuralSplineLayer{<:Vector{<:Flux.Chain}}}, y::AbstractVector ) nsl = insl.orig y1, y2, y3 = partition(nsl.mask, y) rqs = instantiate_rqs(nsl, y2) x1 = transform(Inverse(rqs), y1) return combine(nsl.mask, x1, y2, y3) end function (nsl::NeuralSplineLayer{<:Vector{<:Flux.Chain}})(x::AbstractVector) return Bijectors.transform(nsl, x) end # define logabsdetjac function Bijectors.logabsdetjac( nsl::NeuralSplineLayer{<:Vector{<:Flux.Chain}}, x::AbstractVector ) x_1, x_2, x_3 = Bijectors.partition(nsl.mask, x) Rqs = instantiate_rqs(nsl, x_2) logjac = logabsdetjac(Rqs, x_1) return logjac end function Bijectors.logabsdetjac( insl::Inverse{<:NeuralSplineLayer{<:Vector{<:Flux.Chain}}}, y::AbstractVector ) nsl = insl.orig y1, y2, y3 = partition(nsl.mask, y) rqs = instantiate_rqs(nsl, y2) logjac = logabsdetjac(Inverse(rqs), y1) return logjac end function Bijectors.with_logabsdet_jacobian( nsl::NeuralSplineLayer{<:Vector{<:Flux.Chain}}, x::AbstractVector ) x_1, x_2, x_3 = Bijectors.partition(nsl.mask, x) rqs = instantiate_rqs(nsl, x_2) y_1, logjac = with_logabsdet_jacobian(rqs, x_1) return Bijectors.combine(nsl.mask, y_1, x_2, x_3), logjac end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
1443
using Random, Distributions, LinearAlgebra, Bijectors using ADTypes using Optimisers using FunctionChains using NormalizingFlows using Zygote using Flux: f32 using Plots include("../common.jl") Random.seed!(123) rng = Random.default_rng() ###################################### # 2d Banana as the target distribution ###################################### include("../targets/banana.jl") # create target p p = Banana(2, 1.0f-1, 100.0f0) logp = Base.Fix1(logpdf, p) ###################################### # learn the target using planar flow ###################################### function create_planar_flow(n_layers::Int, q₀) d = length(q₀) Ls = [f32(PlanarLayer(d)) for _ in 1:n_layers] ts = fchain(Ls) return transformed(q₀, ts) end # create a 10-layer planar flow flow = create_planar_flow(20, MvNormal(zeros(Float32, 2), I)) flow_untrained = deepcopy(flow) # train the flow sample_per_iter = 10 cb(iter, opt_stats, re, θ) = (sample_per_iter=sample_per_iter,) flow_trained, stats, _ = train_flow( elbo, flow, logp, sample_per_iter; max_iters=200_00, optimiser=Optimisers.ADAM(), callback=cb, ADbackend=AutoZygote(), ) losses = map(x -> x.loss, stats) ###################################### # evaluate trained flow ###################################### plot(losses; label="Loss", linewidth=2) # plot the loss compare_trained_and_untrained_flow(flow_trained, flow_untrained, p, 1000)
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
1431
using Random, Distributions, LinearAlgebra, Bijectors using ADTypes using Optimisers using FunctionChains using NormalizingFlows using Zygote using Flux: f32 using Plots include("../common.jl") Random.seed!(123) rng = Random.default_rng() ###################################### # 2d Banana as the target distribution ###################################### include("../targets/banana.jl") # create target p p = Banana(2, 1.0f-1, 100.0f0) logp = Base.Fix1(logpdf, p) ###################################### # learn the target using radial flow ###################################### function create_radial_flow(n_layers::Int, q₀) d = length(q₀) Ls = [f32(RadialLayer(d)) for _ in 1:n_layers] ts = fchain(Ls) return transformed(q₀, ts) end # create a 20-layer radial flow flow = create_radial_flow(10, MvNormal(zeros(Float32, 2), I)) flow_untrained = deepcopy(flow) # train the flow sample_per_iter = 10 cb(iter, opt_stats, re, θ) = (sample_per_iter=sample_per_iter,) flow_trained, stats, _ = train_flow( elbo, flow, logp, sample_per_iter; max_iters=200_00, optimiser=Optimisers.ADAM(), callback=cb, ) losses = map(x -> x.loss, stats) ###################################### # evaluate trained flow ###################################### plot(losses; label="Loss", linewidth=2) # plot the loss compare_trained_and_untrained_flow(flow_trained, flow_untrained, p, 1000; legend=:bottom)
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
3404
using Distributions, Random using Plots using IrrationalConstants """ Banana{T<:Real} Multidimensional banana-shape distribution. # Fields $(FIELDS) # Explanation The banana distribution is obtained by applying a transformation ϕ to a multivariate normal distribution ``\\mathcal{N}(0, \\text{diag}(var, 1, 1, …, 1))``. The transformation ϕ is defined as ```math \phi(x_1, … , x_p) = (x_1, x_2 - B x_1^² + \text{var}*B, x_3, … , x_p) ```` which has a unit Jacobian determinant. Hence the density "fb" of a p-dimensional banana distribution is given by ```math fb(x_1, \dots, x_p) = \exp\left[ -\frac{1}{2}\frac{x_1^2}{\text{var}} - \frac{1}{2}(x_2 + B x_1^2 - \text{var}*B)^2 - \frac{1}{2}(x_3^2 + x_4^2 + \dots + x_p^2) \right] / Z, ``` where "B" is the "banananicity" constant, determining the curvature of a banana, and ``Z = \\sqrt{\\text{var} * (2\\pi)^p)}`` is the normalization constant. # Reference Gareth O. Roberts and Jeffrey S. Rosenthal "Examples of Adaptive MCMC." Journal of computational and graphical statistics, Volume 18, Number 2 (2009): 349-367. """ struct Banana{T<:Real} <: ContinuousMultivariateDistribution "Dimension of the distribution, must be >= 2" dim::Int # Dimension "Banananicity constant, the larger |b| the more curved the banana" b::T # Curvature "Variance of the first dimension, must be > 0" var::T # Variance function Banana{T}(dim::Int, b::T, var::T) where {T<:Real} dim >= 2 || error("dim must be >= 2") var > 0 || error("var must be > 0") return new{T}(dim, b, var) end end Banana(dim::Int, b::T, var::T) where {T<:Real} = Banana{T}(dim, b, var) Base.length(p::Banana) = p.dim Base.eltype(p::Banana{T}) where {T<:Real} = T Distributions.sampler(p::Banana) = p # Define the transformation function φ and the inverse ϕ⁻¹ for the banana distribution function ϕ!(p::Banana, x::AbstractVector) d, b, s = p.dim, p.b, p.var d == length(x) || error("Dimension mismatch") return x[2] = x[2] - b * x[1]^2 + s * b end function ϕ⁻¹(p::Banana, x::AbstractVector) d, b, s = p.dim, p.b, p.var d == length(x) || error("Dimension mismatch") y2 = x[2] + b * x[1]^2 - s * b return d == 2 ? [x[1], y2] : reduce(vcat, [x[1], y2, x[3:end]]) end function Distributions._rand!(rng::AbstractRNG, p::Banana, x::AbstractVecOrMat) T = eltype(p) d, s = p.dim, p.var d == size(x, 1) || error("Dimension mismatch") x[1, :] .= randn(rng, T, size(x, 2)) .* sqrt(s) x[2:end, :] .= randn(rng, T, d - 1, size(x, 2)) for y in eachcol(x) ϕ!(p, y) end return x end function Distributions._logpdf(p::Banana, x::AbstractVector) T = eltype(p) d, b, s = p.dim, p.b, p.var ϕ⁻¹_x = ϕ⁻¹(p, x) logz = (log(s) / d + IrrationalConstants.log2π) * d / 2 return -logz - sum(ϕ⁻¹_x .^ 2 ./ vcat(s, ones(T, d - 1))) / 2 end function visualize(p::Banana, samples=rand(p, 1000)) xrange = range(minimum(samples[1, :]) - 1, maximum(samples[1, :]) + 1; length=100) yrange = range(minimum(samples[2, :]) - 1, maximum(samples[2, :]) + 1; length=100) z = [exp(Distributions.logpdf(p, [x, y])) for x in xrange, y in yrange] fig = contour(xrange, yrange, z'; levels=15, color=:viridis, label="PDF", linewidth=2) scatter!(samples[1, :], samples[2, :]; label="Samples", alpha=0.3, legend=:bottomright) return fig end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
1163
using Distributions, Random """ Cross(μ::Real=2.0, σ::Real=0.15) 2-dimensional Cross distribution # Explanation The Cross distribution is a 2-dimension 4-component Gaussian distribution with a "cross" shape that is symmetric about the y- and x-axises. The mixture is defined as ```math \begin{aligned} p(x) = & 0.25 \mathcal{N}(x | (0, \mu), (\sigma, 1)) + \\ & 0.25 \mathcal{N}(x | (\mu, 0), (1, \sigma)) + \\ & 0.25 \mathcal{N}(x | (0, -\mu), (\sigma, 1)) + \\ & 0.25 \mathcal{N}(x | (-\mu, 0), (1, \sigma))) \end{aligned} ``` where ``μ`` and ``σ`` are the mean and standard deviation of the Gaussian components, respectively. See an example of the Cross distribution in Page 18 of [1]. # Reference [1] Zuheng Xu, Naitong Chen, Trevor Campbell "MixFlows: principled variational inference via mixed flows." International Conference on Machine Learning, 2023 """ Cross() = Cross(2.0, 0.15) function Cross(μ::T, σ::T) where {T<:Real} return MixtureModel([ MvNormal([zero(μ), μ], [σ, one(σ)]), MvNormal([-μ, one(μ)], [one(σ), σ]), MvNormal([μ, one(μ)], [one(σ), σ]), MvNormal([zero(μ), -μ], [σ, one(σ)]), ]) end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
2116
using Distributions, Random """ Funnel{T<:Real} Multidimensional Neal's Funnel distribution # Fields $(FIELDS) # Explanation The Neal's Funnel distribution is a p-dimensional distribution with a funnel shape, originally proposed by Radford Neal in [2]. The marginal distribution of ``x_1`` is Gaussian with mean "μ" and standard deviation "σ". The conditional distribution of ``x_2, \dots, x_p | x_1`` are independent Gaussian distributions with mean 0 and standard deviation ``\\exp(x_1/2)``. The generative process is given by ```math x_1 \sim \mathcal{N}(\mu, \sigma^2), \quad x_2, \ldots, x_p \sim \mathcal{N}(0, \exp(x_1)) ``` # Reference [1] Stan User’s Guide: https://mc-stan.org/docs/2_18/stan-users-guide/reparameterization-section.html#ref-Neal:2003 [2] Radford Neal 2003. “Slice Sampling.” Annals of Statistics 31 (3): 705–67. """ struct Funnel{T<:Real} <: ContinuousMultivariateDistribution "Dimension of the distribution, must be >= 2" dim::Int "Mean of the first dimension" μ::T "Standard deviation of the first dimension, must be > 0" σ::T function Funnel{T}(dim::Int, μ::T, σ::T) where {T<:Real} dim >= 2 || error("dim must be >= 2") σ > 0 || error("σ must be > 0") return new{T}(dim, μ, σ) end end Funnel(dim::Int, μ::T, σ::T) where {T<:Real} = Funnel{T}(dim, μ, σ) Funnel(dim::Int, σ::T) where {T<:Real} = Funnel{T}(dim, zero(T), σ) Funnel(dim::Int) = Funnel(dim, 0.0, 9.0) Base.length(p::Funnel) = p.dim Base.eltype(p::Funnel{T}) where {T<:Real} = T function Distributions._rand!(rng::AbstractRNG, p::Funnel, x::AbstractVecOrMat) T = eltype(x) d, μ, σ = p.dim, p.μ, p.σ d == size(x, 1) || error("Dimension mismatch") x[1, :] .= randn(rng, T, size(x, 2)) .* σ .+ μ x[2:end, :] .= randn(rng, T, d - 1, size(x, 2)) .* exp.(@view(x[1, :]) ./ 2)' return x end function Distributions._logpdf(p::Funnel, x::AbstractVector) d, μ, σ = p.dim, p.μ, p.σ lpdf1 = logpdf(Normal(μ, σ), x[1]) lpdfs = logpdf.(Normal.(zeros(T, d - 1), exp(x[1] / 2)), @view(x[2:end])) return lpdf1 + sum(lpdfs) end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
2702
using Distributions, Random, LinearAlgebra, IrrationalConstants """ WarpedGauss{T<:Real} 2-dimensional warped Gaussian distribution # Fields $(FIELDS) # Explanation The banana distribution is obtained by applying a transformation ϕ to a 2-dimensional normal distribution ``\\mathcal{N}(0, diag(\\sigma_1, \\sigma_2))``. The transformation ϕ(x) is defined as ```math ϕ(x_1, x_2) = (r*\cos(\theta + r/2), r*\sin(\theta + r/2)), ``` where ``r = \\sqrt{x\_1^2 + x_2^2}``, ``\\theta = \\atan(x₂, x₁)``, and "atan(y, x) ∈ [-π, π]" is the angle, in radians, between the positive x axis and the ray to the point "(x, y)". See page 18. of [1] for reference. # Reference [1] Zuheng Xu, Naitong Chen, Trevor Campbell "MixFlows: principled variational inference via mixed flows." International Conference on Machine Learning, 2023 """ struct WarpedGauss{T<:Real} <: ContinuousMultivariateDistribution "Standard deviation of the first dimension, must be > 0" σ1::T "Standard deviation of the second dimension, must be > 0" σ2::T function WarpedGauss{T}(σ1, σ2) where {T<:Real} σ1 > 0 || error("σ₁ must be > 0") σ2 > 0 || error("σ₂ must be > 0") return new{T}(σ1, σ2) end end WarpedGauss(σ1::T, σ2::T) where {T<:Real} = WarpedGauss{T}(σ1, σ2) WarpedGauss() = WarpedGauss(1.0, 0.12) Base.length(p::WarpedGauss) = 2 Base.eltype(p::WarpedGauss{T}) where {T<:Real} = T Distributions.sampler(p::WarpedGauss) = p # Define the transformation function φ and the inverse ϕ⁻¹ for the warped Gaussian distribution function ϕ!(p::WarpedGauss, z::AbstractVector) length(z) == 2 || error("Dimension mismatch") x, y = z r = norm(z) θ = atan(y, x) #in [-π , π] θ -= r / 2 z .= r .* [cos(θ), sin(θ)] return z end function ϕ⁻¹(p::WarpedGauss, z::AbstractVector) length(z) == 2 || error("Dimension mismatch") x, y = z r = norm(z) θ = atan(y, x) #in [-π , π] # increase θ depending on r to "smear" θ += r / 2 # get the x,y coordinates foαtransformed point xn = r * cos(θ) yn = r * sin(θ) # compute jacobian logJ = log(r) return [xn, yn], logJ end function Distributions._rand!(rng::AbstractRNG, p::WarpedGauss, x::AbstractVecOrMat) size(x, 1) == 2 || error("Dimension mismatch") σ₁, σ₂ = p.σ₁, p.σ₂ randn!(rng, x) x .*= [σ₁, σ₂] for y in eachcol(x) ϕ!(p, y) end return x end function Distributions._logpdf(p::WarpedGauss, x::AbstractVector) size(x, 1) == 2 || error("Dimension mismatch") σ₁, σ₂ = p.σ₁, p.σ₂ S = [σ₁, σ₂] .^ 2 z, logJ = ϕ⁻¹(p, x) return -sum(z .^ 2 ./ S) / 2 - IrrationalConstants.log2π - log(σ₁) - log(σ₂) + logJ end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
732
module NormalizingFlowsEnzymeExt if isdefined(Base, :get_extension) using Enzyme using NormalizingFlows using NormalizingFlows: ADTypes, DiffResults else using ..Enzyme using ..NormalizingFlows using ..NormalizingFlows: ADTypes, DiffResults end # Enzyme doesn't support f::Bijectors (see https://github.com/EnzymeAD/Enzyme.jl/issues/916) function NormalizingFlows.value_and_gradient!( ad::ADTypes.AutoEnzyme, f, θ::AbstractVector{T}, out::DiffResults.MutableDiffResult ) where {T<:Real} y = f(θ) DiffResults.value!(out, y) ∇θ = DiffResults.gradient(out) fill!(∇θ, zero(T)) Enzyme.autodiff(Enzyme.ReverseWithPrimal, f, Enzyme.Active, Enzyme.Duplicated(θ, ∇θ)) return out end end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
848
module NormalizingFlowsForwardDiffExt if isdefined(Base, :get_extension) using ForwardDiff using NormalizingFlows using NormalizingFlows: ADTypes, DiffResults else using ..ForwardDiff using ..NormalizingFlows using ..NormalizingFlows: ADTypes, DiffResults end # extract chunk size from AutoForwardDiff getchunksize(::ADTypes.AutoForwardDiff{chunksize}) where {chunksize} = chunksize function NormalizingFlows.value_and_gradient!( ad::ADTypes.AutoForwardDiff, f, θ::AbstractVector{T}, out::DiffResults.MutableDiffResult ) where {T<:Real} chunk_size = getchunksize(ad) config = if isnothing(chunk_size) ForwardDiff.GradientConfig(f, θ) else ForwardDiff.GradientConfig(f, θ, ForwardDiff.Chunk(length(θ), chunk_size)) end ForwardDiff.gradient!(out, f, θ, config) return out end end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
581
module NormalizingFlowsReverseDiffExt if isdefined(Base, :get_extension) using NormalizingFlows using NormalizingFlows: ADTypes, DiffResults using ReverseDiff else using ..NormalizingFlows using ..NormalizingFlows: ADTypes, DiffResults using ..ReverseDiff end # ReverseDiff without compiled tape function NormalizingFlows.value_and_gradient!( ad::ADTypes.AutoReverseDiff, f, θ::AbstractVector{T}, out::DiffResults.MutableDiffResult ) where {T<:Real} tp = ReverseDiff.GradientTape(f, θ) ReverseDiff.gradient!(out, tp, θ) return out end end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
578
module NormalizingFlowsZygoteExt if isdefined(Base, :get_extension) using NormalizingFlows using NormalizingFlows: ADTypes, DiffResults using Zygote else using ..NormalizingFlows using ..NormalizingFlows: ADTypes, DiffResults using ..Zygote end function NormalizingFlows.value_and_gradient!( ad::ADTypes.AutoZygote, f, θ::AbstractVector{T}, out::DiffResults.MutableDiffResult ) where {T<:Real} y, back = Zygote.pullback(f, θ) ∇θ = back(one(T)) DiffResults.value!(out, y) DiffResults.gradient!(out, first(∇θ)) return out end end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
3200
module NormalizingFlows using Bijectors using Optimisers using LinearAlgebra, Random, Distributions, StatsBase using ProgressMeter using ADTypes, DiffResults using DocStringExtensions export train_flow, elbo, loglikelihood, value_and_gradient! using ADTypes using DiffResults """ train_flow([rng::AbstractRNG, ]vo, flow, args...; kwargs...) Train the given normalizing flow `flow` by calling `optimize`. # Arguments - `rng::AbstractRNG`: random number generator - `vo`: variational objective - `flow`: normalizing flow to be trained, we recommend to define flow as `<:Bijectors.TransformedDistribution` - `args...`: additional arguments for `vo` # Keyword Arguments - `max_iters::Int=1000`: maximum number of iterations - `optimiser::Optimisers.AbstractRule=Optimisers.ADAM()`: optimiser to compute the steps - `ADbackend::ADTypes.AbstractADType=ADTypes.AutoZygote()`: automatic differentiation backend, currently supports `ADTypes.AutoZygote()`, `ADTypes.ForwardDiff()`, and `ADTypes.ReverseDiff()`. - `kwargs...`: additional keyword arguments for `optimize` (See [`optimize`](@ref) for details) # Returns - `flow_trained`: trained normalizing flow - `opt_stats`: statistics of the optimiser during the training process (See [`optimize`](@ref) for details) - `st`: optimiser state for potential continuation of training """ function train_flow(vo, flow, args...; kwargs...) return train_flow(Random.default_rng(), vo, flow, args...; kwargs...) end function train_flow( rng::AbstractRNG, vo, flow, args...; max_iters::Int=1000, optimiser::Optimisers.AbstractRule=Optimisers.ADAM(), ADbackend::ADTypes.AbstractADType, kwargs..., ) # destruct flow for explicit access to the parameters # use FunctionChains instead of simple compositions to construct the flow when many flow layers are involved # otherwise the compilation time for destructure will be too long θ_flat, re = Optimisers.destructure(flow) # Normalizing flow training loop θ_flat_trained, opt_stats, st = optimize( rng, ADbackend, vo, θ_flat, re, args...; max_iters=max_iters, optimiser=optimiser, kwargs..., ) flow_trained = re(θ_flat_trained) return flow_trained, opt_stats, st end include("train.jl") include("objectives.jl") # optional dependencies if !isdefined(Base, :get_extension) # check whether :get_extension is defined in Base using Requires end # Question: should Exts be loaded here or in train.jl? function __init__() @static if !isdefined(Base, :get_extension) @require ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" include( "../ext/NormalizingFlowsForwardDiffExt.jl" ) @require ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" include( "../ext/NormalizingFlowsReverseDiffExt.jl" ) @require Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" include( "../ext/NormalizingFlowsEnzymeExt.jl" ) @require Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" include( "../ext/NormalizingFlowsZygoteExt.jl" ) end end end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
68
include("objectives/elbo.jl") include("objectives/loglikelihood.jl")
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
5767
""" value_and_gradient!( ad::ADTypes.AbstractADType, f, θ::AbstractVector{T}, out::DiffResults.MutableDiffResult ) where {T<:Real} Compute the value and gradient of a function `f` at `θ` using the automatic differentiation backend `ad`. The result is stored in `out`. The function `f` must return a scalar value. The gradient is stored in `out` as a vector of the same length as `θ`. """ function value_and_gradient! end """ grad!( rng::AbstractRNG, ad::ADTypes.AbstractADType, vo, θ_flat::AbstractVector{<:Real}, reconstruct, out::DiffResults.MutableDiffResult, args... ) Compute the value and gradient for negation of the variational objective `vo` at `θ_flat` using the automatic differentiation backend `ad`. Default implementation is provided for `ad` where `ad` is one of `AutoZygote`, `AutoForwardDiff`, `AutoReverseDiff` (with no compiled tape), and `AutoEnzyme`. The result is stored in `out`. # Arguments - `rng::AbstractRNG`: random number generator - `ad::ADTypes.AbstractADType`: automatic differentiation backend, currently supports `ADTypes.AutoZygote()`, `ADTypes.ForwardDiff()`, and `ADTypes.ReverseDiff()`. - `vo`: variational objective - `θ_flat::AbstractVector{<:Real}`: flattened parameters of the normalizing flow - `reconstruct`: function that reconstructs the normalizing flow from the flattened parameters - `out::DiffResults.MutableDiffResult`: mutable diff result to store the value and gradient - `args...`: additional arguments for `vo` """ function grad!( rng::AbstractRNG, ad::ADTypes.AbstractADType, vo, θ_flat::AbstractVector{<:Real}, reconstruct, out::DiffResults.MutableDiffResult, args...; ) # define opt loss function loss(θ_) = -vo(rng, reconstruct(θ_), args...) # compute loss value and gradient out = value_and_gradient!(ad, loss, θ_flat, out) return out end ####################################################### # training loop for variational objectives ####################################################### function pm_next!(pm, stats::NamedTuple) return ProgressMeter.next!(pm; showvalues=[tuple(s...) for s in pairs(stats)]) end """ optimize( rng::AbstractRNG, ad::ADTypes.AbstractADType, vo, θ₀::AbstractVector{T}, re, args...; kwargs... ) Iteratively updating the parameters `θ` of the normalizing flow `re(θ)` by calling `grad!` and using the given `optimiser` to compute the steps. # Arguments - `rng::AbstractRNG`: random number generator - `ad::ADTypes.AbstractADType`: automatic differentiation backend - `vo`: variational objective - `θ₀::AbstractVector{T}`: initial parameters of the normalizing flow - `re`: function that reconstructs the normalizing flow from the flattened parameters - `args...`: additional arguments for `vo` # Keyword Arguments - `max_iters::Int=10000`: maximum number of iterations - `optimiser::Optimisers.AbstractRule=Optimisers.ADAM()`: optimiser to compute the steps - `show_progress::Bool=true`: whether to show the progress bar. The default information printed in the progress bar is the iteration number, the loss value, and the gradient norm. - `callback=nothing`: callback function with signature `cb(iter, opt_state, re, θ)` which returns a dictionary-like object of statistics to be displayed in the progress bar. re and θ are used for reconstructing the normalizing flow in case that user want to further axamine the status of the flow. - `hasconverged = (iter, opt_stats, re, θ, st) -> false`: function that checks whether the training has converged. The default is to always return false. - `prog=ProgressMeter.Progress( max_iters; desc="Training", barlen=31, showspeed=true, enabled=show_progress )`: progress bar configuration # Returns - `θ`: trained parameters of the normalizing flow - `opt_stats`: statistics of the optimiser - `st`: optimiser state for potential continuation of training """ function optimize( rng::AbstractRNG, ad::ADTypes.AbstractADType, vo, θ₀::AbstractVector{<:Real}, re, args...; max_iters::Int=10000, optimiser::Optimisers.AbstractRule=Optimisers.ADAM(), show_progress::Bool=true, callback=nothing, hasconverged=(i, stats, re, θ, st) -> false, prog=ProgressMeter.Progress( max_iters; desc="Training", barlen=31, showspeed=true, enabled=show_progress ), ) opt_stats = [] θ = copy(θ₀) diff_result = DiffResults.GradientResult(θ) # initialise optimiser state st = Optimisers.setup(optimiser, θ) # general `hasconverged(...)` approach to allow early termination. converged = false i = 1 time_elapsed = @elapsed while (i ≤ max_iters) && !converged # Compute gradient and objective value; results are stored in `diff_results` grad!(rng, ad, vo, θ, re, diff_result, args...) # Save stats ls = DiffResults.value(diff_result) g = DiffResults.gradient(diff_result) stat = (iteration=i, loss=ls, gradient_norm=norm(g)) push!(opt_stats, stat) # callback if !isnothing(callback) new_stat = callback(i, opt_stats, re, θ) stat = !isnothing(new_stat) ? merge(new_stat, stat) : stat end # update optimiser state and parameters st, θ = Optimisers.update!(st, θ, DiffResults.gradient(diff_result)) # check convergence i += 1 converged = hasconverged(i, stat, re, θ, st) pm_next!(prog, stat) end # return status of the optimiser for potential continuation of training return θ, map(identity, opt_stats), st end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
1710
#################################### # training by minimizing reverse KL #################################### function elbo_single_sample(flow::Bijectors.TransformedDistribution, logp, x) y, logabsdetjac = with_logabsdet_jacobian(flow.transform, x) return logp(y) - logpdf(flow.dist, x) + logabsdetjac end """ elbo(flow, logp, xs) elbo([rng, ]flow, logp, n_samples) Compute the ELBO for a batch of samples `xs` from the reference distribution `flow.dist`. # Arguments - `rng`: random number generator - `flow`: variational distribution to be trained. In particular `flow = transformed(q₀, T::Bijectors.Bijector)`, q₀ is a reference distribution that one can easily sample and compute logpdf - `logp`: log-pdf of the target distribution (not necessarily normalized) - `xs`: samples from reference dist q₀ - `n_samples`: number of samples from reference dist q₀ """ function elbo(flow::Bijectors.UnivariateTransformed, logp, xs::AbstractVector) elbo_values = map(x -> elbo_single_sample(flow, logp, x), xs) return mean(elbo_values) end function elbo(flow::Bijectors.MultivariateTransformed, logp, xs::AbstractMatrix) elbo_values = map(x -> elbo_single_sample(flow, logp, x), eachcol(xs)) return mean(elbo_values) end function elbo(rng::AbstractRNG, flow::Bijectors.MultivariateTransformed, logp, n_samples) return elbo(flow, logp, rand(rng, flow.dist, n_samples)) end function elbo(rng::AbstractRNG, flow::Bijectors.UnivariateTransformed, logp, n_samples) return elbo(flow, logp, rand(rng, flow.dist, n_samples)) end function elbo(flow::Bijectors.TransformedDistribution, logp, n_samples) return elbo(Random.default_rng(), flow, logp, n_samples) end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
1103
#################################### # training by minimizing forward KL (MLE) #################################### """ loglikelihood(flow::Bijectors.TransformedDistribution, xs::AbstractVecOrMat) Compute the log-likelihood for variational distribution flow at a batch of samples xs from the target distribution p. # Arguments - `flow`: variational distribution to be trained. In particular "flow = transformed(q₀, T::Bijectors.Bijector)", q₀ is a reference distribution that one can easily sample and compute logpdf - `xs`: samples from the target distribution p. """ function loglikelihood( flow::Bijectors.UnivariateTransformed, # variational distribution to be trained xs::AbstractVector, # sample batch from target dist p ) return mean(Base.Fix1(logpdf, flow), xs) end function loglikelihood( flow::Bijectors.MultivariateTransformed, # variational distribution to be trained xs::AbstractMatrix, # sample batch from target dist p ) llhs = map(x -> logpdf(flow, x), eachcol(xs)) return mean(llhs) end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
1641
@testset "AD correctness" begin f(x) = sum(abs2, x) @testset "$T" for T in [Float32, Float64] x = randn(T, 10) chunksize = size(x, 1) @testset "$at" for at in [ ADTypes.AutoZygote(), ADTypes.AutoForwardDiff(; chunksize=chunksize), ADTypes.AutoForwardDiff(), ADTypes.AutoReverseDiff(false), ADTypes.AutoEnzyme(), ] out = DiffResults.GradientResult(x) NormalizingFlows.value_and_gradient!(at, f, x, out) @test DiffResults.value(out) ≈ f(x) @test DiffResults.gradient(out) ≈ 2x end end end @testset "AD for ELBO" begin @testset "$at" for at in [ ADTypes.AutoZygote(), ADTypes.AutoForwardDiff(), ADTypes.AutoReverseDiff(false), # ADTypes.AutoEnzyme(), # not working now ] @testset "$T" for T in [Float32, Float64] μ = 10 * ones(T, 2) Σ = Diagonal(4 * ones(T, 2)) target = MvNormal(μ, Σ) logp(z) = logpdf(target, z) q₀ = MvNormal(zeros(T, 2), ones(T, 2)) flow = Bijectors.transformed(q₀, Bijectors.Shift(zero.(μ))) sample_per_iter = 10 θ, re = Optimisers.destructure(flow) out = DiffResults.GradientResult(θ) # check grad computation for elbo NormalizingFlows.grad!( Random.default_rng(), at, elbo, θ, re, out, logp, sample_per_iter ) @test DiffResults.value(out) != nothing @test all(DiffResults.gradient(out) .!= nothing) end end end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
1642
@testset "learining 2d Gaussian" begin chunksize = 4 @testset "$adtype" for adtype in [ ADTypes.AutoZygote(), ADTypes.AutoForwardDiff(; chunksize=chunksize), ADTypes.AutoForwardDiff(), ADTypes.AutoReverseDiff(false), # ADTypes.AutoEnzyme(), # doesn't work for Enzyme ] @testset "$T" for T in [Float32, Float64] μ = 10 * ones(T, 2) Σ = Diagonal(4 * ones(T, 2)) target = MvNormal(μ, Σ) logp(z) = logpdf(target, z) q₀ = MvNormal(zeros(T, 2), ones(T, 2)) flow = Bijectors.transformed( q₀, Bijectors.Shift(zero.(μ)) ∘ Bijectors.Scale(ones(T, 2)) ) sample_per_iter = 10 cb(iter, opt_stats, re, θ) = (sample_per_iter=sample_per_iter,) checkconv(iter, stat, re, θ, st) = stat.gradient_norm < 1e-3 flow_trained, stats, _ = train_flow( elbo, flow, logp, sample_per_iter; max_iters=5_000, optimiser=Optimisers.ADAM(0.01 * one(T)), ADbackend=adtype, show_progress=false, callback=cb, hasconverged=checkconv, ) θ, re = Optimisers.destructure(flow_trained) el_untrained = elbo(flow, logp, 1000) el_trained = elbo(flow_trained, logp, 1000) @test all(abs.(θ[1:2] .- μ) .< 0.2) @test all(abs.(θ[3:4] .- 2) .< 0.2) @test el_trained > el_untrained @test el_trained > -1 end end end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
932
@testset "variational objectives" begin @testset "$T" for T in [Float32, Float64] μ = randn(T, 2) Σ = Diagonal(rand(T, 2) .+ T(1e-3)) target = MvNormal(μ, Σ) logp(z) = logpdf(target, z) q₀ = MvNormal(zeros(T, 2), ones(T, 2)) flow = Bijectors.transformed(q₀, Bijectors.Shift(μ) ∘ Bijectors.Scale(sqrt.(Σ))) x = randn(T, 2) @testset "elbo" begin el = elbo(Random.default_rng(), flow, logp, 10) @test abs(el) ≤ 1e-5 @test logpdf(flow, x) + el ≈ logp(x) end @testset "likelihood" begin sample_trained = rand(flow, 1000) sample_untrained = rand(q₀, 1000) llh_trained = NormalizingFlows.loglikelihood(flow, sample_trained) llh_untrained = NormalizingFlows.loglikelihood(flow, sample_untrained) @test llh_trained > llh_untrained end end end
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
code
255
using NormalizingFlows using Distributions using Bijectors, Optimisers using LinearAlgebra using Random using ADTypes, DiffResults using ForwardDiff, Zygote, Enzyme, ReverseDiff using Test include("ad.jl") include("objectives.jl") include("interface.jl")
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
docs
5041
# NormalizingFlows.jl [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://turinglang.github.io/NormalizingFlows.jl/dev/) [![Build Status](https://github.com/TuringLang/NormalizingFlows.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/TuringLang/NormalizingFlows.jl/actions/workflows/CI.yml?query=branch%3Amain) **Last updated: 2023-Aug-23** A normalizing flow library for Julia. The purpose of this package is to provide a simple and flexible interface for variational inference (VI) and normalizing flows (NF) for Bayesian computation or generative modeling. The key focus is to ensure modularity and extensibility, so that users can easily construct (e.g., define customized flow layers) and combine various components (e.g., choose different VI objectives or gradient estimates) for variational approximation of general target distributions, without being tied to specific probabilistic programming frameworks or applications. See the [documentation](https://turinglang.org/NormalizingFlows.jl/dev/) for more. ## Installation To install the package, run the following command in the Julia REPL: ```julia ] # enter Pkg mode (@v1.9) pkg> add [email protected]:TuringLang/NormalizingFlows.jl.git ``` Then simply run the following command to use the package: ```julia using NormalizingFlows ``` ## Quick recap of normalizing flows Normalizing flows transform a simple reference distribution $q_0$ (sometimes known as base distribution) to a complex distribution $q$ using invertible functions. In more details, given the base distribution, usually a standard Gaussian distribution, i.e., $q_0 = \mathcal{N}(0, I)$, we apply a series of parameterized invertible transformations (called flow layers), $T_{1, \theta_1}, \cdots, T_{N, \theta_k}$, yielding that ```math Z_N = T_{N, \theta_N} \circ \cdots \circ T_{1, \theta_1} (Z_0) , \quad Z_0 \sim q_0,\quad Z_N \sim q_{\theta}, ``` where $\theta = (\theta_1, \dots, \theta_N)$ is the parameter to be learned, and $q_{\theta}$ is the variational distribution (flow distribution). This describes **sampling procedure** of normalizing flows, which requires sending draws through a forward pass of these flow layers. Since all the transformations are invertible (technically [diffeomorphic](https://en.wikipedia.org/wiki/Diffeomorphism)), we can evaluate the density of a normalizing flow distribution $q_{\theta}$ by the change of variable formula: ```math q_\theta(x)=\frac{q_0\left(T_1^{-1} \circ \cdots \circ T_N^{-1}(x)\right)}{\prod_{n=1}^N J_n\left(T_n^{-1} \circ \cdots \circ T_N^{-1}(x)\right)} \quad J_n(x)=\left|\text{det} \nabla_x T_n(x)\right|. ``` Here we drop the subscript $\theta_n, n = 1, \dots, N$ for simplicity. Density evaluation of normalizing flow requires computing the **inverse** and the **Jacobian determinant** of each flow layer. Given the feasibility of i.i.d. sampling and density evaluation, normalizing flows can be trained by minimizing some statistical distances to the target distribution $p$. The typical choice of the statistical distance is the forward and backward Kullback-Leibler (KL) divergence, which leads to the following optimization problems: ```math \begin{aligned} \text{Reverse KL:}\quad &\arg\min _{\theta} \mathbb{E}_{q_{\theta}}\left[\log q_{\theta}(Z)-\log p(Z)\right] \\ &= \arg\min _{\theta} \mathbb{E}_{q_0}\left[\log \frac{q_\theta(T_N\circ \cdots \circ T_1(Z_0))}{p(T_N\circ \cdots \circ T_1(Z_0))}\right] \\ &= \arg\max _{\theta} \mathbb{E}_{q_0}\left[ \log p\left(T_N \circ \cdots \circ T_1(Z_0)\right)-\log q_0(X)+\sum_{n=1}^N \log J_n\left(F_n \circ \cdots \circ F_1(X)\right)\right] \end{aligned} ``` and ```math \begin{aligned} \text{Forward KL:}\quad &\arg\min _{\theta} \mathbb{E}_{p}\left[\log q_{\theta}(Z)-\log p(Z)\right] \\ &= \arg\min _{\theta} \mathbb{E}_{p}\left[\log q_\theta(Z)\right] \end{aligned} ``` Both problems can be solved via standard stochastic optimization algorithms, such as stochastic gradient descent (SGD) and its variants. Reverse KL minimization is typically used for **Bayesian computation**, where one wants to approximate a posterior distribution $p$ that is only known up to a normalizing constant. In contrast, forward KL minimization is typically used for **generative modeling**, where one wants to learn the underlying distribution of some data. ## Current status and TODOs - [x] general interface development - [x] documentation - [ ] including more NF examples/Tutorials - WIP: [PR#11](https://github.com/TuringLang/NormalizingFlows.jl/pull/11) - [ ] GPU compatibility - WIP: [PR#25](https://github.com/TuringLang/NormalizingFlows.jl/pull/25) - [ ] benchmarking ## Related packages - [Bijectors.jl](https://github.com/TuringLang/Bijectors.jl): a package for defining bijective transformations, which can be used for defining customized flow layers. - [Flux.jl](https://fluxml.ai/Flux.jl/stable/) - [Optimisers.jl](https://github.com/FluxML/Optimisers.jl) - [AdvancedVI.jl](https://github.com/TuringLang/AdvancedVI.jl)
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
docs
2937
## API ```@index ``` ## Main Function ```@docs NormalizingFlows.train_flow ``` The flow object can be constructed by `transformed` function in `Bijectors.jl` package. For example of Gaussian VI, we can construct the flow as follows: ```@julia using Distributions, Bijectors T= Float32 q₀ = MvNormal(zeros(T, 2), ones(T, 2)) flow = Bijectors.transformed(q₀, Bijectors.Shift(zeros(T,2)) ∘ Bijectors.Scale(ones(T, 2))) ``` To train the Gaussian VI targeting at distirbution $p$ via ELBO maiximization, we can run ```@julia using NormalizingFlows sample_per_iter = 10 flow_trained, stats, _ = train_flow( elbo, flow, logp, sample_per_iter; max_iters=2_000, optimiser=Optimisers.ADAM(0.01 * one(T)), ) ``` ## Variational Objectives We have implemented two variational objectives, namely, ELBO and the log-likelihood objective. Users can also define their own objective functions, and pass it to the [`train_flow`](@ref) function. `train_flow` will optimize the flow parameters by maximizing `vo`. The objective function should take the following general form: ```julia vo(rng, flow, args...) ``` where `rng` is the random number generator, `flow` is the flow object, and `args...` are the additional arguments that users can pass to the objective function. #### Evidence Lower Bound (ELBO) By maximizing the ELBO, it is equivalent to minimizing the reverse KL divergence between $q_\theta$ and $p$, i.e., ```math \begin{aligned} &\min _{\theta} \mathbb{E}_{q_{\theta}}\left[\log q_{\theta}(Z)-\log p(Z)\right] \quad \text{(Reverse KL)}\\ & = \max _{\theta} \mathbb{E}_{q_0}\left[ \log p\left(T_N \circ \cdots \circ T_1(Z_0)\right)-\log q_0(X)+\sum_{n=1}^N \log J_n\left(F_n \circ \cdots \circ F_1(X)\right)\right] \quad \text{(ELBO)} \end{aligned} ``` Reverse KL minimization is typically used for **Bayesian computation**, where one only has access to the log-(unnormalized)density of the target distribution $p$ (e.g., a Bayesian posterior distribution), and hope to generate approximate samples from it. ```@docs NormalizingFlows.elbo ``` #### Log-likelihood By maximizing the log-likelihood, it is equivalent to minimizing the forward KL divergence between $q_\theta$ and $p$, i.e., ```math \begin{aligned} & \min_{\theta} \mathbb{E}_{p}\left[\log q_{\theta}(Z)-\log p(Z)\right] \quad \text{(Forward KL)} \\ & = \max_{\theta} \mathbb{E}_{p}\left[\log q_{\theta}(Z)\right] \quad \text{(Expected log-likelihood)} \end{aligned} ``` Forward KL minimization is typically used for **generative modeling**, where one is given a set of samples from the target distribution $p$ (e.g., images) and aims to learn the density or a generative process that outputs high quality samples. ```@docs NormalizingFlows.loglikelihood ``` ## Training Loop ```@docs NormalizingFlows.optimize ``` ## Utility Functions for Taking Gradient ```@docs NormalizingFlows.grad! NormalizingFlows.value_and_gradient! ```
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git
[ "MIT" ]
0.1.0
d2362147a98d73e1c6a42584844f97d1da35b94c
docs
7292
# Defining Your Own Flow Layer In practice, user might want to define their own normalizing flow. As briefly noted in [What are normalizing flows?](@ref), the key is to define a customized normalizing flow layer, including its transformation and inverse, as well as the log-determinant of the Jacobian of the transformation. `Bijectors.jl` offers a convenient interface to define a customized bijection. We refer users to [the documentation of `Bijectors.jl`](https://turinglang.org/Bijectors.jl/dev/transforms/#Implementing-a-transformation) for more details. `Flux.jl` is also a useful package, offering a convenient interface to define neural networks. In this tutorial, we demonstrate how to define a customized normalizing flow layer -- an `Affine Coupling Layer` (Dinh *et al.*, 2016) -- using `Bijectors.jl` and `Flux.jl`. ## Affine Coupling Flow Given an input vector $\boldsymbol{x}$, the general *coupling transformation* splits it into two parts: $\boldsymbol{x}_{I_1}$ and $\boldsymbol{x}_{I\setminus I_1}$. Only one part (e.g., $\boldsymbol{x}_{I_1}$) undergoes a bijective transformation $f$, noted as the *coupling law*, based on the values of the other part (e.g., $\boldsymbol{x}_{I\setminus I_1}$), which remains unchanged. ```math \begin{array}{llll} c_{I_1}(\cdot ; f, \theta): & \mathbb{R}^d \rightarrow \mathbb{R}^d & c_{I_1}^{-1}(\cdot ; f, \theta): & \mathbb{R}^d \rightarrow \mathbb{R}^d \\ & \boldsymbol{x}_{I \backslash I_1} \mapsto \boldsymbol{x}_{I \backslash I_1} & & \boldsymbol{y}_{I \backslash I_1} \mapsto \boldsymbol{y}_{I \backslash I_1} \\ & \boldsymbol{x}_{I_1} \mapsto f\left(\boldsymbol{x}_{I_1} ; \theta\left(\boldsymbol{x}_{I\setminus I_1}\right)\right) & & \boldsymbol{y}_{I_1} \mapsto f^{-1}\left(\boldsymbol{y}_{I_1} ; \theta\left(\boldsymbol{y}_{I\setminus I_1}\right)\right) \end{array} ``` Here $\theta$ can be an arbitrary function, e.g., a neural network. As long as $f(\cdot; \theta(\boldsymbol{x}_{I\setminus I_1}))$ is invertible, $c_{I_1}$ is invertible, and the Jacobian determinant of $c_{I_1}$ is easy to compute: ```math \left|\text{det} \nabla_x c_{I_1}(x)\right| = \left|\text{det} \nabla_{x_{I_1}} f(x_{I_1}; \theta(x_{I\setminus I_1}))\right| ``` The affine coupling layer is a special case of the coupling transformation, where the coupling law $f$ is an affine function: ```math \begin{aligned} \boldsymbol{x}_{I_1} &\mapsto \boldsymbol{x}_{I_1} \odot s\left(\boldsymbol{x}_{I\setminus I_1}\right) + t\left(\boldsymbol{x}_{I \setminus I_1}\right) \\ \boldsymbol{x}_{I \backslash I_1} &\mapsto \boldsymbol{x}_{I \backslash I_1} \end{aligned} ``` Here, $s$ and $t$ are arbitrary functions (often neural networks) called the "scaling" and "translation" functions, respectively. They produce vectors of the same dimension as $\boldsymbol{x}_{I_1}$. ## Implementing Affine Coupling Layer We start by defining a simple 3-layer multi-layer perceptron (MLP) using `Flux.jl`, which will be used to define the scaling $s$ and translation functions $t$ in the affine coupling layer. ```@example afc using Flux function MLP_3layer(input_dim::Int, hdims::Int, output_dim::Int; activation=Flux.leakyrelu) return Chain( Flux.Dense(input_dim, hdims, activation), Flux.Dense(hdims, hdims, activation), Flux.Dense(hdims, output_dim), ) end ``` #### Construct the Object Following the user interface of `Bijectors.jl`, we define a struct `AffineCoupling` as a subtype of `Bijectors.Bijector`. The functions `parition` , `combine` are used to partition and recombine a vector into 3 disjoint subvectors. And `PartitionMask` is used to store this partition rule. These three functions are all defined in `Bijectors.jl`; see the [documentaion](https://github.com/TuringLang/Bijectors.jl/blob/49c138fddd3561c893592a75b211ff6ad949e859/src/bijectors/coupling.jl#L3) for more details. ```@example afc using Functors using Bijectors using Bijectors: partition, combine, PartitionMask struct AffineCoupling <: Bijectors.Bijector dim::Int mask::Bijectors.PartitionMask s::Flux.Chain t::Flux.Chain end # to apply functions to the parameters that are contained in AffineCoupling.s and AffineCoupling.t, # and to re-build the struct from the parameters, we use the functor interface of `Functors.jl` # see https://fluxml.ai/Flux.jl/stable/models/functors/#Functors.functor @functor AffineCoupling (s, t) function AffineCoupling( dim::Int, # dimension of input hdims::Int, # dimension of hidden units for s and t mask_idx::AbstractVector, # index of dimension that one wants to apply transformations on ) cdims = length(mask_idx) # dimension of parts used to construct coupling law s = MLP_3layer(cdims, hdims, cdims) t = MLP_3layer(cdims, hdims, cdims) mask = PartitionMask(dim, mask_idx) return AffineCoupling(dim, mask, s, t) end ``` By default, we define $s$ and $t$ using the `MLP_3layer` function, which is a 3-layer MLP with leaky ReLU activation function. #### Implement the Forward and Inverse Transformations ```@example afc function Bijectors.transform(af::AffineCoupling, x::AbstractVector) # partition vector using 'af.mask::PartitionMask` x₁, x₂, x₃ = partition(af.mask, x) y₁ = x₁ .* af.s(x₂) .+ af.t(x₂) return combine(af.mask, y₁, x₂, x₃) end function Bijectors.transform(iaf::Inverse{<:AffineCoupling}, y::AbstractVector) af = iaf.orig # partition vector using `af.mask::PartitionMask` y_1, y_2, y_3 = partition(af.mask, y) # inverse transformation x_1 = (y_1 .- af.t(y_2)) ./ af.s(y_2) return combine(af.mask, x_1, y_2, y_3) end ``` #### Implement the Log-determinant of the Jacobian Notice that here we wrap the transformation and the log-determinant of the Jacobian into a single function, `with_logabsdet_jacobian`. ```@example afc function Bijectors.with_logabsdet_jacobian(af::AffineCoupling, x::AbstractVector) x_1, x_2, x_3 = Bijectors.partition(af.mask, x) y_1 = af.s(x_2) .* x_1 .+ af.t(x_2) logjac = sum(log ∘ abs, af.s(x_2)) return combine(af.mask, y_1, x_2, x_3), logjac end function Bijectors.with_logabsdet_jacobian( iaf::Inverse{<:AffineCoupling}, y::AbstractVector ) af = iaf.orig # partition vector using `af.mask::PartitionMask` y_1, y_2, y_3 = partition(af.mask, y) # inverse transformation x_1 = (y_1 .- af.t(y_2)) ./ af.s(y_2) logjac = -sum(log ∘ abs, af.s(y_2)) return combine(af.mask, x_1, y_2, y_3), logjac end ``` #### Construct Normalizing Flow Now with all the above implementations, we are ready to use the `AffineCoupling` layer for normalizing flow by applying it to a base distribution $q_0$. ```@example afc using Random, Distributions, LinearAlgebra dim = 4 hdims = 10 Ls = [ AffineCoupling(dim, hdims, 1:2), AffineCoupling(dim, hdims, 3:4), AffineCoupling(dim, hdims, 1:2), AffineCoupling(dim, hdims, 3:4), ] ts = reduce(∘, Ls) q₀ = MvNormal(zeros(Float32, dim), I) flow = Bijectors.transformed(q₀, ts) ``` We can now sample from the flow: ```@example afc x = rand(flow, 10) ``` And evaluate the density of the flow: ```@example afc logpdf(flow, x[:,1]) ``` ## Reference Dinh, L., Sohl-Dickstein, J. and Bengio, S., 2016. *Density estimation using real nvp.* arXiv:1605.08803.
NormalizingFlows
https://github.com/TuringLang/NormalizingFlows.jl.git