summaryrefslogtreecommitdiff
path: root/modules/dynamic_link/examples/gateway/matmul.c
blob: 1588fa609017c36f58766e8ced2f9742c7355b40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA -
 *
 * This file is released under the 3-clause BSD license. See COPYING-BSD.
 */
#include "matmul.h"

/*--------------------------------------------------------
 *  Matrix multiplication C= A*B, (A,B,C stored columnwise)
 *  C function
 *--------------------------------------------------------*/

#define A(i,k) a[i + k*n]
#define B(k,j) b[k + j*m]
#define C(i,j) c[i + j*n]

void matmul(double a[], int n, int m, double b[], int l, double c[])
{
    int i = 0, j = 0, k = 0;
    double s = 0.0;

    for ( i = 0 ; i < n; i++)
    {
        for ( j = 0; j < l; j++)
        {
            s = 0.;
            for ( k = 0; k < m; k++)
            {
                s += A(i, k) * B(k, j);
            }
            C(i, j) = s;
        }
    }
}