How to handle/get access to "deep" Errors in MathNet: what is parameter 4? - mathnet-numerics

I execute
d = (DenseMatrix)k.Solve(F);
And get an InvalidParameterException:
Message = "An invalid parameter was passed to a native method, parameter number : 4"
What is parameter nr. 4? Where did I pass it into MathNet?
How can I find out what is going wrong and what I can do about it?
I suspect some LaPack-ish routine is called internally with wrong parameters.
Are these errors accessible in any way?
Hm... I found here: https://numerics.mathdotnet.com/api/MathNet.Numerics.Providers.LinearAlgebra/ILinearAlgebraProvider%601.htm#LUFactor
that LUFactor(...) might be the LaPack routine dgetrf.
And at the LaPack doc, I found that the fourth argument of dgetrf is LDA (assuming base 1), a matrix dimension size. But then, how does that number get wrong? I don't enter it anywhere and comes directly from the (c#, MathNet) DenseMatrix itself.

Related

XMLQUERY() WITHIN XMLATTRIBUTES()

I am doing some basic tasks using, sql/xml. I am currently working on an error message that I get when trying to compute a XMLQUERY() within a XMLATTRIBUTES() function. (See code below)
SELECT XMLELEMENT(NAME "Nodename",
XMLATTRIBUTES(XMLQUERY('$t//Element/text()' PASSING Info AS "t") AS "hello"))
FROM Kurs
The error message that I get, says that there is no qualified routine that can run the function. I cant copy-paste the error message because its in Swedish, but this should be enough.
Also this might help: SQLCODE=-440, SQLSTATE=42884, DRIVER=4.18.60
So my question is (I have been looking for the answer), why doesn't this work? I will always get a value from that XMLQUERY, and it should simply translate into a value and used by XMLATTRIBUTES()
Any documentation, or link, is welcomed as well!
Thank you in advance!
The scalar function XMLQUERY returns an XML value. The function XMLATTRIBUTES expects an expression that returns a value of any type, but XML and some other types.
Thus, the functions are not compatible the way you are using them. DB2 cannot find a routine with that function signature. It results in that error -440.
How about wrapping a CAST/XMLCAST around it...?

"cannot call value of non-function type" error when attempting to call the max(_:_:) function

I'm trying to call the max function: max(x: T, y: T). However I keep getting the following error when I type max(2,3):
error: cannot call value of non-function type Int
var a = max(2, 3)
I am a beginner, and I have never encountered a function signature that uses a type "T". SO threads relating to using the max function call it in the manner I am (like max(2,3) ) so I am not sure where I am going wrong.
I am looking for an explanation on the "T" and how to call functions that support generic types and how to make the max function return 3 when comparing integers 2 and 3.
The problem (as you've confirmed in the comments) is that you have defined a variable named max, causing a naming conflict with the function max(_:_:).
The solution therefore is to either specify the Swift module namespace (as George suggested) in order to disambiguate the fact that you're referring to the max(_:_:) function:
Swift.max(2, 3)
Or, preferably, you should consider renaming your variable. I strongly suspect that there's a more descriptive name you could give it (remember, the Swift API Design Guidelines favours clarity over brevity).
Are you calling max within extension Int?
Try Swift.max(2, 3).

Matlab error "Find requires variable sizing"

[~,col] = find(ocpRefPt(2,:)>x1 & ocpRefPt(2,:)<x2 & ocpRefPt(1,:)>y1 & ocpRefPt(1,:)<y2);
About is the line where the compilation fails. The above line is in a loop.
x1,x2,x3,x4 are scalars(natural numbers)
ocpRefPt is a 2x16 matrix
Error: FIND requires variable sizing
What does this mean. How to overcome this error?
So it seems that you are trying to compile with emlmex to make embedded code. The error is saying that the size of the output of find is not known, and apparently the compiler requires fixed size outputs. See this newsgroup post for one explanation.
This method of compilation seems to be obsolete -- use the MATLAB coder (codegen command) instead:
emlmex Generate a C-MEX file from MATLAB code.
emlmex [-options] fun1 [fun2 ...]
This function is obsolete. For general purpose acceleration
and code generation use CODEGEN.

Why is depfun(fun) returning 'too many output arguments' (MATLAB)

depfun's documentation gives the following:
[list,builtins,classes] = depfun(fun) returns the MATLAB classes that
fun requires.
Excellent, this is exactly what I want. However, when I call that on my function it tells me there are too many output arguments. So, I tried
list = depfun(Dynamo)
and to my surprise the same error occurred. How can this be? depfun(Dynamo) must return at least one argument, no?
What I'm trying to do is to create a dependency graph in the way as suggested by Andrew Janke in Automatically generating a diagram of function calls in MATLAB
The following works and gives me a nice report, but I don't want the graph to contain all the hidden functions which is why I'm opting for depfun.
profile on
Dynamo;
profile off
profview
Any insight is much appreciated
You need to pass the function argument as a string
>> [list,builtins,classes] = depfun( 'Dynamo' )

getting multiple outputs from matlab to c#

I have written some functions in matlab.Now I need to get their outputs to C# .net form.I could success fully connect them through .Net Assembly and able to get output of a function which returns only one output to c#.Now I want to do it with a function which returns multiple outputs.Is there any particular way of doing this?????
thanks...
there are different signrature of the method available in the DLL, just use the proper one,
put the first input argument of the method as the number of outputs, then it will return an array of MWArray as outputs : (i.e below, 2 indicates that I expect to have an array of outputs with size 2)
MWArray[] res = MatlabDll.callMethod(2, x, y);
C# uses the Tuple Class for solving this issue.