]> gitweb.factorcode.org Git - factor.git/blob - basis/math/complex/complex-docs.factor
Fix permission bits
[factor.git] / basis / math / complex / complex-docs.factor
1 USING: help.markup help.syntax math math.private math.functions
2 math.complex.private ;
3 IN: math.complex
4
5 ARTICLE: "complex-numbers-zero" "Embedding of real numbers in complex numbers"
6 "Constructing a complex number with an imaginary component equal to an integer zero simply returns the real number corresponding to the real component:"
7 { $example "USING: math prettyprint ;" "C{ 1 2 } C{ 3 -2 } + ." "4" }
8 "Constructing a complex number with an imaginary component equal to floating point zero will still output a new complex number, however:"
9 { $example "USING: math prettyprint ;" "C{ 0.0 2.0 } C{ 0.0 1.0 } * ." "C{ 2.0 0.0 }" }
10 "Unlike math, where all real numbers are also complex numbers, Factor only considers a number to be a complex number if its imaginary part is non-zero. However, complex number operations are fully supported for real numbers; they are treated as having an imaginary part of zero." ;
11
12 ARTICLE: "complex-numbers" "Complex numbers"
13 { $subsection complex }
14 "Complex numbers arise as solutions to quadratic equations whose graph does not intersect the " { $emphasis "x" } " axis. Their literal syntax is covered in " { $link "syntax-complex-numbers" } "."
15 $nl
16 "Complex numbers can be taken apart:"
17 { $subsection real-part }
18 { $subsection imaginary-part }
19 { $subsection >rect }
20 "Complex numbers can be constructed from real numbers:"
21 { $subsection rect> }
22 { $subsection "complex-numbers-zero" }
23 { $see-also "syntax-complex-numbers" } ;
24 HELP: complex
25 { $class-description "The class of complex numbers with non-zero imaginary part." } ;
26
27 ABOUT: "complex-numbers"
28
29 HELP: 2>rect
30 { $values { "x" "a complex number" } { "y" "a complex number" } { "xr" "real part of " { $snippet "x" } } { "xi" "imaginary part of " { $snippet "x" } } { "yr" "real part of " { $snippet "y" } } { "yi" "imaginary part of " { $snippet "y" } } }
31 { $description "Extracts real and imaginary components of two numbers at once." } ;
32
33 HELP: complex/
34 { $values { "x" "a complex number" } { "y" "a complex number" } { "r" "a real number" } { "i" "a real number" } { "m" "a real number" } }
35 { $description
36     "Complex division kernel. If we use the notation from " { $link 2>rect } ", this word computes:"
37     { $code
38         "r = xr*yr+xi*yi"
39         "i = xi*yr-xr*yi"
40         "m = yr*yr+yi*yi"
41     }
42 } ;
43
44 HELP: <complex> ( x y -- z )
45 { $values { "x" "a real number" } { "y" "a real number" } { "z" "a complex number" } }
46 { $description "Low-level complex number constructor. User code should call " { $link rect> } " instead." } ;