Transferring a matrix from Mathematica to Julia

What is the recommended ways to transfer a matrix generated in Mathematica to Julia and benefits/disadvantages? My workflow is the following:

  1. generate matrices in Mathematica
  2. transfer the matrices to Julia (via some standardized data format like MatrixMarket,…)
  3. use those in further applications/packages
  4. going back and forth

Some other methods that I am considering is:

  • call directly the function in 3 using Mathematica ExternalEvaluate
  • or call 1 using Julia’s interoperability

I guess interoperability cannot be much more seamless than this. If you have any other methods please let me know.

If I’m not mistaken Mathematica supports HDF5. Julia does as well, see HDF5.jl. So you could export your matrix into a HDF5 file and load it in Julia.

1 Like

Frankly, I would just use CSV, with the standard library DelimitedFiles on the Julia end.

2 Likes

Thanks guys. My matrix is sparse and big so I guess I will stick to best data format for these.