Transpose of a square matrix in c and find the sum of elements of both diagonals of transposed matrix
Answers
Matrices and Determinants
Matrix definition
A matrix is an ordered rectangular array of elements or entries (components) arranged in rows and columns denoted by bold uppercase letters and indicated by brackets.
A matrix with m rows and n columns is called an m-by-n matrix that has an order (or dimension) of m ´ n
The element denoted aij lies at the intersection of the ith row and the jth column, as is shown above.
Square matrices
A matrix with same number of rows and columns (m = n) is a square matrix of order n.
The main diagonal of a square matrix is the diagonal that runs from the top left corner to the bottom right corner.
A square matrix with all components zero except those on the main diagonal is called the diagonal matrix.
The identity matrix
An n ´ n diagonal matrix with all non-zero elements equal to 1 is the identity matrix of order n.
An upper triangular matrix is a square matrix in which all elements underneath the main diagonal are zeros.
A lower triangular matrix is a square matrix in which all elements above the main diagonal are zeros.
Square matrices for which aij = aji are called symmetric about the main diagonal.
Examples of square matrices
The diagonal matrix of order 4, The identity matrix of order 3,
The upper triangular matrix of order 4, The lower triangular matrix of order 4,
The symmetric matrix of order 5,
The elements of the main diagonal are in bold.
A matrix whose all elements are zero is called the null matrix, written 0.
Vectors
A matrix with only one row or one column is called a vector.
A matrix with one row and n columns is called a row vector.
A matrix with one column and m rows is called a column vector.
Transposition
The transpose is the matrix derived from a given matrix by interchanging the rows and columns. Thus, the transpose of a matrix A of order m ´ n is another matrix denoted AT of order n ´ m.
Therefore, to transpose means to interchange the rows and columns of a matrix, that is,
AT = [aji], where j is the column and i is the row of matrix A = [aij].
Example: Given a matrix A of order 3 ´ 4, find the transpose AT.
Basic matrix operations
Matrix addition and subtraction
Matrices can be added or subtracted only if they have the same dimensions.
Addition
The elements of the sum of the two matrices with the same dimensions, A and B, are equal to the sums of the corresponding elements aij + bij that is,
A + B = [aij + bij].
Subtraction
The elements of the difference of the two matrices with the same dimensions, A and B, are equal to the differences of the corresponding elements aij - bij that is,
A - B = [aij - bij].
Example: Given are matrices, A and B, find the sum A + B and the difference A - B.
and
then,
and