[Mlir-commits] [mlir] [MLIR][Presburger] Definitions for basic functions related to cones (PR #76650)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jan 4 08:10:27 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);
----------------
Abhinav271828 wrote:
it only copies the first n-1 columns, so we can't directly copy, right?
https://github.com/llvm/llvm-project/pull/76650
More information about the Mlir-commits
mailing list