R 语言中的 determinant() 函数是一个通用函数,它分别返回行列式的模数(可选对数刻度)和行列式的符号。
用法: determinant(x, logarithm = TRUE, …)
参数:
x:矩阵
logarithm:如果 TRUE(默认)返回行列式模数的对数
范例1:
# R program to illustrate
# determinant 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 determinant() function
determinant(x)输出:
[, 1] [, 2] [, 3]
[1, ] 3 -1 2
[2, ] 2 7 6
[3, ] 6 3 -1
$modulus
[1] 5.220356
attr(, "logarithm")
[1] TRUE
$sign
[1] -1
attr(, "class")
[1] "det"
范例2:
# R program to illustrate
# determinant function
# Initializing a matrix with
# 2 rows and 2 columns
x <- matrix(c(1, 2, 3, 4), 2, 2)
# Getting the matrix representation
x
# Calling the determinant() function
determinant(x, logarithm = FALSE)输出:
[, 1] [, 2]
[1, ] 1 3
[2, ] 2 4
$modulus
[1] 2
attr(, "logarithm")
[1] FALSE
$sign
[1] -1
attr(, "class")
[1] "det"
相关用法
- R语言 det()用法及代码示例
- R语言 col()用法及代码示例
- R语言 row()用法及代码示例
- R语言 is.matrix()用法及代码示例
- R语言 data.matrix()用法及代码示例
- R语言 as.matrix()用法及代码示例
- R语言 length()用法及代码示例
- R语言 charmatch()用法及代码示例
- R语言 class()用法及代码示例
- R语言 typeof()用法及代码示例
- R语言 strftime()用法及代码示例
- R语言 density()用法及代码示例
- R语言 lower.tri()用法及代码示例
- R语言 dim()用法及代码示例
- R语言 colSums()用法及代码示例
- R语言 colMeans()用法及代码示例
- R语言 diag()用法及代码示例
- R语言 str_detect()用法及代码示例
- R语言 apply()用法及代码示例
注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Getting the Modulus of the Determinant of a Matrix in R Programming – determinant() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
