JuliaApproximation / DomainSets.jl

A Julia package for describing domains as continuous sets of elements
MIT License
72 stars 12 forks source link

Center for HyperRectangle? #137

Closed philip-stuckey closed 1 year ago

philip-stuckey commented 1 year ago

Would it make sense to define the center of a hyper-rectangle as center(rectangle::HyperRectangle)=center.(components(rectangle))? Either way, I would find center(::Rectangle) useful.

daanhb commented 1 year ago

Thanks for the suggestion. I think it may make sense to define it for any product domain. Care to have a go at it?

philip-stuckey commented 1 year ago

Sure, I'll take a swing at it, I'll just need a moment to familiarize myself with the code a bit.

daanhb commented 1 year ago

Hmm, I'm afraid the ProductDomain code is a bit overly complicated at the moment. It should be like the one-liner you write, but for a ProductDomain and perhaps with factors instead of components for clarity. If it isn't, then don't spend too much time and just go for the HyperRectangle like above.

philip-stuckey commented 1 year ago

I just added a function to src/generic/productdomain.jl, what I'm not sure about is where to put tests.

edit: specifically center(d::ProductDomain) = hcat(map(center, factors(d))...) to line 54