ProteoWizard
HouseholderQRTest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17#include "HouseholderQR.hpp"
18using namespace pwiz::math;
19
20int main(int argc, char* argv[])
21{
22 using namespace boost::numeric::ublas;
23 using namespace std;
24 matrix<double> A (3,3);
25 A(0,0) = 1;
26 A(0,1) = 1;
27 A(0,2) = 0;
28 A(1,1) = 1;
29 A(1,0) = 0;
30 A(1,2) = 0;
31 A(2,2) = 1;
32 A(2,0) = 1;
33 A(2,1) = 0;
34 cout << "A=" << A << endl;
35
36 cout << "QR decomposition using Householder" << endl;
37 matrix<double> Q(3,3), R(3,3);
38 HouseholderQR (A,Q,R);
39 matrix<double> Z = prod(Q,R) - A;
40 float f = norm_1 (Z);
41 cout << "Q=" << Q <<endl;
42 cout << "R=" << R << endl;
43 cout << "|Q*R - A|=" << f << endl;
44
45 return 0;
46}
47
#define A
int main(int argc, char *argv[])
void HouseholderQR(const ublas::matrix< T > &M, ublas::matrix< T > &Q, ublas::matrix< T > &R)
STL namespace.