Implement hyperbolic functions for various Algebras #118

Merged
CommanderTvis merged 14 commits from hyp-trig-functions into dev 2020-08-11 18:18:06 +03:00
CommanderTvis commented 2020-07-02 20:50:59 +03:00 (Migrated from github.com)
  1. Merge InverseTrigonometric and Trigonometric operations.
  2. Fix division of Complex.
  3. Introduce new interface - HyperbolicTrigonometricOperations.
  4. Add it to ExtendedField composite.
  5. Write KDoc comments for trigonometric functions.
1. Merge InverseTrigonometric and Trigonometric operations. 2. Fix division of Complex. 3. Introduce new interface - HyperbolicTrigonometricOperations. 4. Add it to ExtendedField composite. 5. Write KDoc comments for trigonometric functions.
altavir (Migrated from github.com) requested changes 2020-07-02 21:26:04 +03:00
altavir (Migrated from github.com) left a comment

Need to add tests for hyperbolic functions and check that there is no performance degradation for inlined operations.

Need to add tests for hyperbolic functions and check that there is no performance degradation for inlined operations.
altavir (Migrated from github.com) commented 2020-07-02 21:18:21 +03:00

You are creating additional intermediate Complex value here.

You are creating additional intermediate Complex value here.
@ -75,27 +103,24 @@ object RealField : ExtendedField<Double>, Norm<Double, Double> {
override inline fun asin(arg: Double): Double = kotlin.math.asin(arg)
override inline fun atan(arg: Double): Double = kotlin.math.atan(arg)
altavir (Migrated from github.com) commented 2020-07-02 21:20:44 +03:00

Does not make a lot of difference. I think the variant from before was more readable.

Does not make a lot of difference. I think the variant from before was more readable.
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
altavir (Migrated from github.com) commented 2020-07-02 21:21:51 +03:00

Does not make sense to add virtual call here. There is not difference, I guess.

Does not make sense to add virtual call here. There is not difference, I guess.
altavir (Migrated from github.com) commented 2020-07-02 21:23:51 +03:00

I do not think that removing this one is free. It could hinder inlining. The same goes for all similar cases. It should not be done without benchmarks.

I do not think that removing this one is free. It could hinder inlining. The same goes for all similar cases. It should not be done without benchmarks.
altavir (Migrated from github.com) commented 2020-07-02 21:22:24 +03:00

I like how one-lines look more

I like how one-lines look more
altavir (Migrated from github.com) commented 2020-07-02 21:24:59 +03:00

Those should be added to exponential operations and tested

Those should be added to exponential operations and tested
CommanderTvis (Migrated from github.com) reviewed 2020-07-03 09:59:15 +03:00
CommanderTvis (Migrated from github.com) commented 2020-07-03 09:59:15 +03:00

However, the previous implementation was just invalid

However, the previous implementation was just invalid
CommanderTvis (Migrated from github.com) reviewed 2020-07-03 10:02:19 +03:00
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
CommanderTvis (Migrated from github.com) commented 2020-07-03 10:02:19 +03:00

The previous property in Java was like:
private int zero = 0; public int getZero() { return zero; }
This one doesn't store zero and doesn't spend any resources to instantiate the value each time because 0 is primitive constant: public int getZero() { return 0; }

The previous property in Java was like: ```private int zero = 0; public int getZero() { return zero; }``` This one doesn't store zero and doesn't spend any resources to instantiate the value each time because `0` is primitive constant: `public int getZero() { return 0; }`
CommanderTvis (Migrated from github.com) reviewed 2020-07-03 10:03:00 +03:00
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
CommanderTvis (Migrated from github.com) commented 2020-07-03 10:02:47 +03:00

So, this implementation is 4 bytes more efficient than previous :)

So, this implementation is 4 bytes more efficient than previous :)
CommanderTvis (Migrated from github.com) reviewed 2020-07-03 10:03:45 +03:00
CommanderTvis (Migrated from github.com) commented 2020-07-03 10:03:45 +03:00

I'll revert it

I'll revert it
CommanderTvis (Migrated from github.com) reviewed 2020-07-03 10:04:33 +03:00
altavir (Migrated from github.com) reviewed 2020-07-03 10:05:36 +03:00
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
altavir (Migrated from github.com) commented 2020-07-03 10:05:36 +03:00

It is a singleton, another 4 bytes do not matter. You have an integer allocation on each call though.

It is a singleton, another 4 bytes do not matter. You have an integer allocation on each call though.
altavir (Migrated from github.com) reviewed 2020-07-03 10:06:09 +03:00
altavir (Migrated from github.com) commented 2020-07-03 10:06:08 +03:00

Maybe, you need to add a test for it.

Maybe, you need to add a test for it.
CommanderTvis (Migrated from github.com) reviewed 2020-07-03 13:15:06 +03:00
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
CommanderTvis (Migrated from github.com) commented 2020-07-03 13:15:05 +03:00

No

No
CommanderTvis (Migrated from github.com) reviewed 2020-07-03 13:15:28 +03:00
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
CommanderTvis (Migrated from github.com) commented 2020-07-03 13:15:28 +03:00

getfield... and iconst_0 produce the equal allocation to the operand stack

`getfield...` and `iconst_0` produce the equal allocation to the operand stack
CommanderTvis (Migrated from github.com) reviewed 2020-07-03 13:15:46 +03:00
CommanderTvis (Migrated from github.com) commented 2020-07-03 13:15:46 +03:00

Tests are added

Tests are added
altavir (Migrated from github.com) reviewed 2020-07-03 13:16:24 +03:00
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
altavir (Migrated from github.com) commented 2020-07-03 13:16:24 +03:00

OK, you are correct in case of primitives.

OK, you are correct in case of primitives.
altavir (Migrated from github.com) reviewed 2020-07-27 10:53:00 +03:00
altavir (Migrated from github.com) left a comment

I think that hyperbolic operation should not for their own class, but instead, be a part of exponential operations and have default implementations based on exponents. Otherwise looks good.

I think that hyperbolic operation should not for their own class, but instead, be a part of exponential operations and have default implementations based on exponents. Otherwise looks good.
altavir (Migrated from github.com) approved these changes 2020-08-11 15:30:04 +03:00
altavir commented 2020-08-11 15:30:28 +03:00 (Migrated from github.com)

Please resolve conflicts

Please resolve conflicts
Sign in to join this conversation.
No description provided.