9 ms·
GNU Octave is a much better language for linear algebra problems that python+numpy. If all you have to do is state and solve some systems, you can typically do
by enriquto 6y ago
GNU Octave is a much better language for linear algebra problems that python+numpy. If all you have to do is state and solve some systems, you can typically do it in one or two lines of octave, while in python you need to import libraries and use a bizarre notation (either @ or .dot look very ugly in formulas).
Besides, the sparse linear solvers are much more performant in octave than in numpy.linalg (because the scipy developers are notorious anti-GPL fanatics and they refuse to use the state of the art free solvers due to stupid license reasons).
I for one use octave almost everyday, and I'm a bit annoyed when I have to turn something into python.
- jsw97 6y agoAmen to this. The effortless translation of matrix expressions into code is a huge positive for Matlab/Octave and negative for Python. Have not worked with Julia, and I wonder what the experience is there.
- leephillips 6y agoWorking with matrices is similar in Julia. In fact, the syntax was partly influenced by the desire to make it easy for MATLAB users to pick up.
- fluidcruft 6y agoDo you know how difficult it is to translate Matlab into Julia? I have a bunch of Matlab code I'm needing to refresh and honestly I could go either to Python or Julia. Python is more mature, but Julia doesn't seem like it's going to die or anything. I haven't had a lot of time to look into it but my hunch is it would be magnificent to code numerical routines in Julia and access them from Python. There was some work for adding that sort of an interface with octave but it never seemed to work well.
- eigenspace 6y agoJulia is not a Matlab clone, but it does have more in common with Matlab than Python does, so translation is easier. That said, Matlab does encourage quite a few bad habits that can kill performance in Julia, so it's important to try and properly learn Julia idioms too before you just blindly start translating if you care about performance.
- fluidcruft 6y agoWhat do you mean by killing performance? Compared to Matlab implementation or compared to better Julia implementations? To me, numpy operates the same way Matlab/Octave/IDL does (slow bulky interpreter that basically orchestrates feeding/retrieving memory to fast/optimized primitives/BLAS etc). Coding in Matlab is about "vectorizing", which is also how I understand numpy to work. So to me numpy has a lot in common with Matlab conceptually in terms of how I approach implementing an algorithm. My assumption was that Julia could at least match that as worst-case but offered better optimizations to get even more performance. I guess it depends on what's considered bad habits. Octave/Matlab do tend to be not terribly memory efficient so I tend to just buy RAM and larger cache CPUs. But my domain is memory-limited anyway. Matlab's JIT does enable some things that are dog slow in octave for example. I assumed that sort of thing would actually be faster in Julia.
- tikej 6y agoJulia isn’t as good as matlab in optimising badly written matrix code. For example some vectorised (in sense A = G(BX + CD) for matrices and vectors) it allocates temporary matrices whreas matlab is great at optimising such stuff. Most things could (and for optimal performance should) be written with loops and that will be much faster in Julia. However, there is Julia package Tullio.jl and it’s great with matrices/vectors/tensor stuff. It fuses operations, uses AVX instructions and creates code for GPU if asked.
- eigenspace 6y agoIt can really depend. It’s certainly possible to write code in Julia that is slower than corresponding Matlab or Python code. Generally, naive Julia code shouldn’t be any slower than Matlab or Python, but it can happen. The Julia Discourse forum has many posts from people surprised to find their code running slower in Julia, but the community is also incredibly helpful so these posts almost always result in some rather simple modifications to the code that makes it handily outperform Matlab or Python implementations.
- leephillips 6y agoNot specifically, but Julia would be a better choice than Python + Numpy.
- kwertzzz 6y agoI have translated quite a bit of Matlab code to Julia. Just the simple fact that indices are handled the same way in Matlab and Julia makes this transition easier than going from Matlab to Python in my opinion. What I would suggest, is that you first write some test suite of your Matlab code (you might have it already), have a look to the Julia documentation and in particular to the performance tips (https://docs.julialang.org/en/v1/manual/performance-tips/ https://docs.julialang.org/en/v1/manual/performance-tips/) and for functions where performance is important check its type-stability. You might want to start first with a small project to familiarize yourself with the (quite rich) type system in julia.
- billfruit 6y agoMATLAB seems ill condusive for structuring and organising code in a sane manner. It tends to give its users bad habits with respect to structuring code is what I observe. It seems to lack data structures that are quite pervasive in modern programming practise. Also python being a general purpose system brings its own benefits, one can easily hook up ones code to fetch or push data to databases and even easily scrape data of the web or extract/reparse/rectify/reformat poorly/complexly structured data before processing. And I find MATLAB not feature rich in terms of being able to manipulate tabular data in a relational DB like manner, that is querying/projecting/selecting rows/colums to find interesting facts.
- enriquto 6y ago> It seems to lack data structures that are quite pervasive in modern programming practise. At least it has multi-dimensional arrays of floats, that is all I need and are sorely lacking in Python. On the other hand, Python has dictionaries and strings, but those are completely useless in a numerical setting. I agree that the M language is not a good general-purpose programming language. But for expressing linear algebra manipulations is probably the best in town.
- leephillips 6y agoExcept for APL!
- bee_rider 6y agoThis makes sense, though, because it isn't really a general purpose language for creating standalone programs. I mean, you can try that, but it is a bit awkward. The usecase is mostly "I've got some matrices and I want to try some things with them before writing a couple thousand lines of FORTRAN with a bunch of ugly BLAS calls." Most programming languages are tools for making tools. Matlab is the tool itself. I've seen scripts where you have to set up your matrices, manually put them in particular named variables, and run them through a script that was basically a bunch of matlab shell commands listed one after another. That's not scalable of course, but if elderly professors were willing to mess around with makefiles, dependencies, interfaces, and importing stuff then grad students would all find themselves unemployed.
- Denvercoder9 6y ago> use a bizarre notation (either @ or .dot look very ugly in formulas). If you use the numpy.matrix type instead of numpy.array, the * operator becomes matrix multiplicaton.
- enriquto 6y agohmmm, I thought the matrix class was deprecated? At least it says so in the official numpy documentation: https://numpy.org/doc/stable/reference/generated/numpy.matrix.html https://numpy.org/doc/stable/reference/generated/numpy.matri... Anyhow, the * operator does not work with sparse matrices, and you really don't want to maintain two versions of your formulas. Thus, you are unfortunately stuck with @ or .dot I guess there might be a much more math-friendly library than numpy, but I have never found it.
- Denvercoder9 6y ago> hmmm, I thought the matrix class was deprecated? At least it says so in the official numpy documentation: Huh, you're right. Bummer, I hadn't noticed that yet. I agree that an ergonomic matrix class is sorely missing in the Python ecosystem. It shouldn't even be that hard to implement, since all the plumbing is already there.
- deleted 6y ago[deleted]
- f6v 6y agoI find Julia great at linear algebra, also heard there’s some ODE support. Octave and Matlab feel outdated in comparison.
- leephillips 6y agoMore than some: the DifferentialEquations.jl library for Julia is one of the best for any language.
- amkkma 6y ago>some ODE support Best ODE/SDE etc support of any programming language. Including composing them with machine learning and AD, GPU, multithreading, DSLs and symbolic simplification etc https://sciml.ai/ https://sciml.ai/
- ljosifov 6y agoLooks like when making use of gazilions numbers, a single and thus minimal data structure that suffices to get the job done is a matrix is a spreadsheet is an sql table. ;-) I too am trying pandas daily after matlab (and q/kdb) and getting more annoyed by the day, of how inept it is. :-O Then again, it could be me - a craftsman & its tools, etc.