Exemplo n.º 1
0
template<typename Scalar> void packetmath_real()
{
  typedef typename ei_packet_traits<Scalar>::type Packet;
  const int PacketSize = ei_packet_traits<Scalar>::size;

  const int size = PacketSize*4;
  EIGEN_ALIGN16 Scalar data1[ei_packet_traits<Scalar>::size*4];
  EIGEN_ALIGN16 Scalar data2[ei_packet_traits<Scalar>::size*4];
  EIGEN_ALIGN16 Scalar ref[ei_packet_traits<Scalar>::size*4];

  for (int i=0; i<size; ++i)
  {
    data1[i] = ei_random<Scalar>(-1e3,1e3);
    data2[i] = ei_random<Scalar>(-1e3,1e3);
  }
  CHECK_CWISE1_IF(ei_packet_traits<Scalar>::HasSin, ei_sin, ei_psin);
  CHECK_CWISE1_IF(ei_packet_traits<Scalar>::HasCos, ei_cos, ei_pcos);

  for (int i=0; i<size; ++i)
  {
    data1[i] = ei_random<Scalar>(-87,88);
    data2[i] = ei_random<Scalar>(-87,88);
  }
  CHECK_CWISE1_IF(ei_packet_traits<Scalar>::HasExp, ei_exp, ei_pexp);

  for (int i=0; i<size; ++i)
  {
    data1[i] = ei_random<Scalar>(0,1e6);
    data2[i] = ei_random<Scalar>(0,1e6);
  }
  CHECK_CWISE1_IF(ei_packet_traits<Scalar>::HasLog, ei_log, ei_plog);
  CHECK_CWISE1_IF(ei_packet_traits<Scalar>::HasSqrt, ei_sqrt, ei_psqrt);
}
Exemplo n.º 2
0
template<typename Scalar> void packetmath_real()
{
  typedef typename internal::packet_traits<Scalar>::type Packet;
  const int PacketSize = internal::packet_traits<Scalar>::size;

  const int size = PacketSize*4;
  EIGEN_ALIGN16 Scalar data1[internal::packet_traits<Scalar>::size*4];
  EIGEN_ALIGN16 Scalar data2[internal::packet_traits<Scalar>::size*4];
  EIGEN_ALIGN16 Scalar ref[internal::packet_traits<Scalar>::size*4];

  for (int i=0; i<size; ++i)
  {
    data1[i] = internal::random<Scalar>(-1e3,1e3);
    data2[i] = internal::random<Scalar>(-1e3,1e3);
  }
  CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasSin, internal::sin, internal::psin);
  CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasCos, internal::cos, internal::pcos);
  CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasTan, internal::tan, internal::ptan);
  
  for (int i=0; i<size; ++i)
  {
    data1[i] = internal::random<Scalar>(-1,1);
    data2[i] = internal::random<Scalar>(-1,1);
  }
  CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasASin, internal::asin, internal::pasin);
  CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasACos, internal::acos, internal::pacos);

  for (int i=0; i<size; ++i)
  {
    data1[i] = internal::random<Scalar>(-87,88);
    data2[i] = internal::random<Scalar>(-87,88);
  }
  CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasExp, internal::exp, internal::pexp);

  for (int i=0; i<size; ++i)
  {
    data1[i] = internal::random<Scalar>(0,1e6);
    data2[i] = internal::random<Scalar>(0,1e6);
  }
  CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasLog, internal::log, internal::plog);
  CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasSqrt, internal::sqrt, internal::psqrt);

  ref[0] = data1[0];
  for (int i=0; i<PacketSize; ++i)
    ref[0] = (std::min)(ref[0],data1[i]);
  VERIFY(internal::isApprox(ref[0], internal::predux_min(internal::pload<Packet>(data1))) && "internal::predux_min");

  CHECK_CWISE2((std::min), internal::pmin);
  CHECK_CWISE2((std::max), internal::pmax);
  CHECK_CWISE1(internal::abs, internal::pabs);

  ref[0] = data1[0];
  for (int i=0; i<PacketSize; ++i)
    ref[0] = (std::max)(ref[0],data1[i]);
  VERIFY(internal::isApprox(ref[0], internal::predux_max(internal::pload<Packet>(data1))) && "internal::predux_max");
  
  for (int i=0; i<PacketSize; ++i)
    ref[i] = data1[0]+Scalar(i);
  internal::pstore(data2, internal::plset(data1[0]));
  VERIFY(areApprox(ref, data2, PacketSize) && "internal::plset");
}