From 44861dcbfeee041223c4aac1ee075e92fa4daa01 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 18 Sep 2016 12:42:15 +0200 Subject: update --- eigen/test/eigen2/eigen2_sparse_vector.cpp | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 eigen/test/eigen2/eigen2_sparse_vector.cpp (limited to 'eigen/test/eigen2/eigen2_sparse_vector.cpp') diff --git a/eigen/test/eigen2/eigen2_sparse_vector.cpp b/eigen/test/eigen2/eigen2_sparse_vector.cpp new file mode 100644 index 0000000..e6d2d77 --- /dev/null +++ b/eigen/test/eigen2/eigen2_sparse_vector.cpp @@ -0,0 +1,84 @@ +// 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) ); + } +} + -- cgit v1.2.3