Skip to content

Introduce a Configurable Scalar Type Instead of Hardcoded double #218

@julianlitz

Description

@julianlitz

Currently, the codebase uses double throughout for floating-point arithmetic. To support other precisions (e.g., float for reduced memory usage or GPU performance), we should introduce a type alias at a central location.

Proposed approach:
Add something like:

using Scalar = double; // or float

in a central header. For the name, Scalar is clean and conventional in numerical computing. Alternatives worth considering: Real (mathematically expressive, common in PDE codes), value_type (STL-style, but verbose), or fp_t (short but cryptic). Scalar or Real are the strongest candidates — preference should lean toward Scalar as it is unambiguous and widely understood in scientific computing contexts.

Follow-up benefits:

  • Removes all explicit template specializations in the Linear Algebra layer.
  • Eliminates the need to cast Vector to ConstVector when passing into functions like l2_norm, since the type relationship becomes consistent across the board.

Open Question: How to make it compatible with Mumps float and double specific data types. How to habdle hard coded thresholds (eps=1e-12).

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions