Least Squares source code in C++?

Click For Summary

Discussion Overview

The discussion centers around finding source code for a least squares solver in C++, with a focus on simplicity and modifiability. Participants explore various resources, algorithms, and challenges related to implementing least squares methods, including regularization and specific functions from existing numerical libraries.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant inquires about simple and fast least squares solver source code in C++.
  • Another suggests using the C++ version of LAPACK, although it is noted to be complicated.
  • A participant expresses a desire for simpler code that allows for modifications, such as implementing regularization.
  • Reference is made to "Numerical Recipes in C" for code snippets related to least squares, specifically in Chapter 15.
  • There is a request for algorithmic pseudocode for least squares to aid in creating custom code, with mention of the normal equations and concerns about modifying them for regularization.
  • A participant reports difficulty using the Levenberg-Marquardt source code from Numerical Recipes due to a missing function, seeking an alternative source for the required gaussj() function.

Areas of Agreement / Disagreement

Participants have not reached a consensus on a specific source code solution, and multiple approaches and resources are discussed without agreement on a preferred method.

Contextual Notes

Some participants express uncertainty about the applicability of normal equations for regularization and the availability of specific functions from referenced materials.

Who May Find This Useful

Individuals interested in implementing least squares algorithms in C++, particularly those looking for simpler code or algorithmic guidance.

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:

Similar threads

  • · Replies 40 ·
2
Replies
40
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 30 ·
2
Replies
30
Views
7K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K