1Statistics::Basic::VectUosre(r3)Contributed Perl DocumenSttaattiiosntics::Basic::Vector(3)
2
3
4

NAME

6       Statistics::Basic::Vector - a class for handling lists of numbers
7

SYNOPSIS

9       Invoke it this way:
10
11           my $vector      = vector(1,2,3);
12           my $same_vector = vector($vector);
13           my $different   = $vector->copy;
14
15       This module tracks which of the other Statistics::Basic modules use it.
16       That's it's primary purpose.  Although, it does also have overloads to
17       print the vectors in a pretty fashion.
18
19           print "$vector\n"; # pretty printed
20

METHODS

22       new()
23           The constructor can take a single array ref or a single
24           Statistics::Basic::Vector as its argument.  It can also take a list
25           of values.
26
27           It returns a Statistics::Basic::Vector object.
28
29           If given a vector object argument, this function will return the
30           argument rather than creating a new vector.  This mainly used by
31           the other Statistics::Basic modules to try to prevent duplicate
32           calculations.
33
34           A vector's max size is set to the size of the argument or list on
35           initialization.
36
37           Note: normally you'd use the vector() constructor, rather than
38           building these by hand using "new()".
39
40       copy()
41           Creates a new vector object with the same contents and size as this
42           one and returns it.
43
44               my $v1 = vector(3,7,9);
45               my $v2 = $v1->copy(); # $v2 is a new object, separate vector
46               my $v3 = vector($v1); # $v3 is the same object as $v1
47
48       insert()
49           Insert new values into the vector.  If the vector was already full
50           (see "set_size()"), this will also shift oldest elements from the
51           vector to compensate.
52
53               $vector->insert( 4, 3 ); # insert a 3 and a 4
54
55           This function returns the object itself, for chaining purposes.
56
57       append() ginsert()
58           Insert new values into the vector.  If the vector was already full
59           (see "set_size()"), these functions will grow the size of the
60           vector to accommodate the new values, rather than shifting things.
61           "ginsert()" does the same thing.
62
63               $vector->append( 4, 3 ); # append a 3 and a 4
64
65           This function returns the object itself, for chaining purposes.
66
67       query()
68           "query()" returns the contents of the vector either as a list or as
69           an arrayref.
70
71               my @copy_of_contents      = $vector->query;
72               my $reference_to_contents = $vector->query;
73
74           Note that changing the $reference_to_contents will not usefully
75           affect the contents of the vector itself, but it will adversely
76           affect any computations based on the vector.  If you need to change
77           the contents of a vector in a special way, use a
78           Statistics::Basic::ComputedVector object instead.
79
80           Keeping $reference_to_contents available long term should work
81           acceptably (since it refers to the vector contents itself).
82
83       query_filled()
84           Returns true when the vector is the same size as the max size set
85           by "set_size()".  This function isn't useful unless operating under
86           the effects of the nofill setting.
87
88       query_size()
89           Returns the current number of elements in the vector object (not
90           the size set with "set_size()").  This is almost never false unless
91           you're using the nofill setting.
92
93       set_size()
94           Sets the max size of the vector.
95
96               my $v1 = vector(1,2,3);
97                  $v1->set_size(7); # [0, 0, 0, 0, 1, 2, 3]
98
99           Unless nofill is set, the vector will be filled with 0s (assuming
100           the vector wouldn't otherwise be full) on the oldest side of the
101           vector (so an insert will push off one of the filled-zeros).
102
103           This function returns the object itself, for chaining purposes.
104
105               my $v1 = vector(2 .. 5)->set_size(5);
106               # [0, 2, 3, 4, 5]
107
108       set_vector()
109           Given a vector or array ref, this will set the contents (and size)
110           of the input vector to match the argument.  If given a vector
111           object argument, this will make the two vectors match, while still
112           remaining separate objects.
113
114               my $v1 = vector(3,7,9);
115               my $v2 = vector()->set_vector($v1);
116               my $v3 = vector($v1); # $v3 is the same object as $v1
117
118           This function returns the object itself, for chaining purposes.
119

OVERLOADS

121       This object is overloaded.  It tries to return an appropriate string
122       for the vector and raises errors in numeric context.
123
124       In boolean context, this object is always true (even when empty).
125

AUTHOR

127       Paul Miller "<jettero@cpan.org>"
128
130       Copyright 2009 Paul Miller -- Licensed under the LGPL
131

SEE ALSO

133       perl(1), Statistics::Basic
134
135
136
137perl v5.12.3                      2009-06-28      Statistics::Basic::Vector(3)
Impressum