complex - Factor Documentation (original) (raw)
complex
Factor handbook » The language » Numbers » Complex numbers
Next: | real-part ( z -- x ) |
---|
Vocabulary
math
Class description
The class of complex numbers with non-zero imaginary part.
Definition
TUPLE: complex
{ real real read-only initial: 0 }
{ imaginary real read-only initial: 0 } ;
Methods
USING: kernel math math.complex.private ;
M: complex * [ *re - ] [ *im + ] 2bi rect> ; inline
USING: math math.complex.private ;
M: complex + [ + ] complex-op ; inline
USING: math math.complex.private ;
M: complex - [ - ] complex-op ; inline
USING: math math.complex.private ;
M: complex / [ / ] complex/ ; inline
USING: math math.complex.private ;
M: complex /f [ /f ] complex/ ; inline
USING: math math.complex.private ;
M: complex /i [ /i ] complex/ ; inline
USING: arrays math prettyprint.custom ;
M: complex >pprint-sequence >rect 2array ;
M: complex >rect [ real-part ] [ imaginary-part ] bi ; inline
USING: math math.functions.private ;
M: complex abs absq sqrt ; inline
USING: kernel math math.functions ;
M: complex absq >rect [ sq ] bi@ + ; inline
M: complex atan i* atanh i* ; inline
USING: alien.data kernel math ;
M: complex binary-zero? >rect [ binary-zero? ] both? ; inline
USING: kernel math math.functions math.libm ;
M: complex cos
>float-rect
[ [ fcos ] [ fcosh ] bi* * ]
[ [ fsin neg ] [ fsinh ] bi* * ] 2bi rect> ;
USING: kernel math math.functions math.libm ;
M: complex cosh
>float-rect
[ [ fcosh ] [ fcos ] bi* * ] [ [ fsinh ] [ fsin ] bi* * ]
2bi rect> ;
USING: kernel math math.functions ;
M: complex e^ >rect [ e^ ] dip polar> ; inline
USING: compiler.tree.propagation.info kernel math ;
M: complex eql? over complex? [ = ] [ 2drop f ] if ;
USING: kernel math math.complex.private ;
M: complex equal?
over complex? [ [ = ] complex= ] [ 2drop f ] if ; inline
M: complex hashcode* nip >rect [ hashcode ] bi@ bitxor ; inline
M: complex imaginary-part imaginary>> ; inline
USING: kernel math math.functions math.libm ;
M: complex log >polar [ flog ] dip rect> ; inline
M: complex log10 log 10 log / ; inline
USING: kernel layouts math math.bitwise math.hashcodes ;
M: complex number-hashcode
>rect [ number-hashcode ] bi@ 1000003 * +
cell-bits on-bits bitand dup -1 = [ drop -2 ] when ;
USING: math math.complex.private ;
M: complex number= [ number= ] complex= ; inline
USING: kernel math math.text.english sequences ;
M: complex number>text
>rect
[ number>text ] [
[ 0 < " minus " " plus " ? ]
[ abs number>text " i" append ] bi
] bi* 3append ;
USING: math prettyprint.custom ;
M: complex pprint* pprint-object ;
USING: kernel math prettyprint.custom ;
M: complex pprint-delims drop \ C{ \ } ;
USING: accessors kernel math math.parser present sequences ;
M: complex present
[ real>> number>string ] [
imaginary>>
[ number>string ] [ 0 >= [ "+" prepend ] when ] bi
] bi "j" 3append ;
M: complex real-part real>> ; inline
USING: kernel math math.functions ;
USING: kernel math math.functions math.libm ;
M: complex sin
>float-rect
[ [ fsin ] [ fcosh ] bi* * ] [ [ fcos ] [ fsinh ] bi* * ]
2bi rect> ;
USING: kernel math math.functions math.libm ;
M: complex sinh
>float-rect
[ [ fsinh ] [ fcos ] bi* * ] [ [ fcosh ] [ fsin ] bi* * ]
2bi rect> ;
USING: kernel math math.functions ;
M: complex sqrt >polar [ sqrt ] [ 2.0 / ] bi* polar> ; inline
USING: kernel math math.functions ;
M: complex tan [ sin ] [ cos ] bi / ;