1

I'm fairly new to using Visual C++ 2010 Express but I'm not new to the basics and I'm trying to figure out how to use an external library to perform boundary constrained least squares optimisation.

To put the problem simply, I want to use linear least squares to find the matrix W from:

X * W = T

where

X is a matrix with 50 columns and 3 rows (50 x 3),

W is a column matrix with 50 elements (1 x 50) and

T is a column matrix with 3 element (1 x 50)

The constraints are on the values of the elements of W - let's call the elements 'w'.

0 <= w <= 1

Doing this in MATLAB is fairly simple but I need to implement this in C++. I've implemented the initial bit of my code for the formulation of the matrices X and T.

Is there any library/function I can use in Visual C++ 2010 Express to accomplish boundary constrained least squares optimisation? I've tried using ALGLIB, LEVMAR and NLOPT.

ALGLIB needs the arrays to be defined in a data type of its own.

LEVMAR has very little info on installation and what function I need to use.

NLOPT doesn't seem to have a function for this. Also, I can't seem to get it to work, even after I've generated a lib file using the instructions given here and linked the lib and source files in VC++.

Can anyone help me out with any suggestions? This is really easy to implement in MATLAB but I'm afraid I need to use C++.

user82582
  • 39
  • 2
  • What do you mean it is easy so solve in matlab? You mean you have a prebacked function? A quick google reviled the documentation for ALGLIB: http://www.alglib.net/translator/man/manual.cpp.html#sub_lsfitlinear Seems mostly straight forward? What is the problem? – rioki Jan 24 '13 at 15:46
  • Yes, but the arrays have to be of the type real_1d_array and real_2d_array and there doesn't seem to be a way to easily convert a normal integer or float array to that data type. – user82582 Jan 24 '13 at 18:33
  • And I forgot to add - yes, in MATLAB there's already a function to do this. – user82582 Jan 24 '13 at 18:48

0 Answers0