Handbook
Glossary
recip ( x -- y )
Factor handbook
»
The language
»
Numbers
»
Mathematical functions
»
Arithmetic functions
Prev:
neg ( x -- -x )
Next:
conjugate ( z -- z* )
Vocabulary
math
Inputs
x
a
number
Outputs
y
a
number
Word description
Computes a number's multiplicative inverse.
Errors
Throws an error if
x
is the integer 0.
Definition
IN:
math
GENERIC:
recip
( x -- y )
Methods
USING:
kernel
math
math.ratios
math.ratios.private
;
M:
integer
recip
1
swap
[
division-by-zero
]
[
dup
0
<
[
[
neg
]
bi@
]
when
fraction>
]
if-zero
;
USING:
math
math.matrices
math.matrices.extras.private
;
M:
matrix
recip
(specialized-inverse)
;
inline
USING:
kernel
math
;
M:
number
recip
1
swap
/
;
inline
USING:
kernel
math
math.ratios.private
;
M:
ratio
recip
>fraction
swap
dup
0
<
[
[
neg
]
bi@
]
when
fraction>
;
USING:
math
math.matrices
math.matrices.extras.private
;
M:
square-matrix
recip
(square-inverse)
;
inline
USING:
math
math.matrices
;
M:
zero-matrix
recip
transpose
;
inline
USING:
math
math.matrices
;
M:
zero-square-matrix
recip
;
inline