Skip to content

Commit 1736367

Browse files
committed
eliminate polyester
1 parent e16cc7b commit 1736367

File tree

2 files changed

+52
-54
lines changed

2 files changed

+52
-54
lines changed

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
2727
MatrixEquations = "99c1a7ee-ab34-5fd5-8076-27c950a045f4"
2828
NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd"
2929
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
30-
Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588"
3130
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
3231
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
3332
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
@@ -83,7 +82,6 @@ MatrixEquations = "2"
8382
NLopt = "0.6, 1"
8483
Optim = "1"
8584
Pigeons = "0.3, 0.4"
86-
Polyester = "0.7"
8785
PrecompileTools = "1"
8886
Preferences = "1"
8987
PythonCall = "0.9"

src/MacroModelling.jl

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ backend = 𝒟.AutoForwardDiff()
3030
# 𝒷 = Diffractor.DiffractorForwardBackend
3131

3232
import LoopVectorization: @turbo
33-
import Polyester
33+
# import Polyester
3434
import NLopt
3535
import Optim, LineSearches
3636
# import Zygote
@@ -1659,66 +1659,66 @@ function compressed_kron³(a::AbstractMatrix{T};
16591659
end
16601660

16611661

1662-
function kron³(A::AbstractSparseMatrix{T}, M₃::third_order_auxiliary_matrices) where T <: Real
1663-
rows, cols, vals = findnz(A)
1662+
# function kron³(A::AbstractSparseMatrix{T}, M₃::third_order_auxiliary_matrices) where T <: Real
1663+
# rows, cols, vals = findnz(A)
16641664

1665-
# Dictionary to accumulate sums of values for each coordinate
1666-
result_dict = Dict{Tuple{Int, Int}, T}()
1665+
# # Dictionary to accumulate sums of values for each coordinate
1666+
# result_dict = Dict{Tuple{Int, Int}, T}()
16671667

1668-
# Using a single iteration over non-zero elements
1669-
nvals = length(vals)
1668+
# # Using a single iteration over non-zero elements
1669+
# nvals = length(vals)
16701670

1671-
lk = ReentrantLock()
1671+
# lk = ReentrantLock()
16721672

1673-
Polyester.@batch for i in 1:nvals
1674-
# for i in 1:nvals
1675-
for j in 1:nvals
1676-
for k in 1:nvals
1677-
r1, c1, v1 = rows[i], cols[i], vals[i]
1678-
r2, c2, v2 = rows[j], cols[j], vals[j]
1679-
r3, c3, v3 = rows[k], cols[k], vals[k]
1673+
# Polyester.@batch for i in 1:nvals
1674+
# # for i in 1:nvals
1675+
# for j in 1:nvals
1676+
# for k in 1:nvals
1677+
# r1, c1, v1 = rows[i], cols[i], vals[i]
1678+
# r2, c2, v2 = rows[j], cols[j], vals[j]
1679+
# r3, c3, v3 = rows[k], cols[k], vals[k]
16801680

1681-
sorted_cols = [c1, c2, c3]
1682-
sorted_rows = [r1, r2, r3] # a lot of time spent here
1683-
sort!(sorted_rows, rev = true) # a lot of time spent here
1681+
# sorted_cols = [c1, c2, c3]
1682+
# sorted_rows = [r1, r2, r3] # a lot of time spent here
1683+
# sort!(sorted_rows, rev = true) # a lot of time spent here
16841684

1685-
if haskey(M₃.𝐈₃, sorted_cols) # && haskey(M₃.𝐈₃, sorted_rows) # a lot of time spent here
1686-
row_idx = M₃.𝐈₃[sorted_rows]
1687-
col_idx = M₃.𝐈₃[sorted_cols]
1688-
1689-
key = (row_idx, col_idx)
1690-
1691-
# begin
1692-
# lock(lk)
1693-
# try
1694-
if haskey(result_dict, key)
1695-
result_dict[key] += v1 * v2 * v3
1696-
else
1697-
result_dict[key] = v1 * v2 * v3
1698-
end
1699-
# finally
1700-
# unlock(lk)
1701-
# end
1702-
# end
1703-
end
1704-
end
1705-
end
1706-
end
1685+
# if haskey(M₃.𝐈₃, sorted_cols) # && haskey(M₃.𝐈₃, sorted_rows) # a lot of time spent here
1686+
# row_idx = M₃.𝐈₃[sorted_rows]
1687+
# col_idx = M₃.𝐈₃[sorted_cols]
1688+
1689+
# key = (row_idx, col_idx)
1690+
1691+
# # begin
1692+
# # lock(lk)
1693+
# # try
1694+
# if haskey(result_dict, key)
1695+
# result_dict[key] += v1 * v2 * v3
1696+
# else
1697+
# result_dict[key] = v1 * v2 * v3
1698+
# end
1699+
# # finally
1700+
# # unlock(lk)
1701+
# # end
1702+
# # end
1703+
# end
1704+
# end
1705+
# end
1706+
# end
17071707

1708-
# Extract indices and values from the dictionary
1709-
result_rows = Int[]
1710-
result_cols = Int[]
1711-
result_vals = T[]
1708+
# # Extract indices and values from the dictionary
1709+
# result_rows = Int[]
1710+
# result_cols = Int[]
1711+
# result_vals = T[]
17121712

1713-
for (ks, valu) in result_dict
1714-
push!(result_rows, ks[1])
1715-
push!(result_cols, ks[2])
1716-
push!(result_vals, valu)
1717-
end
1713+
# for (ks, valu) in result_dict
1714+
# push!(result_rows, ks[1])
1715+
# push!(result_cols, ks[2])
1716+
# push!(result_vals, valu)
1717+
# end
17181718

1719-
# Create the sparse matrix from the collected indices and values
1720-
return sparse!(result_rows, result_cols, result_vals, size(M₃.𝐂₃, 2), size(M₃.𝐔₃, 1))
1721-
end
1719+
# # Create the sparse matrix from the collected indices and values
1720+
# return sparse!(result_rows, result_cols, result_vals, size(M₃.𝐂₃, 2), size(M₃.𝐔₃, 1))
1721+
# end
17221722

17231723
function A_mult_kron_power_3_B(A::AbstractSparseMatrix{R},
17241724
B::Union{ℒ.Adjoint{T,Matrix{T}},DenseMatrix{T}};

0 commit comments

Comments
 (0)