@@ -30,7 +30,7 @@ backend = 𝒟.AutoForwardDiff()
3030# 𝒷 = Diffractor.DiffractorForwardBackend
3131
3232import LoopVectorization: @turbo
33- import Polyester
33+ # import Polyester
3434import NLopt
3535import Optim, LineSearches
3636# import Zygote
@@ -1659,66 +1659,66 @@ function compressed_kron³(a::AbstractMatrix{T};
16591659end
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
17231723function A_mult_kron_power_3_B (A:: AbstractSparseMatrix{R} ,
17241724 B:: Union{ℒ.Adjoint{T,Matrix{T}},DenseMatrix{T}} ;
0 commit comments