Implement hyperbolic functions for various Algebras #118
No reviewers
Labels
No Label
bug
dependencies
discussion
documentation
duplicate
feature
good first issue
misc
performance
question
test
use case
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kscience/kmath#118
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "hyp-trig-functions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Need to add tests for hyperbolic functions and check that there is no performance degradation for inlined operations.
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)
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
Does not make sense to add virtual call here. There is not difference, I guess.
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 like how one-lines look more
Those should be added to exponential operations and tested
However, the previous implementation was just invalid
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 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; }
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
So, this implementation is 4 bytes more efficient than previous :)
I'll revert it
OK
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
It is a singleton, another 4 bytes do not matter. You have an integer allocation on each call though.
Maybe, you need to add a test for it.
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
No
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
getfield...
andiconst_0
produce the equal allocation to the operand stackTests are added
@ -212,1 +253,3 @@
override inline fun multiply(a: Long, b: Long): Long = (a * b)
override val zero: Long
get() = 0
OK, you are correct in case of primitives.
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.
Please resolve conflicts