Skip to content

Commit 5f2b9e1

Browse files
ranochaandreasnoack
authored andcommitted
check for axes instead of size in dot
1 parent 6e97d2a commit 5f2b9e1

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

stdlib/LinearAlgebra/src/bitarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
function dot(x::BitVector, y::BitVector)
44
# simplest way to mimic Array dot behavior
5-
if size(x) != size(y)
6-
throw(DimensionMismatch("The first array has size $(size(x)) which does not match the size of the second, $(size(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
5+
if axes(x) != axes(y)
6+
throw(DimensionMismatch("The first array has axes $(axes(x)) that do not match the axes of the second, $(axes(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
77
end
88
s = 0
99
xc = x.chunks

stdlib/LinearAlgebra/src/blas.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,24 +400,24 @@ end
400400
function dot(DX::Union{DenseArray{T},AbstractVector{T}}, DY::Union{DenseArray{T},AbstractVector{T}}) where T<:BlasReal
401401
require_one_based_indexing(DX, DY)
402402
n = length(DX)
403-
if size(DX) != size(DY)
404-
throw(DimensionMismatch("The first array has size $(size(DX)) which does not match the size of the second, $(size(DY)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
403+
if axes(DX) != axes(DY)
404+
throw(DimensionMismatch("The first array has axes $(axes(DX)) that do not match the axes of the second, $(axes(DY)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
405405
end
406406
return dot(n, DX, stride(DX, 1), DY, stride(DY, 1))
407407
end
408408
function dotc(DX::Union{DenseArray{T},AbstractVector{T}}, DY::Union{DenseArray{T},AbstractVector{T}}) where T<:BlasComplex
409409
require_one_based_indexing(DX, DY)
410410
n = length(DX)
411-
if size(DX) != size(DY)
412-
throw(DimensionMismatch("The first array has size $(size(DX)) which does not match the size of the second, $(size(DY)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
411+
if axes(DX) != axes(DY)
412+
throw(DimensionMismatch("The first array has axes $(axes(DX)) that do not match the axes of the second, $(axes(DY)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
413413
end
414414
return dotc(n, DX, stride(DX, 1), DY, stride(DY, 1))
415415
end
416416
function dotu(DX::Union{DenseArray{T},AbstractVector{T}}, DY::Union{DenseArray{T},AbstractVector{T}}) where T<:BlasComplex
417417
require_one_based_indexing(DX, DY)
418418
n = length(DX)
419-
if size(DX) != size(DY)
420-
throw(DimensionMismatch("The first array has size $(size(DX)) which does not match the size of the second, $(size(DY)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
419+
if axes(DX) != axes(DY)
420+
throw(DimensionMismatch("The first array has axes $(axes(DX)) that do not match the axes of the second, $(axes(DY)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
421421
end
422422
return dotu(n, DX, stride(DX, 1), DY, stride(DY, 1))
423423
end

stdlib/LinearAlgebra/src/generic.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,8 @@ julia> dot([im; im], [1; 1])
924924
```
925925
"""
926926
function dot(x::AbstractArray, y::AbstractArray)
927-
if size(x) != size(y)
928-
throw(DimensionMismatch("The first array has size $(size(x)) which does not match the size of the second, $(size(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
927+
if axes(x) != axes(y)
928+
throw(DimensionMismatch("The first array has axes $(axes(x)) that do not match the axes of the second, $(axes(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
929929
end
930930
if length(x) == 0
931931
return dot(zero(eltype(x)), zero(eltype(y)))

stdlib/SparseArrays/src/sparsevector.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,8 +1487,8 @@ end
14871487
function dot(x::AbstractVector{Tx}, y::SparseVectorUnion{Ty}) where {Tx<:Number,Ty<:Number}
14881488
require_one_based_indexing(x, y)
14891489
n = length(x)
1490-
if size(x) != size(y)
1491-
throw(DimensionMismatch("The first array has size $(size(x)) which does not match the size of the second, $(size(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
1490+
if axes(x) != axes(y)
1491+
throw(DimensionMismatch("The first array has axes $(axes(x)) that do not match the axes of the second, $(axes(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
14921492
end
14931493
nzind = nonzeroinds(y)
14941494
nzval = nonzeros(y)
@@ -1502,8 +1502,8 @@ end
15021502
function dot(x::SparseVectorUnion{Tx}, y::AbstractVector{Ty}) where {Tx<:Number,Ty<:Number}
15031503
require_one_based_indexing(x, y)
15041504
n = length(y)
1505-
if size(x) != size(y)
1506-
throw(DimensionMismatch("The first array has size $(size(x)) which does not match the size of the second, $(size(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
1505+
if axes(x) != axes(y)
1506+
throw(DimensionMismatch("The first array has axes $(axes(x)) that do not match the axes of the second, $(axes(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
15071507
end
15081508
nzind = nonzeroinds(x)
15091509
nzval = nonzeros(x)
@@ -1538,8 +1538,8 @@ end
15381538
function dot(x::SparseVectorUnion{<:Number}, y::SparseVectorUnion{<:Number})
15391539
x === y && return sum(abs2, x)
15401540
n = length(x)
1541-
if size(x) != size(y)
1542-
throw(DimensionMismatch("The first array has size $(size(x)) which does not match the size of the second, $(size(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
1541+
if axes(x) != axes(y)
1542+
throw(DimensionMismatch("The first array has axes $(axes(x)) that do not match the axes of the second, $(axes(y)). You might want to use `dot(vec(x), vec(y))` if `length(x) == length(y)`."))
15431543
end
15441544

15451545
xnzind = nonzeroinds(x)

0 commit comments

Comments
 (0)