Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

introduction matrix.c is_sparse() function error

Open
#1 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
c

Research direction

Read matrix.c around lines 54-55 and 186-189. Verify the sparse calculation against sparse_threshold and the pointer format specifiers, then compile the relevant program to confirm the warning is gone and the reported behavior is corrected.

Written by the indexing model from the issue text.

Description

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);

Dominant language
C
Stars
14
Forks
6
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.