0

Why inferred type is Double and not Float?

final Array1D<Double> doubles = Array1D.factory(Primitive32Array.FACTORY).makeFilled(10, new Uniform());

Or put it differently, what is difference between Primitive32Array.FACTORY and Primitive64Array.FACTORY?

user482745
  • 1,165
  • 1
  • 11
  • 31
  • 1
    Having no knowledge whatsoever of ojalgo, I'd say the 32 only supports 32 bit float and 64 supports a double since there are double the bits. https://en.wikipedia.org/wiki/Double-precision_floating-point_format – Jacob H Apr 26 '18 at 14:54
  • That is what I expected too. But apparently compiler insist on Double not Float.. – user482745 Apr 26 '18 at 15:03

1 Answers1

2

That's for historical reasons. Originally float arrays/matrices was not supported in ojAlgo, and <Double> naturally always referred to an underlying double[].

Now ojAlgo has partial support for float[], but only as space saving "primitive" arrays. Everything internal to Primitive32Array (as an example) is float and float[], but its API is still <Double>.

In ojAlgo <Double> essentially means "primitive".

Full support for float (for the matrices and linear algebra) is contemplated. When/if that happens <Double> may be replaced by <Number> to indicate anything "primitive".

apete
  • 1,250
  • 1
  • 10
  • 16