1 //===- MatrixTest.cpp - Tests for QuasiPolynomial -------------------------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #include "mlir/Analysis/Presburger/GeneratingFunction.h"
11 #include <gmock/gmock.h>
12 #include <gtest/gtest.h>
15 using namespace presburger
;
16 using namespace mlir::presburger::detail
;
18 TEST(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}}});
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}})},