Our next expanded demo focuses on qlsqr, our least-squares linear system solver. We compare against Matlab’s built-in solver, the “\” operator. Matlab’s solver is reasonably fast, but is easily thrown off by ill-conditioned matrices. We’ll show that qlsqr can run even faster while being much more robust to ill conditioning.

Converting a data matrix into a linear system with solve/test sections.
Each test matrix consists of real data – sensor measurements, survey data, etc. We convert each matrix into a linear system by treating the last column as b in Ax = b, then solve for x. You can think of it as a regression of the last column against the other columns; the point is to set up a least-squares problem with real data.
We ran speed and quality comparisons using the code in compare_qlsqr.m. It splits each matrix using the function split_data (included), which a) randomly splits rows into 80%/20% sets, and b) separates out the last column of each row-set for use as a target. We then time the solvers on the 80% set, and evaluate their accuracy (RMSE) on the 20% test set.
Each of the data matrices is listed with a download link, its size, and the error tolerance at which we ran qlsqr in the dataset table. You can replicate our results by running:
>> load example.mat
>> compare_qlsqr(mat)
% compare_qlsqr(mat, epsilon) if using a tolerance other than the default 0.01
First the speedup results. We chose the error tolerances to maximize speed without losing robustness. This plot shows the distribution of speedups over Matlab:

In almost every case qlsqr is at least 2x faster than Matlab, and in 50% of cases it’s faster by 10x or more. So the speedup is substantial. What about solution quality?
We measure solution quality and robustness by RMSE performance on the test set. While the quality of the QLA solution relative to the input matrix is guaranteed (see the user doc for details), more often we are concerned about performance on future data. The test-set RMSE simulates this, and is a key robustness indicator showing how well solutions will perform on novel inputs, whether for a control system, a prediction problem, or some other setting.
The following plot shows the ratio of Matlab vs. qlsqr test-set RMSE for each matrix – values greater than 1 indicate qlsqr has superior (lower) test-set RMSE:

The results speak for themselves, but it’s worth pointing out by what a large margin QLA outperforms Matlab on ill conditioned matrices – ~10-90x in the most extreme 20% of cases.
QLA’s tolerance for a small amount of error allows it to ignore process noise that Matlab’s solver tries to fit. The gain in speed and robustness is a big win in many applications, though if you absolutely must fit to the last decimal place it may not be what you need (keep in mind the error tolerance is adjustable).
We really encourage folks to try this solver – not only is it extremely fast, its solutions tend to perform extremely well on new inputs, and this can make a big difference in applications. That’s some low hanging fruit.
Datasets used in qlsqr experiments, in descending order of speedup
| dataset |
size |
epsilon |
| galaxy |
40,000 x 3,839 |
.01 |
| declaration |
4,656 x 3,923 |
.025 |
| mars |
1,783 x 2,000 |
.1 |
| arcene |
800 x 10,000 |
.25 |
| umist |
575 x 10,304 |
.25 |
| madelon |
4,400 x 500 |
.01 |
| gisette |
12,500 x 5,000 |
.45 |
| bcsstk24 |
3,562 x 3,562 |
.25 |
| dor |
800 x 6,063 |
.01 |
| secom |
1,567 x 590 |
.25 |
| pumsb_star |
49,046 x 63 |
.1 |
| sonar_scatter |
208 x 208 |
.01 |
| frey |
560 x 1,965 |
.01 |
| regression |
124,202 x 37 |
.01 |
| moon |
256 x 384 |
.01 |
| arrhythmia |
452 x 280 |
.25 |
| tic |
9,822 x 86 |
.25 |
| ozone |
2,536 x 73 |
.01 |
| PIE_32x32 |
11,554 x 1,025 |
.01 |
| olivetti |
4,096 x 400 |
.01 |
| timit |
138,839 x 40 |
.01 |
| pumsb |
49,046 x 74 |
.0000001 |
| poker |
1,025,010 x 11 |
.01 |
| ailerons |
13,750 x 41 |
.0005 |
| isolet |
7,797 x 618 |
.05 |
| usps |
11,000 x 256 |
.1 |
| connect |
67,577 x 43 |
0.00001 |
| elevators |
16,599 x 19 |
.01 |
| corel |
61,634 x 16 |
.01 |