R语言 获取矩阵的行列式 – det()函数

R语言 获取矩阵的行列式 – det()函数

R语言中的 det() 函数是用来计算指定矩阵的行列式的。

语法: det(x, …)

参数:

x: 矩阵

例1 :

# R program to illustrate
# det function
  
# Initializing a matrix with
# 3 rows and 3 columns
x <- matrix(c(3, 2, 6, -1, 7, 3, 2, 6, -1), 3, 3)
  
# Getting the matrix representation
x
  
# Calling the det() function
det(x)
R

输出

     [, 1] [, 2] [, 3]
[1, ]    3   -1    2
[2, ]    2    7    6
[3, ]    6    3   -1

[1] -185
R

例2 :

# R program to illustrate
# det function
  
# Initializing a matrix with
# 3 rows and 3 columns
x <- matrix(c(3, 2, 6, -1, 7, 3, 2, 6, -1), 3, 3)
  
# Getting the matrix representation
x
  
# Getting the transpose of the matrix x
y <- t(x)
y
  
# Calling the det() function
det(y)
R

输出

     [, 1] [, 2] [, 3]
[1, ]    3   -1    2
[2, ]    2    7    6
[3, ]    6    3   -1

     [, 1] [, 2] [, 3]
[1, ]    3    2    6
[2, ]   -1    7    3
[3, ]    2    6   -1

[1] -185
R

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册