-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `vecdot` function was deprecated in favor of `dot` in Julia PR 27401; `dot` on matrices now treats them like vectors. The change here updates our extension of `dot` to match this behavior and deprecates `vecnorm`.
- Loading branch information
Showing
2 changed files
with
12 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
import LinearAlgebra.dot | ||
export vecdot, dot | ||
export dot | ||
|
||
dot(x::AbstractExpr, y::AbstractExpr) = sum(broadcast(*, x, y)) | ||
dot(x::Value, y::AbstractExpr) = sum(broadcast(*, Constant(x), y)) | ||
dot(x::AbstractExpr, y::Value) = sum(broadcast(*, x, Constant(y))) | ||
|
||
vecdot(x::AbstractExpr, y::AbstractExpr) = sum(broadcast(*, x, y)) | ||
vecdot(x::Value, y::AbstractExpr) = sum(broadcast(*, Constant(x), y)) | ||
vecdot(x::AbstractExpr, y::Value) = sum(broadcast(*, x, Constant(y))) | ||
|
||
dot(x::AbstractExpr, y::AbstractExpr) = (ismatrix(x) || ismatrix(y)) ? error("dot not implemented for matrices. perhaps you're looking for vecdot?") : vecdot(x, y) | ||
dot(x::Value, y::AbstractExpr) = (ismatrix(x) || ismatrix(y)) ? error("dot not implemented for matrices. perhaps you're looking for vecdot?") : vecdot(x, y) | ||
dot(x::AbstractExpr, y::Value) = (ismatrix(x) || ismatrix(y)) ? error("dot not implemented for matrices. perhaps you're looking for vecdot?") : vecdot(x, y) | ||
|
||
# tests if an array is a matrix (2D array) with both dimensions of size > 1 | ||
function ismatrix(x) | ||
sz = size(x) | ||
if length(sz) != 2 | ||
return false | ||
else | ||
for s in sz | ||
if s == 1 | ||
return false | ||
end | ||
end | ||
end | ||
return true | ||
if isdefined(LinearAlgebra, :vecdot) # defined but deprecated | ||
import LinearAlgebra: vecdot | ||
end | ||
Base.@deprecate vecdot(x::AbstractExpr, y::AbstractExpr) dot(x, y) | ||
Base.@deprecate vecdot(x::Value, y::AbstractExpr) dot(x, y) | ||
Base.@deprecate vecdot(x::AbstractExpr, y::Value) dot(x, y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters