malyzajko / daisy

Other
43 stars 10 forks source link

ds2l function calling #19

Open alpylmz opened 5 months ago

alpylmz commented 5 months ago

Hi, I want to implement an algorithm and try it out with ds2l flags. I'd like to implement helper functions, but I am having trouble in calling a helper function in another one. I have this function:

object Minv { // alphaskew def alphaSkew(m: Real, lever: Vector): Matrix = { require(lever.size(3) && lever >= -0.12 && lever <= 0.18 && m >= 0.0 && m <= 5.0) val x: Real = lever.at(0) val y: Real = lever.at(1) val z: Real = lever.at(2) val res: Matrix = Matrix( List( List(0.0, -m z, m y), List(m z, 0.0, -m x), List(-m y, m x, 0.0) )) res }}

This version compiles and I can get results without problems, but when I add alphaSkewSquare function, I get the error: daisy.DaisyFatalError: Unknown expression alphaSkew(m, lever)

def alphaSkewSquare(m: Real, lever: Vector): Matrix = { require(lever.size(3) && lever >= -0.12 && lever <= 0.18 && m >= 0.0 && m <= 4.0) val res: Matrix = alphaSkew(m, lever) * alphaSkew(m, lever) res }

Is this a problem in my code, or is this not supported in daisy?

malyzajko commented 5 months ago

Function calls are not generally supported by Daisy, unfortunately.

It may be possible to add a pre-processing step that would inline functions (this would be purely for convenience). For that, it would be great if I knew better what kind of programs you would like to analyze. (Feel free to reach out also at eva.darulova - at - it.uu.se)