180a9ef05SNatalie Beams# Floating Point Precision 280a9ef05SNatalie Beams 317be3a41SJeremy L ThompsonCurrently, libCEED supports two options for {code}`CeedScalar` : double and single. 417be3a41SJeremy L ThompsonThe default is to use double precision. 5*8f0d9e13SJed BrownUsers wishing to set {code}`CeedScalar` to single precision should edit `include/ceed/types.h` and change 680a9ef05SNatalie Beams 7*8f0d9e13SJed Brown```{literalinclude} ../../../include/ceed/types.h 880a9ef05SNatalie Beams:end-at: "#include \"ceed-f64.h\"" 980a9ef05SNatalie Beams:language: c 1080a9ef05SNatalie Beams:start-at: "#include \"ceed-f64.h\"" 1180a9ef05SNatalie Beams``` 1280a9ef05SNatalie Beams 1380a9ef05SNatalie Beamsto include {code}`ceed-f32.h` instead, then recompile the library. 1480a9ef05SNatalie BeamsTests can be run using `make test FC=` because the Fortran tests do not support single precision at this time. 1580a9ef05SNatalie Beams 1680a9ef05SNatalie Beams## Language-specific notes 1780a9ef05SNatalie Beams 1817be3a41SJeremy L Thompson - **C**: {code}`CEED_SCALAR_TYPE` will be defined to match one of the values of the {code}`CeedScalarType` {code}`enum`, and can be used for compile-time checking of {code}`CeedScalar`'s type; see, e.g., {code}`tests/t314-basis.c`. 1980a9ef05SNatalie Beams 2017be3a41SJeremy L Thompson - **Fortran**: There is no definition of {code}`CeedScalar` available in the Fortran header. The user is responsible for ensuring that data used in Fortran code is of the correct type ({code}`real*8` or {code}`real*4`) for libCEED's current configuration. 2180a9ef05SNatalie Beams 2217be3a41SJeremy L Thompson - **Julia**: After compiling the single precision version of libCEED, instruct LibCEED.jl to use this library with the {code}`set_libceed_path!` function and restart the Julia session. LibCEED.jl will configure itself to use the appropriate type for {code}`CeedScalar`. 2380a9ef05SNatalie Beams 2417be3a41SJeremy L Thompson - **Python**: Make sure to replace the {code}`ceed-f64.h` inclusion rather than commenting it out, to guarantee that the Python bindings will pick the correct precision. 2517be3a41SJeremy L Thompson The {c:func}`scalar_type()` function has been added to the {code}`Ceed` class for convenience. 2617be3a41SJeremy L Thompson It returns a string corresponding to a numpy datatype matching that of {code}`CeedScalar`. 2780a9ef05SNatalie Beams 2880a9ef05SNatalie Beams - **Rust**: The {code}`Scalar` type corresponds to {code}`CeedScalar`. 2980a9ef05SNatalie Beams 3080a9ef05SNatalie Beams**This is work in progress!** The ability to use single precision is an initial step in ongoing development of mixed-precision support in libCEED. 3180a9ef05SNatalie BeamsA current GitHub [issue](https://github.com/CEED/libCEED/issues/778) contains discussions related to this development. 32