1 | /* |
---|

2 | This file is part of the SLIM-curve package for exponential curve fitting of spectral lifetime data. |
---|

3 | |
---|

4 | Copyright (c) 2010, 2011, Gray Institute University of Oxford & UW-Madison LOCI. |
---|

5 | |
---|

6 | This program is free software: you can redistribute it and/or modify |
---|

7 | it under the terms of the GNU General Public License as published by |
---|

8 | the Free Software Foundation, either version 3 of the License, or |
---|

9 | (at your option) any later version. |
---|

10 | |
---|

11 | This program is distributed in the hope that it will be useful, |
---|

12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|

13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|

14 | GNU General Public License for more details. |
---|

15 | |
---|

16 | You should have received a copy of the GNU General Public License |
---|

17 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|

18 | */ |
---|

19 | |
---|

20 | /* Header file for functions defined in lsqnonneg.c */ |
---|

21 | |
---|

22 | /********************************************************************** |
---|

23 | Function GCI_lsqnonneg |
---|

24 | |
---|

25 | This function solves the non-negative least squares problem: |
---|

26 | minimise |Ax-b| subject to x >= 0 (where |v| is the 2-norm of the |
---|

27 | vector v). |
---|

28 | |
---|

29 | Arguments: A, an m x n matrix, in the form double A[n][m], so |
---|

30 | the columns of A are A[0], A[1], ..., A[n-1] |
---|

31 | b, the m-vector |
---|

32 | |
---|

33 | !!! NB: A and B will both be modified unless preserve is |
---|

34 | !!! non-zero (see below). |
---|

35 | |
---|

36 | x, the solution will be placed here |
---|

37 | m ) the dimensions of A |
---|

38 | n ) |
---|

39 | preserve, copy A and b before solving the problem |
---|

40 | rnorm, (double *) the value of |Ax-b| with the |
---|

41 | determined x if the function was successful or if the |
---|

42 | iteration count was exceeded. This can be NULL. |
---|

43 | lambda, an n-vector which will contain the dual vector |
---|

44 | on completion (that is, the Lagrange multipliers). |
---|

45 | This can be NULL. |
---|

46 | |
---|

47 | On exit: |
---|

48 | The return value will be 0 on success, and negative if |
---|

49 | a problem occurred: |
---|

50 | -1: m > MAX_EQNS or m <= 0 |
---|

51 | -2: n > MAX_VARS or n <= 0 |
---|

52 | -3: iteration count exceeded: more than 3*n iterations |
---|

53 | performed |
---|

54 | -4: memory allocation problems |
---|

55 | |
---|

56 | **********************************************************************/ |
---|

57 | |
---|

58 | int GCI_lsqnonneg(double **A, double *b, double *x, int m, int n, |
---|

59 | int preserve, double *rnorm, double *lambda); |
---|