[Mlir-commits] [mlir] [MLIR][Presburger] Definitions for basic functions related to cones (PR #76650)
Arjun P
llvmlistbot at llvm.org
Thu Jan 4 05:05:29 PST 2024
================
@@ -0,0 +1,65 @@
+//===- QuasiPolynomial.cpp - Barvinok's Algorithm ---------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Analysis/Presburger/Barvinok.h"
+
+using namespace mlir;
+using namespace presburger;
+
+// Assuming that the input cone is pointed at the origin,
+// converts it to its dual in V-representation.
+// Essentially we just remove the all-zeroes constant column.
+ConeV mlir::presburger::getDual(ConeH cone) {
+ unsigned inequalities = cone.getNumInequalities();
+ unsigned variables = cone.getNumCols() - 1;
+ ConeV dual(inequalities, variables, 0, 0);
+ // Assuming that an inequality of the form
+ // a1*x1 + ... + an*xn + b ≥ 0
+ // is represented as a row [a1, ..., an, b]
+ // and that b = 0.
+
+ for (unsigned i = 0; i < inequalities; i++) {
+ assert(cone.atIneq(i, variables) == 0 &&
+ "H-representation of cone is not centred at the origin!");
+ for (unsigned j = 0; j < variables; j++) {
+ dual.at(i, j) = cone.atIneq(i, j);
----------------
Superty wrote:
if there's no function to get the ineq matrix from the cone, you can make one and use that
https://github.com/llvm/llvm-project/pull/76650
More information about the Mlir-commits
mailing list