9 MODULE = Math::Vector::XS PACKAGE = Math::Vector::XS
16 # my $vec = Math::Vector::XS->new( \@numbers );
18 # Create a new vector. The only argument is a reference to an array containing
19 # numbers, used to fill in the vector. The dimension of the newly created
20 # vector is determined by the length of this array.
35 /* create the object and populate it */
37 for ( i=0; i<=av_len(values); i++ ) {
38 orig = av_fetch(values, i, 0);
39 clone = newSViv( SvIV(*orig) );
43 /* Return a blessed reference to the AV */
44 RETVAL = newRV_noinc( (SV *)self );
45 stash = gv_stashpv( class, TRUE );
46 sv_bless( (SV *)RETVAL, stash );
53 # my $vec = Math::Vector::XS->new_zeroes( dimension );
55 # Create a new vector, set to the origin. The only argument is the dimension of
56 # the vector to be created.
58 # ->new_zeroes(2) is exactly equivalent to ->new([0,0])
61 new_zeroes( class, dimension )
72 /* create the object and populate it */
74 for ( i=0; i<dimension; i++ ) {
79 /* return a blessed reference to the AV */
80 RETVAL = newRV_noinc( (SV *)self );
81 stash = gv_stashpv( class, TRUE );
82 sv_bless( (SV *)RETVAL, stash );
92 # my $dims = $vec->get_dims;
94 # Return the number of dimensions, an integer.
101 RETVAL = av_len(self) + 1;
107 # my $val = $vec->get_component( $index );
109 # Return the value for dimension $index.
112 get_component( self, index )
120 val = av_fetch(self, index, 0);