GRASS Programmer's Manual  6.5.svn(2012)-r51648
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
otrsm.c
Go to the documentation of this file.
00001 /*  otrsm.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 <stdlib.h>
00009 void otrsm(double *sm, double *a, double *b, int n)
00010 {
00011     double z, *q0, *p, *s, *t;
00012 
00013     int i, j, k;
00014 
00015     q0 = (double *)calloc(n, sizeof(double));
00016     for (i = 0; i < n; ++i) {
00017         for (j = 0, t = b; j < n; ++j) {
00018             for (k = 0, s = a + i * n, z = 0.; k < n; ++k)
00019                 z += *t++ * *s++;
00020             q0[j] = z;
00021         }
00022         for (j = 0, p = sm + i, t = a; j <= i; ++j, p += n) {
00023             for (k = 0, s = q0, z = 0.; k < n; ++k)
00024                 z += *t++ * *s++;
00025             *p = z;
00026             if (j < i)
00027                 sm[i * n + j] = z;
00028         }
00029     }
00030     free(q0);
00031 }