Trans_orthogonal_basis <- function(A)
{
n_col <- ncol(A)
n_row <- nrow(A)
B <- A
if((n_col == n_row)&(n_row>1))
{
if(Matrix::rankMatrix(A)[1] == n_col)
{
for(i in 2:n_col)
{
temp1 <- 0
temp2 <- 0
for(j in 1:(i-1))
{
temp1 <- ((sum(A[,i]*B[,j]))/(sum(B[,j]*B[,j])))*B[,j]
temp2 <- temp2 + temp1
}
B[,i] <- A[,i] - temp2
}
}
}
A <- B
cat("未单位化\n")
print(MASS::fractions(A))
return(apply(A,2,function(x){x/sqrt(sum(x*x))}))
}
X <- matrix(c(1,-1,-1,1,1,1,0,0,1,0,1,0,-1,0,0,1),nrow = 4)
Trans_orthogonal_basis(X)
把一般的基地化为标准正交基底
最新推荐文章于 2022-06-03 11:25:47 发布