1# Floating Point Precision 2 3Currently, libCEED supports two options for {code}`CeedScalar` : double and single. The default is to use 4double precision. Users wishing to set {code}`CeedScalar` to single precision should edit `include/ceed/ceed.h` and change 5 6```{literalinclude} ../../../include/ceed/ceed.h 7:end-at: "#include \"ceed-f64.h\"" 8:language: c 9:start-at: "#include \"ceed-f64.h\"" 10``` 11 12to include {code}`ceed-f32.h` instead, then recompile the library. 13Tests can be run using `make test FC=` because the Fortran tests do not support single precision at this time. 14 15## Language-specific notes 16 17 - **C**: {code}`CEED_SCALAR_TYPE` will be defined to match one of the values of the {code}`CeedScalarType` {code}`enum`, and can be used 18 for compile-time checking of {code}`CeedScalar`'s type; see, e.g., {code}`tests/t314-basis.c`. 19 20 - **Fortran**: There is no definition of {code}`CeedScalar` available in the Fortran header. The user is responsible for ensuring 21 that data used in Fortran code is of the correct type ({code}`real*8` or {code}`real*4`) for libCEED's current configuration. 22 23 - **Julia**: After compiling the single precision version of libCEED, instruct LibCEED.jl to use this library with the {code}`set_libceed_path!` 24 function and restart the Julia session. LibCEED.jl will configure itself to use the appropriate type for {code}`CeedScalar`. 25 26 - **Python**: Make sure to replace the {code}`ceed-f64.h` inclusion rather than commenting it out, to guarantee that the Python 27 bindings will pick the correct precision. 28 The {c:func}`scalar_type()` function has been added to the {code}`Ceed` class for convenience. It returns a string 29 corresponding to a numpy datatype matching that of {code}`CeedScalar`. 30 31 - **Rust**: The {code}`Scalar` type corresponds to {code}`CeedScalar`. 32 33**This is work in progress!** The ability to use single precision is an initial step in ongoing development of mixed-precision support in libCEED. 34A current GitHub [issue](https://github.com/CEED/libCEED/issues/778) contains discussions related to this development. 35