Skip to content
Snippets Groups Projects
Commit 9ec7d452 authored by Oliver Sander's avatar Oliver Sander Committed by sander@FU-BERLIN.DE
Browse files

add method frobenius_norm

[[Imported from SVN: r7860]]
parent f6bae5d2
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,17 @@ class Tensor3 ...@@ -35,6 +35,17 @@ class Tensor3
return norm; return norm;
} }
T frobenius_norm() 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 std::sqrt(norm);
}
Tensor3<T,N1,N2,N3>& axpy(const T& alpha, const Tensor3<T,N1,N2,N3>& other) Tensor3<T,N1,N2,N3>& axpy(const T& alpha, const Tensor3<T,N1,N2,N3>& other)
{ {
for (int i=0; i<N1; i++) 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