Skip to content

Commit

Permalink
remove matrix multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoms committed Jan 8, 2025
1 parent 358391d commit d18b9ec
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/nonlocal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,27 @@ Base.@propagate_inbounds function _local_bound_correlation_recursive(
return score
end

function _tensor_contraction!(tmp, A::Matrix{T}, ax::Vector{T}) where {T<:Real}
@inbounds mul!(tmp, A, ax)
end
#function _tensor_contraction!(tmp, A::Matrix{T}, ax::Vector{T}) where {T<:Real}
# @inbounds mul!(tmp, A, ax)
#end

# among ci/x orders in the loop and in the indexing,
# this is the fastest contraction, hence the enumeration order
function _tensor_contraction!(tmp, A::Array{T,N}, ax::Vector{T}) where {T<:Real,N}
#function _tensor_contraction!(tmp, A::Array{T,N}, ax::Vector{T}) where {T<:Real,N}
# tmp .= 0
# @inbounds for x in eachindex(ax), ci in CartesianIndices(tmp)
# tmp[ci] += A[ci, x] * ax[x]
# end
#end

function _tensor_contraction!(tmp, A::Array{T,N}, ax) where {T<:Number,N}
tmp .= 0
@inbounds for x in eachindex(ax), ci in CartesianIndices(tmp)
tmp[ci] += A[ci, x] * ax[x]
@inbounds for x eachindex(ax)
if ax[x] == 1
for ci CartesianIndices(tmp)
tmp[ci] += A[ci, x]
end
end
end
end

Expand Down

0 comments on commit d18b9ec

Please sign in to comment.