Commit 5f82708b authored by Praetorius, Simon's avatar Praetorius, Simon

cleanup of operator* overloads for FieldVector and FieldMatrix

parent 94272400
Pipeline #1440 passed with stage
in 19 minutes and 34 seconds
......@@ -40,9 +40,6 @@ namespace Dune
std::enable_if_t<std::is_convertible<S,T>::value, int> = 0>
FieldVector<T,N> operator/(FieldVector<T,N> v, S factor);
template <class T>
FieldVector<T,1> operator*(FieldVector<T,1> v, FieldVector<T,1> w);
// ----------------------------------------------------------------------------
/// Cross-product a 2d-vector = orthogonal vector
......@@ -57,10 +54,6 @@ namespace Dune
template <class T, class S, int N>
auto dot(FieldVector<T,N> const& vec1, FieldVector<S,N> const& vec2);
// template <class T, int N, int M,
// std::enable_if_t<( N!=1 && M!=1 ),int> = 0>
// auto operator*(FieldVector<T,N> const& v, FieldVector<T,M> const& w);
template <class T, class S, int N>
auto dot(FieldMatrix<T,1,N> const& vec1, FieldMatrix<S,1,N> const& vec2);
......@@ -213,10 +206,6 @@ namespace Dune
std::enable_if_t<std::is_convertible<S,T>::value, int> = 0>
FieldMatrix<T,M,N> operator*(FieldMatrix<T, M, N> A, S scalar);
template <class T>
FieldMatrix<T,1,1> operator*(FieldMatrix<T,1,1> lhs, FieldMatrix<T,1,1> rhs);
template <class T, int M, int N, class S,
std::enable_if_t<std::is_convertible<S,T>::value, int> = 0>
FieldMatrix<T,M,N> operator/(FieldMatrix<T, M, N> A, S scalar);
......@@ -232,13 +221,11 @@ namespace Dune
template <class T, int N, int M>
FieldVector<T,N> operator*(FieldMatrix<T,N,M> const& mat, FieldVector<T,M> const& vec);
// -----------------------------------------------------------------------------
template <class T, int M, int N, int L>
FieldMatrix<T,M,N> multiplies(FieldMatrix<T, M, L> const& A, FieldMatrix<T, L, N> const& B);
template <class T, int M, int N, int L>
FieldMatrix<T,M,N> multiplies_AtB(FieldMatrix<T, L, M> const& A, FieldMatrix<T, N, L> const& B);
......@@ -251,16 +238,21 @@ namespace Dune
template <class T, int M, int N>
FieldMatrix<T,M,N>& multiplies_ABt(FieldMatrix<T, M, N> const& A, DiagonalMatrix<T, N> const& B, FieldMatrix<T,M,N>& C);
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
template <class T>
T operator*(FieldVector<T, 1> lhs, FieldVector<T, 1> rhs);
template <class T>
T operator*(FieldMatrix<T, 1, 1> lhs, FieldMatrix<T, 1, 1> rhs);
template <class T>
T operator*(FieldVector<T,1> lhs, FieldMatrix<T,1,1> rhs);
T operator*(FieldVector<T, 1> lhs, FieldMatrix<T, 1, 1> rhs);
template <class T>
T operator*(FieldMatrix<T,1,1> lhs, FieldVector<T,1> rhs);
T operator*(FieldMatrix<T, 1, 1> lhs, FieldVector<T, 1> rhs);
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
template <class T, int N>
T const& at(FieldMatrix<T,N,1> const& vec, std::size_t i);
......@@ -268,6 +260,7 @@ namespace Dune
template <class T, int M>
T const& at(FieldMatrix<T,1,M> const& vec, std::size_t i);
// necessary specialization to resolve ambiguous calls
template <class T>
T const& at(FieldMatrix<T,1,1> const& vec, std::size_t i);
......
......@@ -40,12 +40,6 @@ FieldVector<T,N> operator/(FieldVector<T,N> v, S factor)
return v /= factor;
}
template <class T>
FieldVector<T,1> operator*(FieldVector<T,1> v, FieldVector<T,1> w)
{
return v *= w[0];
}
// ----------------------------------------------------------------------------
/// Cross-product a 2d-vector = orthogonal vector
......@@ -71,14 +65,6 @@ auto dot(FieldVector<T,N> const& vec1, FieldVector<S,N> const& vec2)
return vec1.dot(vec2);
}
// template <class T, int N, int M,
// std::enable_if_t<( N!=1 && M!=1 ),int> >
// auto operator*(FieldVector<T,N> const& v, FieldVector<T,M> const& w)
// {
// static_assert(M == N, "Requires vectors of the same type!");
// return v.dot(w);
// }
template <class T, class S, int N>
auto dot(FieldMatrix<T,1,N> const& vec1, FieldMatrix<S,1,N> const& vec2)
{
......@@ -378,12 +364,6 @@ FieldMatrix<T,M,N> operator*(FieldMatrix<T, M, N> A, S scalar)
return A *= scalar;
}
template <class T>
FieldMatrix<T,1,1> operator*(FieldMatrix<T,1,1> lhs, FieldMatrix<T,1,1> rhs)
{
return lhs *= rhs[0][0];
}
template <class T, int M, int N, class S,
std::enable_if_t<std::is_convertible<S,T>::value, int>>
FieldMatrix<T,M,N> operator/(FieldMatrix<T, M, N> A, S scalar)
......@@ -410,16 +390,12 @@ FieldVector<T,N> operator*(FieldMatrix<T,N,M> const& mat, FieldVector<T,M> const
return Dune::FMatrixHelp::mult(mat, vec);
}
template <class T, int M, int N, int L>
FieldMatrix<T,M,N> multiplies(FieldMatrix<T, M, L> const& A, FieldMatrix<T, L, N> const& B)
{
return A.rightmultiplyany(B);
}
template <class T, int M, int N, int L>
FieldMatrix<T,M,N> multiplies_AtB(FieldMatrix<T, L, M> const& A, FieldMatrix<T, N, L> const& B)
{
......@@ -439,15 +415,7 @@ template <class T, int M, int N, int L>
FieldMatrix<T,M,N> multiplies_ABt(FieldMatrix<T, M, L> const& A, FieldMatrix<T, N, L> const& B)
{
FieldMatrix<T,M,N> C;
for (int m = 0; m < M; ++m) {
for (int n = 0; n < N; ++n) {
C[m][n] = 0;
for (int l = 0; l < L; ++l)
C[m][n] += A[m][l] * B[n][l];
}
}
return C;
return multiplies_ABt(A,B,C);
}
template <class T, int M, int N, int L>
......@@ -475,16 +443,28 @@ FieldMatrix<T,M,N>& multiplies_ABt(FieldMatrix<T, M, N> const& A, DiagonalMatri
}
template <class T>
T operator*(FieldVector<T,1> lhs, FieldVector<T,1> rhs)
{
return lhs[0] * rhs[0];
}
template <class T>
T operator*(FieldMatrix<T,1,1> lhs, FieldMatrix<T,1,1> rhs)
{
return lhs[0][0] * rhs[0][0];
}
template <class T>
T operator*(FieldVector<T,1> lhs, FieldMatrix<T,1,1> rhs)
{
return lhs[0]*rhs[0][0];
return lhs[0] * rhs[0][0];
}
template <class T>
T operator*(FieldMatrix<T,1,1> lhs, FieldVector<T,1> rhs)
{
return lhs[0][0]*rhs[0];
return lhs[0][0] * rhs[0];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment