| 648 | } |
| 649 | |
| 650 | void test_Exp_OP_MUL() { |
| 651 | // Exp = A * I |
| 652 | RG_Matrix A; |
| 653 | RG_Matrix I; |
| 654 | RG_Matrix res; |
| 655 | |
| 656 | // A |
| 657 | // 1 1 |
| 658 | // 0 0 |
| 659 | RG_Matrix_new(&A, GrB_BOOL, 2, 2); |
| 660 | RG_Matrix_setElement_BOOL(A, 0, 0); |
| 661 | RG_Matrix_setElement_BOOL(A, 0, 1); |
| 662 | RG_Matrix_wait(A, true); // force flush |
| 663 | |
| 664 | // I |
| 665 | // 1 0 |
| 666 | // 0 1 |
| 667 | RG_Matrix_new(&I, GrB_BOOL, 2, 2); |
| 668 | RG_Matrix_setElement_BOOL(I, 0, 0); |
| 669 | RG_Matrix_setElement_BOOL(I, 1, 1); |
| 670 | |
| 671 | rax *matrices = raxNew(); |
| 672 | raxInsert(matrices, (unsigned char *)"A", strlen("A"), A, NULL); |
| 673 | raxInsert(matrices, (unsigned char *)"I", strlen("I"), I, NULL); |
| 674 | AlgebraicExpression *exp = AlgebraicExpression_FromString("A*I", matrices); |
| 675 | |
| 676 | // Matrix used for intermidate computations of AlgebraicExpression_Eval |
| 677 | // but also contains the result of expression evaluation. |
| 678 | RG_Matrix_new(&res, GrB_BOOL, 2, 2); |
| 679 | AlgebraicExpression_Eval(exp, res); |
| 680 | |
| 681 | // Using the A matrix described above, |
| 682 | // A * I = A. |
| 683 | GrB_Matrix expected; |
| 684 | RG_Matrix_export(&expected, A); |
| 685 | TEST_ASSERT(_compare_matrices(expected, res)); |
| 686 | |
| 687 | raxFree(matrices); |
| 688 | RG_Matrix_free(&A); |
| 689 | RG_Matrix_free(&I); |
| 690 | RG_Matrix_free(&res); |
| 691 | GrB_Matrix_free(&expected); |
| 692 | AlgebraicExpression_Free(exp); |
| 693 | } |
| 694 | |
| 695 | void test_Exp_OP_ADD_Transpose() { |
| 696 | // Exp = A + Transpose(A) |
nothing calls this directly
no test coverage detected