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

No floored division and modulo operations in IntRing, ShortRing, ByteRing and LongRing #103

Open
CommanderTvis opened this issue Jun 11, 2020 · 5 comments
Labels
discussion feature A new feature request

Comments

@CommanderTvis
Copy link
Collaborator

There are no div and mod operations in integer typed rings. They have some use cases in basic arithmetics, so I think, integer algebra is inconsistent without them.

@CommanderTvis CommanderTvis changed the title No div and mod operations in IntRing, ShortRing, ByteRing and LongRing No floored division and modulo operations in IntRing, ShortRing, ByteRing and LongRing Jun 11, 2020
@Shimuuar
Copy link

I'm not sure how faithful kmath about algebra abstractions. But rings don't have division. You'll get field if you want to add division.

Also while it's possible to define Field for word32/word64. Its division is completely different from usual rounded down division.

@altavir
Copy link
Member

altavir commented Jun 11, 2020

Those operations are not a part of Ring definition. We can add them if it is possible to implement them relying only on basic arithmetic operations. Otherwise, they could be added to short and int rings directly (but it does not make a lot of sense since ints and shorts already have them).

@CommanderTvis
Copy link
Collaborator Author

Those operations are not a part of Ring definition. We can add them if it is possible to implement them relying only on basic arithmetic operations. Otherwise, they could be added to short and int rings directly (but it does not make a lot of sense since ints and shorts already have them).

It does. For example, for adv-expr Expressions API: binaryOperation("mod", a, b). Without algebra-supported operations, mod and div are simply unaccessible.

@altavir
Copy link
Member

altavir commented Jun 12, 2020

@Shimuuar Ring does not have division. It has only multiplication.

@CommanderTvis
Copy link
Collaborator Author

CommanderTvis commented Jun 13, 2020

@Shimuuar Ring does not have division. It has only multiplication.

I suggest introducing new interface, something like:

interface DivisionWithRemainder<T> : RingOperations<T> {
  fun mod(T, T): T
  fun div(T, T): T
}

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

Successfully merging a pull request may close this issue.

3 participants