biped-stabilizer 1.5.0
Stabilizer for Biped Locomotion
Loading...
Searching...
No Matches
wykobi_matrix.hpp
Go to the documentation of this file.
1/*
2(***********************************************************************)
3(* *)
4(* Wykobi Computational Geometry Library *)
5(* Release Version 0.0.5 *)
6(* http://www.wykobi.com *)
7(* Copyright (c) 2005-2017 Arash Partow, All Rights Reserved. *)
8(* *)
9(* The Wykobi computational geometry library and its components are *)
10(* supplied under the terms of the open source MIT License. *)
11(* The contents of the Wykobi computational geometry library and its *)
12(* components may not be copied or disclosed except in accordance with *)
13(* the terms of the MIT License. *)
14(* *)
15(* URL: https://opensource.org/licenses/MIT *)
16(* *)
17(***********************************************************************)
18*/
19
20#ifndef INCLUDE_WYKOBI_MATRIX
21#define INCLUDE_WYKOBI_MATRIX
22
23#include <cassert>
24#include <cstdlib>
25#include <limits>
26#include <vector>
27
28#include "wykobi.hpp"
29#include "wykobi_math.hpp"
30
31namespace wykobi {
32template <typename T, std::size_t M, std::size_t N>
33class matrix {
34 public:
35 matrix() : dptr(reinterpret_cast<T*>(&data)) { zero(); }
36
37 ~matrix() {}
38
40
41 // column major
42 const T& operator()(std::size_t x, std::size_t y) const { return data[y][x]; }
43
44 T& operator()(std::size_t x, std::size_t y) { return data[y][x]; }
45
46 const T& operator()(std::size_t i) const { return dptr[i]; }
47
48 T& operator()(std::size_t i) { return dptr[i]; }
49
50 const T& operator[](std::size_t i) const { return dptr[i]; }
51
52 T& operator[](std::size_t i) { return dptr[i]; }
53
55 matrix<T, M, N>& operator+=(const T& value);
56 matrix<T, M, N>& operator-=(const T& value);
57 matrix<T, M, N>& operator*=(const T& value);
58 matrix<T, M, N>& operator/=(const T& value);
61
62 void zero();
63 void identity();
64 void swap(const unsigned int& x1, const unsigned int& y1,
65 const unsigned int& x2, const unsigned int& y2);
66
67 std::size_t size() const { return M * N; }
68
69 private:
70 T data[M][N];
71 T* dptr;
72};
73
74template <typename T>
75inline T det(const matrix<T, 1, 1>& matrix);
76template <typename T>
77inline T det(const matrix<T, 2, 2>& matrix);
78template <typename T>
79inline T det(const matrix<T, 3, 3>& matrix);
80template <typename T>
81inline T det(const matrix<T, 4, 4>& matrix);
82
83template <typename T>
85template <typename T>
87template <typename T>
89template <typename T>
91
92template <typename T>
93inline void inverse(matrix<T, 2, 2>& out_matrix,
94 const matrix<T, 2, 2>& in_matrix);
95template <typename T>
96inline void inverse(matrix<T, 3, 3>& out_matrix,
97 const matrix<T, 3, 3>& in_matrix);
98template <typename T>
99inline void inverse(matrix<T, 4, 4>& out_matrix,
100 const matrix<T, 4, 4>& in_matrix);
101
102template <typename T, std::size_t N>
103inline void inverse(matrix<T, N, N>& out_matrix,
104 const matrix<T, N, N>& in_matrix);
105
106template <typename T>
107inline void eigen_values(const matrix<T, 2, 2>& matrix, T& eigen_value1,
108 T& eigen_value2);
109template <typename T>
111 vector2d<T>& eigenvector1, vector2d<T>& eigenvector2);
112
113} // namespace wykobi
114
115#include "wykobi_matrix.inl"
116
117#endif
Definition wykobi_matrix.hpp:33
matrix< T, M, N > & operator+=(const T &value)
matrix< T, M, N > & operator=(const matrix< T, M, N > &m)
T & operator()(std::size_t x, std::size_t y)
Definition wykobi_matrix.hpp:44
void swap(const unsigned int &x1, const unsigned int &y1, const unsigned int &x2, const unsigned int &y2)
matrix< T, M, N > & operator-=(const T &value)
T & operator()(std::size_t i)
Definition wykobi_matrix.hpp:48
const T & operator()(std::size_t x, std::size_t y) const
Definition wykobi_matrix.hpp:42
const T & operator[](std::size_t i) const
Definition wykobi_matrix.hpp:50
~matrix()
Definition wykobi_matrix.hpp:37
matrix()
Definition wykobi_matrix.hpp:35
matrix< T, M, N > & operator*=(const T &value)
const T & operator()(std::size_t i) const
Definition wykobi_matrix.hpp:46
matrix< T, M, N > & operator+=(const matrix< T, M, N > &_matrix)
matrix< T, M, N > & operator-=(const matrix< T, M, N > &_matrix)
T & operator[](std::size_t i)
Definition wykobi_matrix.hpp:52
matrix(const matrix< T, M, N > &m)
matrix< T, M, N > & operator/=(const T &value)
std::size_t size() const
Definition wykobi_matrix.hpp:67
Definition wykobi.hpp:582
Definition wykobi.hpp:32
void eigenvector(const matrix< T, 2, 2 > &matrix, vector2d< T > &eigenvector1, vector2d< T > &eigenvector2)
void inverse(matrix< T, 2, 2 > &out_matrix, const matrix< T, 2, 2 > &in_matrix)
T det(const matrix< T, 1, 1 > &matrix)
void transpose(matrix< T, 1, 1 > &matrix)
void eigen_values(const matrix< T, 2, 2 > &matrix, T &eigen_value1, T &eigen_value2)