This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 655 - Non-negative least squares
Summary: Non-negative least squares
Status: REVIEWNEEDED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Unsupported modules (show other bugs)
Version: unspecified
Hardware: All All
: Normal Feature Request
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.x
  Show dependency treegraph
 
Reported: 2013-09-09 12:26 UTC by Hannes Matuschek
Modified: 2019-12-04 12:36 UTC (History)
3 users (show)



Attachments
NNLS implementation (14.59 KB, text/plain)
2013-09-09 12:26 UTC, Hannes Matuschek
no flags Details

Description Hannes Matuschek 2013-09-09 12:26:20 UTC
Created attachment 380 [details]
NNLS implementation

I implemented the NNLS algorithm [1] for Eigen. It is not perfect yet but I think it could be included into the "unsupported" modules of Eigen. 

One think that is definitely missing is a check that the Scalar type of the system is real as the NNLS problem is only defined on R^N and I do not know how to do this. 

I have tested the code against some simple units test [2] so far and I used it for some larger problems where it produces reasonable results although I have not verified them against some other implementation.

Let me know if I can improve the implementation.

Hannes


[1] "SOLVING LEAST SQUARES PROBLEMS", by 
    Charles L. Lawson and Richard J. Hanson, Prentice-Hall, 1974

[2] http://www.turkupetcentre.net/reports/tpcmod0020_app_a.pdf
Comment 1 Christoph Hertzberg 2014-08-21 11:49:45 UTC
To check if a type is complex, use NumTraits<Scalar>::IsComplex.
You can use it in a static assertion like this:
  EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL)
Comment 2 Hannes Matuschek 2014-08-21 12:27:07 UTC
Thanks for this hint, I have included the assertion. To avoid tracking such changes as attachments her, I created a GIT repository for the code, including some unit tests: https://github.com/hmatuschek/eigen3-nnls .
Comment 3 Jitse Niesen 2014-08-23 16:46:08 UTC
Thanks for your contribution. I haven't looked at it in detail, but NNLS is for me important enough and close enough to linear algebra that I'd like to have it included in Eigen. At a first look, the code looks well written and the algorithm is a standard one, so that is promising.

At the moment, the code is not structured as an unsupported module in Eigen. You can look at <root of Eigen tree>/unsupported/Eigen/AlignedVector3 for fairly simple example, or use any of the other unsupported modules as a template. 

I assume you know that development of Eigen is done using mercurial on bitbucket, but if you prefer to use github that should not be too much of a problem (though we will probably not be able to preserve the history of the GIT repository). I suggest that you structure your repository as a fork of https://github.com/RLovelett/eigen which mirrors our mercurial repository.

The test should go in .../unsupported/tests and follow the framework described at http://eigen.tuxfamily.org/index.php?title=Tests section "Writing unit tests" (or use an existing test file as inspiration). I would also like to see one example of how to solve NNLS included in the documentation.

Any questions, please ask.
Comment 4 Nobody 2019-12-04 12:36:47 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/655.

Note You need to log in before you can comment on or make changes to this bug.