C/C++ Least Squares source code in C++?

AI Thread Summary
The discussion revolves around finding a simple and fast least squares solver in C++. Users express a need for code that is easier to modify than LAPACK++, particularly for implementing regularization. A suggestion is made to refer to "Numerical Recipes in C," specifically Chapter 15, which contains relevant code snippets. Additionally, there is a request for algorithmic pseudocode for least squares to facilitate custom code creation. The normal equations method is mentioned, but concerns arise regarding its modification for regularization. Users also encounter issues with the Levenberg-Marquardt source code from "Numerical Recipes in C," specifically needing the gaussj function, which is reportedly inaccessible due to a damaged file. The search for alternative sources for the gaussj function code is highlighted.
SirTristan
Messages
12
Reaction score
0
Does anyone know where to find source code for a simple and fast least squares solver written purely in C++?
 
Technology news on Phys.org
try the C++ version of LAPACK
 
I actually already have LAPACK++ installed, however it's really pretty complicated. I'd like some simpler code that I can modify, for instance to implement regularization.
 
you can find some code snippet in "Numerical Recipes in C book On-Line!"

http://www.fizyka.umk.pl/nrbook/bookcpdf.html

and they are in Chapter 15.

Good luck.
 
Last edited by a moderator:
Thank you, that might be helpful.

Anyone know of algorithmic pseudocode for least squares anywhere, that I myself could use to create code? A http://en.wikipedia.org/wiki/Linear_regression#Example" can be estimated by solving for the (XTX)B=XTy normal equations, but that seems to be different than the decomposition and other approaches I've read about; and also I don't know how I'd be able to modify these normal equations for regularization purposes, as I don't see how the RSS can be modified. What I'm looking for is more of an iterative procedure.
 
Last edited by a moderator:
I'm having a problem trying to use the Levenberg-Marquardt source code from Numerical Recipes in C. The code requires the gaussj(float**, int, float**, int) function, and according to:
http://www.fizyka.umk.pl/nrbook/c0-2.pdf

That is found in section 2.1. However, the http://www.fizyka.umk.pl/nrbook/bookcpdf.html" gives a "file is damaged and could not be repaired" error when trying to open it. Does anyone know where I could find the code for this same gaussj() function? Thanks :smile:
 
Last edited by a moderator:
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
39
Views
319
Replies
2
Views
2K
Replies
1
Views
2K
Replies
30
Views
6K
Replies
1
Views
3K
Replies
2
Views
1K
Replies
1
Views
2K
Back
Top