Showing posts with label MATRIX. Show all posts
Showing posts with label MATRIX. Show all posts

Thursday, 7 May 2015

SPARESE MATRIX[READING & ADDITION]

DESCRIPTION

In numerical analysis, a sparse matrix is a matrix in which most of the elements are zero 
so storing these much zeros ore wastage of memory and hence sparse matrices are represented using triplet  representation in computers
triplet  representation is a 3 column representation of a sparse matrix in which first row represent the whole matrix and preceding each row represent each element in it 

PROGRAM

#include<stdio.h>
#include<conio.h>

int m,n;
void read(int c[5][5]);
void triple(int a[5][5],int t[10][3]);
int triplesum(int t1[10][3],int t2[10][3]);

void main()
{
 int a[5][5],b[5][5],t1[10][3],t2[10][3],i,j;
 clrscr();
 read(a);
 triple(a,t1);
 printf("The triple representation is:\n");
 for(i=0;i<=t1[0][2];i++)
  {
   for(j=0;j<3;j++)
   printf("%d ",t1[i][j]);
   printf("\n");
  }