MathMatrix.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
//
//  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 MathMakeRectangleX
RtlInline 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 + matrix2
RtlExport RtlMatrixRef MathMatrixAdd(RtlMatrixRef matrix1,RtlMatrixRef matrix2);
// matrix(return) = matrix1 - matrix2
RtlExport 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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值