// This file is part of Eigen, a lightweight C++ template library // for linear algebra. Eigen itself is part of the KDE project. // // Copyright (C) 2006-2008 Benoit Jacob // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see . #include "main.h" // using namespace Eigen; template bool areApprox(const Scalar* a, const Scalar* b, int size) { for (int i=0; i const complex& min(const complex& a, const complex& b) { return a.real() < b.real() ? a : b; } template<> const complex& max(const complex& a, const complex& b) { return a.real() < b.real() ? b : a; } } template void packetmath() { typedef typename ei_packet_traits::type Packet; const int PacketSize = ei_packet_traits::size; const int size = PacketSize*4; Scalar data1[ei_packet_traits::size*4]; Scalar data2[ei_packet_traits::size*4]; Packet packets[PacketSize*2]; Scalar ref[ei_packet_traits::size*4]; for (int i=0; i(); data2[i] = ei_random(); } ei_pstore(data2, ei_pload(data1)); VERIFY(areApprox(data1, data2, PacketSize) && "aligned load/store"); for (int offset=0; offset(packets[0], packets[1]); else if (offset==1) ei_palign<1>(packets[0], packets[1]); else if (offset==2) ei_palign<2>(packets[0], packets[1]); else if (offset==3) ei_palign<3>(packets[0], packets[1]); ei_pstore(data2, packets[0]); for (int i=0; i Vector; VERIFY(areApprox(ref, data2, PacketSize) && "ei_palign"); } CHECK_CWISE(REF_ADD, ei_padd); CHECK_CWISE(REF_SUB, ei_psub); CHECK_CWISE(REF_MUL, ei_pmul); #ifndef EIGEN_VECTORIZE_ALTIVEC if (!ei_is_same_type::ret) CHECK_CWISE(REF_DIV, ei_pdiv); #endif CHECK_CWISE(std::min, ei_pmin); CHECK_CWISE(std::max, ei_pmax); for (int i=0; i() ); CALL_SUBTEST( packetmath() ); CALL_SUBTEST( packetmath() ); CALL_SUBTEST( packetmath >() ); } }