Skip to content

introduction matrix.c is_sparse() function error #1

@mennamorato

Description

@mennamorato

Probably nobody is paying attention to this repo..i was going to try a pull request but its very old.
anyways... is_sparse does not work correctly because the formula is inverted, see here to fix it:

54 //if((matrix.cols * matrix.rows)/zero_elements >= sparse_threshold){ <-- BAD
55 if((zero_elements/(matrix.cols * matrix.rows)) >= sparse_threshold){
return 1;
}else{
return 0;
}

also to get rid of warnings about printf''ing pointers change the %d to %p here:
186 // Attempting to multiply m and n, should work
187 error = matrix_multiply(m,n,&p);
188 printf("&p: %p\n",&p);
189 printf("p: %p\n",p);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions