2011-03-10 05:11:03 +00:00
|
|
|
class Fftw < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "C routines to compute the Discrete Fourier Transform"
|
2015-08-03 12:55:31 +00:00
|
|
|
homepage "http://www.fftw.org"
|
|
|
|
url "http://www.fftw.org/fftw-3.3.4.tar.gz"
|
|
|
|
sha256 "8f0cde90929bc05587c3368d2f15cd0530a60b8a9912a8e2979a72dbe5af0982"
|
2014-11-22 19:43:11 +00:00
|
|
|
revision 1
|
2009-06-04 18:21:19 +00:00
|
|
|
|
2014-02-24 15:11:24 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
2015-09-14 07:07:59 +00:00
|
|
|
sha256 "92f9c2aea12100ba53084c5fe886418c348ab744fd47b60a9cee9c922044942b" => :el_capitan
|
2014-12-14 00:39:30 +00:00
|
|
|
sha1 "b5c2d04489567aff02e2e002d906ce7349057f6e" => :yosemite
|
|
|
|
sha1 "af376c8efd9de7501d56f763a1ead65a5d32e533" => :mavericks
|
|
|
|
sha1 "1585929f22c6851d87cf9d451cd26ff403991a8c" => :mountain_lion
|
2014-02-24 15:11:24 +00:00
|
|
|
end
|
|
|
|
|
2013-01-18 17:15:30 +00:00
|
|
|
option "with-fortran", "Enable Fortran bindings"
|
2014-02-26 13:10:09 +00:00
|
|
|
option :universal
|
2014-06-07 06:13:52 +00:00
|
|
|
option "with-mpi", "Enable MPI parallel transforms"
|
2015-06-17 19:47:33 +00:00
|
|
|
option "with-openmp", "Enable OpenMP parallel transforms"
|
2013-01-18 17:15:30 +00:00
|
|
|
|
2013-06-26 02:14:36 +00:00
|
|
|
depends_on :fortran => :optional
|
2014-06-07 06:13:52 +00:00
|
|
|
depends_on :mpi => [:cc, :optional]
|
2015-06-17 19:47:33 +00:00
|
|
|
needs :openmp if build.with? "openmp"
|
2013-06-24 03:29:13 +00:00
|
|
|
|
2009-06-04 18:21:19 +00:00
|
|
|
def install
|
2010-07-01 19:37:36 +00:00
|
|
|
args = ["--enable-shared",
|
|
|
|
"--disable-debug",
|
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--enable-threads",
|
|
|
|
"--disable-dependency-tracking"]
|
2013-11-06 13:36:05 +00:00
|
|
|
simd_args = ["--enable-sse2"]
|
2015-08-03 12:55:31 +00:00
|
|
|
simd_args << "--enable-avx" if ENV.compiler == :clang && Hardware::CPU.avx? && !build.bottle?
|
2010-07-01 19:37:36 +00:00
|
|
|
|
2014-03-06 20:40:26 +00:00
|
|
|
args << "--disable-fortran" if build.without? "fortran"
|
2014-06-07 06:13:52 +00:00
|
|
|
args << "--enable-mpi" if build.with? "mpi"
|
2015-06-17 19:47:33 +00:00
|
|
|
args << "--enable-openmp" if build.with? "openmp"
|
2010-07-01 19:37:36 +00:00
|
|
|
|
2014-02-26 13:10:09 +00:00
|
|
|
ENV.universal_binary if build.universal?
|
|
|
|
|
2010-04-11 14:08:07 +00:00
|
|
|
# single precision
|
2013-11-06 13:36:05 +00:00
|
|
|
# enable-sse2 and enable-avx works for both single and double precision
|
|
|
|
system "./configure", "--enable-single", *(args + simd_args)
|
2015-08-03 12:55:31 +00:00
|
|
|
system "make", "install"
|
2009-08-07 14:41:43 +00:00
|
|
|
|
2010-04-11 14:08:07 +00:00
|
|
|
# clean up so we can compile the double precision variant
|
2015-08-03 12:55:31 +00:00
|
|
|
system "make", "clean"
|
2010-04-11 14:08:07 +00:00
|
|
|
|
|
|
|
# double precision
|
2013-11-06 13:36:05 +00:00
|
|
|
# enable-sse2 and enable-avx works for both single and double precision
|
|
|
|
system "./configure", *(args + simd_args)
|
2015-08-03 12:55:31 +00:00
|
|
|
system "make", "install"
|
2010-04-11 14:08:07 +00:00
|
|
|
|
|
|
|
# clean up so we can compile the long-double precision variant
|
2015-08-03 12:55:31 +00:00
|
|
|
system "make", "clean"
|
2010-04-11 14:08:07 +00:00
|
|
|
|
|
|
|
# long-double precision
|
2010-07-01 19:37:36 +00:00
|
|
|
# no SIMD optimization available
|
2010-08-08 17:20:15 +00:00
|
|
|
system "./configure", "--enable-long-double", *args
|
2015-08-03 12:55:31 +00:00
|
|
|
system "make", "install"
|
2009-06-04 18:21:19 +00:00
|
|
|
end
|
2013-06-02 21:03:36 +00:00
|
|
|
|
|
|
|
test do
|
|
|
|
# Adapted from the sample usage provided in the documentation:
|
|
|
|
# http://www.fftw.org/fftw3_doc/Complex-One_002dDimensional-DFTs.html
|
2015-08-03 12:55:31 +00:00
|
|
|
(testpath/"fftw.c").write <<-TEST_SCRIPT.undent
|
2013-06-02 21:03:36 +00:00
|
|
|
#include <fftw3.h>
|
|
|
|
int main(int argc, char* *argv)
|
|
|
|
{
|
|
|
|
fftw_complex *in, *out;
|
|
|
|
fftw_plan p;
|
|
|
|
long N = 1;
|
|
|
|
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
|
|
|
|
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
|
|
|
|
p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
|
|
|
|
fftw_execute(p); /* repeat as needed */
|
|
|
|
fftw_destroy_plan(p);
|
|
|
|
fftw_free(in); fftw_free(out);
|
2013-06-07 14:54:29 +00:00
|
|
|
return 0;
|
2013-06-02 21:03:36 +00:00
|
|
|
}
|
|
|
|
TEST_SCRIPT
|
|
|
|
|
2015-08-03 12:55:31 +00:00
|
|
|
system ENV.cc, "-o", "fftw", "fftw.c", "-lfftw3", *ENV.cflags.to_s.split
|
|
|
|
system "./fftw"
|
2013-06-02 21:03:36 +00:00
|
|
|
end
|
2010-04-11 14:08:07 +00:00
|
|
|
end
|