Skip to content

Commit

Permalink
use size in general
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed Sep 23, 2024
1 parent 0e9514f commit 4771558
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/matrices/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function coordinates(R::SparseMatrixCSC) # TODO: allow scan every ÷100 elements
is = zeros(Int, nnz(R))
js = zeros(Int, nnz(R))
k = 1;
m, n = oldsize(R)
m, n = size(R)
for j = 1:n
for i in nzrange(R, j)
is[k] = j
Expand Down Expand Up @@ -56,7 +56,7 @@ function recurrenceplot(io::IO, R::Union{ARM,SparseMatrixCSC}; minh = 25, maxh =
end

is, js = coordinates(R)
n, m = oldsize(R)
n, m = size(R)

if ascii == true
asciidef = (border = :ascii, canvas = DotCanvas)
Expand Down Expand Up @@ -121,7 +121,7 @@ end
# Calculate the level of "gray" (0=white, 1=black) corresponding to a matrix block
function block2grayscale(R, rind::Tuple{T,T}, cind::Tuple{T,T}) where T<:Integer
submat = @view R[rind[1]:rind[2], cind[1]:cind[2]]
ratio = count(!iszero, submat)/prod(oldsize(submat))
ratio = count(!iszero, submat)/prod(size(submat))
end

"""
Expand Down Expand Up @@ -161,7 +161,7 @@ function grayscale(R, bwcode::Tuple{TT,T}=(0.0,1.0);
width = nothing, height = nothing, exactsize=false
) where {TT<:Real, T<:Real}

dims = oldsize(R)
dims = size(R)
if !isnothing(width) && isnothing(height)
height = round(Int, width*dims[2]/dims[1])
return grayscale(R, bwcode; width=width, height=height)
Expand Down
2 changes: 1 addition & 1 deletion src/matrices/recurrence_matrix_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
# Pretty printing:
function Base.summary(R::AbstractRecurrenceMatrix)
N = nnz(R.data)
return "$(oldsize(R.data)) $(nameof(typeof(R))) "*
return "$(size(R.data)) $(nameof(typeof(R))) "*
"with $N recurrences of type $(nameof(typeof(R.recurrence_type)))."
end
Base.show(io::IO, R::AbstractRecurrenceMatrix) = println(io, summary(R))
Expand Down
18 changes: 9 additions & 9 deletions src/matrices/skeletonization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function skeletonize(X::Union{ARM,SparseMatrixCSC})

# create a close returns map with horizontal lines represented by
# numbers, equal to their lengths
X_vertical1 = create_close_returns_map(lines_copy1t, lines_copy1l, lines_copy1c, oldsize(X_cl1))
X_vertical1 = create_close_returns_map(lines_copy1t, lines_copy1l, lines_copy1c, size(X_cl1))

else
symm = false
Expand All @@ -47,8 +47,8 @@ function skeletonize(X::Union{ARM,SparseMatrixCSC})

# create close returns maps with horizontal lines represented by
# numbers, equal to their lengths
X_vertical1 = create_close_returns_map(lines_copy1t, lines_copy1l, lines_copy1c, oldsize(X_cl1))
X_vertical2 = create_close_returns_map(lines_copy2t, lines_copy2l, lines_copy2c, oldsize(X_cl2))
X_vertical1 = create_close_returns_map(lines_copy1t, lines_copy1l, lines_copy1c, size(X_cl1))
X_vertical2 = create_close_returns_map(lines_copy2t, lines_copy2l, lines_copy2c, size(X_cl2))
end

# scan the lines, start with the longest one and discard all adjacent lines
Expand All @@ -58,10 +58,10 @@ function skeletonize(X::Union{ARM,SparseMatrixCSC})
if !symm
lines_final2_t, lines_final2_l, lines_final2_c = get_final_line_matrix(lines2t, lines2l, lines2c, lines_copy2t, lines_copy2l, lines_copy2c, X_vertical2)
# build RP based on the histogramm of the reduced lines
X_new = build_skeletonized_RP(lines_final_t, lines_final_l, lines_final_c, lines_final2_t, lines_final2_l, lines_final2_c, oldsize(X_vertical1,1), oldsize(X_vertical1,2))
X_new = build_skeletonized_RP(lines_final_t, lines_final_l, lines_final_c, lines_final2_t, lines_final2_l, lines_final2_c, size(X_vertical1,1), size(X_vertical1,2))
else
# build RP based on the histogramm of the reduced lines
X_new = build_skeletonized_RP(lines_final_t, lines_final_l, lines_final_c, oldsize(X_vertical1,1), oldsize(X_vertical1,2))
X_new = build_skeletonized_RP(lines_final_t, lines_final_l, lines_final_c, size(X_vertical1,1), size(X_vertical1,2))
end
return X_new
end
Expand All @@ -70,7 +70,7 @@ end

# Transforms the standard RP into a close returns map
function create_close_returns_map(R::SparseMatrixCSC; triangle::Bool = true)
nr = oldsize(R, 1)
nr = size(R, 1)
nrplus = nr+1
rowvalues = rowvals(R)
diagvalues = nrplus .+ colvals(R) .- rowvalues # LOI at nrplus (nr+1)
Expand Down Expand Up @@ -103,7 +103,7 @@ end

# Transforms the reverted RP (close returns map) into a normal RP
function revert_close_returns_map(R::SparseMatrixCSC; triangle::Bool = true)
nr = oldsize(R, 1)
nr = size(R, 1)
rowvalues = rowvals(R)
columnvalues = rowvalues .+ colvals(R) .- (nr + 1)
if triangle
Expand Down Expand Up @@ -168,7 +168,7 @@ function get_final_line_matrix(lines1t::Vector{Int}, lines1l::Vector{Int},
lines1c::Vector{Int}, lines_copy1t::Vector{Int}, lines_copy1l::Vector{Int},
lines_copy1c::Vector{Int}, X_vertical1::SparseMatrixCSC)

N, M = oldsize(X_vertical1)
N, M = size(X_vertical1)
# initialize final lines
lines_final_t = Int[]
lines_final_l = Int[]
Expand Down Expand Up @@ -309,7 +309,7 @@ function scan_lines!(XX::SparseMatrixCSC, l_vec1::AbstractVector{<:Integer}, l_v
end

function neighborindices(XX, i::T, li::T, co::T) where T<:Integer
N, M = oldsize(XX)
N, M = size(XX)
for newli in (li+i .+ (-2:0)), newco in (co-1, co+1)
if (1 newli N) && (1 newco M)
(XX[newli, newco] != 0) && return (newli, newco)
Expand Down

0 comments on commit 4771558

Please sign in to comment.