472,791 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

A fast column based Cholesky factorization in C++ needed

Hi all,

I am currently coding a sparse factorization program for my project. I
intend to make a comparison of the column based method and multifrontal
method in terms of running time, but I am not sure if my implementation of
the column based factorization is doing the method just. So I am looking for
some other source of implementation in C++ to see if there is any possible
optimization that I have missed out. Anyone know of such source code
available? Any reference and link is welcome and would be greatly
appreciated. Thanks.

Thuan Seah
Jul 22 '05 #1
4 2909
Tan Thuan Seah wrote:
I am currently coding a sparse factorization program for my project. I
intend to make a comparison of the column based method and multifrontal
method in terms of running time, but I am not sure if my implementation of
the column based factorization is doing the method just. So I am looking for
some other source of implementation in C++ to see if there is any possible
optimization that I have missed out.
Post your code and we can help you optimise it.
Anyone know of such source code
available?
Try comp.sources.wanted.
Any reference and link is welcome and would be greatly
appreciated. Thanks.


www.google.com
Jul 22 '05 #2
Below is my code. I am not sure how readable is it, hope someone can suggest
something. Thanks.

Thuan Seah
INPUT:
Li The non zero indices for the Cholesky factor
L The storage for the L. On input, it hold the non zero
entries of matrix A and fill in entries has value of 0.0.
col The number of column matrix A has.
void ColFact(vector<vector<int> > &Li, int ncol, vector<vector<Real> > &L) {
/*******Initialization***************************** ********/
// machine epsilon
const double epsilon = FLT_MIN*100.0;
int index=0;
int counter=0;
int *head;
Real Ljk=0.0;
Real Lik=0.0;
Real Lij=0.0;
Real *update;
vector<vector<int> > link;
vector<int>::iterator indexstart;
vector<int>::iterator offset;
vector<int>::iterator valstart;
vector<int>::iterator p1;
vector<int>::iterator p2;
vector<Real>::iterator dp1;
update = new Real[ncol];
head = new int[ncol];
link.reserve(ncol);
vector<int> blank;
blank.clear();
for(int i=0; i<ncol; i++) {
update[i] = 0.0f;
head[i] = 1;
link.push_back(blank);
}
cout << "STAGE 3: NUMERIC FACTORIZATION USING COLUMN SPARSE
FACTORIZATION\n";
/**** End of Initialization************************************ ******/

/****Start of Column factorization***********************************/
// outer loop
for(int j=0; j<ncol; j++) {
// inner loop
for(p1=link[j].begin(); p1!=link[j].end(); ++p1) {
int k = *p1;
counter=head[k];
Ljk = L[k][counter];
counter++;
// update the diagonal
update[j] += Ljk*Ljk;
// cmod(j,k) go through all the off diagonal elements of
Lk
for(p2=Li[k].begin()+head[k]; p2!=Li[k].end(); ++p2) {
// update
update[*p2] += L[k][counter]*Ljk;
counter++;
}
head[k] = head[k]+1;
}
/********** Error detection ***************************/
L[j][0] = L[j][0] - update[j];
if(abs(L[j][0]) < epsilon) {
cout << "ERROR: ONE OF THE DIAGONAL ENTRIES IN L IS ZERO\n";
cout << "PROGRAM EXITING..." << endl;
}
if(L[j][0] < 0.0f) {
cout << "ERROR: DIAGONAL ENTRIES IN L" << j << " IS
NEGATIVE\n";
cout << "PROGRAM EXITING..." << endl;
exit(1);
}
/******* Finalize computation for the column **************/
L[j][0] = sqrt(L[j][0]);
update[j] = 0.0f;
counter=1;
for(p1=Li[j].begin(); p1!=Li[j].end(); ++p1) {
L[j][counter] = (L[j][counter]-update[*p1])/L[j][0];
if(abs(L[j][counter]) > epsilon)
link[*p1].push_back(j);
update[*p1] = 0.0f;
counter++;
}
}
cout << "STAGE 3: NUMERIC FACTORIZATION DONE\n";

/******* End of Column Factorization**********************************/
}
------------ And now a word from our sponsor ------------------
Do your users want the best web-email gateway? Don't let your
customers drift off to free webmail services install your own
web gateway!
-- See http://netwinsite.com/sponsor/sponsor_webmail.htm ----
Jul 22 '05 #3
"Tan Thuan Seah" <u2******@anu.edu.au> wrote in message news:<41********@clarion.carno.net.au>...
Hi all,

I am currently coding a sparse factorization program for my project. I
intend to make a comparison of the column based method and multifrontal
method in terms of running time, but I am not sure if my implementation of
the column based factorization is doing the method just. So I am looking for
some other source of implementation in C++ to see if there is any possible
optimization that I have missed out. Anyone know of such source code
available? Any reference and link is welcome and would be greatly
appreciated. Thanks.


try
http://gams.nist.gov/
and
http://math.nist.gov/
Jul 22 '05 #4
Tan Thuan Seah wrote:
I am currently coding a sparse factorization program for my project.
I intend to make a comparison of the column based method
and multifrontal method in terms of running time,
but I am not sure if my implementation of the column based factorization
is doing the method just.
So I am looking for some other source of implementation in C++
to see if there is any possible optimization that I have missed out.
Anyone know of such source code available?
Any reference and link is welcome and would be greatly appreciated.
Take a look at
The C++ Scalar, Vector, Matrix and Tensor class library

http://www.netwood.net/~edwin/svmtl/
cat svmtl/src/square/Square.ccP

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sir Dom | last post by:
Hey! I'd like implement a cholesky factorization for a 8 CPU SMP. Does anyone have experience with this kind of problem? Any help would be nice! Greets!
19
by: Jerry | last post by:
Hi Folks, Ok, here's my story. I was asked to create a website for the church I attend. I am a complete newbie to creating websites. So, I did the usual -- did a bunch of googling, found...
8
by: silentlights | last post by:
Hi, Is there a possibiliy to improve division or Modulo operations in the following, tmp1 = 123; tmp2 = 123; frame = ((char)((tmp1/100)+48)); // Division tmp1 = (tmp2...
20
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg.,...
2
by: Iain | last post by:
I'd like to have a repeater (like) control which may have 1, 2, 3 or more columns to be decided either at run time or design time (each with a potentially complex layout). As far as I can see, I...
2
by: Jon Lapham | last post by:
I have a table that stores TEXT information. I need query this table to find *exact* matches to the TEXT... no regular expressions, no LIKE queries, etc. The TEXT could be from 1 to 10000+...
3
by: jesper | last post by:
I would like some feedback on this. A while back I was trying my hand at some pathfinding for a small game I was making. I did not know anything about it so I read some stuff and came up with the...
4
by: Dawid Pustulka | last post by:
I`ve a problem. I need to code Cholesky-Crout and I don`t know, why it doesn`t work. Please help Source : // tab and cholesky are global 11 void CholeskyCrout() 12 { 13 cholesky =...
3
by: kelvin.koogan | last post by:
Using C++/CLI but I would imagine C# is the same. What is the fastest to do the following operations 1) Compare two Strings without case-sensitivity. 2) Take a group of objects with 4 string...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.