Skip to content

Commit fc01e69

Browse files
blegatodow
authored andcommitted
operate! with add_dot
1 parent 08e00c0 commit fc01e69

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/implementations/BigInt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function operate_to!(
132132
return operate!(op, output, c...)
133133
end
134134

135-
function operate!(op::Function, x::BigInt, args::Vararg{Any,N}) where {N}
135+
function operate_fallback!(op::Function, x::BigInt, args::Vararg{Any,N}) where {N}
136136
return operate_to!(x, op, x, args...)
137137
end
138138

src/interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ function promote_operation_fallback(
755755
::Type{<:AbstractArray{A}},
756756
::Type{<:AbstractArray{B}},
757757
) where {A,B}
758-
C = promote_operation(*, A, B)
758+
C = promote_operation(LinearAlgebra.dot, A, B)
759759
return promote_operation(+, C, C)
760760
end
761761

src/reduce.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,21 @@ end
3939

4040
_concrete_eltype(x) = isempty(x) ? eltype(x) : typeof(first(x))
4141

42-
function fused_map_reduce(op::F, args::Vararg{Any,N}) where {F<:Function,N}
43-
_check_same_length(args...)
42+
43+
function operate!(op::typeof(add_dot), output, args::Vararg{Any,N}) where {N}
4444
T = promote_map_reduce(op, _concrete_eltype.(args)...)
45-
accumulator = neutral_element(reduce_op(op), T)
4645
buffer = buffer_for(op, T, eltype.(args)...)
4746
for I in zip(eachindex.(args)...)
48-
accumulator =
49-
buffered_operate!!(buffer, op, accumulator, getindex.(args, I)...)
47+
output = buffered_operate!!(buffer, op, output, getindex.(args, I)...)
5048
end
51-
return accumulator
49+
return output
50+
end
51+
52+
function fused_map_reduce(op::F, args::Vararg{Any,N}) where {F<:Function,N}
53+
_check_same_length(args...)
54+
T = promote_map_reduce(op, _concrete_eltype.(args)...)
55+
accumulator = neutral_element(reduce_op(op), T)
56+
return operate!(op, accumulator, args...)
5257
end
5358

5459
function operate(

0 commit comments

Comments
 (0)