`mlx` interface for Java packaging of Matlab functions? - matlab-deployment

I am looking at the Matlab information on packaging functions for invocation from Java, specifically in the context of a variable number of input arguments. A number of function signatures are for "mlx interface", but there is no explanation of what this means.
Web searching shows that *.mlx is file extension of Jupyter-like file for Matlab code. It is unclear whether this has anything to do with the use of this acronym in the interface documentation cited above. The manner in which it is presented seems to indicate that any reader should know what it is, and mlx signatures take up half of the examples shown, so it is obviously a prominent use case. In contrast, I've never heard of a Jupyter-like Matlab file before, and likewise, did not know of an *.mlx file extension until now (though there are many TMW corners I've not ventured near).
What does "mlx interface" mean in the context of function signatures in Java packaged Matlab?
Why does it figure so prominently into the Java interface?

It looks as if the answer is not available in Matlab's doc documentation,
nor the HTML counterparts on the web. Hints of the answer are buried deep
in real-book documenation like MATLAB Compiler SDK Java User's Guide:
A standard signature in Java...specifies input arguments for each
overloaded method as one or more input arguments of class
java.lang.Object or any subclass (including subclasses of
MWArray). The standard interface specifies return values, if any,
as a subclass of MWArray.
[The] mlx API...allows the user to specify the inputs to a
function as an Object array, where each array element is one input
argument. Similarly, the user also gives the mlx interface a
preallocated Object array to hold the outputs of the function. The
allocated length of the output array determines the number of
desired function outputs.
The mlx interface may also be accessed using java.util.List
containers in place of Object arrays for the inputs and outputs.
Note that if List containers are used, the output List passed in
must contain a number of elements equal to the desired number of
function outputs.
A web search for mlx-api shows that it is Matlab interface for
C/C++: Functions Generated from MATLAB Files.
While the acronym mlx may have been motivated by this, it seems that
the only thing inheritted by the Java signature is the acronym. The
signature itself is completely dissimilar to that in the posted page
Pass Variable Numbers of
Inputs.

Related

Function which one must not shadow in Matlab

I am writing some helper functions for unit testing in Matlab. For that I need to overload Matlab functions, built-ins etc. In the documentation is written, that one shall not overload the function builtin. I also found out that one must not overload the lt operator, since it seems to get called by the UI all the time.
Is there a list of functions which one shall not overload, or do you know of any particular problems from overloading some specific functions?
Further Information:
My use case: I want to do mutation-testing and faul-injection.
in ther words, sometimes the called functions shall return wrong results or throw an error. If I overload the Matlab functions, I do not have to change the source code to do that.

Why Matlab Coder is slow?

I'm trying to build a Mex function in Matlab-r2015a using Matlab Coder. The entry point function I want to convert is alg.m which is called by main.m.
Following the procedure, I'm at the step in which I'm asked to "define the type of each input for every entry point function". I choose the automatic procedure and enter main.m
My problem is: in order to define the type of each input, the Matlab Coder takes a very long time; the same problem appears at the next step, when I have to check whether there are issues in the Matlab code. Is that because Matlab has to execute the whole main.m+alg.m?
I suspect this should be the case because when I impose values of parameters that make the computation faster, the input types and issue checks are done immediately. Anyway, I would like to have some more explanations and, if any, suggestions to solve the problem.
You are correct, both steps Define Input Types and Check for Run-Time Issues run main.m which will in turn run alg.m.
If the input data types for the entry-point function don’t change, two test-benches (namely two versions of your main.m) can be written – a shorter one that invokes the entry-point once for defining input types, and a more comprehensive one that thoroughly exercises alg.m. The former can be used to quickly define input types, and the latter should be used when checking for run-time issues.

How to see the type of a matlab variable

I'm looking at a rather large and poorly written Matlab program. One of the things that makes understanding the code tricky is the variables don't show their type. In searching I only found explanations how to do this while debugging code(the whos and class commands). I'm looking for a way to view type information in the editor itself.
For example in the following code I would like to know the type of A and B:
classdef Data
properties
B;
function obj = Data(A)
obj.B = A.B;
end
Or is the type not determined until the function is called, and A could be any class with a B parameter?
As I mentioned in the comments, unfortunately there isn't any way I know of to do this in the IDE without entering the debugger because MATLAB is not statically typed. You can also trace through the function and see what is calling the methods/functions/etc. in question and the variables used.
Your ending sentence is correct. Looking at your example solely in the eyes of the IDE A could be any data type, even one where the dot notation isn't valid (and thus would throw an error). It's up to the user to add input validation for functions that are not built in.
Usually numeric variables are defined as doubles, you can ask if a variable belongs or not to a specific data type, here are some ways to do it.

Use Run-time Parameters in a Matlab-code S-Function

I have to write a Level-2 S-Function in Matlab code (C is not viable) which takes in some parameters and uses them alone and in combination.
First I tried tunable parameters, but unfortunately I haven't succeded in tuning them (the documentation doesn't tell how to set_param for this purpose).
Then I have bumped into documentation of Run-Time parameters that says
The value of a run-time parameter that corresponds to multiple dialog
parameters is typically a function of the values of the dialog
parameters.
So I deduced that a runtime parameter would suit well, but the same documentation doesn't say how to tune and access them from a Matlab S-function, only from a C one.
Also, in in this page is documented a RuntimePrm object that seems similar to DialogPrm, but trying to write the values result in an error.
Is there any way to "cache" parameter combinations without using DWorks, which would affect subsequent linearization with fake states?

Where does Scala store information that cannot be represented in Java?

There are some constructs that don't have equivalents in java. Examples would be
named parameters
instance private members
Where/How does Scala store the information necessary for this stuff (some kind of flag in the first case, the parameter names in the second case?
If I get it right this has to get stored in the byte code, since it works even if I just have a compiled library without the source code!?
This information is captured in an annotation named ScalaSig in the class file (see this answer for an example).
You can view the (not very human-friendly) annotation with javap -verbose, or parse it using an internal API, but in general neither should be necessary.