// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2011 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" float *ptr; const float *const_ptr; template struct mapstaticmethods_impl {}; template struct mapstaticmethods_impl { static void run(const PlainObjectType& m) { mapstaticmethods_impl::run(m); int i = internal::random(2,5), j = internal::random(2,5); PlainObjectType::Map(ptr).setZero(); PlainObjectType::MapAligned(ptr).setZero(); PlainObjectType::Map(const_ptr).sum(); PlainObjectType::MapAligned(const_ptr).sum(); PlainObjectType::Map(ptr, InnerStride<>(i)).setZero(); PlainObjectType::MapAligned(ptr, InnerStride<>(i)).setZero(); PlainObjectType::Map(const_ptr, InnerStride<>(i)).sum(); PlainObjectType::MapAligned(const_ptr, InnerStride<>(i)).sum(); PlainObjectType::Map(ptr, InnerStride<2>()).setZero(); PlainObjectType::MapAligned(ptr, InnerStride<3>()).setZero(); PlainObjectType::Map(const_ptr, InnerStride<4>()).sum(); PlainObjectType::MapAligned(const_ptr, InnerStride<5>()).sum(); PlainObjectType::Map(ptr, OuterStride<>(i)).setZero(); PlainObjectType::MapAligned(ptr, OuterStride<>(i)).setZero(); PlainObjectType::Map(const_ptr, OuterStride<>(i)).sum(); PlainObjectType::MapAligned(const_ptr, OuterStride<>(i)).sum(); PlainObjectType::Map(ptr, OuterStride<2>()).setZero(); PlainObjectType::MapAligned(ptr, OuterStride<3>()).setZero(); PlainObjectType::Map(const_ptr, OuterStride<4>()).sum(); PlainObjectType::MapAligned(const_ptr, OuterStride<5>()).sum(); PlainObjectType::Map(ptr, Stride(i,j)).setZero(); PlainObjectType::MapAligned(ptr, Stride<2,Dynamic>(2,i)).setZero(); PlainObjectType::Map(const_ptr, Stride(i,3)).sum(); PlainObjectType::MapAligned(const_ptr, Stride(i,j)).sum(); PlainObjectType::Map(ptr, Stride<2,3>()).setZero(); PlainObjectType::MapAligned(ptr, Stride<3,4>()).setZero(); PlainObjectType::Map(const_ptr, Stride<2,4>()).sum(); PlainObjectType::MapAligned(const_ptr, Stride<5,3>()).sum(); } }; template struct mapstaticmethods_impl { static void run(const PlainObjectType& m) { int rows = m.rows(), cols = m.cols(); int i = internal::random(2,5), j = internal::random(2,5); PlainObjectType::Map(ptr, rows, cols).setZero(); PlainObjectType::MapAligned(ptr, rows, cols).setZero(); PlainObjectType::Map(const_ptr, rows, cols).sum(); PlainObjectType::MapAligned(const_ptr, rows, cols).sum(); PlainObjectType::Map(ptr, rows, cols, InnerStride<>(i)).setZero(); PlainObjectType::MapAligned(ptr, rows, cols, InnerStride<>(i)).setZero(); PlainObjectType::Map(const_ptr, rows, cols, InnerStride<>(i)).sum(); PlainObjectType::MapAligned(const_ptr, rows, cols, InnerStride<>(i)).sum(); PlainObjectType::Map(ptr, rows, cols, InnerStride<2>()).setZero(); PlainObjectType::MapAligned(ptr, rows, cols, InnerStride<3>()).setZero(); PlainObjectType::Map(const_ptr, rows, cols, InnerStride<4>()).sum(); PlainObjectType::MapAligned(const_ptr, rows, cols, InnerStride<5>()).sum(); PlainObjectType::Map(ptr, rows, cols, OuterStride<>(i)).setZero(); PlainObjectType::MapAligned(ptr, rows, cols, OuterStride<>(i)).setZero(); PlainObjectType::Map(const_ptr, rows, cols, OuterStride<>(i)).sum(); PlainObjectType::MapAligned(const_ptr, rows, cols, OuterStride<>(i)).sum(); PlainObjectType::Map(ptr, rows, cols, OuterStride<2>()).setZero(); PlainObjectType::MapAligned(ptr, rows, cols, OuterStride<3>()).setZero(); PlainObjectType::Map(const_ptr, rows, cols, OuterStride<4>()).sum(); PlainObjectType::MapAligned(const_ptr, rows, cols, OuterStride<5>()).sum(); PlainObjectType::Map(ptr, rows, cols, Stride(i,j)).setZero(); PlainObjectType::MapAligned(ptr, rows, cols, Stride<2,Dynamic>(2,i)).setZero(); PlainObjectType::Map(const_ptr, rows, cols, Stride(i,3)).sum(); PlainObjectType::MapAligned(const_ptr, rows, cols, Stride(i,j)).sum(); PlainObjectType::Map(ptr, rows, cols, Stride<2,3>()).setZero(); PlainObjectType::MapAligned(ptr, rows, cols, Stride<3,4>()).setZero(); PlainObjectType::Map(const_ptr, rows, cols, Stride<2,4>()).sum(); PlainObjectType::MapAligned(const_ptr, rows, cols, Stride<5,3>()).sum(); } }; template struct mapstaticmethods_impl { static void run(const PlainObjectType& v) { int size = v.size(); int i = internal::random(2,5); PlainObjectType::Map(ptr, size).setZero(); PlainObjectType::MapAligned(ptr, size).setZero(); PlainObjectType::Map(const_ptr, size).sum(); PlainObjectType::MapAligned(const_ptr, size).sum(); PlainObjectType::Map(ptr, size, InnerStride<>(i)).setZero(); PlainObjectType::MapAligned(ptr, size, InnerStride<>(i)).setZero(); PlainObjectType::Map(const_ptr, size, InnerStride<>(i)).sum(); PlainObjectType::MapAligned(const_ptr, size, InnerStride<>(i)).sum(); PlainObjectType::Map(ptr, size, InnerStride<2>()).setZero(); PlainObjectType::MapAligned(ptr, size, InnerStride<3>()).setZero(); PlainObjectType::Map(const_ptr, size, InnerStride<4>()).sum(); PlainObjectType::MapAligned(const_ptr, size, InnerStride<5>()).sum(); } }; template void mapstaticmethods(const PlainObjectType& m) { mapstaticmethods_impl::run(m); VERIFY(true); // just to avoid 'unused function' warning } void test_mapstaticmethods() { ptr = internal::aligned_new(1000); for(int i = 0; i < 1000; i++) ptr[i] = float(i); const_ptr = ptr; CALL_SUBTEST_1(( mapstaticmethods(Matrix()) )); CALL_SUBTEST_1(( mapstaticmethods(Vector2f()) )); CALL_SUBTEST_2(( mapstaticmethods(Vector3f()) )); CALL_SUBTEST_2(( mapstaticmethods(Matrix2f()) )); CALL_SUBTEST_3(( mapstaticmethods(Matrix4f()) )); CALL_SUBTEST_3(( mapstaticmethods(Array4f()) )); CALL_SUBTEST_4(( mapstaticmethods(Array3f()) )); CALL_SUBTEST_4(( mapstaticmethods(Array33f()) )); CALL_SUBTEST_5(( mapstaticmethods(Array44f()) )); CALL_SUBTEST_5(( mapstaticmethods(VectorXf(1)) )); CALL_SUBTEST_5(( mapstaticmethods(VectorXf(8)) )); CALL_SUBTEST_6(( mapstaticmethods(MatrixXf(1,1)) )); CALL_SUBTEST_6(( mapstaticmethods(MatrixXf(5,7)) )); CALL_SUBTEST_7(( mapstaticmethods(ArrayXf(1)) )); CALL_SUBTEST_7(( mapstaticmethods(ArrayXf(5)) )); CALL_SUBTEST_8(( mapstaticmethods(ArrayXXf(1,1)) )); CALL_SUBTEST_8(( mapstaticmethods(ArrayXXf(8,6)) )); internal::aligned_delete(ptr, 1000); }