answersLogoWhite

0


Best Answer

Program to find the Transpose of a Matrix

#include

#include

void main()

{

int i,j,n,t;

int m[5][5];

clrscr();

printf("Enter Order of Matrix : ");

scanf("%d",&n);

printf("Enter Elements of Matrix :\n\n");

for(i=0;i

{

for(j=0;j

{

scanf("%d",&m[i][j]);

}

}

printf("Transpose of the Matrix :\n\n");

for(i=0;i

{

for(j=i+1;j

{

t=m[i][j];

m[i][j]=m[j][i];

m[j][i]=t;

}

}

for(i=0;i

{

for(j=0;j

{

printf("\t%d",m[i][j]);

}

printf("\n");

}

getch();

}

Output:

Enter Order of Matrix : 3

Enter Elements of Matrix :

45 56 96

75 36 15

29 64 81

Transpose of the Matrix :

45 75 29

56 36 64

96 15 81

with out using temp variable:

#include

#include

void main()

{

int i,j,n,t;

int m[5][5];

clrscr();

printf("Enter Order of Matrix : ");

scanf("%d",&n);

printf("Enter Elements of Matrix :\n\n");

for(i=0;i

{

for(j=0;j

{

scanf("%d",&m[i][j]);

}

}

printf("Transpose of the Matrix :\n\n");

for(i=0;i

{

for(j=i+1;j

{

m[j][i]=(m[i][j]+m[j][i]-(m[i][j]=m[j][i]));

}

}

for(i=0;i

{

for(j=0;j

{

printf("\t%d",m[i][j]);

}

printf("\n");

}

getch();

}

User Avatar

Wiki User

βˆ™ 12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

βˆ™ 11y ago
Algorithm for the Transpose of a Sparse-Matrix:This is the algorithm that converts a compressed-column sparse matrix into a compressed-row sparse matrix. It computes number of rows in A, compares the cummulative sum to generate row pointers and then iterates over each nonzero entry in A, storing the entry in its corresponding row vector. If the matrix resulted in this procedure is a sparce matrix C and can be interpreted as a matrix in compressed-row form then, C is equal to A. If C is a compressed-column matrix, then C contains Transpose of A.

The code is

cs *cs_transpose(const cs *A, int values)

{

int p,q,j,*cp,*ci,n,m,*Ap,*Ai,*W;

cs *C;

double *Cx,*Ax;

if(!CS_CSC(A))

return(NULL);

m=A->m;

n=A->n;

Ap=A->p;

Ai=A->i;

Ax=A->x;

C=cs_spalloc(n,m,Ap[n],values && Ax,0);

W=cs_calloc(m,sizeof(int));

if(!C!W)

return(cs_done(C,W,NULL,0));

Cp=C->p;

Ci=C->i;

Cx=C->x;

for(p=0;p

W[Ai[p]]++;

cs_cumsum(Cp,W,m);

for(j=0;j

{

for(p=Ap[j];p

{

Ci[q=W[Ai[p]]++]=j;

if(Cx)

Cx[q]=Ax=[p];

}

}

return(cs_done(C,W,NULL,1));

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to transpose of a matrix?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you write a java program to find the transpose of the matrix for the given elements?

You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.


What is matrix programming in C programming?

C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.


What is a fast-transpose algorithm for sparse matrices?

A fast-transpose is a computer algorithm that quickly transposes a sparse matrix using a relatively small amount of memory. Using arrays normally to record a sparse matrix uses up a lot of memory since many of the matrix's values are zero. In addition, using the normal transpose algorithm to transpose this matrix will take O(cols*elements) amount of time. The fast-transpose algorithm only uses a little memory to record the matrix and takes only O(cols+elements) amount of time, which is efficient considering the number of elements equals cols*rows.


Write a program to print the sum of a sparse matrix?

This is a directive, not a question.

Related questions

How do you write a java program to find the transpose of the matrix for the given elements?

You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.


Is it true that the transpose of the transpose of a matrix is the original matrix?

yes, it is true that the transpose of the transpose of a matrix is the original matrix


Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix?

Sp[[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix|Answer]]ell chec[[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix&action=edit&section=new|Answer it!]]k your answe[[Q/Discuss:Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix|Disc]][[help/answering questions|guidelin]]Spell check your answeresussionr[[help/signing in|full benefits]] Save C[[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix|Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 ]][[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix&action=edit&section=new|Answering 'Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix?']]matrix?ancel[[Q/How many animals are in West Texas|How many animals are in West Texas?]][[Q/How do you increase the number of four wheelers vehicles for servicing in a Service workshop|How do you increase the number of four wheelers vehicles for servicing in a]][[Q/How do you increase the number of four wheelers vehicles for servicing in a Service workshop|How do you increase the number of four wheelers vehicles for servicing in a Service workshop?]] Service workshop?[[Q/How do you increase the number of four wheelers vehicles for servicing in a Service workshop|How do you increase the number of four wheelers vehicles for servicing in a Service workshop?]]More Q&A


What is the definition of transpose in regards to a matrix?

The Transpose of a MatrixThe matrix of order n x m obtained by interchanging the rows and columns of the m X n matrix, A, is called the transpose of A and is denoted by A' or AT.


Write a program to multiply 33 matrix.?

write a program to multily 3*3 matrix.


What is a symmetric matrix?

a square matrix that is equal to its transpose


What is transpose of the sparse matrix?

Another sparse matrix.


What is matrix programming in C programming?

C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion


How do you find transportation of matrix?

Invert rows and columns to get the transpose of a matrix


2x2 matrix multiplication program in 8085 processor?

how to write a program for matrix multiplication in microprocesspr


What is the meaning of transpose?

The transpose of a matrix A is the matrix B that is obtained by swapping the rows and columns of A into the columns and rows of B. In algebraic form, if A = {aij} then B = {aji} is its transpose, where 1 ≤ i ≤ n and 1 ≤ j ≤ m.


What is an adjoint matrix?

The classical adjoint of a square matrix A the transpose of the matrix who (i, j) entry is the a i j cofactor.