Set Matrix's col amd row to single value (#113)

This commit is contained in:
kritz
2019-12-05 18:16:14 +01:00
committed by Julian Kent
parent ef442fab92
commit 5cbcf6035a
4 changed files with 34 additions and 3 deletions
+9
View File
@@ -407,12 +407,21 @@ public:
slice<1,N>(i,0) = row_in.transpose();
}
void setRow(size_t i, Type val)
{
slice<1,N>(i,0) = val;
}
void setCol(size_t j, const Matrix<Type, M, 1> &column)
{
slice<M,1>(0,j) = column;
}
void setCol(size_t j, Type val)
{
slice<M,1>(0,j) = val;
}
void setZero()
{
memset(_data, 0, sizeof(_data));
+2 -2
View File
@@ -119,9 +119,9 @@ public:
}
}
Vector<Type, P<Q?P:Q> diag()
Vector<Type, P<Q?P:Q> diag() const
{
Slice<Type, P, Q, M, N>& self = *this;
const Slice<Type, P, Q, M, N>& self = *this;
Vector<Type,P<Q?P:Q> res;
for (size_t j = 0; j < (P<Q?P:Q); j++) {
res(j) = self(j,j);
+1 -1
View File
@@ -22,7 +22,7 @@ class Vector;
template <typename Type, size_t P, size_t Q, size_t M, size_t N>
class Slice;
template<typename Type, size_t M>
template <typename Type, size_t M>
class SquareMatrix : public Matrix<Type, M, M>
{
public: