upperbidiagonalization.cpp
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #include "main.h"
00026 #include <Eigen/SVD>
00027 
00028 template<typename MatrixType> void upperbidiag(const MatrixType& m)
00029 {
00030   const typename MatrixType::Index rows = m.rows();
00031   const typename MatrixType::Index cols = m.cols();
00032 
00033   typedef typename MatrixType::Scalar Scalar;
00034   typedef Matrix<typename MatrixType::RealScalar, MatrixType::RowsAtCompileTime,  MatrixType::ColsAtCompileTime> RealMatrixType;
00035 
00036   MatrixType a = MatrixType::Random(rows,cols);
00037   internal::UpperBidiagonalization<MatrixType> ubd(a);
00038   RealMatrixType b(rows, cols);
00039   b.setZero();
00040   b.block(0,0,cols,cols) = ubd.bidiagonal();
00041   MatrixType c = ubd.householderU() * b * ubd.householderV().adjoint();
00042   VERIFY_IS_APPROX(a,c);
00043 }
00044 
00045 void test_upperbidiagonalization()
00046 {
00047   for(int i = 0; i < g_repeat; i++) {
00048    CALL_SUBTEST_1( upperbidiag(MatrixXf(3,3)) );
00049    CALL_SUBTEST_2( upperbidiag(MatrixXd(17,12)) );
00050    CALL_SUBTEST_3( upperbidiag(MatrixXcf(20,20)) );
00051    CALL_SUBTEST_4( upperbidiag(MatrixXcd(16,15)) );
00052    CALL_SUBTEST_5( upperbidiag(Matrix<float,6,4>()) );
00053    CALL_SUBTEST_6( upperbidiag(Matrix<float,5,5>()) );
00054    CALL_SUBTEST_7( upperbidiag(Matrix<double,4,3>()) );
00055   }
00056 }


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:34:00