MEX Fortran Gateway and Sparse Matrices
Show older comments
Hello Community,
I was wondering if the following behaviour is commonplace.
Are the following two expressions the same when passed to a compiled MexFunction subroutine in fortran? Say the source code is rif.F, then
>> M = sprandsym(n, 0.5)
>> F = full(M);
>> rif(M(:,1)) % (1)
>> rif(F(:,1)) % (2)
I am obtaining different results for (1) and (2), inside MexFunction I print the copied vectors and the correct version is (2).
Illustrative example
>> F(:,1)
ans =
2.088396433123533
-0.283514990578777
0
2.161892637140028
0
>> rif(M(:,1))
Copied: 2.0883964331235330 -0.28351499057877672 2.1618926371400278 0.0000000000000000 0.0000000000000000
>> rif(F(:,1))
Copied: 2.0883964331235330 -0.28351499057877672 0.0000000000000000 2.1618926371400278 0.0000000000000000
For this particular example it would seem the elements 3 and 4 were swapped, but different swaps also occur, specially with other elements in M.
Is this the expected behaviour?
Cheers!
Accepted Answer
More Answers (0)
Categories
Find more on Fortran with MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!