3 * Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * See the file ./license.txt
21 /*--------------------------------------------------------------------------*/
24 #include "scicos_block4.h"
25 #include "dynlib_scicos_blocks.h"
26 /*--------------------------------------------------------------------------*/
27 #define matmul2(y1,u1,u2,mu,nu) {for (i=0;i<mu*nu;i++) y1[i]=u1[i]*u2[i];}
28 /*--------------------------------------------------------------------------*/
29 SCICOS_BLOCKS_IMPEXP void matmul2_m(scicos_block *block, int flag)
34 int ut = GetInType(block, 1);
35 int mu = GetOutPortRows(block, 1);
36 int nu = GetOutPortCols(block, 1);
42 double *u1 = GetRealInPortPtrs(block, 1);
43 double *u2 = GetRealInPortPtrs(block, 2);
44 double *y1 = GetRealOutPortPtrs(block, 1);
45 matmul2(y1, u1, u2, mu, nu);
51 long *u1 = Getint32InPortPtrs(block, 1);
52 long *u2 = Getint32InPortPtrs(block, 2);
53 long *y1 = Getint32OutPortPtrs(block, 1);
54 matmul2(y1, u1, u2, mu, nu);
61 short *u1 = Getint16InPortPtrs(block, 1);
62 short *u2 = Getint16InPortPtrs(block, 2);
63 short *y1 = Getint16OutPortPtrs(block, 1);
64 matmul2(y1, u1, u2, mu, nu);
71 char *u1 = Getint8InPortPtrs(block, 1);
72 char *u2 = Getint8InPortPtrs(block, 2);
73 char *y1 = Getint8OutPortPtrs(block, 1);
74 matmul2(y1, u1, u2, mu, nu);
81 unsigned long *u1 = Getuint32InPortPtrs(block, 1);
82 unsigned long *u2 = Getuint32InPortPtrs(block, 2);
83 unsigned long *y1 = Getuint32OutPortPtrs(block, 1);
84 matmul2(y1, u1, u2, mu, nu);
91 unsigned short *u1 = Getuint16InPortPtrs(block, 1);
92 unsigned short *u2 = Getuint16InPortPtrs(block, 2);
93 unsigned short *y1 = Getuint16OutPortPtrs(block, 1);
94 matmul2(y1, u1, u2, mu, nu);
101 unsigned char *u1 = Getuint8InPortPtrs(block, 1);
102 unsigned char *u2 = Getuint8InPortPtrs(block, 2);
103 unsigned char *y1 = Getuint8OutPortPtrs(block, 1);
104 matmul2(y1, u1, u2, mu, nu);
110 double *u1r = GetRealInPortPtrs(block, 1);
111 double *u2r = GetRealInPortPtrs(block, 2);
112 double *y1r = GetRealOutPortPtrs(block, 1);
113 double *u1i = GetImagInPortPtrs(block, 1);
114 double *u2i = GetImagInPortPtrs(block, 2);
115 double *y1i = GetImagOutPortPtrs(block, 1);
116 for (i = 0; i < mu * nu; i++)
118 y1r[i] = (u1r[i] * u2r[i]) - (u1i[i] * u2i[i]);
119 y1i[i] = (u1r[i] * u2i[i]) + (u1i[i] * u2r[i]);
133 /*--------------------------------------------------------------------------*/