Core Image vector comparison bug? - osx-snow-leopard

According to the GLSLangSpec, the == & != operators for vectors consider 2 vectors equal if all corresponding components are equal. The Core Image Kernel Language specification doesn't mention any deviation from this in it's changes from GLSL. But when I do such a compare within a Core Image Filter in Quartz Composer, it clearly only compares the 1st (red) component. Is this a known bug?
This is under OSX 10.6.8. Does it perhaps work correctly in later versions? Or will I just have to use my own custom comparison function?

Related

How to create FMU slave and initialise FMU in C using Modelica's fmi headers

I'm creating a simple FMI demo system to try out FMI where I have 1 simulator connected to an FMU which computes the state of the system (represented as a number calculated from a closed-form equation) and another FMU that controls the system via a parameter in the closed-form equation. So the system looks something like
FMU-system <--> Simulator <--> FMU-control
In every iteration, I'm updating the system state based on 1 equation, and passing it to the control, which returns a parameter to be passed to the system.
I'm using FMI 2.0.3, and have read the specification. Right now I have 3 files, 1 to act as a simulator and 2 to act as the FMUs. But I'm having difficulties with the implementation of the FMUs and the initialisation of the simulator.
To initialise the FMU, my understanding is I need to call fmi2Instantiate which has this signature.
fmi2Component fmi2Instantiate(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID, fmi2String fmuResourceLocation, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn);
But I don't know what to pass in the function for the GUID, resource location and callback function. How should I implement the callback function and initialisation?
Then to implement the FMU, my understanding is I need to implement fmi2SetReal, fmi2GetReal and fmi2DoStep, but I can't figure out how to implement them in terms of code. These are the signatures
fmi2Status setReal(fmi2Component c, fmi2ValueReference vr[], size_t nvr, fmi2Real value[])
fmi2Status getReal(fmi2Component c, fmi2ValueReference vr[], size_t nvr, fmi2Real value[])
fmi2Status doStep(fmi2Component c, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
But I can't figure out how to implement these functions. Is fmi2Component c meaningless here? And I suppose I have to do the system state computation for the FMU-system in doStep. How should I update the state and pass the code here?
Sorry if this is too many questions but I was trying to look for a tutorial too and I couldn't find any.
https://github.com/traversaro/awesome-fmi
This is a curated list of Functional Mock-up Interface (FMI) libraries, tools and resources.
There are non commercial tools available. Check them out, you will get idea to implement these functions for your application.
A good starting point to implement FMI support are the open source Reference FMUs (which recently also got a simple FMU simulator) and fmpy:
https://github.com/CATIA-Systems/FMPy
https://github.com/modelica/Reference-FMUs/tree/main/fmusim

react-chartjs: difference between `scales.x`/`xAxes`/`xAxes[]`

I'm using react-chartjs-2 with Typescript.
I'm very confused with the interface of chartjs (perhaps this is due to severe API changes beneath versions and information running around online without clearly stating the version).
What is the difference between the following options:
options.scales.x: {}
options.scales.xAxes: {}
I thought this was equal to the above, but under certain circumstances I could not get options.scales.xAxes.min working. So I resorted to using x.
options.scales.xAxes: [{}]
I see many examples using this syntax (especially here on SO). However, using it myself results in a type error.
options.scales.xAxes: [{}] is V2 syntax, here all the x axes are grouped in a single array, same for all the y axes.
In v3 all the scales are their own object within the scales object where the key of the object is your scale ID.
by default you should use options.scales.x to configure the default x axis. But to make things a bit easyer chart.js looks at the fist letter of the object to determine its type so if you pass options.scales.xAxes it should result in the same if you dont have any other scales configured

IloNumVarArray Vs IloNumArray

I am working on a project in which the problem is solved using CPLEX. There are two classes IloNumVarArray and IloNumArray that I do not know their difference.
I really appreciate it if someone can explain this.
Thanks
Masoud
The difference is very simple but very important.
The IloNumVarArray is used to hold the CPLEX modelling variables. These are the components used to construct your mathematical model. These variables have a domain or range of possible values (usually specified with upper and lower bounds) and they do not have values until after you have solved the problem with CPLEX.
IloNumArray is an array of simple variables in your programming language e.g. C++ doubles or ints (or the equivalents in C#, Java or whatever). These are used in your code which is creating your model and can appear as constants in your CPLEX model.

Is there a Qiskit function that allows you to see what qubit/quantum register said gate is attached to?

I am trying to find a way to know what named qubit/quantum register a quantum gate (i.e. labelled Pauli-X gate) would be attached to. The documentation does not have a function nor example that informs me of how to go about doing this. The picture below outlines that I am trying to find qubit n0 from quantum gate U0.
Example quantum circuit
The easiest way to do this would probably be to access the data attribute of your QuantumCircuit object (e.g. circuit.data if your circuit object is named circuit). This will be a list of tuples with the instruction objects (ie the gate instance), the quantum bit arguments for that instruction, and the classical bit arguments for the instruction: (instruction, qargs, cargs). For your example circuit it is simple because there is one only one gate so it'll be the first element in that list. So for that case you can do something like u0_qubits = circuit.data[0][1] and u0_qubits will be a list of the Qubit objects. Trying to do this for larger circuits with possible duplicate gates will obviously be more involved.

Different solutions while integrating stiff equation

I am trying to integrate Rosenzweig-MacArthur model (equations) using Backward Differentiation Method using CVODE in C for stiff equations. I have to specify tolerance value for integration. Depending on the tolerance value I give, I get different solutions. I am not able to see which one is the correct solution. Can you please tell me what should (criteria for choosing) the tolerance value be?

Resources