|
1 | 1 | import LinearAlgebra.dot
|
2 |
| -export vecdot, dot |
| 2 | +export dot |
3 | 3 |
|
| 4 | +dot(x::AbstractExpr, y::AbstractExpr) = sum(broadcast(*, x, y)) |
| 5 | +dot(x::Value, y::AbstractExpr) = sum(broadcast(*, Constant(x), y)) |
| 6 | +dot(x::AbstractExpr, y::Value) = sum(broadcast(*, x, Constant(y))) |
4 | 7 |
|
5 |
| -vecdot(x::AbstractExpr, y::AbstractExpr) = sum(broadcast(*, x, y)) |
6 |
| -vecdot(x::Value, y::AbstractExpr) = sum(broadcast(*, Constant(x), y)) |
7 |
| -vecdot(x::AbstractExpr, y::Value) = sum(broadcast(*, x, Constant(y))) |
8 |
| - |
9 |
| -dot(x::AbstractExpr, y::AbstractExpr) = (ismatrix(x) || ismatrix(y)) ? error("dot not implemented for matrices. perhaps you're looking for vecdot?") : vecdot(x, y) |
10 |
| -dot(x::Value, y::AbstractExpr) = (ismatrix(x) || ismatrix(y)) ? error("dot not implemented for matrices. perhaps you're looking for vecdot?") : vecdot(x, y) |
11 |
| -dot(x::AbstractExpr, y::Value) = (ismatrix(x) || ismatrix(y)) ? error("dot not implemented for matrices. perhaps you're looking for vecdot?") : vecdot(x, y) |
12 |
| - |
13 |
| -# tests if an array is a matrix (2D array) with both dimensions of size > 1 |
14 |
| -function ismatrix(x) |
15 |
| - sz = size(x) |
16 |
| - if length(sz) != 2 |
17 |
| - return false |
18 |
| - else |
19 |
| - for s in sz |
20 |
| - if s == 1 |
21 |
| - return false |
22 |
| - end |
23 |
| - end |
24 |
| - end |
25 |
| - return true |
| 8 | +if isdefined(LinearAlgebra, :vecdot) # defined but deprecated |
| 9 | + import LinearAlgebra: vecdot |
26 | 10 | end
|
| 11 | +Base.@deprecate vecdot(x::AbstractExpr, y::AbstractExpr) dot(x, y) |
| 12 | +Base.@deprecate vecdot(x::Value, y::AbstractExpr) dot(x, y) |
| 13 | +Base.@deprecate vecdot(x::AbstractExpr, y::Value) dot(x, y) |
0 commit comments