//------------------------------------------------------------------------------ // GB_convert_full_to_bitmap: convert a matrix from full to bitmap //------------------------------------------------------------------------------ // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2023, All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 //------------------------------------------------------------------------------ #include "GB.h" GrB_Info GB_convert_full_to_bitmap // convert matrix from full to bitmap ( GrB_Matrix A // matrix to convert from full to bitmap ) { //-------------------------------------------------------------------------- // check inputs //-------------------------------------------------------------------------- ASSERT_MATRIX_OK (A, "A converting full to bitmap", GB0) ; ASSERT (GB_IS_FULL (A)) ; ASSERT (!GB_IS_BITMAP (A)) ; ASSERT (!GB_IS_SPARSE (A)) ; ASSERT (!GB_IS_HYPERSPARSE (A)) ; ASSERT (!GB_ZOMBIES (A)) ; ASSERT (!GB_JUMBLED (A)) ; ASSERT (!GB_PENDING (A)) ; //-------------------------------------------------------------------------- // allocate A->b //-------------------------------------------------------------------------- int64_t anz = GB_nnz_full (A) ; GB_BURBLE_N (anz, "(full to bitmap) ") ; A->b = GB_MALLOC (anz, int8_t, &(A->b_size)) ; if (A->b == NULL) { // out of memory return (GrB_OUT_OF_MEMORY) ; } //-------------------------------------------------------------------------- // determine the number of threads to use //-------------------------------------------------------------------------- int nthreads_max = GB_Context_nthreads_max ( ) ; double chunk = GB_Context_chunk ( ) ; int nthreads = GB_nthreads (anz, chunk, nthreads_max) ; //-------------------------------------------------------------------------- // fill the A->b bitmap in parallel //-------------------------------------------------------------------------- GB_memset (A->b, 1, anz, nthreads) ; A->nvals = anz ; //-------------------------------------------------------------------------- // return result //-------------------------------------------------------------------------- ASSERT_MATRIX_OK (A, "A converted from full to bitmap", GB0) ; ASSERT (GB_IS_BITMAP (A)) ; ASSERT (!GB_ZOMBIES (A)) ; ASSERT (!GB_JUMBLED (A)) ; ASSERT (!GB_PENDING (A)) ; return (GrB_SUCCESS) ; }