LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/ff - cocoa_util.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 4 100.0 %
Date: 2026-02-05 12:22:59 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Alex Ozdemir
       4                 :            :  *
       5                 :            :  * This file is part of the cvc5 project.
       6                 :            :  *
       7                 :            :  * Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
       8                 :            :  * in the top-level source directory and their institutional affiliations.
       9                 :            :  * All rights reserved.  See the file COPYING in the top-level source
      10                 :            :  * directory for licensing information.
      11                 :            :  * ****************************************************************************
      12                 :            :  *
      13                 :            :  * CoCoA utilities
      14                 :            :  */
      15                 :            : 
      16                 :            : #ifdef CVC5_USE_COCOA
      17                 :            : 
      18                 :            : #include "cvc5_private.h"
      19                 :            : 
      20                 :            : #ifndef CVC5__THEORY__FF__COCOA_UTIL_H
      21                 :            : #define CVC5__THEORY__FF__COCOA_UTIL_H
      22                 :            : 
      23                 :            : // external includes
      24                 :            : #include <CoCoA/BigInt.H>
      25                 :            : #include <CoCoA/ring.H>
      26                 :            : 
      27                 :            : // std includes
      28                 :            : #include <optional>
      29                 :            : #include <sstream>
      30                 :            : #include <vector>
      31                 :            : 
      32                 :            : // internal includes
      33                 :            : #include "theory/ff/util.h"
      34                 :            : #include "util/finite_field_value.h"
      35                 :            : #include "util/integer.h"
      36                 :            : #include "util/resource_manager.h"
      37                 :            : 
      38                 :            : namespace cvc5::internal {
      39                 :            : namespace theory {
      40                 :            : namespace ff {
      41                 :            : 
      42                 :            : /** Type definitions. */
      43                 :            : 
      44                 :            : /** A polynomial. (note: C++/Cocoa doesn't distinguish this from Scalar) */
      45                 :            : using Poly = CoCoA::RingElem;
      46                 :            : /** A coefficient. (note: C++/Cocoa doesn't distinguish this from Poly) */
      47                 :            : using Scalar = CoCoA::RingElem;
      48                 :            : /** A list of polynomials. */
      49                 :            : using Polys = std::vector<Poly>;
      50                 :            : /** A partial input (point/vector with optional entries) to a polynomial */
      51                 :            : using PartialPoint = std::vector<std::optional<Scalar>>;
      52                 :            : /** An input (point/vector) to a polynomial */
      53                 :            : using Point = std::vector<Scalar>;
      54                 :            : 
      55                 :            : /**
      56                 :            :  * partial evaluation of polynomials
      57                 :            :  *
      58                 :            :  * returns an empty std::optional when some variable in `poly` does not have a
      59                 :            :  * value in `values`
      60                 :            :  */
      61                 :            : std::optional<Scalar> cocoaEval(Poly poly, const PartialPoint& values);
      62                 :            : 
      63                 :            : /** total evaluation of polynomials */
      64                 :            : Scalar cocoaEval(Poly poly, const Point& values);
      65                 :            : 
      66                 :            : /** convert cocoa integer mod p to a FiniteFieldValue. */
      67                 :            : FiniteFieldValue cocoaFfToFfVal(const Scalar& elem, const FfSize& size);
      68                 :            : 
      69                 :            : /** convert an Integer to CoCoA::BitInt. */
      70                 :            : CoCoA::BigInt intToCocoa(const Integer& i);
      71                 :            : 
      72                 :            : /** get the string representation of a type that implements operator<<. */
      73                 :            : template <typename T>
      74                 :     306648 : std::string extractStr(const T& t)
      75                 :            : {
      76                 :     613296 :   std::ostringstream o;
      77                 :     306648 :   o << t;
      78                 :     613296 :   return o.str();
      79                 :            : }
      80                 :            : 
      81                 :            : /**
      82                 :            :  * Compute a GB, with timeout given by `rm`.
      83                 :            :  * Throws an FfTimeoutException if the timeout is exceeded.
      84                 :            :  */
      85                 :            : const std::vector<Poly>& GBasisTimeout(const CoCoA::ideal& ideal,
      86                 :            :                                        const ResourceManager* rm);
      87                 :            : 
      88                 :            : }  // namespace ff
      89                 :            : }  // namespace theory
      90                 :            : }  // namespace cvc5::internal
      91                 :            : 
      92                 :            : #endif /* CVC5__THEORY__FF__COCOA_UTIL_H */
      93                 :            : 
      94                 :            : #endif /* CVC5_USE_COCOA */

Generated by: LCOV version 1.14