Getter function for the diag elements of slice (#112)

This commit is contained in:
kritz
2019-12-05 11:39:21 +01:00
committed by Julian Kent
parent de6a2d31ff
commit ef442fab92
2 changed files with 27 additions and 0 deletions
+10
View File
@@ -119,6 +119,16 @@ public:
}
}
Vector<Type, P<Q?P:Q> diag()
{
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);
}
return res;
}
Type norm_squared()
{
Slice<Type, P, Q, M, N>& self = *this;