]> gitweb.factorcode.org Git - factor.git/blob - core/float-arrays/float-arrays-docs.factor
cb36aade6b51fc66ec89212ce986a8aa1573d5b3
[factor.git] / core / float-arrays / float-arrays-docs.factor
1 USING: arrays bit-arrays vectors strings sbufs
2 kernel help.markup help.syntax math ;
3 IN: float-arrays
4
5 ARTICLE: "float-arrays" "Float arrays"
6 "Float arrays are fixed-size mutable sequences (" { $link "sequence-protocol" } ") whose elements are instances of " { $link float } ". Elements are unboxed, hence the memory usage is lower than an equivalent " { $link array } " of floats. The literal syntax is covered in " { $link "syntax-float-arrays" } "."
7 $nl
8 "Float array words are in the " { $vocab-link "float-arrays" } " vocabulary."
9 $nl
10 "Float arrays play a special role in the C library interface; they can be used to pass binary data back and forth between Factor and C. See " { $link "c-byte-arrays" } "."
11 $nl
12 "Float arrays form a class of objects."
13 { $subsection float-array }
14 { $subsection float-array? }
15 "There are several ways to construct float arrays."
16 { $subsection >float-array }
17 { $subsection <float-array> }
18 "Creating a float array from several elements on the stack:"
19 { $subsection 1float-array }
20 { $subsection 2float-array }
21 { $subsection 3float-array }
22 { $subsection 4float-array } ;
23
24 ABOUT: "float-arrays"
25
26 HELP: float-array
27 { $description "The class of float arrays. See " { $link "syntax-float-arrays" } " for syntax and " { $link "float-arrays" } " for general information." } ;
28
29 HELP: <float-array> ( n initial -- float-array )
30 { $values { "n" "a non-negative integer" } { "initial" float } { "float-array" "a new float array" } }
31 { $description "Creates a new float array holding " { $snippet "n" } " floats with the specified initial element." } ;
32
33 HELP: >float-array
34 { $values { "seq" "a sequence" } { "float-array" float-array } }
35 { $description "Outputs a freshly-allocated float array whose elements have the same floating-point values as a given sequence." }
36 { $errors "Throws an error if the sequence contains elements other than real numbers." } ;
37
38 HELP: 1float-array
39 { $values { "x" object } { "array" float-array } }
40 { $description "Create a new float array with one element." } ;
41
42 { 1array 2array 3array 4array } related-words
43
44 HELP: 2float-array
45 { $values { "x" object } { "y" object } { "array" float-array } }
46 { $description "Create a new float array with two elements, with " { $snippet "x" } " appearing first." } ;
47
48 HELP: 3float-array
49 { $values { "x" object } { "y" object } { "z" object } { "array" float-array } }
50 { $description "Create a new float array with three elements, with " { $snippet "x" } " appearing first." } ;
51
52 HELP: 4float-array
53 { $values { "w" object } { "x" object } { "y" object } { "z" object } { "array" float-array } }
54 { $description "Create a new float array with four elements, with " { $snippet "w" } " appearing first." } ;