sparse matrix docs

This commit is contained in:
Krishna Vedala 2020-05-28 14:25:00 -04:00
parent 0994e6e028
commit bc8fda9056
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -1,10 +1,11 @@
/** @file /** @file
* A sparse matrix is a matrix which has number of zeroes greater than * A sparse matrix is a matrix which has number of zeroes greater than
* \f$\frac{m*n}{2}\f$, where m and n are the dimensions of the matrix. * \f$\frac{m\times n}{2}\f$, where m and n are the dimensions of the matrix.
*/ */
#include <iostream> #include <iostream>
/** main function */
int main() { int main() {
int m, n; int m, n;
int counterZeros = 0; int counterZeros = 0;
@ -30,7 +31,8 @@ int main() {
// counts the zero's // counts the zero's
for (int i = 0; i < m; i++) { for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
if (a[i][j] == 0) counterZeros++; // Counting number of zeroes if (a[i][j] == 0)
counterZeros++; // Counting number of zeroes
} }
} }