Handbook
Glossary
p-norm ( k p -- x )
Matrix operations
Prev:
l-infinity-norm ( k -- x )
Vocabulary
math
.
vectors
Inputs
k
a
sequence
of
number
s
p
a positive real number
Outputs
x
a non-negative real number
Generic word contract
Computes the norm (size) of
k
in 𝑙ₚ (
L^p
) vector space, usually written ∥・∥ₚ.
See also
norm-sq
,
l1-norm
,
norm
,
l-infinity-norm
Definition
USING:
combinators
kernel
math
sequences
;
IN:
math.vectors
:
p-norm
( k p -- x )
{
{
[
dup
1
=
]
[
drop
l1-norm
]
}
{
[
dup
2
=
]
[
drop
l2-norm
]
}
{
[
dup
fp-infinity?
]
[
drop
maximum
]
}
[
p-norm-default
]
}
cond
;