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