Skip to content

Implementation of linear algebra for ArrayPartition  #105

@vnvasquez

Description

@vnvasquez

The following MWE pertains to the implementation of vec: basically, if the elements inside the ArrayPartition are vectors, all works as it should. However, if the ArrayPartition contents are matrices then the size of the return from vec is incorrect.

using NLsolve
using RecursiveArrayTools

function mymodel(F, vars)
    for i in 1:2
        x = vars.x[i]    
        F.x[i][1,1] = (x[1,1]+3)*(x[1,2]^3-7)+18.0
        F.x[i][1,2] = sin(x[1,2]*exp(x[1,1])-1)
        F.x[i][2,1] = (x[2,1]+3)*(x[2,2]^3-7)+19.0
        F.x[i][2,2] = sin(x[2,2]*exp(x[2,1])-3)
    end
end

# To show that the function works
F = ArrayPartition([0.0 0.0; 0.0 0.0],[0.0 0.0; 0.0 0.0])
u0= ArrayPartition([0.1 1.2; 0.1 1.2], [0.1 1.2; 0.1 1.2])
result = mymodel(F, u0) 
vec(u0)

# To show the NLsolve error that results with ArrayPartition: 
nlsolve(mymodel, u0)

This may be related to the way that linear algebra was implemented for the fix to this issue: #44 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions