Skip to content

Commit

Permalink
Int64 -> Int to work on 32bit
Browse files Browse the repository at this point in the history
  • Loading branch information
PGS62 committed Apr 5, 2024
1 parent a1d9ae9 commit 951b391
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/pairwise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ presence `missing`, `NaN` or `Inf` entries.
Only allowed when entries in `x` and `y` are vectors.
# Examples
```jldoctest
```julia-repl
julia> using StatsBase, Statistics
julia> dest = zeros(3, 3);
Expand Down Expand Up @@ -287,7 +287,7 @@ presence `missing`, `NaN` or `Inf` entries.
Only allowed when entries in `x` and `y` are vectors.
# Examples
```jldoctest
```julia-repl
julia> using StatsBase, Statistics
julia> x = [1 3 7
Expand Down Expand Up @@ -432,8 +432,8 @@ true
```
"""
struct EqualSumSubsets
n::Int64
num_subsets::Int64
n::Int
num_subsets::Int

function EqualSumSubsets(n, num_subsets)
n >= 0 || throw("n must not be negative, but got $n")
Expand All @@ -447,12 +447,12 @@ Base.eltype(::EqualSumSubsets) = TwoStepRange
Base.length(x::EqualSumSubsets) = min(x.n, x.num_subsets)
Base.firstindex(::EqualSumSubsets) = 1

function Base.iterate(ess::EqualSumSubsets, state::Int64=1)
function Base.iterate(ess::EqualSumSubsets, state::Int=1)
state > length(ess) && return nothing
return getindex(ess, state), state + 1
end

function Base.getindex(ess::EqualSumSubsets, i::Int64=1)
function Base.getindex(ess::EqualSumSubsets, i::Int=1)
n, nss = ess.n, ess.num_subsets
step1 = 2i - 2nss - 1
step2 = 1 - 2i
Expand All @@ -467,7 +467,7 @@ between `step1` and `step2`. `start` must be positive and `step1` and `step2` mu
negative.
# Examples
```jldoctest
```julia-repl
julia> collect(StatsBase.TwoStepRange(30,-7,-3))
6-element Vector{Int64}:
30
Expand All @@ -480,9 +480,9 @@ julia> collect(StatsBase.TwoStepRange(30,-7,-3))
```
"""
struct TwoStepRange
start::Int64
step1::Int64
step2::Int64
start::Int
step1::Int
step2::Int

function TwoStepRange(start, step1, step2)
start > 0 || throw("start must be positive, but got $start")
Expand All @@ -492,19 +492,19 @@ struct TwoStepRange
end
end

Base.eltype(::TwoStepRange) = Int64
Base.eltype(::TwoStepRange) = Int

function Base.length(tsr::TwoStepRange)
return length((tsr.start):(tsr.step1+tsr.step2):1) +
length((tsr.start+tsr.step1):(tsr.step1+tsr.step2):1)
end

function Base.iterate(tsr::TwoStepRange, i::Int64=1)
function Base.iterate(tsr::TwoStepRange, i::Int=1)
(i > length(tsr)) && return nothing
return getindex(tsr, i), i + 1
end

function Base.getindex(tsr::TwoStepRange, i::Int64=1)::Int64
function Base.getindex(tsr::TwoStepRange, i::Int=1)::Int
a, b = divrem(i - 1, 2)
return tsr.start + (tsr.step1 + tsr.step2) * a + b * tsr.step1
end

0 comments on commit 951b391

Please sign in to comment.