From d0b783ddc8c392f582a3468d8a22f8c90c4491df Mon Sep 17 00:00:00 2001 From: schillic Date: Mon, 30 Dec 2024 21:39:44 +0100 Subject: [PATCH] use old implementation when available --- docs/src/lib/sets/DensePolynomialZonotope.md | 2 +- docs/src/lib/sets/Hyperrectangle.md | 2 +- docs/src/lib/sets/LineSegment.md | 3 ++- docs/src/lib/sets/Singleton.md | 2 +- docs/src/lib/sets/VPolytope.md | 2 +- docs/src/lib/sets/Zonotope.md | 8 +++++++- .../DensePolynomialZonotopeModule.jl | 4 ++-- src/Sets/DensePolynomialZonotope/scale.jl | 4 ++++ src/Sets/Hyperrectangle/HyperrectangleModule.jl | 8 ++++---- src/Sets/Hyperrectangle/scale.jl | 4 ++++ src/Sets/LineSegment/LineSegmentModule.jl | 6 +++--- src/Sets/LineSegment/scale.jl | 4 ++++ src/Sets/Singleton/SingletonModule.jl | 4 ++-- src/Sets/Singleton/scale.jl | 4 ++++ src/Sets/VPolytope/VPolytopeModule.jl | 8 +++++--- src/Sets/VPolytope/scale.jl | 4 ++++ src/Sets/Zonotope/ZonotopeModule.jl | 4 ++-- src/Sets/Zonotope/scale.jl | 4 ++++ 18 files changed, 55 insertions(+), 22 deletions(-) diff --git a/docs/src/lib/sets/DensePolynomialZonotope.md b/docs/src/lib/sets/DensePolynomialZonotope.md index b386f544c4..cc316b598f 100644 --- a/docs/src/lib/sets/DensePolynomialZonotope.md +++ b/docs/src/lib/sets/DensePolynomialZonotope.md @@ -24,6 +24,7 @@ Undocumented implementations: * [`center`](@ref center(::LazySet)) * [`isoperationtype`](@ref isoperationtype(::Type{LazySet})) * [`linear_map`](@ref linear_map(::AbstractMatrix, ::LazySet)) +* [`scale`](@ref scale(::Real, ::LazySet)) * [`scale!`](@ref scale!(::Real, ::LazySet)) ```@meta @@ -66,7 +67,6 @@ Inherited from [`LazySet`](@ref): * [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet)) * [`project`](@ref project(::LazySet, ::AbstractVector{Int})) * [`sample`](@ref sample(::LazySet, ::Int=1)) -* [`scale`](@ref scale(::Real, ::LazySet)) * [`ρ`](@ref ρ(::AbstractVector, ::LazySet)) * [`translate`](@ref translate(::LazySet, ::AbstractVector)) * [`cartesian_product`](@ref cartesian_product(::LazySet, ::LazySet)) diff --git a/docs/src/lib/sets/Hyperrectangle.md b/docs/src/lib/sets/Hyperrectangle.md index b2a85a576b..70b97b620c 100644 --- a/docs/src/lib/sets/Hyperrectangle.md +++ b/docs/src/lib/sets/Hyperrectangle.md @@ -63,6 +63,7 @@ CurrentModule = LazySets.API ``` * [`isoperationtype`](@ref isoperationtype(::Type{LazySet})) * [`permute`](@ref permute(::LazySet, ::AbstractVector{Int})) +* [`scale`](@ref scale(::Real, ::LazySet)) * [`scale!`](@ref scale!(::Real, ::LazySet)) * [`ρ`](@ref ρ(::AbstractVector, ::LazySet)) * [`σ`](@ref σ(::AbstractVector, ::LazySet)) @@ -92,7 +93,6 @@ Inherited from [`LazySet`](@ref): * [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet)) * [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet)) * [`sample`](@ref sample(::LazySet, ::Int=1)) -* [`scale`](@ref scale(::Real, ::LazySet)) * [`convex_hull`](@ref convex_hull(::LazySet, ::LazySet)) * [`exact_sum`](@ref exact_sum(::LazySet, ::LazySet)) * [`≈`](@ref ≈(::LazySet, ::LazySet)) diff --git a/docs/src/lib/sets/LineSegment.md b/docs/src/lib/sets/LineSegment.md index 5e174c0788..c0d4691f96 100644 --- a/docs/src/lib/sets/LineSegment.md +++ b/docs/src/lib/sets/LineSegment.md @@ -107,6 +107,8 @@ Undocumented implementations: * [`dim`](@ref dim(::LazySet)) * [`isoperationtype`](@ref isoperationtype(::Type{LazySet})) * [`vertices_list`](@ref vertices_list(::LazySet)) +* [`scale`](@ref scale(::Real, ::LazySet)) +* [`scale!`](@ref scale!(::Real, ::LazySet)) * [`ρ`](@ref ρ(::AbstractVector, ::LazySet)) ```@meta @@ -136,7 +138,6 @@ Inherited from [`LazySet`](@ref): * [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet)) * [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet)) * [`sample`](@ref sample(::LazySet, ::Int)) -* [`scale`](@ref scale(::Real, ::LazySet)) * [`≈`](@ref ≈(::LazySet, ::LazySet)) * [`==`](@ref ==(::LazySet, ::LazySet)) * [`isequivalent`](@ref isequivalent(::LazySet, ::LazySet)) diff --git a/docs/src/lib/sets/Singleton.md b/docs/src/lib/sets/Singleton.md index c744155157..d2c3a70dc3 100644 --- a/docs/src/lib/sets/Singleton.md +++ b/docs/src/lib/sets/Singleton.md @@ -61,6 +61,7 @@ Undocumented implementations: * [`linear_map`](@ref linear_map(::AbstractMatrix, ::LazySet)) * [`permute`](@ref permute(::LazySet, ::AbstractVector{Int})) * [`project`](@ref project(::LazySet, ::AbstractVector{Int})) +* [`scale`](@ref scale(::Real, ::LazySet)) * [`scale!`](@ref scale!(::Real, ::LazySet)) ```@meta @@ -84,7 +85,6 @@ Inherited from [`LazySet`](@ref): * [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet)) * [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet)) * [`sample`](@ref sample(::LazySet)) -* [`scale`](@ref scale(::Real, ::LazySet)) * [`translate`](@ref translate(::LazySet, ::AbstractVector)) * [`≈`](@ref ≈(::LazySet, ::LazySet)) * [`==`](@ref ==(::LazySet, ::LazySet)) diff --git a/docs/src/lib/sets/VPolytope.md b/docs/src/lib/sets/VPolytope.md index 6d7618a906..b7ad68161b 100644 --- a/docs/src/lib/sets/VPolytope.md +++ b/docs/src/lib/sets/VPolytope.md @@ -140,6 +140,7 @@ Undocumented implementations: * [`permute`](@ref permute(::LazySet, ::AbstractVector{Int})) * [`project`](@ref project(::LazySet, ::AbstractVector{Int})) * [`reflect`](@ref reflect(::LazySet)) +* [`scale`](@ref scale(::Real, ::LazySet)) * [`scale!`](@ref scale!(::Real, ::LazySet)) * [`ρ`](@ref ρ(::AbstractVector, ::LazySet)) * [`translate`](@ref translate(::LazySet, ::AbstractVector)) @@ -173,7 +174,6 @@ Inherited from [`LazySet`](@ref): * [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet)) * [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet)) * [`sample`](@ref sample(::LazySet, ::Int=1)) -* [`scale`](@ref scale(::Real, ::LazySet)) * [`exact_sum`](@ref exact_sum(::LazySet, ::LazySet)) * [`≈`](@ref ≈(::LazySet, ::LazySet)) * [`==`](@ref ==(::LazySet, ::LazySet)) diff --git a/docs/src/lib/sets/Zonotope.md b/docs/src/lib/sets/Zonotope.md index 0d7dff0360..33ce466dde 100644 --- a/docs/src/lib/sets/Zonotope.md +++ b/docs/src/lib/sets/Zonotope.md @@ -88,6 +88,13 @@ CurrentModule = LazySets.API CurrentModule = LazySets ``` * [`reduce_order`](@ref reduce_order(::AbstractZonotope, ::Real, ::AbstractReductionMethod=GIR05())) +```@meta +CurrentModule = LazySets.API +``` +* [`scale`](@ref scale(::Real, ::LazySet)) +```@meta +CurrentModule = LazySets +``` * [`split`](@ref split(::AbstractZonotope, ::Int)) * [`split`](@ref split(::AbstractZonotope, ::AbstractVector{Int}, ::AbstractVector{Int})) ```@meta @@ -123,7 +130,6 @@ Inherited from [`LazySet`](@ref): * [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet)) * [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet)) * [`sample`](@ref sample(::LazySet, ::Int=1)) -* [`scale`](@ref scale(::Real, ::LazySet)) * [`translate`](@ref translate(::LazySet, ::AbstractVector)) * [`convex_hull`](@ref convex_hull(::LazySet, ::LazySet)) * [`exact_sum`](@ref exact_sum(::LazySet, ::LazySet)) diff --git a/src/Sets/DensePolynomialZonotope/DensePolynomialZonotopeModule.jl b/src/Sets/DensePolynomialZonotope/DensePolynomialZonotopeModule.jl index 4a98238e6f..647f1c73c5 100644 --- a/src/Sets/DensePolynomialZonotope/DensePolynomialZonotopeModule.jl +++ b/src/Sets/DensePolynomialZonotope/DensePolynomialZonotopeModule.jl @@ -2,9 +2,9 @@ module DensePolynomialZonotopeModule using Reexport -using ..LazySets: AbstractPolynomialZonotope +using ..LazySets: AbstractPolynomialZonotope, _scale_copy_inplace -@reexport import ..API: center, isoperationtype, linear_map, scale! +@reexport import ..API: center, isoperationtype, linear_map, scale, scale! @reexport import ..LazySets: ngens_dep, ngens_indep, polynomial_order @reexport using ..API diff --git a/src/Sets/DensePolynomialZonotope/scale.jl b/src/Sets/DensePolynomialZonotope/scale.jl index a2ad2c10b2..08a11bd337 100644 --- a/src/Sets/DensePolynomialZonotope/scale.jl +++ b/src/Sets/DensePolynomialZonotope/scale.jl @@ -1,3 +1,7 @@ +function scale(α::Real, P::DensePolynomialZonotope) + return _scale_copy_inplace(α, P) +end + function scale!(α::Real, P::DensePolynomialZonotope) P.c .*= α P.E .*= α diff --git a/src/Sets/Hyperrectangle/HyperrectangleModule.jl b/src/Sets/Hyperrectangle/HyperrectangleModule.jl index 151c54ea6f..c6a4d750db 100644 --- a/src/Sets/Hyperrectangle/HyperrectangleModule.jl +++ b/src/Sets/Hyperrectangle/HyperrectangleModule.jl @@ -2,16 +2,16 @@ module HyperrectangleModule using Reexport, Requires -using ..LazySets: AbstractHyperrectangle, _ρ_sev_hyperrectangle, - _σ_sev_hyperrectangle +using ..LazySets: AbstractHyperrectangle, _scale_copy_inplace, + _ρ_sev_hyperrectangle, _σ_sev_hyperrectangle using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Arrays: SingleEntryVector using ReachabilityBase.Comparison: isapproxzero using ReachabilityBase.Distribution: reseed! using SparseArrays: SparseVector, findnz, sparse -@reexport import ..API: center, isoperationtype, rand, permute, scale!, ρ, σ, - translate, translate! +@reexport import ..API: center, isoperationtype, rand, permute, scale, scale!, + ρ, σ, translate, translate! @reexport import ..LazySets: genmat, radius_hyperrectangle, □ import ..LazySets: _genmat_static import Base: convert diff --git a/src/Sets/Hyperrectangle/scale.jl b/src/Sets/Hyperrectangle/scale.jl index 94e4c9050e..cd49f6201b 100644 --- a/src/Sets/Hyperrectangle/scale.jl +++ b/src/Sets/Hyperrectangle/scale.jl @@ -1,3 +1,7 @@ +function scale(α::Real, H::Hyperrectangle) + return _scale_copy_inplace(α, H) +end + function scale!(α::Real, H::Hyperrectangle) H.center .*= α H.radius .*= abs(α) diff --git a/src/Sets/LineSegment/LineSegmentModule.jl b/src/Sets/LineSegment/LineSegmentModule.jl index 4fc74a94e8..bcc1bbd50b 100644 --- a/src/Sets/LineSegment/LineSegmentModule.jl +++ b/src/Sets/LineSegment/LineSegmentModule.jl @@ -2,7 +2,7 @@ module LineSegmentModule using Reexport, Requires -using ..LazySets: AbstractZonotope, right_turn +using ..LazySets: AbstractZonotope, right_turn, _scale_copy_inplace using LinearAlgebra: dot using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Comparison: _isapprox, isapproxzero, _leq @@ -11,8 +11,8 @@ using ReachabilityBase.Iteration: EmptyIterator, SingletonIterator using ReachabilityBase.Require: require @reexport import ..API: an_element, center, constraints_list, dim, - isoperationtype, rand, vertices_list, ∈, scale!, ρ, σ, - translate, intersection + isoperationtype, rand, vertices_list, ∈, scale, scale!, + ρ, σ, translate, intersection @reexport import ..LazySets: generators, genmat, ngens, halfspace_left, halfspace_right @reexport using ..API diff --git a/src/Sets/LineSegment/scale.jl b/src/Sets/LineSegment/scale.jl index c5dbcda736..7764f363b7 100644 --- a/src/Sets/LineSegment/scale.jl +++ b/src/Sets/LineSegment/scale.jl @@ -1,3 +1,7 @@ +function scale(α::Real, L::LineSegment) + return _scale_copy_inplace(α, L) +end + function scale!(α::Real, L::LineSegment) L.p .*= α L.q .*= α diff --git a/src/Sets/Singleton/SingletonModule.jl b/src/Sets/Singleton/SingletonModule.jl index e2ca545c4b..1bda7760cf 100644 --- a/src/Sets/Singleton/SingletonModule.jl +++ b/src/Sets/Singleton/SingletonModule.jl @@ -2,12 +2,12 @@ module SingletonModule using Reexport -using ..LazySets: AbstractSingleton +using ..LazySets: AbstractSingleton, _scale_copy_inplace using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Distribution: reseed! @reexport import ..API: isoperationtype, rand, rectify, linear_map, permute, - project, scale!, translate! + project, scale, scale!, translate! @reexport import ..LazySets: element, singleton_list @reexport using ..API diff --git a/src/Sets/Singleton/scale.jl b/src/Sets/Singleton/scale.jl index ed793dad74..83ea4dc836 100644 --- a/src/Sets/Singleton/scale.jl +++ b/src/Sets/Singleton/scale.jl @@ -1,3 +1,7 @@ +function scale(α::Real, S::Singleton) + return _scale_copy_inplace(α, S) +end + function scale!(α::Real, S::Singleton) S.element .*= α return S diff --git a/src/Sets/VPolytope/VPolytopeModule.jl b/src/Sets/VPolytope/VPolytopeModule.jl index cc907bc7a5..750ab01221 100644 --- a/src/Sets/VPolytope/VPolytopeModule.jl +++ b/src/Sets/VPolytope/VPolytopeModule.jl @@ -5,7 +5,8 @@ using Reexport, Requires using ..LazySets: AbstractPolytope, LazySet, LinearMapVRep, default_lp_solver, default_lp_solver_polyhedra, default_polyhedra_backend, is_lp_infeasible, is_lp_optimal, linprog, _extrema_vlist, - _high_vlist, _low_vlist, _minkowski_sum_vrep_nd + _high_vlist, _low_vlist, _minkowski_sum_vrep_nd, + _scale_copy_inplace using LinearAlgebra: dot using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Arrays: projection_matrix @@ -15,8 +16,9 @@ using ReachabilityBase.Require: require @reexport import ..API: constraints_list, dim, extrema, high, isoperationtype, low, rand, reflect, vertices_list, ∈, linear_map, - permute, project, scale!, ρ, σ, translate, translate!, - cartesian_product, convex_hull, minkowski_sum + permute, project, scale, scale!, ρ, σ, translate, + translate!, cartesian_product, convex_hull, + minkowski_sum @reexport import ..LazySets: remove_redundant_vertices, tohrep, tovrep import ..LazySets: _linear_map_vrep import Base: convert diff --git a/src/Sets/VPolytope/scale.jl b/src/Sets/VPolytope/scale.jl index de2f451411..f1e657bf9c 100644 --- a/src/Sets/VPolytope/scale.jl +++ b/src/Sets/VPolytope/scale.jl @@ -1,3 +1,7 @@ +function scale(α::Real, P::VPolytope) + return _scale_copy_inplace(α, P) +end + function scale!(α::Real, P::VPolytope) P.vertices .*= α return P diff --git a/src/Sets/Zonotope/ZonotopeModule.jl b/src/Sets/Zonotope/ZonotopeModule.jl index 28051ccf5f..0bd767a04f 100644 --- a/src/Sets/Zonotope/ZonotopeModule.jl +++ b/src/Sets/Zonotope/ZonotopeModule.jl @@ -2,7 +2,7 @@ module ZonotopeModule using Reexport, Requires -using ..LazySets: AbstractZonotope, generators_fallback +using ..LazySets: AbstractZonotope, generators_fallback, _scale_copy_inplace using LinearAlgebra: mul! using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Arrays: ismultiple, remove_zero_columns, to_matrix, @@ -11,7 +11,7 @@ using ReachabilityBase.Distribution: reseed! using ReachabilityBase.Require: require @reexport import ..API: center, high, isoperationtype, low, rand, - permute, scale!, translate! + permute, scale, scale!, translate! @reexport import ..LazySets: generators, genmat, ngens, reduce_order, remove_redundant_generators, togrep import Base: convert diff --git a/src/Sets/Zonotope/scale.jl b/src/Sets/Zonotope/scale.jl index 0ed496835b..4508feea84 100644 --- a/src/Sets/Zonotope/scale.jl +++ b/src/Sets/Zonotope/scale.jl @@ -1,3 +1,7 @@ +function scale(α::Real, Z::Zonotope) + return _scale_copy_inplace(α, Z) +end + """ # Extended help