Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 1 | // This file is part of Eigen, a lightweight C++ template library |
Benoit Jacob | 6347b1d | 2009-05-22 20:25:33 +0200 | [diff] [blame] | 2 | // for linear algebra. |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 3 | // |
| 4 | // Copyright (C) 2008 Daniel Gomez Ferro <dgomezferro@gmail.com> |
| 5 | // |
| 6 | // Eigen is free software; you can redistribute it and/or |
| 7 | // modify it under the terms of the GNU Lesser General Public |
| 8 | // License as published by the Free Software Foundation; either |
| 9 | // version 3 of the License, or (at your option) any later version. |
| 10 | // |
| 11 | // Alternatively, you can redistribute it and/or |
| 12 | // modify it under the terms of the GNU General Public License as |
| 13 | // published by the Free Software Foundation; either version 2 of |
| 14 | // the License, or (at your option) any later version. |
| 15 | // |
| 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY |
| 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the |
| 19 | // GNU General Public License for more details. |
| 20 | // |
| 21 | // You should have received a copy of the GNU Lesser General Public |
| 22 | // License and a copy of the GNU General Public License along with |
| 23 | // Eigen. If not, see <http://www.gnu.org/licenses/>. |
| 24 | |
| 25 | #include "sparse.h" |
| 26 | |
Gael Guennebaud | 178858f | 2009-01-19 15:20:45 +0000 | [diff] [blame] | 27 | template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& ref) |
| 28 | { |
Hauke Heibel | f1679c7 | 2010-06-20 17:37:56 +0200 | [diff] [blame] | 29 | typedef typename SparseMatrixType::Index Index; |
| 30 | |
| 31 | const Index rows = ref.rows(); |
| 32 | const Index cols = ref.cols(); |
Gael Guennebaud | 178858f | 2009-01-19 15:20:45 +0000 | [diff] [blame] | 33 | typedef typename SparseMatrixType::Scalar Scalar; |
| 34 | enum { Flags = SparseMatrixType::Flags }; |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 35 | |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 36 | double density = std::max(8./(rows*cols), 0.01); |
| 37 | typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; |
| 38 | typedef Matrix<Scalar,Dynamic,1> DenseVector; |
| 39 | Scalar eps = 1e-6; |
| 40 | |
Gael Guennebaud | 178858f | 2009-01-19 15:20:45 +0000 | [diff] [blame] | 41 | SparseMatrixType m(rows, cols); |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 42 | DenseMatrix refMat = DenseMatrix::Zero(rows, cols); |
| 43 | DenseVector vec1 = DenseVector::Random(rows); |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 44 | Scalar s1 = internal::random<Scalar>(); |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 45 | |
| 46 | std::vector<Vector2i> zeroCoords; |
| 47 | std::vector<Vector2i> nonzeroCoords; |
| 48 | initSparse<Scalar>(density, refMat, m, 0, &zeroCoords, &nonzeroCoords); |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 49 | |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 50 | if (zeroCoords.size()==0 || nonzeroCoords.size()==0) |
| 51 | return; |
| 52 | |
| 53 | // test coeff and coeffRef |
| 54 | for (int i=0; i<(int)zeroCoords.size(); ++i) |
| 55 | { |
| 56 | VERIFY_IS_MUCH_SMALLER_THAN( m.coeff(zeroCoords[i].x(),zeroCoords[i].y()), eps ); |
Hauke Heibel | 7bc8e3a | 2010-10-25 22:13:49 +0200 | [diff] [blame] | 57 | if(internal::is_same<SparseMatrixType,SparseMatrix<Scalar,Flags> >::value) |
Gael Guennebaud | 178858f | 2009-01-19 15:20:45 +0000 | [diff] [blame] | 58 | VERIFY_RAISES_ASSERT( m.coeffRef(zeroCoords[0].x(),zeroCoords[0].y()) = 5 ); |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 59 | } |
| 60 | VERIFY_IS_APPROX(m, refMat); |
| 61 | |
| 62 | m.coeffRef(nonzeroCoords[0].x(), nonzeroCoords[0].y()) = Scalar(5); |
| 63 | refMat.coeffRef(nonzeroCoords[0].x(), nonzeroCoords[0].y()) = Scalar(5); |
| 64 | |
| 65 | VERIFY_IS_APPROX(m, refMat); |
Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 66 | /* |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 67 | // test InnerIterators and Block expressions |
| 68 | for (int t=0; t<10; ++t) |
| 69 | { |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 70 | int j = internal::random<int>(0,cols-1); |
| 71 | int i = internal::random<int>(0,rows-1); |
| 72 | int w = internal::random<int>(1,cols-j-1); |
| 73 | int h = internal::random<int>(1,rows-i-1); |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 74 | |
Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 75 | // VERIFY_IS_APPROX(m.block(i,j,h,w), refMat.block(i,j,h,w)); |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 76 | for(int c=0; c<w; c++) |
| 77 | { |
| 78 | VERIFY_IS_APPROX(m.block(i,j,h,w).col(c), refMat.block(i,j,h,w).col(c)); |
| 79 | for(int r=0; r<h; r++) |
| 80 | { |
Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 81 | // VERIFY_IS_APPROX(m.block(i,j,h,w).col(c).coeff(r), refMat.block(i,j,h,w).col(c).coeff(r)); |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 82 | } |
| 83 | } |
Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 84 | // for(int r=0; r<h; r++) |
| 85 | // { |
| 86 | // VERIFY_IS_APPROX(m.block(i,j,h,w).row(r), refMat.block(i,j,h,w).row(r)); |
| 87 | // for(int c=0; c<w; c++) |
| 88 | // { |
| 89 | // VERIFY_IS_APPROX(m.block(i,j,h,w).row(r).coeff(c), refMat.block(i,j,h,w).row(r).coeff(c)); |
| 90 | // } |
| 91 | // } |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | for(int c=0; c<cols; c++) |
| 95 | { |
| 96 | VERIFY_IS_APPROX(m.col(c) + m.col(c), (m + m).col(c)); |
| 97 | VERIFY_IS_APPROX(m.col(c) + m.col(c), refMat.col(c) + refMat.col(c)); |
| 98 | } |
| 99 | |
| 100 | for(int r=0; r<rows; r++) |
| 101 | { |
| 102 | VERIFY_IS_APPROX(m.row(r) + m.row(r), (m + m).row(r)); |
| 103 | VERIFY_IS_APPROX(m.row(r) + m.row(r), refMat.row(r) + refMat.row(r)); |
| 104 | } |
| 105 | */ |
| 106 | |
Gael Guennebaud | 2829314 | 2009-05-04 14:25:12 +0000 | [diff] [blame] | 107 | // test insert (inner random) |
Gael Guennebaud | 5015e48 | 2008-12-11 18:26:24 +0000 | [diff] [blame] | 108 | { |
| 109 | DenseMatrix m1(rows,cols); |
| 110 | m1.setZero(); |
Gael Guennebaud | 178858f | 2009-01-19 15:20:45 +0000 | [diff] [blame] | 111 | SparseMatrixType m2(rows,cols); |
Gael Guennebaud | 2829314 | 2009-05-04 14:25:12 +0000 | [diff] [blame] | 112 | m2.reserve(10); |
Gael Guennebaud | 5015e48 | 2008-12-11 18:26:24 +0000 | [diff] [blame] | 113 | for (int j=0; j<cols; ++j) |
| 114 | { |
| 115 | for (int k=0; k<rows/2; ++k) |
| 116 | { |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 117 | int i = internal::random<int>(0,rows-1); |
Gael Guennebaud | 5015e48 | 2008-12-11 18:26:24 +0000 | [diff] [blame] | 118 | if (m1.coeff(i,j)==Scalar(0)) |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 119 | m2.insert(i,j) = m1(i,j) = internal::random<Scalar>(); |
Gael Guennebaud | 5015e48 | 2008-12-11 18:26:24 +0000 | [diff] [blame] | 120 | } |
| 121 | } |
Gael Guennebaud | 2829314 | 2009-05-04 14:25:12 +0000 | [diff] [blame] | 122 | m2.finalize(); |
| 123 | VERIFY_IS_APPROX(m2,m1); |
| 124 | } |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 125 | |
Gael Guennebaud | 2829314 | 2009-05-04 14:25:12 +0000 | [diff] [blame] | 126 | // test insert (fully random) |
| 127 | { |
| 128 | DenseMatrix m1(rows,cols); |
| 129 | m1.setZero(); |
| 130 | SparseMatrixType m2(rows,cols); |
| 131 | m2.reserve(10); |
| 132 | for (int k=0; k<rows*cols; ++k) |
| 133 | { |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 134 | int i = internal::random<int>(0,rows-1); |
| 135 | int j = internal::random<int>(0,cols-1); |
Gael Guennebaud | 2829314 | 2009-05-04 14:25:12 +0000 | [diff] [blame] | 136 | if (m1.coeff(i,j)==Scalar(0)) |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 137 | m2.insert(i,j) = m1(i,j) = internal::random<Scalar>(); |
Gael Guennebaud | 2829314 | 2009-05-04 14:25:12 +0000 | [diff] [blame] | 138 | } |
| 139 | m2.finalize(); |
Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 140 | VERIFY_IS_APPROX(m2,m1); |
Gael Guennebaud | 5015e48 | 2008-12-11 18:26:24 +0000 | [diff] [blame] | 141 | } |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 142 | |
Gael Guennebaud | 2d53466 | 2009-01-14 21:27:54 +0000 | [diff] [blame] | 143 | // test basic computations |
| 144 | { |
| 145 | DenseMatrix refM1 = DenseMatrix::Zero(rows, rows); |
| 146 | DenseMatrix refM2 = DenseMatrix::Zero(rows, rows); |
| 147 | DenseMatrix refM3 = DenseMatrix::Zero(rows, rows); |
| 148 | DenseMatrix refM4 = DenseMatrix::Zero(rows, rows); |
Gael Guennebaud | 178858f | 2009-01-19 15:20:45 +0000 | [diff] [blame] | 149 | SparseMatrixType m1(rows, rows); |
| 150 | SparseMatrixType m2(rows, rows); |
| 151 | SparseMatrixType m3(rows, rows); |
| 152 | SparseMatrixType m4(rows, rows); |
Gael Guennebaud | 2d53466 | 2009-01-14 21:27:54 +0000 | [diff] [blame] | 153 | initSparse<Scalar>(density, refM1, m1); |
| 154 | initSparse<Scalar>(density, refM2, m2); |
| 155 | initSparse<Scalar>(density, refM3, m3); |
| 156 | initSparse<Scalar>(density, refM4, m4); |
| 157 | |
| 158 | VERIFY_IS_APPROX(m1+m2, refM1+refM2); |
| 159 | VERIFY_IS_APPROX(m1+m2+m3, refM1+refM2+refM3); |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 160 | VERIFY_IS_APPROX(m3.cwiseProduct(m1+m2), refM3.cwiseProduct(refM1+refM2)); |
Gael Guennebaud | 2d53466 | 2009-01-14 21:27:54 +0000 | [diff] [blame] | 161 | VERIFY_IS_APPROX(m1*s1-m2, refM1*s1-refM2); |
| 162 | |
| 163 | VERIFY_IS_APPROX(m1*=s1, refM1*=s1); |
| 164 | VERIFY_IS_APPROX(m1/=s1, refM1/=s1); |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 165 | |
Gael Guennebaud | e7c48fa | 2009-01-23 13:59:32 +0000 | [diff] [blame] | 166 | VERIFY_IS_APPROX(m1+=m2, refM1+=refM2); |
| 167 | VERIFY_IS_APPROX(m1-=m2, refM1-=refM2); |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 168 | |
Gael Guennebaud | a9688f0 | 2009-02-09 09:59:30 +0000 | [diff] [blame] | 169 | VERIFY_IS_APPROX(m1.col(0).dot(refM2.row(0)), refM1.col(0).dot(refM2.row(0))); |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 170 | |
Gael Guennebaud | 2d53466 | 2009-01-14 21:27:54 +0000 | [diff] [blame] | 171 | refM4.setRandom(); |
| 172 | // sparse cwise* dense |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 173 | VERIFY_IS_APPROX(m3.cwiseProduct(refM4), refM3.cwiseProduct(refM4)); |
Gael Guennebaud | 2d53466 | 2009-01-14 21:27:54 +0000 | [diff] [blame] | 174 | // VERIFY_IS_APPROX(m3.cwise()/refM4, refM3.cwise()/refM4); |
| 175 | } |
| 176 | |
Gael Guennebaud | ece48a6 | 2010-06-18 11:28:30 +0200 | [diff] [blame] | 177 | // test transpose |
| 178 | { |
| 179 | DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows); |
| 180 | SparseMatrixType m2(rows, rows); |
| 181 | initSparse<Scalar>(density, refMat2, m2); |
| 182 | VERIFY_IS_APPROX(m2.transpose().eval(), refMat2.transpose().eval()); |
| 183 | VERIFY_IS_APPROX(m2.transpose(), refMat2.transpose()); |
| 184 | |
| 185 | VERIFY_IS_APPROX(SparseMatrixType(m2.adjoint()), refMat2.adjoint()); |
| 186 | } |
| 187 | |
Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 188 | // test innerVector() |
| 189 | { |
| 190 | DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows); |
Gael Guennebaud | 178858f | 2009-01-19 15:20:45 +0000 | [diff] [blame] | 191 | SparseMatrixType m2(rows, rows); |
Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 192 | initSparse<Scalar>(density, refMat2, m2); |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 193 | int j0 = internal::random(0,rows-1); |
| 194 | int j1 = internal::random(0,rows-1); |
Gael Guennebaud | 2d53466 | 2009-01-14 21:27:54 +0000 | [diff] [blame] | 195 | VERIFY_IS_APPROX(m2.innerVector(j0), refMat2.col(j0)); |
| 196 | VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.col(j0)+refMat2.col(j1)); |
Gael Guennebaud | 8ce4503 | 2009-01-27 22:48:17 +0000 | [diff] [blame] | 197 | //m2.innerVector(j0) = 2*m2.innerVector(j1); |
| 198 | //refMat2.col(j0) = 2*refMat2.col(j1); |
| 199 | //VERIFY_IS_APPROX(m2, refMat2); |
| 200 | } |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 201 | |
Gael Guennebaud | 8ce4503 | 2009-01-27 22:48:17 +0000 | [diff] [blame] | 202 | // test innerVectors() |
| 203 | { |
| 204 | DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows); |
| 205 | SparseMatrixType m2(rows, rows); |
| 206 | initSparse<Scalar>(density, refMat2, m2); |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 207 | int j0 = internal::random(0,rows-2); |
| 208 | int j1 = internal::random(0,rows-2); |
| 209 | int n0 = internal::random<int>(1,rows-std::max(j0,j1)); |
Gael Guennebaud | 8ce4503 | 2009-01-27 22:48:17 +0000 | [diff] [blame] | 210 | VERIFY_IS_APPROX(m2.innerVectors(j0,n0), refMat2.block(0,j0,rows,n0)); |
| 211 | VERIFY_IS_APPROX(m2.innerVectors(j0,n0)+m2.innerVectors(j1,n0), |
| 212 | refMat2.block(0,j0,rows,n0)+refMat2.block(0,j1,rows,n0)); |
| 213 | //m2.innerVectors(j0,n0) = m2.innerVectors(j0,n0) + m2.innerVectors(j1,n0); |
| 214 | //refMat2.block(0,j0,rows,n0) = refMat2.block(0,j0,rows,n0) + refMat2.block(0,j1,rows,n0); |
Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 215 | } |
| 216 | |
Gael Guennebaud | 52cf07d | 2009-01-21 18:46:04 +0000 | [diff] [blame] | 217 | // test prune |
| 218 | { |
| 219 | SparseMatrixType m2(rows, rows); |
| 220 | DenseMatrix refM2(rows, rows); |
| 221 | refM2.setZero(); |
| 222 | int countFalseNonZero = 0; |
| 223 | int countTrueNonZero = 0; |
Gael Guennebaud | 52cf07d | 2009-01-21 18:46:04 +0000 | [diff] [blame] | 224 | for (int j=0; j<m2.outerSize(); ++j) |
Gael Guennebaud | 2829314 | 2009-05-04 14:25:12 +0000 | [diff] [blame] | 225 | { |
| 226 | m2.startVec(j); |
Gael Guennebaud | 52cf07d | 2009-01-21 18:46:04 +0000 | [diff] [blame] | 227 | for (int i=0; i<m2.innerSize(); ++i) |
| 228 | { |
Benoit Jacob | 4716040 | 2010-10-25 10:15:22 -0400 | [diff] [blame] | 229 | float x = internal::random<float>(0,1); |
Gael Guennebaud | 52cf07d | 2009-01-21 18:46:04 +0000 | [diff] [blame] | 230 | if (x<0.1) |
| 231 | { |
| 232 | // do nothing |
| 233 | } |
| 234 | else if (x<0.5) |
| 235 | { |
| 236 | countFalseNonZero++; |
Gael Guennebaud | 8710bd2 | 2010-06-02 13:32:13 +0200 | [diff] [blame] | 237 | m2.insertBackByOuterInner(j,i) = Scalar(0); |
Gael Guennebaud | 52cf07d | 2009-01-21 18:46:04 +0000 | [diff] [blame] | 238 | } |
| 239 | else |
| 240 | { |
| 241 | countTrueNonZero++; |
Gael Guennebaud | 8710bd2 | 2010-06-02 13:32:13 +0200 | [diff] [blame] | 242 | m2.insertBackByOuterInner(j,i) = refM2(i,j) = Scalar(1); |
Gael Guennebaud | 52cf07d | 2009-01-21 18:46:04 +0000 | [diff] [blame] | 243 | } |
| 244 | } |
Gael Guennebaud | 2829314 | 2009-05-04 14:25:12 +0000 | [diff] [blame] | 245 | } |
| 246 | m2.finalize(); |
Gael Guennebaud | 52cf07d | 2009-01-21 18:46:04 +0000 | [diff] [blame] | 247 | VERIFY(countFalseNonZero+countTrueNonZero == m2.nonZeros()); |
| 248 | VERIFY_IS_APPROX(m2, refM2); |
Hauke Heibel | d204ec4 | 2010-11-02 14:33:33 +0100 | [diff] [blame] | 249 | m2.prune(Scalar(1)); |
Gael Guennebaud | 52cf07d | 2009-01-21 18:46:04 +0000 | [diff] [blame] | 250 | VERIFY(countTrueNonZero==m2.nonZeros()); |
| 251 | VERIFY_IS_APPROX(m2, refM2); |
| 252 | } |
Gael Guennebaud | fa6d36e | 2010-07-22 15:57:01 +0200 | [diff] [blame] | 253 | |
Gael Guennebaud | 9a3ec63 | 2010-11-15 14:14:05 +0100 | [diff] [blame^] | 254 | // test selfadjointView |
| 255 | { |
| 256 | DenseMatrix refMat2(rows, rows), refMat3(rows, rows); |
| 257 | SparseMatrixType m2(rows, rows), m3(rows, rows); |
| 258 | initSparse<Scalar>(density, refMat2, m2); |
| 259 | refMat3 = refMat2.template selfadjointView<Lower>(); |
| 260 | m3 = m2.template selfadjointView<Lower>(); |
| 261 | VERIFY_IS_APPROX(m3, refMat3); |
| 262 | } |
| 263 | |
Gael Guennebaud | fa6d36e | 2010-07-22 15:57:01 +0200 | [diff] [blame] | 264 | // test sparseView |
| 265 | { |
| 266 | DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows); |
| 267 | SparseMatrixType m2(rows, rows); |
Gael Guennebaud | 9a3ec63 | 2010-11-15 14:14:05 +0100 | [diff] [blame^] | 268 | initSparse<Scalar>(density, refMat2, m2); |
Gael Guennebaud | fa6d36e | 2010-07-22 15:57:01 +0200 | [diff] [blame] | 269 | VERIFY_IS_APPROX(m2.eval(), refMat2.sparseView().eval()); |
| 270 | } |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | void test_sparse_basic() |
| 274 | { |
| 275 | for(int i = 0; i < g_repeat; i++) { |
Benoit Jacob | 2840ac7 | 2009-10-28 18:19:29 -0400 | [diff] [blame] | 276 | CALL_SUBTEST_1( sparse_basic(SparseMatrix<double>(8, 8)) ); |
| 277 | CALL_SUBTEST_2( sparse_basic(SparseMatrix<std::complex<double> >(16, 16)) ); |
| 278 | CALL_SUBTEST_1( sparse_basic(SparseMatrix<double>(33, 33)) ); |
Gael Guennebaud | 9f79558 | 2009-12-16 19:18:40 +0100 | [diff] [blame] | 279 | |
Benoit Jacob | 2840ac7 | 2009-10-28 18:19:29 -0400 | [diff] [blame] | 280 | CALL_SUBTEST_3( sparse_basic(DynamicSparseMatrix<double>(8, 8)) ); |
Gael Guennebaud | 86ccd99 | 2008-11-05 13:47:55 +0000 | [diff] [blame] | 281 | } |
| 282 | } |