NAME

VectorDouble - a perl scalar reference to a fixed packed array of doubles with arithmetic operations on the scalars, implemented in C.


SYNOPSIS

  use VectorDouble;
  my $a = new VectorDouble size => 5000, value => 10.1 ;
  print " \$a is " . $a . "\n";
  my $b = new VectorDouble size => 5000, first => 1, by => 3 ;
  print " \$b is " . $b . "\n";
  $a->[1] = 22;
  print " \$a->[1] is " . $a->[1] . "\n";
  my $c = $a * $b + $a;
  print " \$a * \$b + \$a is " . $c . "\n";


DESCRIPTION

A demonstration of Inline for the IPL class in the MSIE program at the Gradcenter of Marlboro College.

To see a demo, type

     perl VectorDouble.pm

at the shell prompt.

The currently implemented operations are

  * creating a constant array
     $a = new VectorDouble size=>10, value=>2;
  * creating a sequence
     $b = new VectorDouble size=>10, first=>1, by=>2
  * addition and multiplication
     $a + $b ; $a * $b
  * setting and fetching individual values
      $a->[2] = $b->[5]
  * testing for the existance of a value
      if ( exists $a->[101] ) { ... }
  * string representation
      print $a;

The size of a VectorDouble is fixed when it is created, and can be found from either $a->size or the perlism $#$a

Like perl arrays, the first element is always $a->[0] and the last is $a->[size-1]. All subscripts outside this range are converted to ones within this range with j=j % size.

A full implementation would also include things like

  * more binary operations (-, /, **, etc)
  * arithmetic with perl scalars,
    i.e. "$a=new VectorDouble; $b = $a + 1;"
  * mathematical functions like sin, cos, ...
  * some kind iteration,
    i.e. functions (perl or C) applied to each element.
  * better error testing and return values


AUTHOR

Jim Mahoney, Marlboro College (mahoney@marlboro.edu)


LICENSE

Same terms as Perl.


SEE ALSO

perl(1), PDL