Skip to content

Use floating point types consistently #1018

@reneSchm

Description

@reneSchm

Motivation / Current Behaviour

We did not consistently use ScalarType for some time, but now we added a FP ("floating point") template parameter to several classes. Instead of fixing inconsistencies we now have three contenders for a floating point type, each of which being almost exclusively used as double - hence it is not a current problem, but could definitely become one in the future. Below is an example where each type is present, but probably only one (FP) should be used.

We probably want to use FP where available and ScalarType where it is not. The difficulty is, that there may be components that require double explicitly.

Enhancement description

Decide which type to use where. Then make usage of that type consistent.

Additional context

template <typename FP = ScalarType, class... Categories>
class Populations : public CustomIndexArray<UncertainValue<FP>, Categories...>
{
public:

...

    void set_total(ScalarType value)
    {
        double current_population = get_total();
        if (fabs(current_population) < 1e-12) {
            double ysize = double(this->array().size());
            for (size_t i = 0; i < this->get_num_compartments(); i++) {
                this->array()[(Eigen::Index)i] = value / ysize;
            }
        }
        else {
            for (size_t i = 0; i < this->get_num_compartments(); i++) {
                this->array()[(Eigen::Index)i] *= value / current_population;
            }
        }
    }

...

};

Checklist

  • Attached labels, especially loc:: or model:: labels.
  • Linked to project

Metadata

Metadata

Assignees

Labels

Epicclass::improvementCleanup that doesn't affect functionalityloc::backendThis issue concerns the C++ backend implementation.

Type

No type

Projects

Status

Epics

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions