How can I label a solution as NaN in a MEX code?
Afficher commentaires plus anciens
I am using solvers of LAPACK libraries in a MATLAB MEX file for solving linear system of equations. For some of the cases, the system that I solve is singular. For example, the system is as follows for one of my cases:
A =
0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 77.31867171
b:
-0.00000000 -0.00000000 -0.00000000
What would be the best approach to label this solution as NaN similar to MATLAB?
Réponse acceptée
Plus de réponses (1)
José-Luis
le 24 Juin 2014
if (some_condition)
some_value = 0.0/0.0; %This will produce a NaN
end
4 commentaires
AP
le 24 Juin 2014
I am afraid I don't understand the problem. To test for singularity you could use:
rank(some_matrix)
And if you find out some_matrix is singular then set some_value as NaN.
double myNaN = 0.0/0.0;
will produce a NaN in C++. Alternatively, you could set it to some other value
double flag = numeric_limits<double>::max();
that you then change into NaN in Matlab.
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!