Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: the scale of the exponential value is zero #16

Open
lucabart97 opened this issue Sep 22, 2023 · 1 comment
Open

bug: the scale of the exponential value is zero #16

lucabart97 opened this issue Sep 22, 2023 · 1 comment

Comments

@lucabart97
Copy link

Description

In the code, the scale is set to scalar_type(1/2) when the exponential value is used. This is to ensure that there is a compile-time conversion between the scalar type of the class and the scalar type of the exponential value. However, this can cause an issue because the value is computed at compile time with integer division, which result zero.

Position

You can find this issue in the code by searching for scalar_type(1/2). The issue is ever present in the exponential computation.

Small test

#include <iostream>
template <class scale_type> class Test {
public:
  Test() { std::cout << scale_type(1 / 2) << ' '; }
};

int main() {
  Test<int> t0;
  Test<float> t1;
  Test<double> t2;
  return 0;
}

Result:

0 0 0
@xiaodong2077
Copy link

xiaodong2077 commented Mar 27, 2024

The usage of scalar(1/2) in S2.hpp is also wrong.

exp_delta.w() = MTK::exp<scalar, 3>(exp_delta.vec(), Bu, scalar(1/2));

1 / 2 = 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants