# forum.alglib.net

ALGLIB forum
 It is currently Tue Sep 10, 2024 1:39 pm

 All times are UTC

### Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: SKS solverPosted: Mon Mar 20, 2023 9:55 am

Joined: Mon Mar 20, 2023 9:44 am
Posts: 2
Dear all,

I am trying to understand how it works the SKS format. Since I am obtaining incorrect results, I tried first to create a normal NxN sparse matrix, and then convert it to sks format. However, I am still getting incongruous results. Here is the piece of code (C#) that I am using for testing:

alglib.sparsematrix ss = new alglib.sparsematrix();
int nndof = 3;
alglib.sparsecreate(nndof, nndof,out ss);
alglib.sparseset(ss, 0, 0, 1.0);
alglib.sparseset(ss, 1, 1, 20.0);
alglib.sparseset(ss, 2, 2, 10.0);
alglib.sparseset(ss, 1, 2, -10.0);
alglib.sparseset(ss, 2, 1, -10.0);
alglib.sparsesolverreport report2 = new alglib.sparsesolverreport();
double[] force2 = new double[nndof];
force2[2] = -10.0;
double[] disp2 = new double[nndof];
alglib.sparsesolve(ss, force2, out disp2, out report2);
double[] disp3 = new double[nndof];
alglib.sparseconverttosks(ss);
alglib.sparsespdcholeskysolve(ss, true, force2, out disp3, out report2);

Results:
Disp2 = [0, -1, -2] (Correct)
Disp3 = [0, -0.05, -0.1] (Incorrect)

Best regards,
Gabbia

Top

 Post subject: Re: SKS solverPosted: Wed Mar 29, 2023 5:06 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 922
Hi!

The reason is that spdcholeskysolve() family of functions expects its data to be not the matrix itself, but its Cholesky decomposition. That's why it gives wrong result - you passed original matrix which is used as if it was a Cholesky factor.

You should use:
* sparsespdsolvesks to solve SPD system in SKS format, usually low profile
* sparsespdsolve to solve general SPD system
* sparsesolve to solve general nonsymmetric system

Top

 Post subject: Re: SKS solverPosted: Mon Apr 03, 2023 4:08 pm

Joined: Mon Mar 20, 2023 9:44 am
Posts: 2
Many thanks!

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 3 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for: