Julia IntervalRootFinding doesn't allow function variables to be vector or matrix?

Viewed 68

I'm new to Julia and just trying to move my MATLAB code to IntervalRootFinding package to find all potential roots. Apologies if I'm using my habits of writing matrix operations in MATLAB and didn't understand the way Julia treats variable types.

I'm trying to find all roots of a function of 6 variables (one vector and one 2x2 matrix.) My first version of codes looked like this

function EXAMPLE1((a, b); param=param_default)
    (Some operations taking a as a 2x1 vector and b as a 2x2 matrix.)
    return SVector{6}(condition1, condition2,...,condition6)
end

I then realized it's not possible to tell the roots function the interval of the elements in the matrix, so I rewrote my function so that it took scalar variables as input. But since all my calculations are way more efficient doing in matrix so I constructed the vector and matrix in the first line of the function, which made my codes to

function EXAMPLE2((a1, a2, b11, b12, b21, b22); param=param_default)
    a = [a1 a2]';
    b = [b11 b12; b21 b22];
    (Same operations taking a as a 2x1 vector and b as a 2x2 matrix.)
    return SVector{6}(condition1, condition2,...,condition6)
end

# Define intervals and finding roots
A = 0..10
B = 0..1
rts = roots(EXAMPLE2, A × A × B × B × B × B )

When I tested the function using random inputs like

    EXAMPLE2(1.0,1.0,0.3,0.3,0.3,0.3)

it went through and gave me 6-element SVector{6, Float64} with indices SOneTo(6):. But when I run roots on my function, I got the following error

ERROR: LoadError: MethodError: no method matching Float64(::Interval{Float64})

and the line a = [a1 a2]'; was marked red.

It looks like a data type mismatch issue - it can't assign a Float64 Interval as an element of the array a? Is it because IntervalRootFinding or roots only works with functions that operate on scalars, and not support functions of multi-dimensional arrays?

Another way of asking is, since I'm just trying to find all roots of a function of matrix, are there better packages in Julia for this purpose? More flexible for matrices, like fsolve in MATLAB but gives all roots?

Rewriting my functions into scalar operation is almost impossible, I won't bother to try. Thanks very much for anyone discussing this.

0 Answers
Related