Skip to content

Commit

Permalink
Doing OLS with QR decomposition in C++ version
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfoose committed Jul 21, 2015
1 parent 74d3ac4 commit 150806b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions freeimodpoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Octave; see the file COPYING. If not, see
// along with Octave; see the file LICENSE. If not, see
// <http://www.gnu.org/licenses/>.
//
// FreeIModPoly: A free software implementation of the Vancouver Raman Algorithm
Expand Down Expand Up @@ -157,8 +157,9 @@ vec FreeIModPoly::CalcPoly(const vec &coefs, const vec &x)
///
vec FreeIModPoly::OrdinaryLeastSquares(const mat &X, const vec &y)
{
return (pinv(X.t() * X) * (X.t() * y));

mat Q, R;
qr(Q, R, X);
return solve(R, Q.t()) * y;
}

///
Expand Down
2 changes: 1 addition & 1 deletion freeimodpoly.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Octave; see the file COPYING. If not, see
// along with Octave; see the file LICENSE. If not, see
// <http://www.gnu.org/licenses/>.
//
// FreeIModPoly: A free software implementation of the Vancouver Raman Algorithm
Expand Down

0 comments on commit 150806b

Please sign in to comment.