{"id":20500595,"url":"https://github.com/juliaapproximation/domainsets.jl","last_synced_at":"2026-04-07T10:02:57.868Z","repository":{"id":21460875,"uuid":"92808785","full_name":"JuliaApproximation/DomainSets.jl","owner":"JuliaApproximation","description":"A Julia package for describing domains as continuous sets of elements","archived":false,"fork":false,"pushed_at":"2025-01-29T07:37:30.000Z","size":1570,"stargazers_count":74,"open_issues_count":18,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-25T16:14:13.691Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuliaApproximation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-30T07:35:41.000Z","updated_at":"2025-01-22T09:55:21.000Z","dependencies_parsed_at":"2023-11-07T02:41:40.504Z","dependency_job_id":"8d452344-8a1b-4612-9d65-dc89052452bd","html_url":"https://github.com/JuliaApproximation/DomainSets.jl","commit_stats":{"total_commits":375,"total_committers":16,"mean_commits":23.4375,"dds":0.528,"last_synced_commit":"d5ad4db5217ff1cd7fd365efa432d0f84f0fbd76"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaApproximation%2FDomainSets.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaApproximation%2FDomainSets.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaApproximation%2FDomainSets.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaApproximation%2FDomainSets.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuliaApproximation","download_url":"https://codeload.github.com/JuliaApproximation/DomainSets.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242092548,"owners_count":20070555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T18:21:50.930Z","updated_at":"2026-01-27T23:47:54.962Z","avatar_url":"https://github.com/JuliaApproximation.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DomainSets.jl\n\n[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaApproximation.github.io/DomainSets.jl/dev)\n[![Build Status](https://github.com/JuliaApproximation/DomainSets.jl/workflows/CI/badge.svg)](https://github.com/JuliaApproximation/DomainSets.jl/actions)\n[![Coverage Status](https://codecov.io/gh/JuliaApproximation/DomainSets.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaApproximation/DomainSets.jl)\n[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)\n\nDomainSets.jl is a package designed to represent simple infinite sets. The package makes it easy to represent sets, verify membership of the set, compare sets and construct new sets from existing ones. Domains are considered equivalent if they describe the same set, regardless of their type.\n\n## Examples\n\nFor more information, see the [documentation](https://JuliaApproximation.github.io/DomainSets.jl/dev).\n\n### Intervals\n\nDomainSets.jl uses [IntervalSets.jl](https://github.com/JuliaMath/IntervalSets.jl) for closed and open intervals. In addition, it defines a few standard intervals.\n\n```julia\njulia\u003e using DomainSets\n\njulia\u003e UnitInterval()\n0.0..1.0 (Unit)\n\njulia\u003e ChebyshevInterval()\n-1.0..1.0 (Chebyshev)\n\njulia\u003e HalfLine()\n0.0..Inf (closed–open) (HalfLine)\n```\n\n### Rectangles\n\nRectangles can be constructed as a product of intervals, where the elements of the domain\nare `SVector{2}`:\n\n```julia\njulia\u003e using DomainSets: ×\n\njulia\u003e (-1..1) × (0..3) × (4.0..5.0)\n(-1.0..1.0) × (0.0..3.0) × (4.0..5.0)\n\njulia\u003e [1,2] in (-1..1) × (0..3)\ntrue\n\njulia\u003e UnitInterval()^3\nUnitCube()\n```\n\n### Circles and Spheres\n\nA `UnitSphere`  contains `x` if `norm(x) == 1`. The unit sphere is N-dimensional,\nand its dimension is specified with the constructor. The element types are\n`SVector{N,T}` when the dimension is specified as `Val(3)`, and they\nare `Vector{T}` when the dimension is specified by an integer value instead:\n```julia\njulia\u003e using StaticArrays\n\njulia\u003e SA[0,0,1.0] in UnitSphere(Val(3))\ntrue\n\njulia\u003e [0.0,1.0,0.0,0.0] in UnitSphere(4)\ntrue\n```\n`UnitSphere` itself is an abstract type, hence the examples above return\nconcrete types `\u003c:UnitSphere`. The intended element type can also be explicitly\nspecified with the `UnitSphere{T}` constructor:\n```julia\njulia\u003e typeof(UnitSphere{SVector{3,BigFloat}}())\nEuclideanUnitSphere{3, BigFloat} (alias for StaticUnitSphere{SArray{Tuple{3}, BigFloat, 1, 3}})\n\njulia\u003e typeof(UnitSphere{Vector{Float32}}(6))\nVectorUnitSphere{Float32} (alias for DynamicUnitSphere{Array{Float32, 1}})\n```\n\nWithout arguments, `UnitSphere()` defaults to a 3D domain with `SVector{3,Float64}`\nelements. Similarly, there is a special case `UnitCircle` in 2D:\n```julia\njulia\u003e SVector(1,0) in UnitCircle()\ntrue\n```\n\n\n\n### Disks and Balls\n\nA `UnitBall`  contains `x` if `norm(x) ≤ 1`. As with `UnitSphere`, the dimension\nis specified via the constructor by type or by value:\n```julia\njulia\u003e SVector(0.1,0.2,0.3) in UnitBall(Val(3))\ntrue\n\njulia\u003e [0.1,0.2,0.3,-0.1] in UnitBall(4)\ntrue\n```\nBy default `N=3`, but `UnitDisk` is a special case in 2D, and so are `ComplexUnitDisk` and `ComplexUnitCircle` in the complex plane:\n```julia\njulia\u003e SVector(0.1,0.2) in UnitDisk()\ntrue\n\njulia\u003e 0.5+0.2im ∈ ComplexUnitDisk()\ntrue\n```\n\n`UnitBall` itself is an abstract type, hence the examples above return\nconcrete types `\u003c:UnitBall`. The types are similar to those associated with\n`UnitSphere`. Like intervals, balls can also be open or closed:\n```julia\njulia\u003e EuclideanUnitBall{3,Float64,:open}()\nthe 3-dimensional open unit ball\n```\n\n\n### Product domains\n\nThe cartesian product of domains is constructed with the `ProductDomain` or\n`ProductDomain{T}` constructor. This abstract constructor returns concrete types\nbest adapted to the arguments given.\n\nIf `T` is not given, `ProductDomain` makes a suitable choice based on the\narguments. If all arguments are Euclidean, i.e., their element types are numbers\nor static vectors, then the product is a Euclidean domain as well:\n```julia\njulia\u003e ProductDomain(0..2, UnitCircle())\n0.0..2.0 x the unit circle\n\njulia\u003e eltype(ans)\nSVector{3, Float64} (alias for SArray{Tuple{3}, Float64, 1, 3})\n```\nThe elements of the interval and the unit circle are flattened into a single\nvector, much like the `vcat` function. The result is a `VcatDomain`.\n\nIf a `Vector` of domains is given, the element type is a `Vector` as well:\n```julia\njulia\u003e 1:5 in ProductDomain([0..i for i in 1:5])\ntrue\n```\nIn other cases, the points are concatenated into a tuple and membership is\nevaluated element-wise:\n```julia\njulia\u003e (\"a\", 0.4) ∈ ProductDomain([\"a\",\"b\"], 0..1)\ntrue\n```\n\nSome arguments are recognized and return a more specialized product domain.\nExamples are the unit box and more general hyperrectangles:\n```julia\njulia\u003e ProductDomain(UnitInterval(), UnitInterval())\n0.0..1.0 (Unit) x 0.0..1.0 (Unit)\n\njulia\u003e ProductDomain(0..2, 4..5, 6..7.0)\n0.0..2.0 x 4.0..5.0 x 6.0..7.0\n\njulia\u003e typeof(ans)\nRectangle{SVector{3, Float64}}\n```\n\n\n### Union, intersection, and setdiff of domains\n\nDomains can be unioned and intersected together:\n```julia\njulia\u003e d = UnitCircle() ∪ 2UnitCircle();\n\njulia\u003e in.([SVector(1,0),SVector(0,2), SVector(1.5,1.5)], d)\n3-element BitArray{1}:\n 1\n 1\n 0\n\njulia\u003e d = UnitCircle() ∩ (2UnitCircle() .+ SVector(1.0,0.0))\nthe intersection of 2 domains:\n\t1.\t: the unit circle\n\t2.\t: A mapped domain based on the unit circle\n\njulia\u003e SVector(1,0) in d\nfalse\n\njulia\u003e SVector(-1,0) in d\ntrue\n```\n\n\n### Level sets\n\nA domain can be defined by the level sets of a function. The domains of all\npoints `[x,y]` for which `x*y = 1` or `x*y \u003e= 1` are represented as follows:\n```julia\njulia\u003e d = LevelSet{SVector{2,Float64}}(prod, 1.0)\nlevel set f(x) = 1.0 with f = prod\n\njulia\u003e [0.5,2] ∈ d\ntrue\n\njulia\u003e SuperlevelSet{SVector{2,Float64}}(prod, 1.0)\nsuperlevel set f(x) \u003e= 1.0 with f = prod\n```\nThere is also `SublevelSet`, and there are the special cases `ZeroSet`,\n`SubzeroSet` and `SuperzeroSet`.\n\n### Indicator functions\n\nA domain can be defined by an indicator function or a characteristic function.\nThis is a function `f(x)` which evaluates to true or false, depending on whether or\nnot the point `x` belongs to the domain.\n```julia\njulia\u003e d = IndicatorFunction{Float64}( t -\u003e  cos(t) \u003e 0)\nindicator domain defined by function f = #5\n\njulia\u003e 0.5 ∈ d, 3.1 ∈ d\n(true, false)\n```\nThis enables generator syntax to define domains:\n```julia\njulia\u003e d = Domain(x\u003e0 for x in -1..1)\nindicator function bounded by: -1..1\n\njulia\u003e 0.5 ∈ d, -0.5 ∈ d\n(true, false)\n\njulia\u003e d = Domain( x*y \u003e 0 for (x,y) in UnitDisk())\nindicator function bounded by: the 2-dimensional closed unit ball\n\njulia\u003e [0.2, 0.3] ∈ d, [0.2, -0.3] ∈ d\n(true, false)\n\njulia\u003e d = Domain( x+y+z \u003e 0 for (x,y,z) in ProductDomain(UnitDisk(), 0..1))\nindicator function bounded by: the 2-dimensional closed unit ball x 0..1\n\njulia\u003e [0.3,0.2,0.5] ∈ d\ntrue\n```\n\n### The domain interface\n\nA domain is any type that implements the functions `eltype` and `in`. If\n`d` is an instance of a type that implements the domain interface, then\nthe domain consists of all `x` that is an `eltype(d)` such that `x in d`\nreturns true.\n\nDomains often represent continuous mathematical domains, for example, a domain\n`d`  representing the interval `[0,1]` would have `eltype(d) == Int` but still\nhave `0.2 in d` return true.\n\n### The `Domain` type\n\nDomainSets.jl contains an abstract type `Domain{T}`. All subtypes of `Domain{T}`\nmust implement the domain interface, and in addition support `convert(Domain{T}, d)`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaapproximation%2Fdomainsets.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliaapproximation%2Fdomainsets.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaapproximation%2Fdomainsets.jl/lists"}