MathMatrix.h

来源:互联网 发布:星际淘宝网第488章 编辑:程序博客网 时间:2024/05/17 13:12
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
////  MathMatrix.h////  Created by RetVal on 7/7/12.//  Copyright (c) 2012 RetVal. All rights reserved.//   #ifndef MathMatrix_h#define MathMatrix_h#include "RtlServicesMacro.h"struct_RtlRectangle{    RtlUInteger     row;    RtlUInteger     column;};typedefstruct _RtlRectangle RtlRectangle;typedefRtlRectangle* RtlRectangleRef;struct_RtlMatrix{    RtlFloat**      base;    RtlRectangle    info;};   typedefstruct _RtlMatrix RtlMatrix;typedefRtlMatrix* RtlMatrixRef;   #ifndef MathMakeRectangleX#define MathMakeRectangleXRtlInline RtlRectangle MathMakeRectangle(RtlUInteger row, RtlUInteger column){    RtlRectangle rr;    rr.row = row;    rr.column = column;    returnrr;}#endif   #ifndef RtlDoubleMatrixChange#define RtlDoubleMatrixChange(a,b)  RtlReserved#endif#include "MathError.h"   #pragma mark Create Methods   RtlExport RtlMatrixRef MathMatrixCreate(RtlMatrixRef matrix,RtlUInteger row,RtlUInteger column);RtlExport RtlMatrixRef MathMatrixCreateEMatrix(RtlMatrixRef matrix,RtlUInteger row);RtlExport RtlMatrixRef MathMatrixCopy(RtlMatrixRef matrix);   #pragma mark Free Method   RtlExportvoid        MathMatrixFree(RtlMatrixRef matrix);   #pragma mark Size Methods   RtlExport RtlUInteger  MathMatrixGetRow(RtlMatrixRef matrix);RtlExport RtlUInteger  MathMatrixGetColumn(RtlMatrixRef matrix);RtlExport RtlFloat     MathMatrixGetContent(RtlMatrixRef matrix, RtlUInteger row, RtlUInteger column);RtlExportvoid    MathMatrixSetContent(RtlMatrixRef matrix, RtlUInteger row, RtlUInteger column,RtlFloat n);RtlExport RtlRectangle MathMatrixGetMulSize(RtlMatrixRef matrix1, RtlMatrixRef matrix2);#pragma mark Check Methods//Check if the size of matrix1 is equal to matrix2.(row, column)RtlExportBOOL        MathMatrixIsEqualSize(RtlMatrixRef matrix1,RtlMatrixRef matrix2);//Check if the matrix1 is equal to matrix2.RtlExportBOOL        MathMatrixIsEqual(RtlMatrixRef matrix1,RtlMatrixRef matrix2);RtlExportBOOL        MathMatrixIsSquare(RtlMatrixRef matrix);RtlExportBOOL        MathMatrixIsCanMul(RtlMatrixRef matrix1,RtlMatrixRef matrix2);#pragma mark Calculate Methods// the result is stored in the return matrix, should call MathMatrixFree to release it when you done.   // matrix(return) = matrix1 + matrix2RtlExport RtlMatrixRef MathMatrixAdd(RtlMatrixRef matrix1,RtlMatrixRef matrix2);// matrix(return) = matrix1 - matrix2RtlExport RtlMatrixRef MathMatrixSub(RtlMatrixRef matrix1,RtlMatrixRef matrix2);// matrix(return) = matrix1 * matrix2 (result is not equal to matrix2 * matrix1)RtlExport RtlMatrixRef MathMatrixMul(RtlMatrixRef matrix1,RtlMatrixRef matrix2);#pragma mark Transpose Method   RtlExport RtlMatrixRef MathMatrixTranspose(RtlMatrixRef matrix);   #pragma mark Calculate Row Methods/* MathMatrixDivRow matrix[rowSelector]/n */RtlExport MathError MathMatrixRowDiv(RtlMatrixRef matrix,RtlUInteger rowSelector,RtlFloat n);/* MathMatrixMulRow matrix[rowSelector]*n */RtlExport MathError MathMatrixRowMul(RtlMatrixRef matrix,RtlUInteger rowSelector,RtlFloat n);   /* MathMatrixMulRow matrix[rowSelector]+n */RtlExport MathError MathMatrixRowAdd(RtlMatrixRef matrix,RtlUInteger rowSelector,RtlFloat n);   /* MathMatrixMulRow matrix[rowSelector]-n */RtlExport MathError MathMatrixRowSub(RtlMatrixRef matrix,RtlUInteger rowSelector,RtlFloat n);   /* MathMatrixRowDivWithRow matrix[rowSelectorAdd] += matrix[rowSelector]/n */RtlExport MathError MathMatrixRowDivWithRow(RtlMatrixRef matrix,RtlUInteger rowSelectorAdd,RtlUInteger rowSelector,RtlFloat n);   /* MathMatrixRowMulWithRow matrix[rowSelectorAdd] += matrix[rowSelector]*n */RtlExport MathError MathMatrixRowMulWithRow(RtlMatrixRef matrix,RtlUInteger rowSelectorAdd,RtlUInteger rowSelector,RtlFloat n);      #endif

原创粉丝点击