// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2009 Hauke Heibel <hauke.heibel@gmail.com> // // 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/.
// boundary cases ...
m = n = MatrixType::Random(50,50);
m.conservativeResize(1,50);
VERIFY_IS_APPROX(m, n.block(0,0,1,50));
m = n = MatrixType::Random(50,50);
m.conservativeResize(50,1);
VERIFY_IS_APPROX(m, n.block(0,0,50,1));
m = n = MatrixType::Random(50,50);
m.conservativeResize(50,50);
VERIFY_IS_APPROX(m, n.block(0,0,50,50));
// random shrinking ... for (int i=0; i<25; ++i)
{ const Index rows = internal::random<Index>(1,50); const Index cols = internal::random<Index>(1,50);
m = n = MatrixType::Random(50,50);
m.conservativeResize(rows,cols);
VERIFY_IS_APPROX(m, n.block(0,0,rows,cols));
}
// random growing with zeroing ... for (int i=0; i<25; ++i)
{ const Index rows = internal::random<Index>(50,75); const Index cols = internal::random<Index>(50,75);
m = n = MatrixType::Random(50,50);
m.conservativeResizeLike(MatrixType::Zero(rows,cols));
VERIFY_IS_APPROX(m.block(0,0,n.rows(),n.cols()), n);
VERIFY( rows<=50 || m.block(50,0,rows-50,cols).sum() == Scalar(0) );
VERIFY( cols<=50 || m.block(0,50,rows,cols-50).sum() == Scalar(0) );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.