-
Notifications
You must be signed in to change notification settings - Fork 3
/
xxmatrix.h
executable file
·151 lines (114 loc) · 7.1 KB
/
xxmatrix.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**********************************************************
* This file is generated by 20-sim ANSI-C Code Generator
*
* file: src\xxmatrix.h
* model: R2G2P_Body_Only
* expmt: R2G2P_Body_Only
* date: April 5, 2016
* time: 10:29:15 AM
* user: INTO-CPS
* from: 20-sim 4.6 Professional Single
* build: 4.6.0.6684
**********************************************************/
#ifndef XX_MATRIX_H
#define XX_MATRIX_H
/* 20-sim include files */
#include "xxtypes.h"
/* fill in a matrix struct with a given array, rows and columns */
void XXCreateMatrixStruct (XXMatrix *mat_dest, XXInteger rows, XXInteger columns, XXDouble *values);
/* allocate a matrix struct with rows and columns
void XXAllocateMatrixStruct (XXMatrix *mat_dest, XXInteger rows, XXInteger columns);
free a matrix struct with rows and columns
void XXFreeMatrixStruct (XXMatrix *mat_dest);
*/
/* and the function declarations */
/* copy a matrix source to a matrix destination */
void XXMatrixMov (XXMatrix *mat_dest, XXMatrix *mat_source);
/* copy a scalar to every element in a matrix destination */
void XXMatrixScalarMov (XXMatrix *mat_dest, XXDouble s);
/* get the row(zero_based) designated by the integer
from the source to the destination. destination is vector */
void XXMatrixGetRow (XXMatrix *mat_dest, XXMatrix *mat_source, XXInteger row);
/* set the row(zero_based) designated by the integer
to the destination from the source. source is vector*/
void XXMatrixSetRow (XXMatrix *mat_dest, XXMatrix *mat_source, XXInteger row);
/* get the column(zero_based) designated by the integer
from the source to the destination. destination is vector */
void XXMatrixGetColumn (XXMatrix *mat_dest, XXMatrix *mat_source, XXInteger column);
/* set the column(zero_based) designated by the integer
to the destination from the source. source is vector */
void XXMatrixSetColumn (XXMatrix *mat_dest, XXMatrix *mat_source, XXInteger column);
/* add a matrix source1 to a matrix source2 to a matrix destination */
void XXMatrixAdd (XXMatrix *mat_dest, XXMatrix *mat_source1, XXMatrix *mat_source2);
/* add a matrix source1 to a scalar source2 to a matrix destination */
void XXMatrixScalarAdd (XXMatrix *mat_dest, XXMatrix *mat_source1, XXDouble s2);
/* add a scalar source1 to a matrix source2 to a matrix destination */
void XXScalarMatrixAdd (XXMatrix *mat_dest, XXDouble s1, XXMatrix *mat_source2);
/* add a scalar source1 to a scalar source2 to a matrix destination */
void XXScalarScalarAdd (XXMatrix *mat_dest, XXDouble s1, XXDouble s2);
/* subtract a Matrix source2 from a matrix source1 to a matrix destination */
void XXMatrixSub (XXMatrix *mat_dest, XXMatrix *mat_source1, XXMatrix *mat_source2);
/* subtract a scalar source2 from a matrix source1 to a matrix destination */
void XXMatrixScalarSub (XXMatrix *mat_dest, XXMatrix *mat_source1, XXDouble s2);
/* subtract a matrix source2 from a scalar source1 to a matrix destination */
void XXScalarMatrixSub (XXMatrix *mat_dest, XXDouble s1, XXMatrix *mat_source2);
/* subtract a scalar source2 from a scalar source1 to a matrix destination */
void XXScalarScalarSub (XXMatrix *mat_dest, XXDouble s1, XXDouble s2);
/* multiply matrix source1 and matrix source2 to destination matrix */
void XXMatrixMul (XXMatrix *mat_dest, XXMatrix *mat_source1, XXMatrix *mat_source2);
/* multiply matrix source1 with scalar source2 to matrix destination */
void XXMatrixScalarMul (XXMatrix *mat_dest, XXMatrix *mat_source1, XXDouble s2);
/* multiply scalar source1 with matrix source2 to matrix destination */
void XXScalarMatrixMul (XXMatrix *mat_dest, XXDouble s1, XXMatrix *mat_source2);
/* multiply scalar source1 with scalar source2 to matrix destination */
void XXScalarScalarMul(XXMatrix *mat_dest, XXDouble s1, XXDouble s2);
/* multiply matrix source1 with matrix source2 to scalar destination
the sizes are not checked but it should be that rows of source1 == 1 and columns source2 == 1*/
void XXScalarMatrixMatrixMul (XXDouble *dest, XXMatrix *mat_source1, XXMatrix *mat_source2);
/* multiply all elements element-wise to the destination */
void XXMatrixMulElement (XXMatrix *mat_dest, XXMatrix *mat_source1, XXMatrix *mat_source2);
/* take the inverse of a matrix source to a matrix destination
workarray size at least (3 * n * n + 2 * n)
with n is rows is columns from source (=equal to destination) */
void XXMatrixInverse (XXMatrix *mat_dest, XXMatrix *mat_source, XXDouble *workarray);
/* divide matrix source1 with matrix source2 to matrix destination
workarray size at least (4 * n * n + 2 * n)
with n is rows is columns from source2 */
void XXMatrixDiv (XXMatrix *mat_dest, XXMatrix *mat_source1, XXMatrix *mat_source2, XXDouble *workarray);
/* divide matrix source1 with scalar source2 to matrix destination */
void XXMatrixScalarDiv (XXMatrix *mat_dest, XXMatrix *mat_source1, XXDouble s2);
/* divide scalar source1 with matrix source2 to matrix destination
workarray size at least (3 * n * n + 2 * n)
with n is rows is columns from source2 (=equal to destination) */
void XXScalarMatrixDiv (XXMatrix *mat_dest, XXDouble s1, XXMatrix *mat_source2, XXDouble *workarray);
/* divide scalar source1 with scalar source2 to matrix destination */
void XXScalarScalarDiv (XXMatrix *mat_dest, XXDouble s1, XXDouble s2);
/* take the negative value of the matrix source to the the matrix destination */
void XXMatrixInv (XXMatrix *mat_dest, XXMatrix *mat_source);
/* take the transpose of the matrix source to the the matrix destination */
void XXMatrixTranspose (XXMatrix *mat_dest, XXMatrix *mat_source);
/* use the source1 as an integer index for the destination
and copy the scalar value of source2 at this point */
void XXMatrixMovRelAbs (XXMatrix *mat_dest, XXDouble s1, XXDouble s2);
/* use the source2 as an integer index for the source1
and copy this value of source1 to the scalar destination */
void XXMatrixMovAbsRel (XXDouble *dest, XXMatrix *mat_source1, XXDouble s2);
/* summize all the elements of the matrix and put the result in the dest */
void XXMatrixSum (XXDouble *dest, XXMatrix *mat_source);
/* set the destination to the eye matrix */
void XXMatrixEye (XXMatrix *mat_dest);
/* multiply the source1 n times with itself, with n in source2
an integer number. The result is put in the destination,
workarray must have at least the size of the destination matrix
plus the workarray size of an inverse matrix operation
this makes 4 * n * n + 2 * n with n = rows/columns of source/dest.
source and destination should be square */
void XXMatrixPow (XXMatrix *mat_dest, XXMatrix *mat_source1,
XXDouble s2, XXDouble *workarray);
/* and the scalar scalar variant */
void XXScalarScalarPow (XXMatrix *mat_dest, XXDouble s1, XXDouble s2);
/* calculate the solution of Ax=b towards x
inside 20-sim this is done with an advanced linear solver
code generation uses the x=inverse(A)*b approach instead */
void XXLinearSolve (XXMatrix *mat_dest, XXMatrix *mat_source1, XXMatrix *mat_source2, XXString method, XXInteger id, XXDouble *workarray);
#endif /* XX_MATRIX_H */