// This file is part of Eigen, a lightweight C++ template library // for linear algebra. Eigen itself is part of the KDE project. // // Copyright (C) 2008 Daniel Gomez Ferro // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "sparse.h" template void sparse_vector(int rows, int cols) { double densityMat = std::max(8./(rows*cols), 0.01); double densityVec = std::max(8./float(rows), 0.1); typedef Matrix DenseMatrix; typedef Matrix DenseVector; typedef SparseVector SparseVectorType; typedef SparseMatrix SparseMatrixType; Scalar eps = 1e-6; SparseMatrixType m1(rows,cols); SparseVectorType v1(rows), v2(rows), v3(rows); DenseMatrix refM1 = DenseMatrix::Zero(rows, cols); DenseVector refV1 = DenseVector::Random(rows), refV2 = DenseVector::Random(rows), refV3 = DenseVector::Random(rows); std::vector zerocoords, nonzerocoords; initSparse(densityVec, refV1, v1, &zerocoords, &nonzerocoords); initSparse(densityMat, refM1, m1); initSparse(densityVec, refV2, v2); initSparse(densityVec, refV3, v3); Scalar s1 = ei_random(); // test coeff and coeffRef for (unsigned int i=0; i(8, 8) ); CALL_SUBTEST_2( sparse_vector >(16, 16) ); CALL_SUBTEST_1( sparse_vector(299, 535) ); } }