GRASS Programmer's Manual  6.5.svn(2012)-r51648
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
ortho.c
Go to the documentation of this file.
00001 /*  ortho.c    CCMATH mathematics library source code.
00002  *
00003  *  Copyright (C)  2000   Daniel A. Atkinson    All rights reserved.
00004  *  This code may be redistributed under the terms of the GNU library
00005  *  public license (LGPL). ( See the lgpl.license file for details.)
00006  * ------------------------------------------------------------------------
00007  */
00008 #include "ccmath.h"
00009 static double tpi = 6.28318530717958647;
00010 
00011 void ortho(double *e, int n)
00012 {
00013     int i, j, k, m;
00014 
00015     double *p, *q, c, s, a, unfl();
00016 
00017     for (i = 0, p = e; i < n; ++i) {
00018         for (j = 0; j < n; ++j) {
00019             if (i == j)
00020                 *p++ = 1.;
00021             else
00022                 *p++ = 0.;
00023         }
00024     }
00025     for (i = 0, m = n - 1; i < m; ++i) {
00026         for (j = i + 1; j < n; ++j) {
00027             a = tpi * unfl();
00028             c = cos(a);
00029             s = sin(a);
00030             p = e + n * i;
00031             q = e + n * j;
00032             for (k = 0; k < n; ++k) {
00033                 a = *p * c + *q * s;
00034                 *q = *q * c - *p * s;
00035                 *p++ = a;
00036                 ++q;
00037             }
00038         }
00039     }
00040 }