40 lines · cpp
1//===- MatrixTest.cpp - Tests for QuasiPolynomial -------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "mlir/Analysis/Presburger/GeneratingFunction.h"10#include "./Utils.h"11#include <gmock/gmock.h>12#include <gtest/gtest.h>13 14using namespace mlir;15using namespace presburger;16using namespace mlir::presburger::detail;17 18TEST(GeneratingFunctionTest, sum) {19 GeneratingFunction gf1(2, {1, -1},20 {makeFracMatrix(3, 2, {{1, 2}, {5, 7}, {2, 6}}),21 makeFracMatrix(3, 2, {{5, 2}, {5, 3}, {7, 2}})},22 {{{3, 6}, {7, 2}}, {{2, 8}, {6, 3}}});23 GeneratingFunction gf2(2, {1, 1},24 {makeFracMatrix(3, 2, {{6, 2}, {1, 4}, {2, 6}}),25 makeFracMatrix(3, 2, {{3, 2}, {6, 9}, {2, 5}})},26 {{{3, 7}, {5, 1}}, {{5, 2}, {6, 2}}});27 28 GeneratingFunction sum = gf1 + gf2;29 EXPECT_EQ_REPR_GENERATINGFUNCTION(30 sum, GeneratingFunction(2, {1, -1, 1, 1},31 {makeFracMatrix(3, 2, {{1, 2}, {5, 7}, {2, 6}}),32 makeFracMatrix(3, 2, {{5, 2}, {5, 3}, {7, 2}}),33 makeFracMatrix(3, 2, {{6, 2}, {1, 4}, {2, 6}}),34 makeFracMatrix(3, 2, {{3, 2}, {6, 9}, {2, 5}})},35 {{{3, 6}, {7, 2}},36 {{2, 8}, {6, 3}},37 {{3, 7}, {5, 1}},38 {{5, 2}, {6, 2}}}));39}40