static void test_composition()
{
  Eigen::Tensor<float, 2, DataLayout> matrix(7, 11);
  matrix.setRandom();

  const DSizes<ptrdiff_t, 3> newDims(1, 1, 11);
  Eigen::Tensor<float, 3, DataLayout> tensor =
      matrix.slice(DSizes<ptrdiff_t, 2>(2, 0), DSizes<ptrdiff_t, 2>(1, 11)).reshape(newDims);

  VERIFY_IS_EQUAL(tensor.dimensions().TotalSize(), 11);
  VERIFY_IS_EQUAL(tensor.dimension(0), 1);
  VERIFY_IS_EQUAL(tensor.dimension(1), 1);
  VERIFY_IS_EQUAL(tensor.dimension(2), 11);
  for (int i = 0; i < 11; ++i) {
    VERIFY_IS_EQUAL(tensor(0,0,i), matrix(2,i));
  }
}
Eigen::Tensor<std::complex<double>,2>
to_Tnl_pn(const Eigen::Tensor<std::complex<double>,2>& Tnl, alps::gf::statistics::statistics_type s) {
  int niw = Tnl.dimension(0);
  int nl = Tnl.dimension(1);
  Eigen::Tensor<std::complex<double>,2> Tnl_pn(2*niw, nl);
  Tnl_pn.setZero();
  if (s==alps::gf::statistics::FERMIONIC) {
    for (int l=0; l<nl; ++l) {
      for (int n=0; n<niw; ++n) {
        Tnl_pn(niw + n, l) = Tnl(n, l);
        Tnl_pn(niw - 1 - n, l) = std::conj(Tnl(n, l));
      }
    }
  } else if (s==alps::gf::statistics::BOSONIC) {
    for (int l=0; l<nl; ++l) {
      for (int n=0; n<niw; ++n) {
        Tnl_pn(niw + n, l) = Tnl(n, l);
      }
      for (int n=1; n<niw; ++n) {
        Tnl_pn(niw - n, l) = std::conj(Tnl(n, l));
      }
    }
  } else {
    throw std::runtime_error("Unknown statistics type");
  }
  return Tnl_pn;
}
Beispiel #3
0
void load( Archive & ar,
           Eigen::Tensor<T,1> & t,
           const unsigned int file_version )
{
    int n0,n1=1,n2=1;
    ar >> BOOST_SERIALIZATION_NVP( n0 );
    t.resize( n0 );
    ar >> make_array( t.data(), n0 );
}
Beispiel #4
0
void save( Archive & ar,
           const Eigen::Tensor<T,N> & t,
           const unsigned int file_version )
{
    int n0 = t.dimension(0);
    ar << BOOST_SERIALIZATION_NVP( n0 );
    if ( N >= 2 )
    {
        int n1 = t.dimension(1);
        ar << BOOST_SERIALIZATION_NVP( n1 );
    }
    if ( N >= 3 )
    {
        int n2 = t.dimension(2);
        ar << BOOST_SERIALIZATION_NVP( n2 );
    }

    ar << boost::serialization::make_array( t.data(),
                                            t.size() );
}