Skip to content
Related Articles

Related Articles

Check if a Matrix is Symmetric or not in R Programming – isSymmetric() Function
  • Last Updated : 16 Jun, 2020

isSymmetric() function in R Language is used to check if a matrix is a symmetric matrix. A Symmetric matrix is one whose transpose is equal to the matrix itself.

Syntax: isSymmetric(x)

Parameters:
x: Matrix to be checked

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to check if 
# a matrix is symmetric
  
# Creating a diagonal matrix
x1 <- diag(3)
  
# Creating a matrix
x2 <- matrix(c(1, 2, 2, 3), 2)
  
# Calling isSymmetric() function
isSymmetric(x1)
isSymmetric(x2)

chevron_right


Output:

[1] TRUE
[1] TRUE

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to check if 
# a matrix is symmetric
  
# Creating a matrix
x1 <- matrix(c(1:9), 3, 3)
  
# Calling isSymmetric() function
isSymmetric(x1)

chevron_right


Output:

[1] FALSE
My Personal Notes arrow_drop_up
Recommended Articles
Page :