Skip to content

Masked set overwrites values not covered by the mask #402

@GiovaGa

Description

@GiovaGa

Consider the following snippet:

	for(size_t i = 0; i < n ; ++i ){
		rc = rc ? rc :  grb::setElement( y, i, i );
	}

	rc = rc ? rc : grb::setElement( mask, 1, 2 );
	rc = rc ? rc : grb::setElement( mask, 1, 3 );
	rc = rc ? rc : grb::setElement( mask, 1, 5 );
	rc = rc ? rc : grb::setElement( mask, 1, 7 );

	rc = rc ? rc : grb::setElement( x, 1, 4 );
	rc = rc ? rc : grb::setElement( x, 2, 1 );

	std::cerr << "x before:\t";
	for(const auto& a : x){
		std::cerr << a.first << ", " << a.second << " | ";
	}	std::cerr << std::endl;

	rc = rc ? rc : grb::set( x, mask, y );

	std::cerr << "x after:\t";
	for(const auto& a : x){
		std::cerr << a.first << ", " << a.second << " | ";
	}	std::cerr << std::endl;
	assert( rc == grb::SUCCESS );

The output is:

x before:	4, 1 | 1, 2 | 
x after:	2, 2 | 3, 3 | 5, 5 | 7, 7 | 

But I would expect the values in x not covered by the mask to be kept as before, so the expected output would be something like:

x before:	4, 1 | 1, 2 | 
x after:	4, 1 | 1, 2 | 2, 2 | 3, 3 | 5, 5 | 7, 7 | 

The documentation is unclear about this, as it does not specify what happens to the elements in x where the mask is false

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions