-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix.c
64 lines (51 loc) · 1.01 KB
/
matrix.c
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "matrix.h"
void mxv(double *out, double *in, double **mtrx, int n, int m)
{
int i, j;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
out[i] += mtrx[i][j] * in[j];
}
void mtxv(double *out, double *in, double **mtrx, int n, int m)
{
int i, j;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
out[i] += mtrx[j][i] * in[j];
}
void vxvt(double **out, double *u, double *v, int m, int n)
{
int i, j;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
out[i][j] += u[i]*v[j];
}
void nxm(double **mtrx, double c, int m, int n)
{
int i, j;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
mtrx[i][j] *= c;
}
void mam(double **a, double **b, int m, int n)
{
int i, j;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
a[i][j] += b[i][j];
}
void entmul(double *dst, double *src, int n)
{
while (n-- > 0)
*dst++ *= *src++;
}
void entadd(double *dst, double *src, int n)
{
while (n-- > 0)
*dst++ += *src++;
}
void nummul(double *dst, double c, int n)
{
while (n-- > 0)
*dst++ *= c;
}