Undocumented Matlab
  • SERVICES
    • Consulting
    • Development
    • Training
    • Gallery
    • Testimonials
  • PRODUCTS
    • IQML: IQFeed-Matlab connector
    • IB-Matlab: InteractiveBrokers-Matlab connector
    • EODML: EODHistoricalData-Matlab connector
    • Webinars
  • BOOKS
    • Secrets of MATLAB-Java Programming
    • Accelerating MATLAB Performance
    • MATLAB Succinctly
  • ARTICLES
  • ABOUT
    • Policies
  • CONTACT
  • SERVICES
    • Consulting
    • Development
    • Training
    • Gallery
    • Testimonials
  • PRODUCTS
    • IQML: IQFeed-Matlab connector
    • IB-Matlab: InteractiveBrokers-Matlab connector
    • EODML: EODHistoricalData-Matlab connector
    • Webinars
  • BOOKS
    • Secrets of MATLAB-Java Programming
    • Accelerating MATLAB Performance
    • MATLAB Succinctly
  • ARTICLES
  • ABOUT
    • Policies
  • CONTACT

Sparse data math info

July 31, 2013 2 Comments

Two weeks ago, I posted about Matlab’s math libraries and their various versions across Matlab releases. Matlab relies on the proprietary Intel MKL and AMD ACML libraries for most of its core math, matrix manipulation and linear algebra functions, for Intel/AMD CPUs (respectively). MKL and ACML are adaptations of, and wrappers for, the ubiquitous BLAS and LAPACK packages (LAPACK uses BLAS for its low-level functionality).

Introducing SuiteSparse

