[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Question about solving linear equation with GSL
From: |
Sheng Yu |
Subject: |
Re: [Help-gsl] Question about solving linear equation with GSL |
Date: |
Wed, 7 Jan 2009 00:35:03 -0500 |
Thanks for replying!
Yes, the results are the same. I also tried TNT and JAMA, which claim
to supersed Lapack++. But the running time was even
longer than GSL. Any other suggestions? Thanks!
Yu Sheng
On Tue, Jan 6, 2009 at 5:22 PM, Steven Vancoillie
<address@hidden> wrote:
> On Tuesday 06 January 2009 22:25:17 Sheng Yu wrote:
>> Hi,
>>
>> I'm new to GSL. I'm trying to solve equation Ax=b, using one of the
>> solvers in Linear Algebra pack.
>> A is a 914x914 matrix. It is symmetric and positive definite. I use
>> Cholesky Decomposition to decomposite A first and then
>> solve it. Here is the pseudo code:
>>
>> const size_t N = 914;
>> gsl_matrix *A = gsl_matrix_alloc(N, N);
>> gsl_vector *b = gsl_vector_alloc(N);
>> gsl_vector *x = gsl_vector_alloc(N);
>>
>> // code to initialize A and b
>>
>> gsl_linalg_cholesky_decomp(A);
>> gsl_linalg_cholesky_solve(A, b, x);
>>
>> It takes 0.25 seconds for the code to do Cholesky Decomposition and
>> solve. However, when I do it with Matlab with A\b, it only
>> takes 0.045 seonds (It even does not take advantage of the fact that A
>> is symmetric and positive definite). I'm wondering why
>> Matlab is much faster. Did I do something wrong?
>>
> I don't think GSL is meant to be the fastest code out there, so this is not
> really an issue.
> As long as you get the same results from GSL or matlab I don't think you're
> doing anything wrong.
> If you're looking for speed, you should turn to some optimized linear algebra
> routine like e.g. LAPACK.
>
> grtz
> Steven
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>
>