| 746 | } |
| 747 | |
| 748 | void test_Exp_OP_MUL_Transpose() { |
| 749 | // Exp = Transpose(A) * A |
| 750 | GrB_Matrix B; |
| 751 | RG_Matrix res; |
| 752 | |
| 753 | /* We must use matrices that we've added to the graph, or else |
| 754 | * the transpose optimization will erroneously use the adjacency matrix |
| 755 | * (since there is no schema associated with the operands). |
| 756 | |
| 757 | * The 'visit' matrix represented by V has the form: |
| 758 | * 0 0 1 1 |
| 759 | * 0 0 1 0 |
| 760 | * 0 0 0 0 |
| 761 | * 0 0 0 0 |
| 762 | * |
| 763 | * Its transpose, TV, has the form: |
| 764 | * 0 0 0 0 |
| 765 | * 0 0 0 0 |
| 766 | * 1 1 0 0 |
| 767 | * 1 0 0 0 |
| 768 | * |
| 769 | * The expected result of the multiplication is: |
| 770 | * 1 1 0 0 |
| 771 | * 1 1 0 0 |
| 772 | * 1 0 0 0 |
| 773 | * 1 0 0 0 |
| 774 | */ |
| 775 | GraphContext *gc = QueryCtx_GetGraphCtx(); |
| 776 | Graph *g = gc->g; |
| 777 | GrB_Index n = Graph_RequiredMatrixDim(g); |
| 778 | |
| 779 | GrB_Matrix_new(&B, GrB_BOOL, n, n); |
| 780 | GrB_Matrix_setElement_BOOL(B, true, 0, 0); |
| 781 | GrB_Matrix_setElement_BOOL(B, true, 0, 1); |
| 782 | GrB_Matrix_setElement_BOOL(B, true, 1, 0); |
| 783 | GrB_Matrix_setElement_BOOL(B, true, 1, 1); |
| 784 | |
| 785 | // Matrix used for intermidate computations of AlgebraicExpression_Eval |
| 786 | // but also contains the result of expression evaluation. |
| 787 | RG_Matrix_new(&res, GrB_BOOL, n, n); |
| 788 | |
| 789 | // Transpose(A) * A |
| 790 | AlgebraicExpression *exp = AlgebraicExpression_FromString("V*tV", _matrices); |
| 791 | AlgebraicExpression_Eval(exp, res); |
| 792 | |
| 793 | // Using the A matrix described above, |
| 794 | // Transpose(A) * A = B. |
| 795 | TEST_ASSERT(_compare_matrices(B, res)); |
| 796 | |
| 797 | GrB_Matrix_free(&B); |
| 798 | RG_Matrix_free(&res); |
| 799 | AlgebraicExpression_Free(exp); |
| 800 | } |
| 801 | |
| 802 | void test_Exp_OP_A_MUL_B_Plus_C() { |
| 803 |
nothing calls this directly
no test coverage detected