ID EN
Vector & List

crossprod

R Base 3.6.2 🇮🇩 Bahasa Indonesia

Mengingat matriks x dan y sebagai argumen, kembalikan perkalian silang matriks. Ini secara formal setara dengan (tetapi biasanya sedikit lebih cepat dari) panggilan t(x) %*% y (crossprod) atau x %*% t(y) (tcrossprod).

Syntax

R
crossprod(x, y = NULL)<p></p><p>tcrossprod(x, y = NULL)</p>

Arguments

Parameter Deskripsi
x, y numeric or complex matrices (or vectors): y = NULL is taken to be the same matrix as x. Vectors are promoted to single-column or single-row matrices, depending on the context.

Return Value

Matriks ganda atau kompleks, dengan nama dim yang sesuai diambil dari x dan y.

Contoh

Example
R
# NOT RUN {
(z <- crossprod(1:4))    # = sum(1 + 2^2 + 3^2 + 4^2)
drop(z)                  # scalar
x <- 1:4; names(x) <- letters[1:4]; x
tcrossprod(as.matrix(x)) # is
identical(tcrossprod(as.matrix(x)),
          crossprod(t(x)))
tcrossprod(x)            # no dimnames

m <- matrix(1:6, 2,3) ; v <- 1:3; v2 <- 2:1
stopifnot(identical(tcrossprod(v, m), v %*% t(m)),
          identical(tcrossprod(v, m), crossprod(v, t(m))),
          identical(crossprod(m, v2), t(m) %*% v2))
# }

See Also

%*% and outer product %o%.