Skip to content

Commit 1c90854

Browse files
committed
Tests: add tests for block format hyper rotate
1 parent 3b3c7c7 commit 1c90854

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

experimental/algorithm/LAGraph_CFL_optimized_matrix_opt.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -341,26 +341,13 @@ GrB_Info block_matrix_hyper_rotate_i(Matrix *matrix, enum CFL_Matrix_block forma
341341
TRY(GxB_Matrix_build_Scalar(new, nrows, ncols, scalar_true, matrix->nvals));
342342
TRY(GrB_Matrix_free(&matrix->base_row));
343343
TRY(GrB_Matrix_free(&matrix->base_col));
344-
matrix->base = NULL;
345344
matrix->base = new;
346345
matrix->base_row = new;
347346
TRY(TO_ROW(matrix->base));
348347
TRY(GrB_Matrix_new(&new, GrB_BOOL, matrix->ncols, matrix->nrows));
349348
TRY(TO_COL(new));
350349
TRY(GxB_Matrix_build_Scalar(new, nrows, ncols, scalar_true, matrix->nvals));
351350
matrix->base_col = new;
352-
353-
int format;
354-
TRY(GrB_get(matrix->base_row, &format, GrB_STORAGE_ORIENTATION_HINT));
355-
if (format != GrB_ROWMAJOR) {
356-
fprintf(stderr, "WRONG FORMAT\n");
357-
exit(-1);
358-
}
359-
TRY(GrB_get(matrix->base_col, &format, GrB_STORAGE_ORIENTATION_HINT));
360-
if (format != GrB_COLMAJOR) {
361-
fprintf(stderr, "WRONG FORMAT\n");
362-
exit(-1);
363-
}
364351
matrix->format = GrB_ROWMAJOR;
365352
} else {
366353
TRY(GrB_Matrix_free(&matrix->base));

experimental/test/test_CFL_optimized_matrix_opt.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,9 @@ static void test_CFL_lazy_create(void) {
813813
}
814814

815815
// Create lazy matrix
816-
// 1 1 1 0 .. 0 (count of 1: 111)
817816
// 1 0 0 0 .. 0 (count of 1: 1)
818817
// 1 1 0 0 .. 0 (count of 1: 11)
818+
// 1 1 1 0 .. 0 (count of 1: 111)
819819
// . . . . .. .
820820
// 0 0 0 0 .. 0
821821
static GrB_Info make_lazy_matrix(Matrix **M, size_t base_matrices_count) {
@@ -1299,6 +1299,38 @@ static void test_CFL_block_hyper_rotate(void) {
12991299
OK(free_matrix(&A));
13001300
}
13011301

1302+
// Format
1303+
{
1304+
Matrix *A;
1305+
make_block_vector(&A, 5, 5, VEC_VERT);
1306+
matrix_to_format(A, GrB_COLMAJOR, true);
1307+
1308+
OK(block_matrix_hyper_rotate_i(A, VEC_HORIZ));
1309+
TEST_CHECK(A->nvals != 0);
1310+
TEST_CHECK(A->is_both = true);
1311+
1312+
GrB_Index nrows_A, ncols_A, nrows_B, ncols_B;
1313+
OK(GrB_Matrix_nrows(&nrows_A, A->base_row));
1314+
OK(GrB_Matrix_ncols(&ncols_A, A->base_row));
1315+
OK(GrB_Matrix_nrows(&nrows_B, A->base_col));
1316+
OK(GrB_Matrix_ncols(&ncols_B, A->base_col));
1317+
1318+
TEST_CHECK(nrows_A == nrows_B);
1319+
TEST_CHECK(ncols_A == ncols_B);
1320+
1321+
OK(block_matrix_hyper_rotate_i(A, VEC_VERT));
1322+
1323+
OK(GrB_Matrix_nrows(&nrows_A, A->base_row));
1324+
OK(GrB_Matrix_ncols(&ncols_A, A->base_row));
1325+
OK(GrB_Matrix_nrows(&nrows_B, A->base_col));
1326+
OK(GrB_Matrix_ncols(&ncols_B, A->base_col));
1327+
1328+
TEST_CHECK(nrows_A == nrows_B);
1329+
TEST_CHECK(ncols_A == ncols_B);
1330+
1331+
OK(free_matrix(&A));
1332+
}
1333+
13021334
teardown();
13031335
#endif
13041336
}

0 commit comments

Comments
 (0)