Skip to content

Compilation error when Scalar is Eigen::half and not float #346

Open
@hamlatzis

Description

@hamlatzis

Since class Matrix is templatized

template <typename Scalar>
class Matrix final {
......
 private:
...........
  // The zero_point, i.e. which Scalar value is to be interpreted as zero.
  // When Scalar is floating-point, this must be 0.
  Scalar zero_point_ = 0;
};

I could have something like: Matrix<Eigen::half> myMatrix;

but then at compilation I get error: no viable conversion from 'int' to 'Eigen::half' Scalar zero_point_ = 0; since the zero isn't templatized

integer 0 and float zero are interchangeable so the above code works; but it's not the generic case for templates. I believe an implementation like Scalar zero_point_ = Scalar{0}; is more generic

Similar fixes to other classes and parts of the code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions