From 0be89a4796543a7e7b8c244d3f1aabcf672cf114 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 5 Mar 2009 10:25:22 +0000 Subject: big addons: * add Homogeneous expression for vector and set of vectors (aka matrix) => the next step will be to overload operator* * add homogeneous normalization (again for vector and set of vectors) * add a Replicate expression (with uni-directional replication facilities) => for all of them I'll add examples once we agree on the API * fix gcc-4.4 warnings * rename reverse.cpp array_reverse.cpp --- test/array_replicate.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 test/array_replicate.cpp (limited to 'test/array_replicate.cpp') diff --git a/test/array_replicate.cpp b/test/array_replicate.cpp new file mode 100644 index 000000000..e8d0f33cb --- /dev/null +++ b/test/array_replicate.cpp @@ -0,0 +1,86 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2009 Gael Guennebaud +// +// 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" +#include + +template void replicate(const MatrixType& m) +{ + /* this test covers the following files: + Replicate.cpp + */ + + typedef typename MatrixType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix VectorType; + typedef Matrix MatrixX; + typedef Matrix VectorX; + + int rows = m.rows(); + int cols = m.cols(); + + MatrixType m1 = MatrixType::Random(rows, cols), + m2 = MatrixType::Random(rows, cols); + + VectorType v1 = VectorType::Random(rows); + + MatrixX x1, x2; + VectorX vx1; + + int f1 = ei_random(1,10), + f2 = ei_random(1,10); + + x1.resize(rows*f1,cols*f2); + for(int j=0; j())); + + x2.resize(rows,f1); + for (int j=0; j()) ); + CALL_SUBTEST( replicate(Vector2f()) ); + CALL_SUBTEST( replicate(Vector3d()) ); + CALL_SUBTEST( replicate(Vector4f()) ); + CALL_SUBTEST( replicate(VectorXf(16)) ); + CALL_SUBTEST( replicate(VectorXcd(10)) ); + } +} -- cgit v1.2.3