CSparse book Unfortunately, BLAS can be used only with full (non-sparse) matrix data on a CPU. So, for GPU support Matlab uses MAGMA (libmwmagma.dll). Similarly, for sparse data Matlab uses the SuiteSparse library by University of Florida’s Tim Davis, whose work on sparse matrix software has very recently earned him SIAM fellowship. SuiteSparse is used by Google Earth and Street-View to create their amazing real-time 3D renditions.
SuiteSparse relies on sparse-data algorithms that have been developed over many years (since the 70’s elsewhere, since 1991 at UFL), and continuously evolve to this day. A presentation about the algorithms in 2006 is available: video, slides (FEX #12295). A detailed presentation of some of the algorithms can be found in Tim’s book “Direct Methods for Sparse Linear Systems” (SIAM, 2006), which should not be confused with Tim’s other book, the widely-popular “Matlab Primer“. A more recent technical description of the sparse algorithms is provided in an ACM paper.

SuiteSparse in Matlab

SuiteSparse has been incorporated into Matlab’s core functionality over the span of several years, between 2000 and 2009 (details). The functions were apparently incorporated into libmwmathlinalg.dll, libmwmathcore.dll, libcolamd.dll, libmwspmatrix.dll, libmwumfpack.dll, libmwumfpack_api.dll, libmwcholmod.dll, libmwamd.dll, libmwspqr.dll, libmwma57.dll, libmwcsparse.dll, libmwspqr.dll (and possibly a couple of other DLLs I missed). On *nix systems, the libraries have the same name, with an *.so extension (e.g., libmwcsparse.so). All these dynamic libraries are located in the /bin/%arch%/ folder of the Matlab installation, alongside the rest of Matlab’s libs. The lib names are pretty self-explanatory, for example libmwspqr.dll contains the SuiteSparse QR library; libmwcsparse.dll contains the CSparse library (which is described in the above-mentioned SIAM book).
Back in 2007, SuiteSparse could be used in Matlab as a separate package on the File Exchange (#12233), which was discussed on Loren’s blog. Since Matlab has incorporated SuiteSparse into its core functions, FEX #12233 is no longer available. We can still download the sources directly from the SuiteSparse page on UFL.

Sparse libs version info in Matlab

Unlike BLAS, LAPACK, FFTW and MKL, there is no known way to directly extract the sparse-libs version info in Matlab. But there is an indirect way to do so, and in the process, we discover lots of interesting information about the internal mechanisms of the sparse algos.
We begin by setting the debugging information to maximum using the spparms function. This not only provides version info, but also all kinds of diagnostics about the sparse matrices and the selected algorithm path. For example (note the highlighted version info text):

>> spparms('spumoni',2)
>> load west0479
>> b = rand(size(west0479,1));
>> x = west0479 \ b;
sp\: bandwidth = 388+1+337.
sp\: is A diagonal? no.
sp\: is band density (0.01) > bandden (0.50) to try banded solver? no.
sp\: is A triangular? no.
sp\: is A morally triangular? no.
sp\: is A a candidate for Cholesky (symmetric, real positive diagonal)? no.
sp\: use Unsymmetric MultiFrontal PACKage with automatic reordering.
UMFPACK V5.4.0 (May 20, 2009), Control:    Matrix entry defined as: double
    Int (generic integer) defined as: UF_long
    BLAS library used: Fortran BLAS.  size of BLAS integer: 8
    MATLAB:                           yes.
    CPU timer:                        ANSI clock ( ) routine.
    number of rows in matrix A:       479
    number of columns in matrix A:    479
    entries in matrix A:              1887
    memory usage reported in:         16-byte Units
    size of int:                      4 bytes
    size of UF_long:                  8 bytes
    size of pointer:                  8 bytes
    size of numerical entry:          8 bytes
    strategy used:                    unsymmetric
    ordering used:                    colamd on A
    modify Q during factorization:    yes
    prefer diagonal pivoting:         no
    pivots with zero Markowitz cost:               133
    ...  % lots of other interesting internal information

>> spparms('spumoni',2) >> load west0479 >> b = rand(size(west0479,1)); >> x = west0479 \ b; sp\: bandwidth = 388+1+337. sp\: is A diagonal? no. sp\: is band density (0.01) > bandden (0.50) to try banded solver? no. sp\: is A triangular? no. sp\: is A morally triangular? no. sp\: is A a candidate for Cholesky (symmetric, real positive diagonal)? no. sp\: use Unsymmetric MultiFrontal PACKage with automatic reordering. UMFPACK V5.4.0 (May 20, 2009), Control: Matrix entry defined as: double Int (generic integer) defined as: UF_long BLAS library used: Fortran BLAS. size of BLAS integer: 8 MATLAB: yes. CPU timer: ANSI clock ( ) routine. number of rows in matrix A: 479 number of columns in matrix A: 479 entries in matrix A: 1887 memory usage reported in: 16-byte Units size of int: 4 bytes size of UF_long: 8 bytes size of pointer: 8 bytes size of numerical entry: 8 bytes strategy used: unsymmetric ordering used: colamd on A modify Q during factorization: yes prefer diagonal pivoting: no pivots with zero Markowitz cost: 133 ... % lots of other interesting internal information

A Matlab script to extract the sparse libs’ version info is provided here. The script runs a few sparse math operations that more-or-less cover the sparse libs, and then reports the version data when it’s done. In order to parse the debugging info, the script uses either an external OS grep command (which is available on Linux & Macs), or a Matlab equivalent. Here are the results on my R2013a system:

>> sparse_lib_versions
...  % numerous debugging info...
=> sparse matrix library versions (from C:\Users\Yair\AppData\Local\Temp\sparse_info.txt):
============================================================
AMD version 2.2.0, May 31, 2007: approximate minimum degree ordering
AMD version 2.2.0, May 31, 2007, results:
colamd version 2.5, May 5, 2006: OK.
CHOLMOD version 1.7.0, Sept 20, 2008:  : status: OK
CHOLMOD version 1.7.0, Sept 20, 2008: : status: OK
SuiteSparseQR, version 1.1.0 (Sept 20, 2008)
UMFPACK V5.4.0 (May 20, 2009), Control:
UMFPACK V5.4.0 (May 20, 2009), Info:

>> sparse_lib_versions ... % numerous debugging info... => sparse matrix library versions (from C:\Users\Yair\AppData\Local\Temp\sparse_info.txt): ============================================================ AMD version 2.2.0, May 31, 2007: approximate minimum degree ordering AMD version 2.2.0, May 31, 2007, results: colamd version 2.5, May 5, 2006: OK. CHOLMOD version 1.7.0, Sept 20, 2008: : status: OK CHOLMOD version 1.7.0, Sept 20, 2008: : status: OK SuiteSparseQR, version 1.1.0 (Sept 20, 2008) UMFPACK V5.4.0 (May 20, 2009), Control: UMFPACK V5.4.0 (May 20, 2009), Info:

It looks like MathWorks haven’t updated Matlab’s sparse libs in quite a few years. These libraries continue to be improved continuously, but most of the tweaks are quite minor and no important bugs were found for many years, so I guess that we can’t really complain.

Austria & Switzerland visit

I will be visiting clients in Austria and Switzerland in August. If you live in the area, I will be happy to meet you to discuss how I could bring value to your needs, as consultant, contractor or trainer. Please email me if you think that this could be relevant for you. The relevant dates are:

  • Vienna – Aug 18, 25-26
  • Salzburg – Aug 19-23
  • Zurich – Aug 26-29

Bis bald!

Related posts:

  1. Math libraries version info & upgrade – Matlab exposes undocumented info about its internal math libraries; these libraries can be upgraded manually. ...
  2. Function definition meta-info – There are multiple ways to retrieve meta-info about functions in Matlab. ...
  3. Simulink Data Dictionary – Simulink contains undocumented public API for access to its data dictionary functionality. ...
  4. Controlling plot data-tips – Data-tips are an extremely useful plotting tool that can easily be controlled programmatically....
  5. Draggable plot data-tips – Matlab's standard plot data-tips can be customized to enable dragging, without being limitted to be adjacent to their data-point. ...
  6. Additional license data – Additional meta-data about installed toolboxes can be retrieved in Matlab. ...
Internal component Pure Matlab Undocumented feature
Print Print
« Previous
Next »
2 Responses
  1. Drazick August 8, 2013 at 09:17 Reply

    Why don’t you open a Google+ Page?

    • Yair Altman August 8, 2013 at 09:21 Reply

      …because it’s too much trouble to manually update the g+ page with each post every week…

      If you wish to follow this blog, the best way is to subscribe via RSS or email using the links at the top-right of each page on this website.

Leave a Reply
HTML tags such as <b> or <i> are accepted.
Wrap code fragments inside <pre lang="matlab"> tags, like this:
<pre lang="matlab">
a = magic(3);
disp(sum(a))
</pre>
I reserve the right to edit/delete comments (read the site policies).
Not all comments will be answered. You can always email me (altmany at gmail) for private consulting.

Click here to cancel reply.

Useful links
  •  Email Yair Altman
  •  Subscribe to new posts (feed)
  •  Subscribe to new posts (reader)
  •  Subscribe to comments (feed)
 
Accelerating MATLAB Performance book
Recent Posts

Speeding-up builtin Matlab functions – part 3

Improving graphics interactivity

Interesting Matlab puzzle – analysis

Interesting Matlab puzzle

Undocumented plot marker types

Matlab toolstrip – part 9 (popup figures)

Matlab toolstrip – part 8 (galleries)

Matlab toolstrip – part 7 (selection controls)

Matlab toolstrip – part 6 (complex controls)

Matlab toolstrip – part 5 (icons)

Matlab toolstrip – part 4 (control customization)

Reverting axes controls in figure toolbar

Matlab toolstrip – part 3 (basic customization)

Matlab toolstrip – part 2 (ToolGroup App)

Matlab toolstrip – part 1

Categories
  • Desktop (45)
  • Figure window (59)
  • Guest bloggers (65)
  • GUI (165)
  • Handle graphics (84)
  • Hidden property (42)
  • Icons (15)
  • Java (174)
  • Listeners (22)
  • Memory (16)
  • Mex (13)
  • Presumed future risk (394)
    • High risk of breaking in future versions (100)
    • Low risk of breaking in future versions (160)
    • Medium risk of breaking in future versions (136)
  • Public presentation (6)
  • Semi-documented feature (10)
  • Semi-documented function (35)
  • Stock Matlab function (140)
  • Toolbox (10)
  • UI controls (52)
  • Uncategorized (13)
  • Undocumented feature (217)
  • Undocumented function (37)
Tags
ActiveX (6) AppDesigner (9) Callbacks (31) Compiler (10) Desktop (38) Donn Shull (10) Editor (8) Figure (19) FindJObj (27) GUI (141) GUIDE (8) Handle graphics (78) HG2 (34) Hidden property (51) HTML (26) Icons (9) Internal component (39) Java (178) JavaFrame (20) JIDE (19) JMI (8) Listener (17) Malcolm Lidierth (8) MCOS (11) Memory (13) Menubar (9) Mex (14) Optical illusion (11) Performance (78) Profiler (9) Pure Matlab (187) schema (7) schema.class (8) schema.prop (18) Semi-documented feature (6) Semi-documented function (33) Toolbar (14) Toolstrip (13) uicontrol (37) uifigure (8) UIInspect (12) uitools (20) Undocumented feature (187) Undocumented function (37) Undocumented property (20)
Recent Comments
  • Nicholas (7 days 2 hours ago): Hi Yair, Thanks for the reply. I am on Windows 10. I also forgot to mention that this all works wonderfully out of the editor. It only fails once compiled. So, yes, I have tried a...
  • Nicholas (7 days 2 hours ago): Hi Yair, Thanks for the reply. I am on Windows 10. I also forgot to mention that this all works wonderfully out of the editor. It only fails once compiled. So, yes, I have tried a...
  • Yair Altman (7 days 9 hours ago): Nicholas – yes, I used it in a compiled Windows app using R2022b (no update). You didn’t specify the Matlab code location that threw the error so I can’t help...
  • Nicholas (8 days 5 hours ago): Hi Yair, Have you attempted your displayWebPage utility (or the LightweightHelpPanel in general) within a compiled application? It appears to fail in apps derived from both R2022b...
  • João Neves (11 days 10 hours ago): I am on matlab 2021a, this still works: url = struct(struct(struct(struct(hF ig).Controller).PlatformHost). CEF).URL; but the html document is empty. Is there still a way to do...
  • Yair Altman (14 days 9 hours ago): Perhaps the class() function could assist you. Or maybe just wrap different access methods in a try-catch so that if one method fails you could access the data using another...
  • Jeroen Boschma (14 days 11 hours ago): Never mind, the new UI components have an HTML panel available. Works for me…
  • Alexandre (14 days 12 hours ago): Hi, Is there a way to test if data dictionnatry entry are signal, simulink parameters, variables … I need to access their value, but the access method depends on the data...
  • Nicholas (15 days 2 hours ago): In case anyone is looking for more info on the toolbar: I ran into some problems creating a toolbar with the lightweight panel. Previously, the Browser Panel had an addToolbar...
  • Jeroen Boschma (18 days 9 hours ago): I do not seem to get the scrollbars (horizontal…) working in Matlab 2020b. Snippets of init-code (all based on Yair’s snippets on this site) handles.text_explorer...
  • Yair Altman (46 days 12 hours ago): m_map is a mapping tool, not even created by MathWorks and not part of the basic Matlab system. I have no idea why you think that the customizations to the builtin bar function...
  • chengji chen (46 days 18 hours ago): Hi, I have tried the method, but it didn’t work. I plot figure by m_map toolbox, the xticklabel will add to the yticklabel at the left-down corner, so I want to move down...
  • Yair Altman (54 days 11 hours ago): @Alexander – this is correct. Matlab stopped including sqlite4java in R2021b (it was still included in 21a). You can download the open-source sqlite4java project from...
  • Alexander Eder (60 days 7 hours ago): Unfortunately Matlab stopped shipping sqlite4java starting with R2021(b?)
  • K (66 days 17 hours ago): Is there a way to programmatically manage which figure gets placed where? Let’s say I have 5 figures docked, and I split it into 2 x 1, I want to place 3 specific figures on the...
Contact us
Captcha image for Custom Contact Forms plugin. You must type the numbers shown in the image
Undocumented Matlab © 2009 - Yair Altman
This website and Octahedron Ltd. are not affiliated with The MathWorks Inc.; MATLAB® is a registered trademark of The MathWorks Inc.
Scroll to top