Skip to content
Snippets Groups Projects
Commit dd4431a2 authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Add a method to compute the squared Frobenius norm

[[Imported from SVN: r9396]]
parent d210a39e
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,18 @@ class Tensor3
return std::sqrt(norm);
}
/** \brief The squared Frobenius norm, i.e., the sum of squared entries */
T frobenius_norm2() const
{
T norm = 0;
for (int i=0; i<N1; i++)
for (int j=0; j<N2; j++)
for (int k=0; k<N3; k++)
norm += (*this)[i][j][k] * (*this)[i][j][k];
return norm;
}
Tensor3<T,N1,N2,N3>& axpy(const T& alpha, const Tensor3<T,N1,N2,N3>& other)
{
for (int i=0; i<N1; i++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment