MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_Exp_OP_MUL_Transpose

Function test_Exp_OP_MUL_Transpose

tests/unit/test_algebraic_expression.c:748–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

746}
747
748void 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
802void test_Exp_OP_A_MUL_B_Plus_C() {
803

Callers

nothing calls this directly

Calls 10

QueryCtx_GetGraphCtxFunction · 0.85
Graph_RequiredMatrixDimFunction · 0.85
GrB_Matrix_newFunction · 0.85
RG_Matrix_newFunction · 0.85
AlgebraicExpression_EvalFunction · 0.85
_compare_matricesFunction · 0.85
GrB_Matrix_freeFunction · 0.85
RG_Matrix_freeFunction · 0.85
AlgebraicExpression_FreeFunction · 0.85

Tested by

no test coverage detected