complex
Factor documentation > 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
IN: math

TUPLE: complex
{ real real read-only initial: 0 }
{ imaginary real read-only initial: 0 } ;


Methods
USING: kernel math math.complex.private math.functions ;

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 math.functions prettyprint.custom ;

M: complex >pprint-sequence >rect 2array ;


USING: kernel math math.functions ;

M: complex >rect [ real-part ] [ imaginary-part ] bi ; inline


USING: math math.functions.private ;

M: complex ^n (^n) ;


USING: math math.functions ;

M: complex abs absq sqrt ; inline


USING: kernel math math.functions ;

M: complex absq >rect [ sq ] bi@ + ; inline


USING: math math.functions ;

M: complex atan i* atanh i* ; inline


USING: alien.data kernel math math.functions ;

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


USING: kernel math math.functions ;

M: complex hashcode* nip >rect [ hashcode ] bi@ bitxor ; inline


USING: accessors math ;

M: complex imaginary-part imaginary>> ; inline


USING: kernel math math.functions math.libm ;

M: complex log >polar [ flog ] dip rect> ; inline


USING: math math.functions ;

M: complex log10 log 10 log / ; inline


USING: kernel layouts math math.bitwise math.functions
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: math prettyprint.custom ;

M: complex pprint* pprint-object ;


USING: kernel math prettyprint.custom ;

M: complex pprint-delims drop \ C{ \ } ;


USING: accessors math ;

M: complex real-part real>> ; inline


USING: kernel math math.functions ;

M: complex signum dup abs / ;


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 / ;


USING: kernel math math.functions ;

M: complex tanh [ sinh ] [ cosh ] bi / ;