-
-
Notifications
You must be signed in to change notification settings - Fork 3
Linear Algebra DSL #3
Comments
Some pretty nice idioms are emerging :) fun main(args: Array<String>) {
val matrixA = primitivematrix(3,3) {
populate { row, col -> 1 }
}
val matrixB = primitivematrix(3,1) {
populate { row, col -> 10 }
}
println(matrixA * matrixB)
} |
Really nice! fun main(args: Array<String>) {
val colors = sequenceOf(
Color.RED,
Color.PINK,
Color.YELLOW,
Color.BLUE,
Color.GREEN
)
val matrix = colors.toPrimitiveMatrix(
{ it.red },
{ it.green },
{ it.blue }
)
println(matrix)
} |
I think I'm almost ready for another release @apete. What do you think? I'll document some beautiful examples later. https://github.com/optimatika/okAlgo/blob/master/src/main/kotlin/org/ojalgo/okalgo/algebra.kt |
Whenever I see people use BasicMatrix I worry they think that's the only option and/but it's not what they actually need or want. Did you read this? |
@apete yes many times. I can definitely add the other interfaces. |
Rethinking the Kotlin functions here. Taking inventory again, it looks like I need to balance having a simple Kotlin API that doesn't worry itself about lower-level implementations, while streamlining access to the implementations. https://github.com/optimatika/ojAlgo/wiki/Working-with-arrays |
I'd like to get this done by this weekend, as well as the ANN API, in time for KotlinConf 2018. |
What do you need from me? |
I need to take inventory and make sure I fully understand every matrix flavor, and figure out how which ones should be the defaults in certain parts of the API. I'd like to get the linear algrebra up and running not just for KotlinConf, but also so I can start using it in my ML research. So I may come to you with questions in the next few days. If you like and don't mind getting your hands dirty with some Kotlin, please feel free to take a look at my work so far and make changes where you see fit. You should be able to clone the project and build it with Gradle. https://github.com/optimatika/okAlgo/blob/master/src/main/kotlin/org/ojalgo/okalgo/algebra.kt I'll add some unit tests later that will demonstrate how usage works. |
@apete I wrote some passing unit tests that should also give an idea what the DSL looks like. Can you take a look and make sure I'm using the correct matrix types now? After this I'd like to do a release. I'll start documenting this better and getting this much-prolonged project off the ground. |
I'm not sure what you want to achieve, and I'm not fluent in Kotlin. org.ojalgo.matrix is for when you just need to use matrices in a relatively standard way. org.ojalgo.matrix.store / org.ojalgo.matrix.decomposition is for when plan to implement algorithms and need lower level control. I think maybe you should start out doing one of each, and pretty soon you're going to figure out which suits you. At this point I think you can forget about Quaternions. Just use Primitive, ComplexNumber and RationalNumber if you like. |
What I'm trying to achieve is making ojAlgo idiomatic for Kotlin via extension functions and builder functions. And like you said those types are my only goal right now: just implement Primitive, ComplexNumber, and RationalNumber which are already done. I'll wait on quaternion when somebody I know actually uses it. I don't see this library going into But I'm ready to pull the trigger on a release |
Extensions need to be built for everything else outside the solver, including data structures and linear algebra API's.
The text was updated successfully, but these errors were encountered: