Skip to content

mod misnormer in Matlab #2767

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

Closed
jgillis opened this issue Apr 19, 2021 · 2 comments
Closed

mod misnormer in Matlab #2767

jgillis opened this issue Apr 19, 2021 · 2 comments
Milestone

Comments

@jgillis
Copy link
Member

jgillis commented Apr 19, 2021

The CasADi primitive mod corresponds to rem.

C fmod == Matlab rem
C remainder != Matlab mod

#2394

jgillis added a commit that referenced this issue Apr 20, 2021
jgillis added a commit that referenced this issue Nov 21, 2022
jgillis added a commit that referenced this issue Nov 29, 2022
@jgillis jgillis added this to the Version 3.6 milestone Mar 28, 2023
@jgillis
Copy link
Member Author

jgillis commented Mar 30, 2023

I'll be dumping some result tables here

op 3 -3
5 op(5,3) op(5,-3)
-5 op(-5,3) op(-5,-3)

matlab

matlab.mod
2|-1
1|-2
matlab.rem
2|2
-2|-2

Python

numpy.fmod
2.0|2.0|
-2.0|-2.0
numpy.mod / numpy.remainder /  %
2.0|-1.0|
1.0|-2.0
math.remainder
-1.0|-1.0|
1.0|1.0

C

c99 fmod
2|2|
-2|-2|
c99 remainder
-1|-1|
1|1|

@jgillis
Copy link
Member Author

jgillis commented Mar 30, 2023

Added documentation

@jgillis jgillis closed this as completed Mar 30, 2023
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

1 participant