www.farid-hajji.net banner

Farid Hajji

Perl: Einführung, Anwendungen, Referenz (2/e) [Support-Site]

Farid Hajji: Perl - Einführung, Anwendungen, Referenz
2., aktualisierte und erweiterte Auflage
Addison-Wesley Longman, ISBN 3-8273-1535-2

Beispielprogramm

ST/Xten/Xten.pm
package ST::Xten;

use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

require Exporter;
require DynaLoader;
require AutoLoader;

@ISA       = qw(Exporter DynaLoader);
@EXPORT    = qw();
@EXPORT_OK = qw(t_norm1 t_norm2 t_norminf
        v_norm1 v_norm2 v_norminf
        v_normalize);
$VERSION = '0.01';

bootstrap ST::Xten $VERSION;

# Wir haben keine Anpassungsfunktionen hier.
# Preloaded methods go here.
# Autoload methods go after =cut, and are processed by the
# autosplit program.

1;
__END__

=head1 NAME

ST::Xten - Perl extension for calculating various norms.

=head1 SYNOPSIS

  use ST::Xten qw(t_norm1 t_norm2 t_norm3
          v_norm1 v_norm2 v_norm3
          v_normalize);

  $norm1 = t_norm1($x0, $x1, $x2);     # |x0| + |x1| + |x2|
  $norm2 = t_norm2($x0, $x2, $x2);     # sqrt(x0^2 + x1^2 + x2^2)
  $normi = t_norminf($x0, $x1, $x2);   # max(|x0|,|x1|,|x2|)

  $vn1   = v_norm1($x0, $x1, $x2, ...);   # t_norm1 with n coords
  $vn2   = v_norm2(@coodlist);            # t_norm2 with n coords
  $vn3   = v_norminf(@list_of_coords);    # t_norminf with n coords

  @normalized = v_normalize(@coordlist);  # normalizes with eukl. norm
  
=head1 DESCRIPTION

Calculating the norm of a vector can be done more efficiently in
C, if the number of coodinates is big. This extension just shows
how to calculate the various norms of a vector.

The first three t_*() functions calculate the norms of a
threedimensional vector. Please note that the number of
coordinates are fixed here.

The v_norm*() functions calculate the norms of a vector having
an arbitrary number of coordinates ranging from 1 to the number
of passed parameters.

The v_normalize() function returns a vector, normalized with
respect to the euclidian norm.

The 1-norm is just the sum of the absolute values of all coordinates
of a vector. The 2-norm is the familiar distance norm.
The infinity-norm, also termed maximum norm is the maximum
of the absolute values of the coordinates of a vector.

=head1 AUTHOR

Farid Hajji, farid.hajji@ob.kamp.net

=head1 SEE ALSO

perl(1), perlxs(1), perlxstut(1) and perlguts(1).

=cut
   

[Prev] [Up] [Relevant Chapter] [Next]

[Alte Quelle]


Last modified: $Date: 2006/05/18 12:56:13 $
FH. Search :: Sitemap :: Disclaimer :: Copyright :: Privacy
FreeBSD Logo