Commit d4e95d6a authored by Praetorius, Simon's avatar Praetorius, Simon

Added some missing FieldVector and FieldMatrix operations

parent e034a097
Pipeline #1423 passed with stage
in 30 minutes and 58 seconds
......@@ -10,6 +10,9 @@ namespace Dune
{
// some arithmetic operations with FieldVector
template <class T, int N>
FieldVector<T,N> operator-(FieldVector<T,N> v);
template <class T, int N, class S,
std::enable_if_t<std::is_arithmetic<S>::value,int> = 0 >
FieldVector<T,N> operator*(FieldVector<T,N> v, S factor);
......@@ -201,6 +204,25 @@ namespace Dune
std::enable_if_t<std::is_arithmetic<S>::value,int> = 0 >
FieldMatrix<T,M,N> operator*(FieldMatrix<T, M, N> A, S scalar);
template <class T, int M, int N >
FieldMatrix<T,M,N> operator*(FieldMatrix<T,1,1> scalar, FieldMatrix<T, M, N> A);
template <class T, int M, int N >
FieldMatrix<T,M,N> operator*(FieldMatrix<T, M, N> A, FieldMatrix<T,1,1> scalar);
template <class T, int N, int M>
FieldMatrix<T,N,M> operator*(FieldVector<T,1> scalar, FieldMatrix<T,N,M> mat);
template <class T, int N>
FieldMatrix<T,N,1> operator*(FieldVector<T,1> scalar, FieldMatrix<T,N,1> mat);
template <class T, int N, int M>
FieldMatrix<T,N,M> operator*(FieldMatrix<T,N,M> mat, FieldVector<T,1> scalar);
template <class T, int N>
FieldMatrix<T,N,1> operator*(FieldMatrix<T,N,1> mat, FieldVector<T,1> scalar);
template <class T, int M, int N, class S,
std::enable_if_t<std::is_arithmetic<S>::value,int> = 0 >
FieldMatrix<T,M,N> operator/(FieldMatrix<T, M, N> A, S scalar);
......@@ -216,12 +238,6 @@ 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 N, int M>
FieldMatrix<T,N,M> operator*(FieldMatrix<T,N,M> mat, FieldVector<T,1> const& scalar);
template <class T, int N>
FieldMatrix<T,N,1> operator*(FieldMatrix<T,N,1> mat, FieldVector<T,1> const& scalar);
template <class T, int M, int N, int L>
......@@ -241,6 +257,16 @@ 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, int N>
T const& at(FieldMatrix<T,N,1> const& vec, std::size_t i);
template <class T, int M>
T const& at(FieldMatrix<T,1,M> const& vec, std::size_t i);
template <class T, int N>
T const& at(FieldVector<T,N> const& vec, std::size_t i);
} // end namespace Dune
namespace AMDiS
......
......@@ -13,6 +13,12 @@ namespace Dune {
// some arithmetic operations with FieldVector
template <class T, int N>
FieldVector<T,N> operator-(FieldVector<T,N> v)
{
return v *= -1;
}
template <class T, int N, class S,
std::enable_if_t<std::is_arithmetic<S>::value,int> >
FieldVector<T,N> operator*(FieldVector<T,N> v, S factor)
......@@ -384,6 +390,42 @@ FieldMatrix<T,M,N> operator*(FieldMatrix<T, M, N> A, S scalar)
return A *= scalar;
}
template <class T, int N, int M>
FieldMatrix<T,N,M> operator*(FieldMatrix<T,1,1> scalar, FieldMatrix<T,N,M> mat)
{
return mat *= scalar[0][0];
}
template <class T, int N, int M>
FieldMatrix<T,N,M> operator*(FieldMatrix<T,N,M> mat, FieldMatrix<T,1,1> scalar)
{
return mat *= scalar[0][0];
}
template <class T, int N, int M>
FieldMatrix<T,N,M> operator*(FieldVector<T,1> scalar, FieldMatrix<T,N,M> mat)
{
return mat *= scalar[0];
}
template <class T, int N>
FieldMatrix<T,N,1> operator*(FieldVector<T,1> scalar, FieldMatrix<T,N,1> mat)
{
return mat *= scalar[0];
}
template <class T, int N, int M>
FieldMatrix<T,N,M> operator*(FieldMatrix<T,N,M> mat, FieldVector<T,1> scalar)
{
return mat *= scalar[0];
}
template <class T, int N>
FieldMatrix<T,N,1> operator*(FieldMatrix<T,N,1> mat, FieldVector<T,1> scalar)
{
return mat *= scalar[0];
}
template <class T, int M, int N, class S,
std::enable_if_t<std::is_arithmetic<S>::value,int> >
FieldMatrix<T,M,N> operator/(FieldMatrix<T, M, N> A, S scalar)
......@@ -410,18 +452,6 @@ FieldVector<T,N> operator*(FieldMatrix<T,N,M> const& mat, FieldVector<T,M> const
return Dune::FMatrixHelp::mult(mat, vec);
}
template <class T, int N, int M>
FieldMatrix<T,N,M> operator*(FieldMatrix<T,N,M> mat, FieldVector<T,1> const& scalar)
{
return mat *= scalar[0];
}
template <class T, int N>
FieldMatrix<T,N,1> operator*(FieldMatrix<T,N,1> mat, FieldVector<T,1> const& scalar)
{
return mat *= scalar[0];
}
template <class T, int M, int N, int L>
......@@ -486,6 +516,25 @@ FieldMatrix<T,M,N>& multiplies_ABt(FieldMatrix<T, M, N> const& A, DiagonalMatri
return C;
}
template <class T, int N>
T const& at(FieldMatrix<T,N,1> const& vec, std::size_t i)
{
return vec[i][0];
}
template <class T, int M>
T const& at(FieldMatrix<T,1,M> const& vec, std::size_t i)
{
return vec[0][i];
}
template <class T, int N>
T const& at(FieldVector<T,N> const& vec, std::size_t i)
{
return vec[i];
}
} // end namespace AMDiS
#endif
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