homebrew-core/Formula/xtensor.rb

55 lines
1.5 KiB
Ruby

class Xtensor < Formula
desc "Multi-dimensional arrays with broadcasting and lazy computing"
homepage "https://xtensor.readthedocs.io/en/latest/"
url "https://github.com/xtensor-stack/xtensor/archive/0.24.3.tar.gz"
sha256 "3acde856b9fb8cf4e2a7b66726da541275d40ab9b002e618ad985ab97f08ca4f"
license "BSD-3-Clause"
bottle do
sha256 cellar: :any_skip_relocation, all: "f681564ba0eb7cb6cc35bfba688449fedcdfff9d1372806ab7b5082f676c64ab"
end
depends_on "cmake" => :build
resource "xtl" do
url "https://github.com/xtensor-stack/xtl/archive/0.7.4.tar.gz"
sha256 "3c88be0e696b64150c4de7a70f9f09c00a335186b0b0b409771ef9f56bca7d9a"
end
def install
resource("xtl").stage do
system "cmake", ".", *std_cmake_args
system "make", "install"
end
system "cmake", ".", "-Dxtl_DIR=#{lib}/cmake/xtl", *std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cc").write <<~EOS
#include <iostream>
#include "xtensor/xarray.hpp"
#include "xtensor/xio.hpp"
#include "xtensor/xview.hpp"
int main() {
xt::xarray<double> arr1
{{11.0, 12.0, 13.0},
{21.0, 22.0, 23.0},
{31.0, 32.0, 33.0}};
xt::xarray<double> arr2
{100.0, 200.0, 300.0};
xt::xarray<double> res = xt::view(arr1, 1) + arr2;
std::cout << res(2) << std::endl;
return 0;
}
EOS
system ENV.cxx, "-std=c++14", "test.cc", "-o", "test", "-I#{include}"
assert_equal "323", shell_output("./test").chomp
end
end