From: Matthias Maier Date: Tue, 15 Sep 2015 03:26:24 +0000 (-0500) Subject: tensor.h: Bugfix: make determinant compatible with arbitrary number types X-Git-Tag: v8.4.0-rc2~413^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9a18eafa051708a5eca53ebf4c9e27706959392;p=dealii.git tensor.h: Bugfix: make determinant compatible with arbitrary number types --- diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index ee4159d7af..54d12dc537 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -2129,7 +2129,7 @@ Number determinant (const Tensor<2,dim,Number> &t) { // Compute the determinant using the Laplace expansion of the // determinant. We expand along the last row. - Number det = 0; + Number det = Number(); for (unsigned int k=0; k &t) for (unsigned int j=0; j(k+1)) * - determinant (minor); + const Number cofactor = ((k % 2 == 0) ? -1. : 1.) * determinant(minor); det += t[dim-1][k] * cofactor; } - return std::pow (-1., static_cast(dim)) * det; + return ((dim % 2 == 0) ? 1. : -1.) * det; } #ifndef DOXYGEN