hello Everyone!
I want to implement fast transpose of a sparse matrix. It's really hard for me to understand the algorithm explained in book.
Can anyone please explain in simple manner?
Thank you ! :)

Simple. A matrix is made up of rows and columns. Given a matrix with 3 rows and 3 columns:
1 2 3
4 5 6
7 8 9

After transpose you have:
1 4 7
2 5 8
3 6 9

Simple algorithm:

A ^= B
B ^= A
A ^= B

Swaps without temporary storage.

I know transpose of a matrix. I want to know about "fast transpose" method of a sparse matrix.

Call a function transopose(*x, *y) and pass the address of the items to swap. You can use the xor method described in my previous post to do the swap. First call would swap item 2 in col 1 with item 2 in row 1. and so on.

``````void ftrans(int a[],int b[])
{
int i,j,k=0,min,pos=0,c;
for(i=0;i<=a;i++)
{
for(j=0;j<3;j++)
c[i][j]=a[i][j];
}
b[k]=c[pos];
b[k]=c[pos];
b[k]=c[pos];
for(j=c;j>0;j--)
{
min=c;
for(i=c;i>0;i--)
{
if(c[i]<=min&&c[i]!=0)
{
min=c[i];
pos=i;
}
}
k++;
b[k]=c[pos];
b[k]=c[pos];
b[k]=c[pos];
c[pos]=0;
}
}``````

simple funda hai yr n it works only whn........your input function is as follows

``````void input(int a[],int r,int c)
{
int n,i,j,k=0;
a=r;
a=c;
a=0;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&n);
if(n!=0)
{
++k;
a[k]=i;
a[k]=j;
a[k]=n;
a++;
}
}
}
}``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.