Skip to content

Commit

Permalink
TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
MaEtUgR committed Dec 19, 2023
1 parent 613564f commit dc07f55
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 104 deletions.
2 changes: 1 addition & 1 deletion cmake/px4_add_common_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function(px4_add_common_flags)
# Warnings
-Wall
-Wextra
-Werror
#-Werror

-Warray-bounds
-Wcast-align
Expand Down
1 change: 1 addition & 0 deletions src/lib/matrix/matrix/Dcm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include "math.hpp"
#include "SquareMatrix.hpp"

namespace matrix
{
Expand Down
7 changes: 4 additions & 3 deletions src/lib/matrix/matrix/Dcm2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@

#pragma once

#include "math.hpp"
#include "SquareMatrix.hpp"
#include "Vector2.hpp"

namespace matrix
{
Expand Down Expand Up @@ -115,8 +116,8 @@ class Dcm2 : public SquareMatrix<Type, 2>
{
/* renormalize rows */
for (size_t r = 0; r < 2; r++) {
matrix::Vector2<Type> rvec(Matrix<Type, 1, 2>(this->Matrix<Type, 2, 2>::row(r)).transpose());
this->Matrix<Type, 2, 2>::row(r) = rvec.normalized();
matrix::Vector2<Type> rvec(Matrix<Type, 1, 2>(this->row(r)).transpose());
this->row(r) = rvec.normalized();
}
}
};
Expand Down
30 changes: 18 additions & 12 deletions src/lib/matrix/matrix/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@
#include <cstdio>
#include <cstring>

#include "math.hpp"
#include "Slice.hpp"

namespace matrix
{

template <typename Type, size_t M>
class Vector;

template<typename Type, size_t M, size_t N>
class Matrix;

template <typename Type, size_t P, size_t Q, size_t M, size_t N>
class Slice;

template<typename Type, size_t M, size_t N>
class Matrix
{
Expand Down Expand Up @@ -75,6 +69,18 @@ class Matrix
}
}

template<size_t P, size_t Q>
Matrix(const ConstSlice<Type, M, N, P, Q> &in_slice)
{
Matrix<Type, M, N> &self = *this;

for (size_t i = 0; i < M; i++) {
for (size_t j = 0; j < N; j++) {
self(i, j) = in_slice(i, j);
}
}
}

/**
* Accessors/ Assignment etc.
*/
Expand Down Expand Up @@ -395,18 +401,18 @@ class Matrix
}

template<size_t P, size_t Q>
const Slice<Type, P, Q, M, N> slice(size_t x0, size_t y0) const
ConstSlice<Type, P, Q, M, N> slice(size_t x0, size_t y0) const
{
return Slice<Type, P, Q, M, N>(x0, y0, this);
return {x0, y0, this};
}

template<size_t P, size_t Q>
Slice<Type, P, Q, M, N> slice(size_t x0, size_t y0)
{
return Slice<Type, P, Q, M, N>(x0, y0, this);
return {x0, y0, this};
}

const Slice<Type, 1, N, M, N> row(size_t i) const
ConstSlice<Type, 1, N, M, N> row(size_t i) const
{
return slice<1, N>(i, 0);
}
Expand All @@ -416,7 +422,7 @@ class Matrix
return slice<1, N>(i, 0);
}

const Slice<Type, M, 1, M, N> col(size_t j) const
ConstSlice<Type, M, 1, M, N> col(size_t j) const
{
return slice<M, 1>(0, j);
}
Expand Down
Loading

0 comments on commit dc07f55

Please sign in to comment.