Alien-FFTW3

 view release on metacpan or  search on metacpan

lib/Alien/FFTW3.pm  view on Meta::CPAN

Alien::FFTW3 - Alien wrapper for FFTW3

=head1 SYNOPSIS

  use strict;
  use warnings;

  use Module::Build;
  use Alien::FFTW3 3.003_002;  # Require fftw v3.3.2 or later

  my $cflags = Alien::FFTW3->cflags;
  my $ldflags = Alien::FFTW3->libs;

  if( Alien::FFTW3->precision('q') ) {
    # compile quad-precision library...
  }

  my $cflags_for_float = Alien::FFTW3->cflags('f');

=head1 ABSTRACT

Alien wrapper for FFTW3.  

=head1 DESCRIPTION

This module provides package validation and installation for FFTW3.
It currently depends on the external POSIX program pkg-config to find
the FFTW3 libraries.

Because FFTW3 comes in several flavors for different levels of
numerical precision, the typical access methods 'cflags' and 'libs'
work slightly differently than the simple Alien::Base case.  You can
feed in nothing at all, in which case you get back cflags and libs
strings appropriate for compiling *all* available fftw3 libraries; or
you can specify which precision you want by passing in an allowed
precision.  The allowed precisions are currently 'f','d','l', and 'q'
for floats, doubles, long doubles, and quad doubles respecetively.

On initial use, Alien::FFTW3 checks for which precisions are
available.  If more than zero are available, it succeeds.  If none are
available, then it fails.  If you specify a version number, it is
translated from Perl-style version numbers to a POSIX module version
string.  The load will throw an exception unless every located libfftw

lib/Alien/FFTW3.pm  view on Meta::CPAN

	}
    }
    
    if(keys %$out) {
	return $out;
    } else {
	return undef;
    }
}

=head2 cflags

=for ref

Returns the cflags compiler flags required for the specified precision, or for all of 'em.

=cut

sub cflags {
    shift if(($_[0]//"") =~ m/Alien/ );       # discard package name or blessed ref on call

    my $precision = shift;
    
    my $h = precision($precision);
    die "No fftw package found!" unless($h);

    my $pkgs = join(" ",sort values %$h);

    my $s = `$pkgconfig --cflags $pkgs`;
    chomp $s;
    return $s;
}

=head2 libs

=for ref

Returns the libs linker flags required for the specified precision, or for all of 'em.

=cut

sub libs {
    shift if(($_[0]//"") =~ m/Alien/);       # discard package name on call
    my $precision = shift;
    my $h =precision($precision);
    die "No fftw package found!" unless($h);
    
    my $pkgs = join(" ",sort values %$h);



( run in 1.418 second using v1.01-cache-2.11-cpan-94b05bcf43c )