Integrate internal fixes
[platform/core/system/sensord.git] / src / fusion-sensor / rotation_vector / fusion_utils / matrix.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef _MATRIX_H_
21 #define _MATRIX_H_
22
23 #include <assert.h>
24 #include <iostream>
25 using namespace std;
26
27 #define TYPE_ROW_COL template<typename TYPE, int ROW, int COL>
28 #define T_R_C template<typename T, int R, int C>
29 #define T_R_C_C2 template<typename T, int R, int C, int C2>
30 #define T_R1_C1_R2_C2 template<typename T, int R1, int C1, int R2, int C2>
31
32 TYPE_ROW_COL class matrix {
33 public:
34         TYPE m_mat[ROW][COL];
35
36         matrix(void);
37         matrix(TYPE mat_data[ROW][COL]);
38         matrix(const matrix<TYPE, ROW, COL>& m);
39         ~matrix();
40
41         matrix<TYPE, ROW, COL> operator =(const matrix<TYPE, ROW, COL>& m);
42
43         T_R_C friend ostream& operator << (ostream& dout, matrix<T, R, C>& m);
44         T_R_C friend matrix<T, R, C> operator +(const matrix<T, R, C> m1, const matrix<T, R, C> m2);
45         T_R_C friend matrix<T, R, C> operator +(const matrix<T, R, C> m, const T val);
46         T_R_C friend matrix<T, R, C> operator -(const matrix<T, R, C> m1, const matrix<T, R, C> m2);
47         T_R_C friend matrix<T, R, C> operator -(const matrix<T, R, C> m, const T val);
48         T_R_C_C2 friend matrix<T, R, C2> operator *(const matrix<T, R, C> m1, const matrix<T, C, C2> m2);
49         T_R_C friend matrix<T, R, C> operator *(const matrix<T, R, C> m, const T val);
50         T_R_C friend matrix<T, R, C> operator /(const matrix<T, R, C> m1, const T val);
51         T_R1_C1_R2_C2 friend bool operator ==(const matrix<T, R1, C1> m1, const matrix<T, R2, C2> m2);
52         T_R1_C1_R2_C2 friend bool operator !=(const matrix<T, R1, C1> m1, const matrix<T, R2, C2> m2);
53         T_R_C friend matrix<T, R, C> tran(const matrix<T, R, C> m);
54 };
55
56 #include "matrix.cpp"
57
58 #endif  //_MATRIX_H_