Skip to content

Commit

Permalink
cpp/python: export operators for isl_pw_aff
Browse files Browse the repository at this point in the history
This patch adds operators for:

	isl_pw_aff_neg
	isl_pw_aff_add
	isl_pw_aff_sub
	isl_pw_aff_mul
	isl_pw_aff_div

We only export operators which have a direct mathematical counterpart
and which consequently are unlikely to cause any confusion.

Signed-off-by: Tobias Grosser <tobias@grosser.es>
  • Loading branch information
tobiasgrosser committed Aug 3, 2017
1 parent e591474 commit 08d1b28
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/isl/aff.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,19 @@ __isl_give isl_pw_aff *isl_pw_aff_min(__isl_take isl_pw_aff *pwaff1,
__isl_export
__isl_give isl_pw_aff *isl_pw_aff_max(__isl_take isl_pw_aff *pwaff1,
__isl_take isl_pw_aff *pwaff2);
__isl_export
__isl_operator
__isl_give isl_pw_aff *isl_pw_aff_mul(__isl_take isl_pw_aff *pwaff1,
__isl_take isl_pw_aff *pwaff2);
__isl_export
__isl_operator
__isl_give isl_pw_aff *isl_pw_aff_div(__isl_take isl_pw_aff *pa1,
__isl_take isl_pw_aff *pa2);
__isl_export
__isl_operator
__isl_give isl_pw_aff *isl_pw_aff_add(__isl_take isl_pw_aff *pwaff1,
__isl_take isl_pw_aff *pwaff2);
__isl_export
__isl_operator
__isl_give isl_pw_aff *isl_pw_aff_sub(__isl_take isl_pw_aff *pwaff1,
__isl_take isl_pw_aff *pwaff2);
__isl_export
__isl_operator
__isl_give isl_pw_aff *isl_pw_aff_neg(__isl_take isl_pw_aff *pwaff);
__isl_export
__isl_give isl_pw_aff *isl_pw_aff_ceil(__isl_take isl_pw_aff *pwaff);
Expand Down
26 changes: 26 additions & 0 deletions interface/isl_test_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,31 @@ void test_operators_aff(isl::ctx ctx)
assert((four / two).plain_is_equal(two));
}

/* Test C++ operators for isl_pw_aff
*
* This includes:
*
* # Arithmetic
* - negation
* - addition / subtraction
* - multiplication / division
*/
void test_operators_pw_aff(isl::ctx ctx)
{
isl::pw_aff i(ctx, "{ [i] -> [i] }");
isl::pw_aff zero(ctx, "{ [i] -> [0] }");
isl::pw_aff one(ctx, "{ [i] -> [1] }");
isl::pw_aff neg_one(ctx, "{ [i] -> [-1] }");
isl::pw_aff two(ctx, "{ [i] -> [2] }");
isl::pw_aff four(ctx, "{ [i] -> [4] }");

assert((-one).plain_is_equal(neg_one));
assert((zero + one).plain_is_equal(one));
assert((zero - one).plain_is_equal(neg_one));
assert((zero * one).plain_is_equal(zero));
assert((four / two).plain_is_equal(two));
}

/* Test C++ operators for:
*
* - isl_val
Expand All @@ -375,6 +400,7 @@ void test_operators(isl::ctx ctx)
{
test_operators_val(ctx);
test_operators_aff(ctx);
test_operators_pw_aff(ctx);
}

/* Test the isl C++ interface
Expand Down

0 comments on commit 08d1b28

Please sign in to comment.