~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to src/lib/libqt/schmidt_add.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
  \file schmidt_add.c
3
 
  \ingroup (QT)
4
 
*/
5
 
 
6
 
#include <stdio.h>
7
 
#include <math.h>
8
 
#include <libciomr/libciomr.h>
9
 
 
10
 
#define NORM_TOL 1.0E-5
11
 
 
12
 
/*!
13
 
** SCHMIDT_ADD(): Assume A is a orthogonal matrix.  This function Gram-Schmidt
14
 
** orthogonalizes a new vector v and adds it to matrix A.  A must contain
15
 
** a free row pointer for a new row.  Don't add orthogonalized v' if 
16
 
** norm(v') < NORM_TOL.
17
 
**
18
 
** David Sherrill, Feb 1994
19
 
**
20
 
** Arguments:
21
 
**    \param A    = matrix to add new vector to
22
 
**    \param rows = current number of rows in A 
23
 
**                  (A must have ptr for 'rows+1' row.)
24
 
**    \param cols = columns in A
25
 
**    \parm v     = vector to add to A after it has been made orthogonal 
26
 
**                  to rest of A
27
 
**
28
 
** Returns: 1 if a vector is added to A, 0 otherwise
29
 
** \ingroup (QT)
30
 
*/
31
 
int schmidt_add(double **A, int rows, int cols, double *v)
32
 
{
33
 
   double dotval, normval ;
34
 
   int i, I ;
35
 
 
36
 
   for (i=0; i<rows; i++) {
37
 
      dot_arr(A[i], v, cols, &dotval) ;
38
 
      for (I=0; I<cols; I++) v[I] -= dotval * A[i][I] ;
39
 
      }                 
40
 
 
41
 
   dot_arr(v, v, cols, &normval) ;
42
 
   normval = sqrt(normval) ;
43
 
 
44
 
   if (normval < NORM_TOL) 
45
 
      return(0) ;
46
 
   else {
47
 
      if (A[rows] == NULL) A[rows] = init_array(cols) ;
48
 
      for (I=0; I<cols; I++) A[rows][I] = v[I] / normval ;
49
 
      return(1) ;
50
 
      }
51
 
}
52
 
      
53