Slashdot Mirror


MATLAB Can't Manipulate 64-Bit Integers

An anonymous reader writes "MATLAB, an important package of mathematical software heavily used in industry and academia, has had support for 64-bit machines for several years now. However, the MATLAB developers still haven't gotten around to implementing even basic arithmetic operations for 64-bit integers. Attempting to add, divide, subtract, or multiply two 64-bit integers will result in an error message saying that the corresponding method does not exist. As one commentator put it, 'What is the point of having numerical data types that can't be manipulated?'" The post notes that the free MATLAB clone GNU Octave deals with 64-bit integers just fine.

39 of 334 comments (clear)

  1. So... by Anonymous Coward · · Score: 5, Insightful

    How is this news?

  2. Re:It's not that big of deal by wizardforce · · Score: 3, Informative

    If you're a physicist and you wanted to do calculations that involved a few coulombs of charge worth of electrons, MATLAB would throw out an error as this mathematical operation in particular happens to require the calculation of a ~64 bit integer and not be terribly unreasonable.

    --
    Sigs are too short to say anything truly profound so read the above post instead.
  3. Re:It's not that big of deal by seeker_1us · · Score: 3, Insightful

    Yes it is. People who do the kind of hardcore math that MATLAB is good at are the ones who actually need 64 bit computing.

  4. Re:It's not that big of deal by Anonymous Coward · · Score: 3, Insightful

    Yes it is. People who do the kind of hardcore math that MATLAB is good at are the ones who actually need 64 bit computing.

    Surprisingly, not all that often. People who work with very sensitive systems (chaotic one in particular) or VERY precise data need 64 bit precision, but for 98% of everyone else, it's just not necessary. Anyone doing really advanced work is going to use a supercomputer, for obvious reasons.

    MATLAB's largest audience is engineers, although applied mathematicians and physicists use it often, just not nearly in equal numbers with engineers (who also outnumber the others greatly). Given that engineers work with real data, which never has more than 6 digits of accuracy anyway (3 is more realistic), the push for higher precision just isn't there.

    It's one reason MATLAB doesn't have the greatest 64-bit support: there's no real demand for it, yet. The few who need it can just as easily work in C++, since all MATLAB really is is a collection of routines with a nice interface, much easier plotting/graphic commands, and a nice set of help files.

    For reference, I've had 64 bit computing readily available to me for...my entire career, and I've never once NEEDED it, despite being an applied mathematician.

  5. A Heavy User's Opinion by TerribleNews · · Score: 5, Insightful

    As someone who uses math quite a lot in academia, I can tell you that I've never noticed the missing operators. I just don't use 64-bit integers. The reason *I* upgraded to 64-bit Matlab is because I kept running up against memory constraints. 64-bit Matlab can allocate much larger arrays. I am sure there are places where it would be convenient to use really big integers but I find it hard to believe that this is really a big headache for anyone; the main improvement with the 64-bit version is a much bigger memory space.

  6. Who uses integers in MATLAB? by dissipative_struct · · Score: 5, Informative

    MATLAB isn't strongly typed, and by default variables are floating-point (I think 64-bit is the standard if type isn't specified). Makes sense for scientific programming. You need to go out of your way to use integer types in MATLAB, and the only reason I've ever had to do it is when trying to convert MATLAB scripts to C code to run on fixed-point processors. I do think that not supporting 64-bit integer operations is an oversight but I don't think it affects the vast majority of MATLAB users.

  7. Re:It's not that big of deal by zippthorne · · Score: 3, Interesting

    Seems like a lot of effort. You can always use the c interface (which itself is weird, considering matlab's roots in fortran...) but then you'd have to learn c. Matlab is a tool for physicists and engineers, not computer scientists. They don't necessarily want to take the time to learn c, or they'd have done that. Some do, anyway, of course, but usually what they produce will be one off functions for a specific goal, not entire libraries suitable for sharing.

    Frankly, even equally worrisome is that Matlab doesn't appear to take advantage of GPGPU yet. The concept has been around for over half a decade, and I'd have expected the MAtrix LABoratory to jump on the bandwagon quicker than most. It's a game changer in their core competency, after all.

    --
    Can you be Even More Awesome?!
  8. Re:It's not that big of deal by robot256 · · Score: 5, Insightful

    If you're a physicist using MATLAB, then you are (a) using floating point arithmetic, not huge integers and (b) more likely to be using Mathematica than MATLAB in the first place. Huge integers are more useful in computer science, doing encryption and data processing and such, than in physical simulations. Says the EE/Physics guy with no background in CS.

  9. Re:It's not that big of deal by Jeffrey+Baker · · Score: 3, Informative

    I think you're right, and I see the same kind of thinking when I ask about 64-bit integers in R. The people who use R are statisticians who can't imagine why a double isn't close enough. The people who complain about it are the computer programmers who are trying to use 64-bit exact fields to merge two datasets etc.

  10. Not that big a deal by usul294 · · Score: 3, Insightful

    MATLAB does most everything with doubles, int and float formats are really only there when dealing with input/output to files. If i put A = 1 into a command line, its put in memory as a double. I use MATLAB most of my working day for signal processing algorithim design, and I don't think I've ever needed the precision of a 64 bit integer. Numbers bigger than a 32 bit integer can handle pop up from time to time, but never with more precision than a double provides.

  11. Memory moreso than computations by dunc78 · · Score: 3, Informative

    As another Engineer that uses MATLAB quite frequently, the only reason I have used 64-bit support was to analyze larger data sets.

  12. Re:MATLAB ~= fast by dunc78 · · Score: 3, Informative

    Don't know what your scientific language of choice is, but I have compared MATLAB programs to FORTRAN programs and the difference in speed was negligible. A properly written MATLAB function can be quite fast.

  13. I'm not surprised... by Jah-Wren+Ryel · · Score: 5, Informative

    I'm not a MATLAB user, just someone who has had to troubleshoot problems with it for a variety of clients.

    A while back, more than a few years now, MATLAB on HPUX was limited to about 1GB of memory. Any MATLAB code that needed more memory than that was shit out of luck - even on a 64-bit machine with 64GB of RAM. This was partly due to MATLAB only being available as a 32-bit binary for HPUX and partly due to MATLAB having been compiled and linked in the most naive way possible. After diagnosing the problem with a client's MATLAB code (they had a lab full of $2M computers and couldn't run this software that only needed a couple of GB of data), I wrote a short explanation of the compile and link flags necessary to enable any process to access at least 2GB of RAM with practically no impact and 3GB with only minimal impact. In either case, no code changes necessary whatsoever.

    MATLAB's customer support group responded with a categorical denial that it was even possible to do - that HPUX architecturally limited all 32-bit processes to 1GB of addressable memory. While a customer-specific test release would have been the ideal response, I was really only expecting them to open a feature request and get the next release built the right way. But they wouldn't even give my client that (despite them having an expensive support contract) - just a flat out denial of reality instead. The solution for my client was ultimately to rewrite their software in C and link it with the right flags to get access to 3GB of memory.

    So, given just how strong their disinterest was in even trying to make their software work for big boys doing scientific computing, I'm not surprised to hear that all these years later they still haven't even bothered to implement native 64-bit math. They are entrenched and there just isn't enough competition to make them lift a finger.

    --
    When information is power, privacy is freedom.
  14. Especially since someone has implemented it.... by welcher · · Score: 5, Informative

    If you really want this support, get the user contributed package from matlab central. That wasn't too hard was it?

    1. Re:Especially since someone has implemented it.... by ProfMobius · · Score: 5, Insightful

      Well, having to go dig an additional library to add native types is a bit paradoxal isn't it ? Even more when the software cost a lot of money and is directed at engineers.

      --
      EULA : By reading the above message, you agree that I now own your soul.
    2. Re:Especially since someone has implemented it.... by welcher · · Score: 4, Informative

      The point is that very few engineers currently want or need this functionality -- if they did, the Mathworks folks would surely be on to it. The native type is defined, abstract methods are waiting there to be defined, and someone who needed it has implemented it and made it available. Incidentally, that package has had 38 downloads since july, perhaps indicating the level of demand. From this thread, it looks like the company is waiting for the demand before implementing it themselves.

    3. Re:Especially since someone has implemented it.... by thegarbz · · Score: 5, Interesting

      38 downloads may not indicate a lack of demand. The demand may be there, but it may be masked in the confusion of what may be thought to have been a standard part of the program.

      When our uni upgraded the maths lab computers Matlab versions to R2008a they installed the 64bit version as well. The logical thought was that the computers are 64bit, they have the option, so why not. Well at the time the basic add-on packages weren't available for the 64bit version, which included the package with the solve() function. Sure they could have looked on the website and found a few basic implementations of Newtonian solve functions written for 64bit, but their response to student complaints was to remove the 64bit Matlab and install the 32bit version.

      Much like how a pirated copy does not indicate a lost sale, the fact that only few people have "demand" for the application, does not mean there's a lack of demand for the functionality in the 64bit program. It may just mean that people have tried, found it lacking, and dropped back to 32bit. I'd be interested to see stats of how many people use the 64bit Matlab on computers that natively support 64bit instructions

    4. Re:Especially since someone has implemented it.... by welcher · · Score: 4, Informative

      We are talking about 64 bit integers. Matlab has 64 bit floating point arithmetic. This means you can do exact integer arithmetic up to 2^53. I'd say mathworks has a pretty good idea of the demand for 64 bit integers and it is not that great -- it's not like it is a huge job for them to implement it so they would surely do it if their customers wanted it.

    5. Re:Especially since someone has implemented it.... by sadtrev · · Score: 4, Insightful

      using 64-bit integers instead of floats is a common trick in embedded C for control and signal processing on low power processors. I have experience of four different embedded systems used in commercial products from three different companies I've worked with - three of the four used 64-bit integers for roundoff-sensitive calculations.
      I was a bit surprised that Matlab can't handle this, but then I've seen the poor quality of the ostensibly production-ready code that comes out of their M2C converter - it was about ten times the code footprint and a fifth the speed of a minimally-optimised C version of the same algorithm.

      Honestly, I don't know how anyone can justify paying for this, when R (and even Octave in this instance) is more capable. Where the target platform requires C or asm code, then doing development in Matlab is usually more trouble than it saves. The graphs are prettier, though.

    6. Re:Especially since someone has implemented it.... by Rockoon · · Score: 3, Insightful

      1998 called. It wants to know why you havent learned anything since then.

      --
      "His name was James Damore."
  15. Python as an alternative by physicsphairy · · Score: 4, Informative

    The summary mentioned Octave as an alternative to Matlab. There is also Scilab (which has some more c-like features).

    In recency I have simply been using Python. Use the iPython (interactive python) shell and load scipy (from scipy import *) and you have a very nice calculating environment. The scipy arrays are quite a joy to work with compared with what I remember from Matlab. If you're working with equal size 1D arrays then they can be used without modification in normal mathematical expressions, so a lot of my code no longer involves any iteration with for loops.

    There is a graphing library (pylab) based on Matlab syntax. If you start iPython with the -pylab flag it will print out plots the same way as in Matlab. There is also Easyviz which I believe also uses Matlab syntax but interfaces with a number of standard graphing programs (like Gnuplot.)

    The sympy package for doing symbolic manipulations is also quite nice, IMHO.

    Disclaimer: I only used Matlab casually for my undergraduate math classes.

  16. Numeric Python by Efreet · · Score: 4, Informative

    Just another reason to switch to numeric python. The more I use Matlab the less I find that I like it.

    --
    This sig wasn't worth reading, was it.
    1. Re:Numeric Python by mathfeel · · Score: 4, Interesting

      Just another reason to switch to numeric python. The more I use Matlab the less I find that I like it.

      I don't have mod point, so allow me to second that.

      The advantage of MATLab for me was ease of development that it allows me to quickly get some simple proof-of-concept code up. If I want run time speed, I'd use CLAPACK and GNU SL. I can't imagine doing any very serious numeric code in anything else (not that my work was very numeric heavy). With NumPy and SciPy, it is just as easy to do what MATLab does in a language that's actually fun to work with.

      --
      The only possible interpretation of any research whatever in the 'social sciences' is: some do, some don't
    2. Re:Numeric Python by Kensai7 · · Score: 3, Informative

      With NumPy and SciPy, it is just as easy to do what MATLab does in a language that's actually fun to work with.

      I just hope Sage succeeds and becomes more well-known. It's the best open alternative we have.

      --
      "Sum Ergo Cogito"
  17. Re:It's not that big of deal by Flavio · · Score: 5, Informative

    You can always use the c interface (which itself is weird, considering matlab's roots in fortran...)

    The reason the C interface is weird is because MATLAB stores multidimensional arrays in column-major order, like Fortran. C, on the other hand, uses row-major order. However, if you work with linear algebra, then you'll appreciate the column-major layout, because it coincides with the order returned by the vec operator (which is used all the time in computational linear algebra, and stacks the columns of a matrix).

    but then you'd have to learn c. Matlab is a tool for physicists and engineers, not computer scientists. They don't necessarily want to take the time to learn c, or they'd have done that. Some do, anyway, of course, but usually what they produce will be one off functions for a specific goal, not entire libraries suitable for sharing.

    I work with digital signal processing and use MATLAB almost on a daily basis. The reason DSP engineers use MATLAB is not because they don't know or don't want to know C. In fact, a good DSP engineer must be very competent at writing clear and efficient C code, because that's what he needs to actually implement algorithms on hardware. Modern high performance DSPs are so complex that coding things in assembly is completely out of the question.

    The reason MATLAB is so valuable is that it allows one to prototype things extremely fast with minimal performance loss (if you know what you're doing). Of course you won't have a MATLAB environment running on a DSP, so you'll eventually have to write the C code. But since most of my time is spent developing algorithms instead of actually implementing them, MATLAB lets me be much more productive.

  18. Re:Yes but Octave by ObsessiveMathsFreak · · Score: 5, Insightful

    For a program like octave, having no GUI is very forgiveable. There is really no way to work with the system outside of prompt commands. Even Matlab is very prompt based.

    What is unforgivable in Octave's case is its graphing capabilities. Octave used Gnuplot for drawing which basically means it is stuck in the 1990s when it comes to making plots. 3D plots are slow, difficult and complicated things to create. Animations are out of the question. 99% of the time, you're better off exporting to png (itself a nighmare), and animating from those. 3D data is all but ungraphable on Linux systems anyway, so I suppose Octave is not alone here.

    --
    May the Maths Be with you!
  19. exellent competition by Anonymous Coward · · Score: 3, Interesting

    There's excellent competititon for Matlab, foremost NumPy. It has tons of packages, 64bit support, and just works all around a lot better.

    Matlab is succeeding not because of lack of competition, but because it's entrenched and people are lazy

  20. Re:It's not that big of deal by KibibyteBrain · · Score: 4, Insightful

    Umm, you realize you can do math on greater than 32 bits values in Matlab, just not using the 64-bit platforms's ability to natively handle 64 bit datatypes. After all, I can do make on 64-bit values on an 8-bit micro-controller just fine, it will just take more than a few instructions.
    And as stated before, this matters little as it is a performance issue, and matlab still offers the best performance of its class, even vs. those who do have this feature.

  21. Re:Yes but Octave by ceoyoyo · · Score: 4, Informative

    So it clones Matlab very well then.

  22. Re:Yes but Octave by Vyse+of+Arcadia · · Score: 4, Informative

    3D data is all but ungraphable on Linux systems anyway, so I suppose Octave is not alone here.

    As I recall, MATLAB has a Linux port. As does Maple, Mathematica, et cetera. And Mayavi is an open source program capable of excellent 3D graphics that works with Python, and therefore SciPy.

    So what you really mean is that 3D data graphing is inadequate with Octave and gnuplot on any system. 3D data is perfectly graphable in Linux.

  23. Circular Logic by Obsolete+Disks · · Score: 3, Funny

    What do we do when the value of 1 starts to float away?
    QT/Octave:

    >>> sqrt(-1)^((4)^1)
    ans = 1
    >>> sqrt(-1)^((4)^15)
    ans = 1
    >>> sqrt(-1)^((4)^16)
    ans = 1.0000e+00 - 2.6298e-07i
    >>> sqrt(-1)^((4)^17)
    ans = 1.0000e+00 - 1.0519e-06i
    >>> sqrt(-1)^((4)^21)
    ans = 1.0000e+00 - 2.6929e-04i
    >>> sqrt(-1)^((4)^22)
    ans = 0.9999994 - 0.0010772i
    >>> sqrt(-1)^((4)^32)
    ans = 0.56253 + 0.82678i
    >>> sqrt(-1)^((4)^40)
    ans = -0.97448 + 0.22446i

    The fractal community will be outraged.

  24. Re:Negative Slashvertisment? by mgblst · · Score: 5, Funny

    Slashdot are going after the Yelp model. Looks like MATLAB hasn't been keeping up with their payments. Would hate for something to happen to all those great slashdot stories about you guys lately.

  25. Re:It's not that big of deal by hazem · · Score: 3, Insightful

    Hmm, a double has 64 bits, where do the last 12 go?

    A 64 bit integer will lose precision when converted to a 64 bit double because the double has to use some of the bits for the exponent and the rest go the mantissa. If 12 bits go to the exponent, then your 64 bit integer now has to be expressed as a 52 bit integer, raised to some power. There are (I think) 2^11 distinct numbers that would have the same representation as a double.

  26. 64-bit INT, not float. Design choice, not bug by goodmanj · · Score: 4, Interesting

    Two things:

    1) This is true for 64-bit INTEGERS. The default data type for MATLAB is a 64-bit float, and has been forever.

    2) This is a design decision by MATLAB's designers. You don't have to declare or type variables in MATLAB: you just set a = 5 and a new variable "a" is created. You set a(2) = 3, and now a grows into a 1-d array.

    It's a handy feature and a core aspect of MATLAB's ease-of-use design, but to do this, you need to have a default data type.

    64-bit float is the best choice: you can represent any number up to around 4,503,599,627,370,496 without error. For practical purposes, this means MATLAB will work fine for any real-world integer counting task: it only fails if you're interested in cryptography, primes, or other discrete math tasks, in which case you're not using MATLAB anyway.

  27. Re:The R program can't do 64 either by Anonymous Coward · · Score: 3, Interesting

    GNU R, the freetard knockoff of S...

    "Freetard knockoff?" R overtook S-PLUS several years ago in terms of importance among statisticians. Indeed, it's not just in academia where this freetard knockoff has taken over; I work as a quant at an algorithmic trading hedge fund and we dumped S-PLUS in favour of R four or five years ago.

    Sometimes, just sometimes, the open source implementation actually is better.

  28. A view from Octave developer by highegg · · Score: 5, Informative

    Being the guy who implemented the proper 64-bit arithmetics support in Octave 3.2, I can maybe share some interesting points. Matlab's design choice of double as the default type is both a blessing and a curse. Usually the blessing strikes you first (I always disliked it that 1/2 is 0 in C++ and Python, finally Python 3 changed that as well), but you start to feel the curse when diving deeper, and integer arithmetics (which I agree is far less used than floating point) is a perfect example. Initially, Matlab probably had no integers. Given that double is the default, Matlab creators decided to make the integers "intrusive", in the sense that integers combined with reals result in integers, not reals, contrary to most other languages. The motivation is probably so that you can write things like a + 1 or 2*a without a silent conversion. Hence, when I is integer, D is double and OP is any operator, I OP D behaves like int (double (I) OP D). Except that things like a + 1 seem to be optimized (something Octave currently lacks, but it shouldn't be hard to do). int64 is where things start to get messy, because not all 64-bit integers can be exactly represented in double. So, using the simple formula above, 0.5 * i64 could occassionally do something else that i64 / 2, which is highly undesirable. In order to do the "right thing", Octave will choose one of two options: first, if it discovers that "long double" is at least 80-bits wide (so that it can hold any 64-bit integers), it will use that to do the operations. If not, it will employ a custom code to emulate the operation as if it was performed with enough precision. It's based on manipulating the mantissa and exponent of the double and is much slower. Although it was kinda fun to implement it, it is really a lot of work for too little music, so that can partially explain MathWorks' attitude to this. Unlike Octave, MathWorks doesn't really need to aim at source portability (as they just distribute binaries), so maybe they're just waiting for proper long double support in all compilers they use, and then they will just use the simple approach. Or maybe they're waiting for some important future design change. When I implemented this, I was fully aware that it's not a killer feature, yet I thought it may make Octave more interesting to some Matlab users. So I'm glad someone noticed :) In any case, I suppose at some point Matlab will support this as well.

  29. Re:Yes but Octave by orzetto · · Score: 4, Interesting

    That's funny. I am researcher and work with math and plotting software on a professional basis, and even when I need Matlab to do the work (e.g. if I have to use nlinfit), I always prefer to export the data to .mat and plot in Octave. Gnuplot's output generally looks better when exported to EPS/PDF.

    Gnuplot does not allow to do GUI editing: that's a big plus, because I am forced, every time, to write a script: I know that if I don't write it, I will miss it later when I want to change something (it always happens). Also, it is much easier in Octave to specify a font (-F:Palatino, for example) than in Matlab: possibly not on top of your list of priorities, but when I wrote my PhD thesis I wanted to write everything with the same font: Matlab plots require you to edit the EPS source.

    3D plots are slow, difficult and complicated things to create.

    Curious. I just published an article with several 3D plots (which I usually eschew), and it was not really more difficult to get things done in Octave than in Matlab.

    3D data is all but ungraphable on Linux systems anyway

    I call bullshit, you never really tried. Have a look at matplotlib. And, that aside, Matlab is available on Linux too.

    --
    Victims of 9/11: <3000. Traffic in the US: >30,000/y
  30. Re:Exactly, 64 bits is so over rated by Skapare · · Score: 3, Insightful

    CPU operations are limited to a certain number of bits for their operations. Programming languages like C/C++ perform their basic arithmetic operations at the machine level, so they inherit the same limitations. These bounds are not a limit either through library/template facilities at the C/C++ level, or with basic operations in high level (particular object oriented) languages such as Pike and Python.

    I can tell you libgmp is not stuck with bcd. But the bcd aspect will exist because some kinds of uses for extended precision are financial/money based, and conversion to and from an external decimal format is sufficiently frequent that it's easier/faster to just do the arithmetic directly on decimal, even if tightly squeezed into 4 bits per digit. This has been going on since early computers. FYI, the ancient IBM model 1620 computer could do this in hardware. As you can see from the code in the links I posted earlier, a choice of language can hide the fact that the underlying architecture has fixed width arithmetic.

    BTW, for fun, compare the speeds of those two programs, which are implementations of the same algorithm.

    --
    now we need to go OSS in diesel cars
  31. Re:It's not that big of deal by tepples · · Score: 3, Informative

    You don't even have to write C when you want to get it on your DSP

    ...unless you want it to be efficient. See someone else's post.