If `A`

is complex valued, it computes the norm of `A$abs()`

Supports input of float, double, cfloat and cdouble dtypes.
This function does not necessarily treat multidimensonal `A`

as a batch of
vectors, instead:

## Arguments

- A
(Tensor): tensor, flattened by default, but this behavior can be controlled using

`dim`

.- ord
(int, float, inf, -inf, 'fro', 'nuc', optional): order of norm. Default:

`2`

- dim
(int, Tupleint, optional): dimensions over which to compute the vector or matrix norm. See above for the behavior when

`dim=NULL`

. Default:`NULL`

- keepdim
(bool, optional): If set to

`TRUE`

, the reduced dimensions are retained in the result as dimensions with size one. Default:`FALSE`

- dtype
dtype (

`torch_dtype`

, optional): If specified, the input tensor is cast to`dtype`

before performing the operation, and the returned tensor's type will be`dtype`

. Default:`NULL`

## Details

If

`dim=NULL`

,`A`

will be flattened before the norm is computed.If

`dim`

is an`int`

or a`tuple`

, the norm will be computed over these dimensions and the other dimensions will be treated as batch dimensions.

This behavior is for consistency with `linalg_norm()`

.

`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)}` |

## See also

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_norm()`

,
`linalg_pinv()`

,
`linalg_qr()`

,
`linalg_slogdet()`

,
`linalg_solve()`

,
`linalg_svdvals()`

,
`linalg_svd()`

,
`linalg_tensorinv()`

,
`linalg_tensorsolve()`

## Examples

```
if (torch_is_installed()) {
a <- torch_arange(0, 8, dtype = torch_float()) - 4
a
b <- a$reshape(c(3, 3))
b
linalg_vector_norm(a, ord = 3.5)
linalg_vector_norm(b, ord = 3.5)
}
#> torch_tensor
#> 5.43449
#> [ CPUFloatType{} ]
```