Multiplication of Sparse Matrix
Multiplication of Sparse Matrix
Multiplication of Sparse Matrix
#include<stdio.h>
swap(&k[0][j], &k[1][j]);
}
sort(k, count);
return;
}
transpose(l, size);
tempk = kpos;
templ = lpos;
sum =0;
if (sum !=0)
{
result[0][rcount] = r;
result[1][rcount] = c;
result[2][rcount] = sum;
rcount++;
}
while (lpos < size && l[0][lpos] == c)
{
lpos++;
}
}
while (kpos < count && k[0][kpos] == r)
{
kpos++;
}
}
print(result, rcount);
}
int main()
{
int a[20][20], k[3][100], i, j, m, n, count = 0;
printf("Enter no of rows");
scanf("%d",&m);
printf("Enter no ofcoloumns");
scanf("%d",&n);
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
scanf("%d", &a[i][j]);
if (a[i][j])
{
k[0][count] = i;
k[1][count] = j;
k[2][count] = a[i][j];
count++;
}
}
}
Output
Dhruv sachdeva