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

Function test_GRMatrix_managed_transposed

tests/unit/test_rg_matrix.c:848–1035  ·  view source on GitHub ↗

M[i,j] = x, M[i,j] = y

Source from the content-addressed store, hash-verified

846
847// M[i,j] = x, M[i,j] = y
848void test_GRMatrix_managed_transposed() {
849 GrB_Type t = GrB_UINT64;
850 RG_Matrix A = NULL;
851 RG_Matrix T = NULL; // A transposed
852 GrB_Matrix M = NULL; // primary internal matrix
853 GrB_Matrix DP = NULL; // delta plus
854 GrB_Matrix DM = NULL; // delta minus
855 GrB_Info info = GrB_SUCCESS;
856 GrB_Index nvals = 0;
857 GrB_Index nrows = 100;
858 GrB_Index ncols = 100;
859 GrB_Index i = 0;
860 GrB_Index j = 1;
861 uint64_t x = 0; // M[i,j] = x
862 bool b = false;
863 bool entry_deleted = false;
864
865 //--------------------------------------------------------------------------
866 // create RGMatrix
867 //--------------------------------------------------------------------------
868
869 info = RG_Matrix_new(&A, t, nrows, ncols);
870 TEST_ASSERT(info == GrB_SUCCESS);
871
872 // make sure transposed was created
873 T = RG_Matrix_getTranspose(A);
874 TEST_ASSERT(T != A);
875 TEST_ASSERT(T != NULL);
876
877 // get internal matrices
878 M = RG_MATRIX_M(T);
879 DP = RG_MATRIX_DELTA_PLUS(T);
880 DM = RG_MATRIX_DELTA_MINUS(T);
881
882 //--------------------------------------------------------------------------
883 // set element at position i,j
884 //--------------------------------------------------------------------------
885
886 info = RG_Matrix_setElement_UINT64(A, x, i, j);
887 TEST_ASSERT(info == GrB_SUCCESS);
888
889 // make sure element at position j,i exists
890 info = RG_Matrix_extractElement_BOOL(&b, T, j, i);
891 TEST_ASSERT(info == GrB_SUCCESS);
892 TEST_ASSERT(true == b);
893
894 // matrix should contain a single element
895 RG_Matrix_nvals(&nvals, T);
896 TEST_ASSERT(nvals == 1);
897
898 // matrix should be mark as dirty
899 TEST_ASSERT(RG_Matrix_isDirty(T));
900
901 //--------------------------------------------------------------------------
902 // validations
903 //--------------------------------------------------------------------------
904
905 // TM should be empty

Callers

nothing calls this directly

Calls 10

RG_Matrix_newFunction · 0.85
RG_Matrix_getTransposeFunction · 0.85
RG_Matrix_nvalsFunction · 0.85
RG_Matrix_isDirtyFunction · 0.85
RG_Matrix_waitFunction · 0.85
RG_Matrix_freeFunction · 0.85

Tested by

no test coverage detected