#!/bin/sh
set -e

cd "$AUTOPKGTEST_TMP"

cat > test.cc <<'END'
#include <cmath>
#include <iostream>
#include <purify/IndexMapping.h>
#include <purify/kernels.h>

int main() {
  purify::Sparse<purify::t_complex> m(2, 5);
  m.insert(0, 1) = 1;
  m.insert(1, 3) = 2;
  m.makeCompressed();

  auto const c = purify::compress_outer(m);
  if (c.rows() != 2 || c.cols() != 2 || c.coeff(0, 0) != purify::t_complex(1)
      || c.coeff(1, 1) != purify::t_complex(2))
    return 1;

  if (!std::isfinite(purify::kernels::kaiser_bessel(0.5, 4)))
    return 1;

  std::cout << "purify " << purify::version() << " OK" << std::endl;
  return 0;
}
END

g++ -std=c++17 -o test test.cc -I/usr/include/eigen3 -lpurify -lsopt
./test
