| 693 | } |
| 694 | |
| 695 | void test_Exp_OP_ADD_Transpose() { |
| 696 | // Exp = A + Transpose(A) |
| 697 | RG_Matrix res; |
| 698 | GrB_Matrix expected; |
| 699 | /* We must use matrices that we've added to the graph, or else |
| 700 | * the transpose optimization will erroneously use the adjacency matrix |
| 701 | * (since there is no schema associated with the operands). |
| 702 | |
| 703 | * The 'visit' matrix represented by V has the form: |
| 704 | * 0 0 1 1 |
| 705 | * 0 0 1 0 |
| 706 | * 0 0 0 0 |
| 707 | * 0 0 0 0 |
| 708 | * |
| 709 | * Its transpose, TV, has the form: |
| 710 | * 0 0 0 0 |
| 711 | * 0 0 0 0 |
| 712 | * 1 1 0 0 |
| 713 | * 1 0 0 0 |
| 714 | * |
| 715 | * The expected result of the addition is: |
| 716 | * 0 0 1 1 |
| 717 | * 0 0 1 0 |
| 718 | * 1 1 0 0 |
| 719 | * 1 0 0 0 |
| 720 | */ |
| 721 | |
| 722 | GraphContext *gc = QueryCtx_GetGraphCtx(); |
| 723 | Graph *g = gc->g; |
| 724 | GrB_Index n = Graph_RequiredMatrixDim(g); |
| 725 | |
| 726 | GrB_Matrix_new(&expected, GrB_BOOL, n, n); |
| 727 | GrB_Matrix_setElement_BOOL(expected, true, 0, 2); |
| 728 | GrB_Matrix_setElement_BOOL(expected, true, 0, 3); |
| 729 | GrB_Matrix_setElement_BOOL(expected, true, 1, 2); |
| 730 | GrB_Matrix_setElement_BOOL(expected, true, 2, 0); |
| 731 | GrB_Matrix_setElement_BOOL(expected, true, 2, 1); |
| 732 | GrB_Matrix_setElement_BOOL(expected, true, 3, 0); |
| 733 | // Matrix used for intermidate computations of AlgebraicExpression_Eval |
| 734 | // but also contains the result of expression evaluation. |
| 735 | RG_Matrix_new(&res, GrB_BOOL, n, n); |
| 736 | AlgebraicExpression *exp = AlgebraicExpression_FromString("V+tV", _matrices); |
| 737 | AlgebraicExpression_Eval(exp, res); |
| 738 | |
| 739 | // Using the A matrix described above, |
| 740 | // A + Transpose(A) = B. |
| 741 | TEST_ASSERT(_compare_matrices(expected, res)); |
| 742 | |
| 743 | RG_Matrix_free(&res); |
| 744 | GrB_Matrix_free(&expected); |
| 745 | AlgebraicExpression_Free(exp); |
| 746 | } |
| 747 | |
| 748 | void test_Exp_OP_MUL_Transpose() { |
| 749 | // Exp = Transpose(A) * A |
nothing calls this directly
no test coverage detected