// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@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/.
// this test relies a lot on Random.h, and there's not much more that we can do // to test it, hence I consider that we will have tested Random.h
MatrixType m1 = MatrixType::Random(rows, cols),
m2 = MatrixType::Random(rows, cols),
m3(rows, cols),
mzero = MatrixType::Zero(rows, cols),
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>::Random(rows, rows);
VectorType v1 = VectorType::Random(rows),
vzero = VectorType::Zero(rows);
SquareMatrixType sm1 = SquareMatrixType::Random(rows,rows), sm2(rows,rows);
Scalar x = 0; while(x == Scalar(0)) x = internal::random<Scalar>();
Index r = internal::random<Index>(0, rows-1),
c = internal::random<Index>(0, cols-1);
// test fetching with various index types.
Index r1 = internal::random<Index>(0, numext::mini(Index(127),rows-1));
x = v1(static_cast<char>(r1));
x = v1(static_cast<signedchar>(r1));
x = v1(static_cast<unsignedchar>(r1));
x = v1(static_cast<signedshort>(r1));
x = v1(static_cast<unsignedshort>(r1));
x = v1(static_cast<signedint>(r1));
x = v1(static_cast<unsignedint>(r1));
x = v1(static_cast<signedlong>(r1));
x = v1(static_cast<unsignedlong>(r1)); #if EIGEN_HAS_CXX11
x = v1(static_cast<longlongint>(r1));
x = v1(static_cast<unsignedlonglongint>(r1)); #endif
// always test operator() on each read-only expression class, // in order to check const-qualifiers. // indeed, if an expression class (here Zero) is meant to be read-only, // hence has no _write() method, the corresponding MatrixBase method (here zero()) // should return a const-qualified object so that it is the const-qualified // operator() that gets called, which in turn calls _read().
VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows,cols)(r,c), static_cast<Scalar>(1));
// now test copying a row-vector into a (column-)vector and conversely.
square.col(r) = square.row(r).eval();
Matrix<Scalar, 1, MatrixType::RowsAtCompileTime> rv(rows);
Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> cv(rows);
rv = square.row(r);
cv = square.col(r);
VERIFY(numext::real(s1)==numext::real_ref(s1));
VERIFY(numext::imag(s1)==numext::imag_ref(s1));
numext::real_ref(s1) = numext::real(s2);
numext::imag_ref(s1) = numext::imag(s2);
VERIFY(internal::isApprox(s1, s2, NumTraits<RealScalar>::epsilon())); // extended precision in Intel FPUs means that s1 == s2 in the line above is not guaranteed.
¤ 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.0.15Bemerkung:
(vorverarbeitet)
¤
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.