C++ API

The public C++ interface is intentionally small: construct an exact integer matrix and call one synchronous function. The function uses the production solver and complete preprocessing pipeline.

Core types

enum class coposit::copositivity_mode

Values:

enumerator copositive
enumerator strictly_copositive
enumerator both
struct copositivity_result
class matrix_integer

Classifier

copositivity_result coposit::check(const matrix_integer &matrix, copositivity_mode mode = copositivity_mode::both)

The default mode is both. In a single-property call, the unrequested member of coposit::copositivity_result is empty. An unresolved resource failure is reported as an exception or process-level failure by the surrounding interface; it is never converted into false.

Minimal native example

Add cpp/ as a CMake subdirectory and link the public target:

add_subdirectory(path/to/coposit/cpp coposit-build)
target_link_libraries(my_program PRIVATE coposit::coposit)

Then construct a symmetric exact matrix:

#include <coposit/coposit.hpp>

#include <iostream>

int main()
{
    coposit::matrix_integer matrix(2, 2);
    matrix(0, 0) = 1;
    matrix(0, 1) = -1;
    matrix(1, 0) = -1;
    matrix(1, 1) = 1;

    const coposit::copositivity_result result = coposit::check(matrix);
    std::cout << std::boolalpha
              << "copositive=" << *result.is_copositive << '\n'
              << "strictly_copositive=" << *result.is_strictly_copositive << '\n';
}

Input boundary

Direct callers must supply a nonempty square symmetric coposit::matrix_integer. coposit::check() validates this public boundary. Entries are arbitrary-precision integers stored by FLINT.

Rational matrices can be multiplied by one common positive denominator before the call. This preserves copositivity and strict copositivity because it preserves the sign of \(x^\mathsf{T}Ax\). The command-line and Python parsers perform this scaling automatically for fractions, finite decimals, and scientific notation.