Skip to content

Commit d518fed

Browse files
authored
Use CanonicalVector from MOI (#206)
* Use CanonicalVector from MOI * Remove tests
1 parent 12310ce commit d518fed

3 files changed

Lines changed: 1 addition & 73 deletions

File tree

src/dual_equality_constraints.jl

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -498,47 +498,8 @@ function _fill_scalar_affine_terms!(
498498
return
499499
end
500500

501-
struct _CanonicalVector{T} <: AbstractVector{T}
502-
index::Int
503-
n::Int
504-
end
505-
506-
Base.eltype(::Type{_CanonicalVector{T}}) where {T} = T
507-
508-
Base.length(v::_CanonicalVector) = v.n
509-
510-
Base.size(v::_CanonicalVector) = (v.n,)
511-
512-
function Base.getindex(v::_CanonicalVector{T}, i::Integer) where {T}
513-
return convert(T, i == v.index)
514-
end
515-
516-
# This is much faster than the default implementation that goes
517-
# through all entries even if only one is nonzero.
518-
function LinearAlgebra.dot(
519-
x::_CanonicalVector{T},
520-
y::_CanonicalVector{T},
521-
) where {T}
522-
return convert(T, x.index == y.index)
523-
end
524-
525-
function MOI.Utilities.triangle_dot(
526-
x::_CanonicalVector{T},
527-
y::_CanonicalVector{T},
528-
dim::Int,
529-
offset::Int,
530-
) where {T}
531-
if x.index != y.index || x.index <= offset
532-
return zero(T)
533-
elseif MOI.Utilities.is_diagonal_vectorized_index(x.index - offset)
534-
return one(T)
535-
else
536-
return 2one(T)
537-
end
538-
end
539-
540501
function set_dot(i::Integer, s::MOI.AbstractVectorSet, T::Type)
541-
vec = _CanonicalVector{T}(i, MOI.dimension(s))
502+
vec = MOI.Utilities.CanonicalVector{T}(i, MOI.dimension(s))
542503
return MOI.Utilities.set_dot(vec, vec, s)
543504
end
544505

test/Tests/test_dot.jl

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ include("Tests/test_dualize_exponential.jl")
7272
include("Tests/test_dualize_power.jl")
7373
include("Tests/test_dualize_quadratic.jl")
7474
include("Tests/test_dual_names.jl")
75-
include("Tests/test_dot.jl")
7675

7776
include("Tests/test_partial_dual_linear.jl")
7877
include("Tests/test_partial_dual_quadratic.jl")

0 commit comments

Comments
 (0)