Skip to content

[doc] Document IsNumber.

Jö Fahlke requested to merge doc/document-IsNumber into master

The exact meaning of IsNumber is important for SIMD-abstractions.

Such an abstraction will provide a default implementation such that built-in types can be treated as SIMD vectors of one element. This default implementation should also be prepared to handle things like std::complex, extended precision types, or automatic differentiation types. Those types cannot be elements of 'real' SIMD vectors, but it greatly simplyfies the implementation of dense vectors and matrices if the SIMD library can treat them as SIMD vectors of one element.

The exact meaning of IsNumber determines two things:

  1. whether the SIMD library should specialize IsNumber<T> to true for any SIMD vector types,

  2. and whether the default implementation of the SIMD abstraction can use IsNumber<T> to determine whether it should apply to type T.

These two things are mutually exclusive, but it may also be the case that none of them holds.

For this commit, I looked at where in dune-common IsNumber is actually used. The only places were the implementation of the assignment for DenseMatrix and DynamicMatrix, to determine whether to treat the right hand side as a scalar or not. Since SIMD vector types should be treated as scalars when assigned to a dense matrix, it turns out that 1. is true. (Of course, the element type of the dense matrix must itself be a compatible SIMD vector type, the same way you cannot assign a std::complex<double> to a FieldMatrix<double, n>.)

I'll wait for comments until before merging 2017-02-09.

Merge request reports

Loading