Skip to content

WeaklyTypedFloat (WTF)

This repo is still under heavy development! I am hoping for an alpha release this week.

The goal of WTF is to provide a small domain-specific language (DSL) that can be used to unify interfaces involving floating-point types. Using WTF the user writes their interfaces in terms of "weakly typed" objects like Float and FloatBuffer, and determination of the actual floating-point type is deferred to runtime.

Development Setup

Prerequisites

  • CMake >= 3.14
  • A C++20-capable compiler
  • Python >= 3.8

Editable install

Create and activate a virtual environment, then install the package in editable (dev) mode. This builds the Python bindings and the C++ test suite:

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Running the C++ tests

The editable install keeps its build tree in build/ (configured via build-dir in pyproject.toml). Run CTest directly from there:

cd build && ctest --output-on-failure

Running the Python tests

With the virtual environment active:

pytest tests/python/

Problem Description

Full description (TODO: Add link to the documentation)

Depending on the standard, C++ already natively has a lot of floating-point types, e.g., float, double, long double, std::complex<float>, and std::complex<double>. This is before considering custom floating-point types, such as those needed for automatic differentiation, or hardware-specific types. When attempting to maintain interfaces with explicit types (such as is required for C-style interfaces) this leads to a combinatorial explosion in the number of interfaces.

About

Type-erasure for floating point types. Facilitates writing general floating-point code without needing to worry about the exact floating-point type being used.

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages