Introduction:
A square matrix A = [aij] is said to be skew symmetric matrix if A' = -A , that is aji = -aij for all possible values of i an dj. Now, if we put i=j, we have
aii = -aii. Therefore 2aii = 0 or aii = 0 for all i's. This means that all the diagonal element of a skew symmetric matrix are zero.
For example:
Code snippet:
A square matrix A = [aij] is said to be skew symmetric matrix if A' = -A , that is aji = -aij for all possible values of i an dj. Now, if we put i=j, we have
aii = -aii. Therefore 2aii = 0 or aii = 0 for all i's. This means that all the diagonal element of a skew symmetric matrix are zero.
For example:
Fig: Skew Symmetric matrix |
- using System;
- public class SkewSymmetry
- {
- public static void Main()
- {
- int[,] matA = new int[10,10];
- int[,] matB = new int[10,10];
- int[,] matC = new int[10,10];
- bool isSkew = true;
- int i, j, ord;
- Console.Write("Enter the order of Matrix A: ");
- ord = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("\nEnter the Element of Matrix: ");
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- Console.Write("Matrix[{0},{1}] : ", i, j);
- matA[i,j]=Convert.ToInt32(Console.ReadLine());
- }
- }
- Console.ReadLine();
- Console.WriteLine("Matrix A: ");
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- Console.Write(" {0}", matA[i,j]);
- }
- }
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- matB[i,j] = matA[i,j] * (-1);
- }
- }
- Console.WriteLine("Matrix A' : ");
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- Console.Write(" {0}", matA[j,i]);
- }
- }
- Console.ReadLine();
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- matC[i,j] = matA[j,i];
- }
- }
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- if(matC[i,j] != matB[i,j])
- {
- isSkew = false;
- break;
- }
- }
- }
- if(isSkew == false)
- {
- Console.WriteLine("Not Skew Symmetric");
- }
- else
- {
- Console.WriteLine("The matrix is Skew Symmetric");
- }
- Console.ReadLine();
- }
- }
** Complete code
Description:
In the above code first of all we ask user to input the order of matrix after that we enter the element of the matrix and we print the matrix on the console. there are three 2-dimensional array in the above code matA, matB, matC. MatA is the main 2-dimensional array on which we apply the transpose operation. To do this firstly we copy all the element of matA to matC now multiply the matC[] to -1 after matA[] is going to the transpose operation.
- Console.WriteLine("Matrix A' : ");
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- Console.Write(" {0}", matA[j,i]);
- }
- }
- Console.ReadLine();
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- matC[i,j] = matA[j,i];
- }
- }
- for(i = 0; i<ord; i++)
- {
- Console.WriteLine();
- for(j = 0; j<ord; j++)
- {
- if(matC[i,j] != matB[i,j])
- {
- isSkew = false;
- break;
- }
- }
- }
- if(isSkew == false)
- {
- Console.WriteLine("Not Skew Symmetric");
- }
- else
- {
- Console.WriteLine("The matrix is Skew Symmetric");
- }
In this code:
the transpose of matrix is copied in matC[] aafter that we compare matB[] and matC[] and according result answer print in console.
Logic:
Step 1: matA[i,j];
Step 2: matB[i,j] = matA[i,j];
Step 3: matB[i,j] = matB[i,j] * (-1);
Step 3: matA'[i,j];
Step 4: matC[i,j] = matA'[i,j];
Step 5: compare (matB[i,j] == matC[i,j]);
Step 6: if yes
matrix is symmetric;
Step 7: else
not symmetric matrix
Screenshots:
Screenshot of Output |
Read Also: