Replies: 2 comments 1 reply
-
Yeah, matmuls should just get parametrized by a |
Beta Was this translation helpful? Give feedback.
1 reply
-
It's a choice we would have to make. While I do think that there's value in highlighting algebraic properties of data using those type classes, it is also quite easy to go too far and make the whole system too verbose and inaccessible for people without a proper algebra background. So I would treat that as a design/usability question, but |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now we have 3 monoid type classes:
Mul
over*
andone
Add
over+
andzero
Monoid
over<>
andmempty
(possibly this should be calledFreeMonoid
?)I don't have the background in functional programming to know if people do something cool with that.
Another example:
right now matmul
**
is defines explictly and only onl=>m=>Float
matrixes,and it uses
+
and*
as the operations.(well it actually uses
fsum
but that will at some point besum
i.e.reduce +
)One of the things you can do with matmul is:
If you have an adjancy
x
matrix, then you can dox^p
(for ^ being matrix power) to get a matrix showing how many walks of lengthp
there are between given vertexs, and you can sum them to get all the walks of length up top
.But in principle the matmul operation can be generalized to any semiring.
Not just the one over
+
and*
.If you apply it to
|
and&
(the boolean semiring), thenx^p
gives an answer to is there a walk bconnecting between vextexes of lengthp
.And if you do a sum to fixed point you get the connectivity matrix of the the graph.
idk if there is anothing that exposes this kind of abstraction, or of there is anything here to work with.
Beta Was this translation helpful? Give feedback.
All reactions