## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Jan 31 2019 21:02
LukaJCB commented #758
• Jan 31 2019 20:29

tixxit on master

Fix Polynomial Gen Merge pull request #758 from Lu… (compare)

• Jan 31 2019 20:29
tixxit closed #758
• Jan 31 2019 18:55
LukaJCB commented #758
• Jan 31 2019 12:07
lmazzon starred non/spire
• Jan 31 2019 03:06
SethTisue commented #742
• Jan 30 2019 23:41
niebloomj starred non/spire
• Jan 30 2019 21:11
GusevTimofey starred non/spire
• Jan 30 2019 15:12
qsctr starred non/spire
• Jan 30 2019 14:00
tusharbihani starred non/spire
• Jan 28 2019 15:07
roman0x58 starred non/spire
• Jan 25 2019 14:56
invkrh starred non/spire
• Jan 23 2019 18:00
mtomko forked
• Jan 23 2019 12:20
cwheikki starred non/spire
• Jan 23 2019 02:18
• Jan 22 2019 15:44
paulhirschi starred non/spire
• Jan 22 2019 09:46
shreyanshp starred non/spire
• Jan 20 2019 12:39
midnio starred non/spire
• Jan 20 2019 12:37
midnio starred non/spire
• Jan 20 2019 12:34
midnio starred non/spire
Srepfler Srdan
@schrepfler
I’m looking for that as well @LukaJCB , if you find something let me know :)
Srepfler Srdan
@schrepfler
how is your rational defined, as a pair of BigInteger?
Luka Jacobowitz
@LukaJCB
@schrepfler I guess the easiest way is to provide your own implicit conversion:
import cats.Monoid
import cats.implicits._
import spire.math._
import spire.implicits._

val x = List(Rational(4) / 5, Rational(2) / 3).combineAll
println(x)
My Rational is just spire.math.Rational
I actually think AdditiveMonoid should just be Monoid 😝
Srepfler Srdan
@schrepfler
meaning it should cover multiplication like operation? wouldn’t that cause issue with inverse/division by zero?
Luka Jacobowitz
@LukaJCB
What do you mean? I’m just saying that my preference would be to have a single blessed Monoid instance as default instead of having two and not getting to use either with foldMap and company
I don’t really understand why if you have two possible instances, instead of choosing one, you just don’t choose either and get nothing :smile:
Luka Jacobowitz
@LukaJCB
I think ideally I’d like to see
trait Semiring[A] extends CommutativeMonoid[A] {
def combine[A](x: A, y: A): A

def plus[A](x: A, y: A): A = combine(x, y)
def zero[A] = empty[A]
}
And then if you want to use the multiplicative monoid instance just use something like this:
case class Multiplicative[A](a: A) extends AnyVal // or opaque type
implicit def multiplicativeMonoidSemiring[A: Semiring]: Monoid[Multiplicative[A]] = …
Denis Rosset
@denisrosset
Please no! SemiRing can be noncommutative
and actually, if something should be a default monoid, it should be the multiplicative one due to the representation of groups as matrices (that's the standard use in algebra, see "Group ring")
Denis Rosset
@denisrosset
(note: I am not saying Spire is universally right, or that your idea is universally wrong. In the context of numerics/mathematics, I think the choices made in algebra/Spire are sane and consistent, and should only be changed with care and domain knowledge)
Indeed, it is painful to not be able to use the wonderful cats derivations to combine Map (for example, when a Map represents a polynomial)
But then, an additive monoid -> monoid conversion is the way to go
Luka Jacobowitz
@LukaJCB
Yeah, I’m not doubting what you came up with :smile: It’s just a bit unfortunate I can’t reuse a bunch of my Monoid code :P
A Semiring can be non commutative?
I thought it was always commutative in its addition :o
trait Semiring[A] extends CommutativeMonoid[A] {
def times[A](x: A, y: A): A

def plus[A](x: A, y: A): A = combine(x, y)
def zero[A] = empty[A]
}

trait Rig[A] extends Semiring[A] {
def one[A]: A
}
Luka Jacobowitz
@LukaJCB
Would it be very wrong to add a cats.kernel.Monoid[Rational] that’s consistent with the Monoids for Int, Long,BigInt, etc.?
Denis Rosset
@denisrosset
Spire does not extend the cats instances yet, and we haven't taken a position on whether our instances/laws/... should be inherited through the chain cats-kernel/algebra/spire
You're very welcome to add an optional Monoid[Rational] in spire.optional; however, I'm not clear about the default instances in spire, and reluctant to pile more stuff on top of it
Spire is currently in "clean up" mode as it accumulated a lot of things, and we lack the bandwidth to do that clean up
(we are currently at ~ 50% code coverage, which is a shame)
Luka Jacobowitz
@LukaJCB
Yeah it’s a pretty big project, but it has a lot of awesome stuff
Denis Rosset
@denisrosset
Thanks! Actually, can you open a spire issue with the problem of the default Monoids? We will likely not make a lot of progress in the next weeks, but it's something we have to address during the cleanup
Luka Jacobowitz
@LukaJCB
I can try to help out where I can as well :)
Denis Rosset
@denisrosset
Thanks a lot!
Luka Jacobowitz
@LukaJCB
I really love Algebra and Spire and they deserve more attention than they get :D
Denis Rosset
@denisrosset
@peterewills How is it going? Need help digging through Spire's code?
Me too! Love that we actually have a better type tower than Haskell in some places (TruncatedDivision notably!)
:p
Luka Jacobowitz
@LukaJCB
Indeed!
Should I open the issue in Typelevel/algebra? Technically Semiring is defined there
Denis Rosset
@denisrosset
Would say both.
Another underlying theme is whether we should share default instances as well.
Luka Jacobowitz
@LukaJCB
What do you mean by “share”? :)
Luka Jacobowitz
@LukaJCB
Srepfler Srdan
@schrepfler
is a Rational(1, 0) valid?
Luka Jacobowitz
@LukaJCB
If we end up merging algebra into cats it would be great to have you on the team @denisrosset :)
Denis Rosset
@denisrosset
@schrepfler No it's not. Should throw an Exception during construction.
Colt Frederickson
@coltfred
Where are the notes for 0.15 and 0.16? Latest I see here is 0.14.1 https://github.com/non/spire/blob/master/CHANGES.md
Also, I assume they're not compatible? My tests freak out with cNoSuchMethodError...
Denis Rosset
@denisrosset
@coltfred, we are breaking compatibility all the time, and indeed, the latest releases do not have accompanying notes.
The biggest pain with Spire now is that some parts are production ready (and simply need more test coverage), while others are shaky.
@LukaJCB That would be cool!
Cory Parent
@goedelsoup
has anyone explored or knows of an exploration in applying spire to geodesics?
Denis Rosset
@denisrosset
@goedelsoup Haven't heard of it, but I would be curious of seeing which algebraic structure underlie geodesics