Git Product home page Git Product logo

Comments (5)

cdrnet avatar cdrnet commented on May 24, 2024

Indeed, there is no support for matrix expressions. There was in old Math.NET Classic, but not in Symbolics yet.

from mathnet-symbolics.

MovGP0 avatar MovGP0 commented on May 24, 2024

I would skip matrices completely and go for tensors (#14) instead.

This would make sense since scalars, vectors, and matrices are just a special kind of tensors.

from mathnet-symbolics.

MovGP0 avatar MovGP0 commented on May 24, 2024

the lack for matrices and tensors is annoying. it is currently not possible to solve system of equations symbolically:

let burger = symbol "burger"
let pommes = symbol "pommes"
let coke = symbol "coke"
let bill = symbol "bill"

let equations = [
        (2*coke) == 30.0
        (1*coke + 2*burger) == 20.0 // equals does not exist
        (1*burger + 4*pommes) == 9.0
        (burger + pommes * coke) == bill
    ]

linSolve equations bill // not working

the only way i could figure out was the numerical solution:

let M = matrix [[3.0; 0.0; 0.0]
                [1.0; 2.0; 0.0]
                [0.0; 1.0; 4.0]]

let R = vector [30.0; 20.0; 9.0]

let result = M.Solve(R)

let coke = result.[0]
let burger = result.[1]
let pommes = result.[2]

burger + pommes * coke // 15

maybe we could port Redberry (Sourcecode), since it has great support for tensors.

from mathnet-symbolics.

ingted avatar ingted commented on May 24, 2024

Quick way / ugly way to achieve vector/matrix support

from mathnet-symbolics.

ingted avatar ingted commented on May 24, 2024

Matrix multiplication supported with an ugly way

    let v = FloatingPoint.RealVector <| vector[1.0;2.0;3.0]

    let M = FloatingPoint.RealMatrix <|
            matrix [[3.0; 0.0; 0.0]
                        [1.0; 2.0; 0.0]
                        [0.0; 1.0; 4.0]]

    let symbols2 = dict[ "a", v; "m", M ]
    let a0 = SymbolicExpression(Infix.parseOrThrow("a * 2")).Evaluate(symbols2)
    printfn "%A" a0.RealVectorValue
    let a1 = SymbolicExpression(Infix.parseOrThrow("a + 1")).Evaluate(symbols2)
    printfn "%A" a1.RealVectorValue
    let a2 = SymbolicExpression(Infix.parseOrThrow("mat_by_row(a, a)")).Evaluate(symbols2)
    printfn "%A" a2.RealMatrixValue
    let a4 = SymbolicExpression(Infix.parseOrThrow("mat_multiply(m, mat_by_col(a, vec(1.0, 2.0, 3.0), a), a)")).Evaluate(symbols2)
    printfn "%A" a4

Result

seq [2.0; 4.0; 6.0]
seq [2.0; 3.0; 4.0]
DenseMatrix 2x3-Double
1  2  3
1  2  3

DenseMatrix 3x2-Double
1  1
2  2
3  3

RealVector (seq [9.0; 13.0; 61.0])

from mathnet-symbolics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.