R의 행렬 곱셈
Sheeraz Gul
2023년6월21일
R
R Matrix

이 튜토리얼은 R에서 행렬 곱셈을 수행하는 방법을 보여줍니다.
R의 행렬 곱셈
R에서 %*%
연산자는 두 행렬 간의 곱셈을 수행합니다. 구문은 간단합니다. A %*% B
.
예를 보겠습니다.
demo_data <- c(2, 4, 2, 10, 41, 32, 20, 22, 61)
A <- matrix(demo_data, nrow = 3, ncol = 3)
demo_data1 <- c(10, 14, 21, 31, 50, 23, 11, 33, 23)
B <- matrix(demo_data1, nrow = 3, ncol = 3)
Multi_Result <- A %*% B
print("The Matrix A is: ")
print(A)
print("The Matrix B is: ")
print(B)
print("The Matrix Multiplication Result is:")
print(Multi_Result)
위의 코드는 두 개의 주어진 행렬을 곱합니다. 출력을 참조하십시오.
[1] "The Matrix A is: "
[,1] [,2] [,3]
[1,] 2 10 20
[2,] 4 41 22
[3,] 2 32 61
[1] "The Matrix B is: "
[,1] [,2] [,3]
[1,] 10 31 11
[2,] 14 50 33
[3,] 21 23 23
[1] "The Matrix Multiplication Result is:"
[,1] [,2] [,3]
[1,] 580 1022 812
[2,] 1076 2680 1903
[3,] 1749 3065 2481
튜토리얼이 마음에 드시나요? DelftStack을 구독하세요 YouTube에서 저희가 더 많은 고품질 비디오 가이드를 제작할 수 있도록 지원해주세요. 구독하다
작가: Sheeraz Gul
Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.
LinkedIn Facebook