linalg_norm | R Documentation |
If A
is complex valued, it computes the norm of A$abs()
Supports input of float, double, cfloat and cdouble dtypes.
Whether this function computes a vector or matrix norm is determined as follows:
linalg_norm(A, ord = NULL, dim = NULL, keepdim = FALSE, dtype = NULL)
A |
(Tensor): tensor of shape |
ord |
(int, float, inf, -inf, 'fro', 'nuc', optional): order of norm. Default: |
dim |
(int, Tupleint, optional): dimensions over which to compute
the vector or matrix norm. See above for the behavior when |
keepdim |
(bool, optional): If set to |
dtype |
dtype ( |
If dim
is an int, the vector norm will be computed.
If dim
is a 2-tuple, the matrix norm will be computed.
If dim=NULL
and ord=NULL
, A will be flattened to 1D and the 2-norm of the resulting vector will be computed.
If dim=NULL
and ord!=NULL
, A must be 1D or 2D.
ord
defines the norm that is computed. The following norms are
supported:
ord | norm for matrices | norm for vectors |
NULL (default) | Frobenius norm | 2 -norm (see below) |
"fro" | Frobenius norm | – not supported – |
"nuc" | nuclear norm | – not supported – |
Inf | max(sum(abs(x), dim=2)) | max(abs(x)) |
-Inf | min(sum(abs(x), dim=2)) | min(abs(x)) |
0 | – not supported – | sum(x != 0) |
1 | max(sum(abs(x), dim=1)) | as below |
-1 | min(sum(abs(x), dim=1)) | as below |
2 | largest singular value | as below |
-2 | smallest singular value | as below |
other int or float | – not supported – | sum(abs(x)^{ord})^{(1 / ord)} |
Other linalg:
linalg_cholesky_ex()
,
linalg_cholesky()
,
linalg_det()
,
linalg_eigh()
,
linalg_eigvalsh()
,
linalg_eigvals()
,
linalg_eig()
,
linalg_householder_product()
,
linalg_inv_ex()
,
linalg_inv()
,
linalg_lstsq()
,
linalg_matrix_norm()
,
linalg_matrix_power()
,
linalg_matrix_rank()
,
linalg_multi_dot()
,
linalg_pinv()
,
linalg_qr()
,
linalg_slogdet()
,
linalg_solve_triangular()
,
linalg_solve()
,
linalg_svdvals()
,
linalg_svd()
,
linalg_tensorinv()
,
linalg_tensorsolve()
,
linalg_vector_norm()
if (torch_is_installed()) {
a <- torch_arange(0, 8, dtype = torch_float()) - 4
a
b <- a$reshape(c(3, 3))
b
linalg_norm(a)
linalg_norm(b)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.