Skip to content

Add is_in method to HPolytope for point membership testing - #2

Open
DHRUV-1-star wants to merge 2 commits into
GeomScale:mainfrom
DHRUV-1-star:add-hpolytope-is-in
Open

DHRUV-1-star wants to merge 2 commits into
GeomScale:mainfrom
DHRUV-1-star:add-hpolytope-is-in

Conversation

@DHRUV-1-star

Copy link
Copy Markdown

Summary

This PR introduces the is_in method to the HPolytope class, enabling point membership testing for H-representation convex polytopes against the linear inequality system $Ax \le b$.

Changes Made

  1. Oct-File C++ Binding (src/__volesti_HPolytope__.cc):

    • Added do_is_in method interfacing directly with volesti's underlying P.is_in(pt, tol) point membership algorithm.
    • Vectorized evaluation across columns to efficiently evaluate multiple points in a single oct-file call.
    • Added validation ensuring x and tol are strictly real values (!args(3).isreal() / !args(4).isreal()) so imaginary components are never silently discarded.
    • Mapped volesti's internal return code (-1 inside / on boundary within tolerance) to Octave logical return values.
  2. Octave Classdef Interface (inst/HPolytope.m):

    • Implemented is_in(P, x, tol) with strict input validation (checks for non-empty, real numeric matrix, rejection of complex/NaN/Inf values, non-negative real tolerance).
    • Dimension checking: supports both single $d \times 1$ vectors and $d \times N$ matrices of points. For 1D polytopes, transposes column vectors to row vectors while strictly rejecting multi-dimensional matrices with dimension mismatch errors.
    • Added full Texinfo help documentation accessible via help HPolytope.is_in and updated @seealso.
  3. BIST Test Suite (inst/tests/HPolytope.m-tst):

    • Added comprehensive error-checking tests (missing arguments, type mismatches, NaN/Inf, complex x, complex tol, multi-dimensional matrix for 1D polytope, dimension mismatch).
    • Added execution tests verifying interior points, boundary points, exterior points, batch testing across multiple points, tolerance handling, and 1D interval polytopes.
  4. Documentation (README.md):

    • Updated the status table to reflect the is_in method implementation.
    • Added usage examples demonstrating membership testing.

Implement HPolytope.is_in with C++ oct-file binding to volesti's
P.is_in() point membership algorithm. Supports both single d x 1
points and d x N matrices of points, with an optional tolerance
parameter. Includes input validation, comprehensive BIST test cases,
and documentation in Texinfo and README.
- Reject non-real x and tol at both Octave and C++ oct-file levels so
  complex inputs are not silently cast to real parts.
- When d == 1, require vector inputs and reject non-vector matrices,
  transposing column vectors while reporting dimension errors for
  multi-dimensional matrices.
- Add BIST tests for complex input rejection and 1D polytope handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant