Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.

Linear Algebra DSL #3

Open
thomasnield opened this issue Apr 22, 2018 · 12 comments
Open

Linear Algebra DSL #3

thomasnield opened this issue Apr 22, 2018 · 12 comments

Comments

@thomasnield
Copy link
Contributor

Extensions need to be built for everything else outside the solver, including data structures and linear algebra API's.

@thomasnield
Copy link
Contributor Author

thomasnield commented May 24, 2018

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)
}

@thomasnield
Copy link
Contributor Author

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)
}

@thomasnield
Copy link
Contributor Author

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

@apete
Copy link
Contributor

apete commented May 31, 2018

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?

https://github.com/optimatika/ojAlgo/wiki/Getting-Started

@thomasnield
Copy link
Contributor Author

thomasnield commented May 31, 2018

@apete yes many times. I can definitely add the other interfaces.

@thomasnield
Copy link
Contributor Author

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
https://github.com/optimatika/ojAlgo/wiki/Sparse-Matrices
https://github.com/optimatika/ojAlgo/wiki/Getting-Started

@thomasnield
Copy link
Contributor Author

I'd like to get this done by this weekend, as well as the ANN API, in time for KotlinConf 2018.

@apete
Copy link
Contributor

apete commented Sep 25, 2018

What do you need from me?

@thomasnield
Copy link
Contributor Author

thomasnield commented Sep 25, 2018

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.

@thomasnield
Copy link
Contributor Author

@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.

@apete
Copy link
Contributor

apete commented May 27, 2019

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.

@thomasnield
Copy link
Contributor Author

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 store or decomposition at the moment. I'll expand this with needed use cases to streamline in Kotlin.

But I'm ready to pull the trigger on a release 0.1.0 if that's okay.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants