Gram–Schmidt Orthogonalization

We wrote the program gschmidt.c to perform Gram–Schmidt orthogonalization to factor a matrix

A = QR   or   At = RtQt

where Q is a matrix with orthogonal columns and R is an upper triangular matrix.

The Makefile compiles the program with the option -std=gnu99. The output of the program is

dotprod(u,v)=11
norm(u)=3.74166
Qt=
0.267261 0.534522 0.801784 
0.524631 0.617213 -0.586353 
Rt=
3.74166 -3.33067e-16 
2.93987 2.31455 
We may check our results using Octave as follows:
$ /nfs/home/ejolson/opt/bin/octave
GNU Octave, version 3.8.2
Copyright (C) 2014 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-unknown-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> Qt= [[0.267261 0.534522 0.801784]
> [0.524631 0.617213 -0.586353]]
Qt =

   0.26726   0.53452   0.80178
   0.52463   0.61721  -0.58635

octave:2> Rt= [[3.74166 -3.33067e-16]
> [2.93987 2.31455]]
Rt =

   3.7417e+00  -3.3307e-16
   2.9399e+00   2.3146e+00

octave:3> Rt*Qt
ans =

   1.00000   2.00000   3.00000
   2.00000   3.00000   1.00000

octave:4> quit
The answer is the original matrix.

At the end of the workshop we compared a simple Gaussian elimiation routine to the optimized LAPACK linear algebra solver.


Last Updated: Sat Sep 27 20:06:45 PDT 2014