Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Least Squares source code in C++?

  1. Jul 10, 2008 #1
    Does anyone know where to find source code for a simple and fast least squares solver written purely in C++?
  2. jcsd
  3. Jul 11, 2008 #2
    try the C++ version of LAPACK
  4. Jul 11, 2008 #3
    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.
  5. Jul 13, 2008 #4


    User Avatar

  6. Jul 14, 2008 #5
    Thank you, that might be helpful.

    Anyone know of algorithmic pseudocode for least squares anywhere, that I myself could use to create code? A linear regression 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: Jul 14, 2008
  7. Sep 4, 2008 #6
    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:

    That is found in section 2.1. However, the book's section 2.1 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:
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Least Squares source code in C++?
  1. Least Square Solution (Replies: 2)