Git Product home page Git Product logo

domainsets.jl's Introduction

DomainSets.jl

Build Status Coverage Status

DomainSets.jl is a package designed to represent simple infinite sets, that can be used to encode domains of functions. For example, the domain of the function log(x::Float64) is the infinite open interval, which is represented by the type HalfLine{Float64}().

Examples

Intervals

DomainSets.jl uses IntervalSets.jl for Closed and open intervals.

Rectangles

Rectangles can be constructed as a product of intervals, where the elements of the domain are SVector{2}:

julia> using DomainSets, StaticArrays; import DomainSets: ×

julia> SVector(1,2) in (-1..1) × (0..3)
true

Circles and Spheres

A UnitHyperSphere{N,T} contains x::SVector{N,T} if norm(x) == one(T). UnitCircle and UnitSphere are two important cases:

julia> SVector(1,0) in UnitCircle()
true

julia> SVector(1,0,0) in UnitSphere()
true

Disks and Balls

A UnitHyperBall{N,T} contains x::SVector{N,T} if norm(x) ≤ one(T). UnitDisk and UnitHyperBall are two important cases:

julia> SVector(0.1,0.2) in UnitDisk()
true

julia> SVector(0.1,0.2,0.3) in UnitBall()
true

Union, intersection, and setdiff of domains

Domains can be unioned and intersected together:

julia> d = UnitCircle()  2UnitCircle();

julia> in.([SVector(1,0),SVector(0,2), SVector(1.5,1.5)], Ref(d))
3-element BitArray{1}:
  true
  true
 false

julia> d = UnitCircle()  (2UnitCircle() + SVector(1.0,0.0))
the intersection of 2 domains:
	1.	: UnitHyperSphere{2,Float64}()
	2.	: A mapped domain based on UnitHyperSphere{2,Float64}()

julia> SVector(1,0) in d
false

julia> SVector(-1,0) in d
true

The domain interface

A domain is any type that implements the functions eltype and in. If d is an instance of a type that implements the domain interface, then the domain consists of all x that is an eltype(d) such that x in d returns true.

Domains often represent continuous mathematical domains, for example, a domain d representing the interval [0,1] would have eltype(d) == Int but still have 0.2 in d return true.

The Domain type

DomainSets.jl contains an abstract type Domain{T}. All subtypes of Domain{T} must implement the domain interface, and in addition support convert(Domain{T}, d).

domainsets.jl's People

Contributors

daanhb avatar dlfivefifty avatar femtocleaner[bot] avatar roelmatthysen avatar vincentcp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.