![]() |
Re: OPR-computation-related linear algebra problem
Quote:
Even normal Gaussian elimination will be pretty fast on a sparse matrix (though still slower than most methods above), but it has problems with numerical stability that get worse and worse as matrix size increases and is for that main reason avoided by most people solving numerical linear algebra problems. |
Re: OPR-computation-related linear algebra problem
2 Attachment(s)
Re-ran using Scipy's sparse matrix solver.
Average run time: 0.085s Standard deviation: 0.005s Code:
import sys |
Re: OPR-computation-related linear algebra problem
Nikhil,
Is there a reason why you are not using the "pcg" function which assumes symmetric positive definite inputs? This should be faster. Also please consider using the diagonal as a preconditioner. Unfortunately I do not have access the MATLAB at the moment. Could you try please the following? And sorry in advance for any bugs: Ns = sparse(N); D = diag(Ns); Ds = sparse(diag(D)); #This was a bug... maybe it still is! # Reference Solution tic output = Ns\d; toc # CG Solution tic output = pcg(Ns,d) toc # Diagonal PCG Solution tic output = pcg(Ns,d,[],[],Ds) toc # Reverse Cutthill-McKee re-ordering tic p = symrcm(Ns); # permutation array Nr = Ns(p,p); # re-ordered problem toc # Re-ordered Solve tic output = Nr\d; #answer is stored in a permuted matrix indexed by 'p' toc Another advantage to the conjugate gradient methods is concurrent form of the solution within each iteration (parallel processing). Best regards |
Re: OPR-computation-related linear algebra problem
New Code, based on what James put up (I just added some disp's so that the results would be more clear. disps are outside of tics and tocs. I did not find any bugs though had to change #'s to %'s.
Code:
clcCode:
Loading Data... |
Re: OPR-computation-related linear algebra problem
Quote:
MATLAB 2012b: Code:
>> N = dlmread('N.dat');Code:
octave:1> N = dlmread('N.dat'); |
Re: OPR-computation-related linear algebra problem
Quote:
Quote:
Just installed SciLab 5.4.1 with Intel Math Kernel Library 10.3 on a 7-year-old desktop PC:
Code:
-->stacksize(70000000); |
Re: OPR-computation-related linear algebra problem
2 Attachment(s)
Quote:
ryan.exe 2509 N.dat d.dat x.dat So I dug up an old piece of code I wrote back in 1990 with a Cholesky factoring algorithm in it1 and modified it for this application and ran it. It took about 22.5 seconds: Nx=d build 5/26/2013 921p If your code took only 3 seconds to run on your machine, but 80 on mine, I'm wondering what the Rice algorithm would do on your machine. 1John Rischard Rice, Numerical Methods, Software, and Analysis, 1983, Page 139 (see attachments) |
Re: OPR-computation-related linear algebra problem
Quote:
MATLAB R2012b: Code:
>> tic ; N = dlmread('N.dat'); tocGNU Octave 3.6.2: Code:
octave:1> tic ; N = dlmread('N.dat'); tocScilab 5.3.3: Code:
-->stacksize(70000000);FreeMat 4.0: Code:
--> tic ; N = dlmread('N.dat'); toc |
Re: OPR-computation-related linear algebra problem
Quote:
Ax~b (overdetermined system) ATAx = ATb (normal equations; least squares solution of Ax~b) Let N=ATA and d=ATb (N is symmetric positive definite) then Nx=d A is the binary design matrix of alliances and b is the vector of alliance scores for all the qual matches for the 2013 season, including 75 Regionals and Districts, plus MAR and MSC, plus Archi, Curie, Galileo, and Newton. So solving Nx=d for x is solving for 2013 World OPR. |
Re: OPR-computation-related linear algebra problem
1 Attachment(s)
Hi Ether,
Quote:
Quote:
Makes me wonder what you may have done better in your coding of the algorithm. EDIT: Changing the order of the summations got me down to 2.68 and changing to in-place computation like your code got me to 2.58. Beyond that, any improvements would seem to be in the way the Pascal compiler is generating code. Best, |
Re: OPR-computation-related linear algebra problem
1 Attachment(s)
Quote:
|
Re: OPR-computation-related linear algebra problem
1 Attachment(s)
Finally had time to speak with the math guys.
The built-in LV linear algebra I was using links to an older version of Intel's MKL, but if I had used the SPD option on the solver it would indeed have been faster than the general version. There is a toolkit called "Multicore Analysis and Sparse Matrix Toolkit", and they ran the numbers using that tool as well. Due to a newer version of MKL, the general solver is much faster. The right column converts the matrix into sparse form and uses a sparse solver. Greg McKaskle |
Re: OPR-computation-related linear algebra problem
Quote:
|
Re: OPR-computation-related linear algebra problem
Yes, they are in milliseconds. SPD stands for symmetric positive definite, column three enables the algorithms to utilize more than one core -- though this doesn't seem to help that much.
Greg McKaskle |
Re: OPR-computation-related linear algebra problem
I did the computation on this computer using a slightly modified version of DMetalKong's Python code. Python 2.7.5 SciPy 0.12.0 NumPy 1.7.1 Code:
>>> import numpyPerhaps there's an MKL for Python I need to install? |
| All times are GMT -5. The time now is 05:08. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi