Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

least_squares Namespace Reference

Typedefs

typedef Vx::value_type T

Functions

template<class T >
void invert (M(T)&m)
 Invert a matrix, in-place, using Gauss-Jordan elimination.
template void invert (M(float)&m)
template void invert (M(double)&m)
template<class T >
 V (T) linearFit(const M(T)&x
 Returns parameters 'a' via ordinary least squares such that y = x·a.
template V (float) linearFit(const M(float)&x
template V (double) linearFit(const M(double)&x
template<class Vx , class Vy >
 V (typename Vx::value_type) polyFit(size_t degree
 Returns fit 'a' of degree powers of x: y = [ 1 x .. xⁿ ] · a.
const Vx const Vy &y if (degree >0)
 if (y.size()< degree)
 M (T) xn(V(T)(1
return linearFit (xn, V(T)(&y[0], N))

Variables

const Vx & x
const Vx const Vy & y
const size_t N = y.size()
 degree

Detailed Description

Least Squares Solver by Ethan Tira-Thompson, © 2011

Solves linear systems using Ordinary Least Squares.

Provides the namespace 'least_squares'.

There are two solver functions:

linearFit(x,y) Returns the parameters 'a' such that y = x·a minimizes squared error. x should be a valarray< valarray<T> >, where each x[i] is a column of data with length matching that of the valarray y.

polyFit(degree,x,y) Performs a polynomial fit of degree n: y = [ 1 x .. xⁿ ] · a given x and y (as vector or valarray) Results will be in order of increasing power (i.e. index 0 is constant term, 1 is linear term, etc.)

Additionally, there are two helper functions:

polyApply(poly,x) Computes the polynomial of 'x' given polynomial terms 'poly'. These arguments can be either vector or valarray.

invert(x) Inverts a square valarray matrix 'x', overwriting results in-place. Throws std::underflow_error if the matrix is deficient.

TODO: does not handle degenerate/low-rank conditions very well. Ideally, the fit functions should handle internally instead of allowing invert()'s std::underflow_error to pass through

LICENSE: least_squares is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, waiving any requirement to distribute the license document itself.

least_squares is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public License for more details.


Typedef Documentation

typedef Vx::value_type least_squares::T

Definition at line 119 of file least_squares.h.


Function Documentation

least_squares::if (  ) 

Definition at line 115 of file least_squares.h.

least_squares::if ( degree  ,
 
)
template void least_squares::invert ( M(double)&  m  ) 
template void least_squares::invert ( M(float)&  m  ) 
template<class T >
void least_squares::invert ( M(T)&  m  ) 

Invert a matrix, in-place, using Gauss-Jordan elimination.

Throws std::underflow_error if the matrix is deficient.

return least_squares::linearFit ( xn  ,
V(T)&[0],  N 
)
least_squares::M (  ) 
template<class Vx , class Vy >
least_squares::V ( typename Vx::value_type   ) 

Returns fit 'a' of degree powers of x: y = [ 1 x .. xⁿ ] · a.

Computes the polynomial of x given terms from poly.

Accepts vector or valarray... results will be in order of increasing power (i.e. 0 is constant term, 1 is linear term, etc.)

TODO: does not handle degenerate/low-rank conditions. Ideally, this should be handled internally instead of allowing invert()'s std::underflow_error to pass through.

Accepts either vector and valarray arguments... poly terms should be in order of increasing degree à la polyFit()

template const least_squares::V ( double   )  const
template const least_squares::V ( float   )  const
template<class T >
const least_squares::V (  )  const

Returns parameters 'a' via ordinary least squares such that y = x·a.

Each element of x should be a valarray with length matching that of y. Will then compute invert(x' * x) * x' * y to find the fit.

TODO: does not handle degenerate/low-rank conditions. Ideally, this should be handled internally instead of allowing invert()'s std::underflow_error to pass through.

Definition at line 71 of file least_squares.cc.


Variable Documentation

Definition at line 121 of file least_squares.h.

least_squares::N = y.size()

Definition at line 120 of file least_squares.h.

Referenced by fmat::abs(), fmat::Row< N, R >::abs(), fmat::Column< 2, float >::abs(), fmat::SubVector< H, R >::abs(), CBracketGrasperPredicate< N >::admissible(), fmat::Row< N, R >::apply(), fmat::Column< 2, float >::apply(), fmat::SubVector< H, R >::apply(), BoundingBox< 3 >::BoundingBox(), CBracketGrasperPredicate< N >::CBracketGrasperPredicate(), GJK::collides(), BoundingBox< 3 >::collides(), RRTNode3DR< N >::CollisionChecker::CollisionChecker(), RRTNode2DR< N >::CollisionChecker::CollisionChecker(), fmat::Column< 2, float >::Column(), RRTNode3DR< N >::distance(), RRTNode2DR< N >::distance(), fmat::dotProduct(), fmat::Row< N, R >::exportTo(), fmat::Column< 2, float >::exportTo(), fmat::SubVector< H, R >::exportTo(), fmat::Row< N, R >::fmt(), fmat::Column< 2, float >::fmt(), fmat::SubVector< H, R >::fmt(), RRTNode3DR< N >::generateSample(), RRTNode2DR< N >::generateSample(), BoundingBox< 3 >::getCorner(), BoundingBox< 3 >::getRandom(), CBracketGrasperPredicate< N >::gripperPosition(), fmat::Row< N, R >::importFrom(), fmat::Column< 2, float >::importFrom(), fmat::SubVector< H, R >::importFrom(), RRTNode3DR< N >::interpolate(), RRTNode2DR< N >::interpolate(), fmat::Row< N, R >::map(), fmat::Column< 2, float >::map(), fmat::SubVector< H, R >::map(), fmat::Row< N, R >::max(), fmat::Column< 2, float >::max(), fmat::SubVector< H, R >::max(), fmat::Row< N, R >::maximize(), fmat::Column< 2, float >::maximize(), fmat::SubVector< H, R >::maximize(), fmat::Row< N, R >::min(), fmat::Column< 2, float >::min(), fmat::SubVector< H, R >::min(), fmat::Row< N, R >::minimize(), fmat::Column< 2, float >::minimize(), fmat::SubVector< H, R >::minimize(), fmat::Row< N, R >::norm(), fmat::Column< 2, float >::norm(), fmat::SubVector< H, R >::norm(), fmat::Row< N, R >::operator!=(), fmat::Column< 2, float >::operator!=(), fmat::SubVector< H, R >::operator!=(), fmat::TransformT< R >::operator*(), fmat::Row< N, R >::operator*=(), fmat::Column< 2, float >::operator*=(), fmat::SubVector< H, R >::operator*=(), fmat::Row< N, R >::operator+=(), fmat::Column< 2, float >::operator+=(), fmat::SubVector< H, R >::operator+=(), fmat::Row< N, R >::operator-(), fmat::Column< 2, float >::operator-(), fmat::SubVector< H, R >::operator-(), fmat::Row< N, R >::operator-=(), fmat::Column< 2, float >::operator-=(), fmat::SubVector< H, R >::operator-=(), fmat::Row< N, R >::operator/=(), fmat::Column< 2, float >::operator/=(), fmat::SubVector< H, R >::operator/=(), fmat::Row< N, R >::operator<(), fmat::Column< 2, float >::operator<(), fmat::SubVector< H, R >::operator<(), fmat::Row< N, R >::operator<<(), fmat::Column< 2, float >::operator<<(), fmat::SubVector< H, R >::operator<<(), fmat::Row< N, R >::operator=(), fmat::Column< 2, float >::operator=(), fmat::SubVector< H, R >::operator=(), fmat::Row< N, R >::operator==(), fmat::Column< 2, float >::operator==(), fmat::SubVector< H, R >::operator==(), fmat::pack(), GJK::processTriangle(), BoundingBox< 3 >::rotate(), fmat::rotationZN(), fmat::Row< N, R >::Row(), CBracketGrasperPredicate< N >::stateOrien(), fmat::SubVector< H, R >::SubVector(), fmat::Row< N, R >::sum(), fmat::Column< 2, float >::sum(), fmat::SubVector< H, R >::sum(), fmat::Row< N, R >::sumSq(), fmat::Column< 2, float >::sumSq(), fmat::SubVector< H, R >::sumSq(), RRTNode3DR< N >::toString(), RRTNode2DR< N >::toString(), fmat::Row< N, R >::transpose(), fmat::Column< 2, float >::transpose(), and fmat::SubVector< H, R >::transpose().

const Vx & least_squares::x

Definition at line 83 of file least_squares.h.

Referenced by Kinematics::baseToLocal(), RawImage::buildNextLayer(), LedEngine::calcCycle(), InterleavedYUVGenerator::calcImage(), CMVision::CheckRuns(), SiftMatch::computeBoundingBox(), VL::Sift::computeKeypointDescriptor(), VL::Sift::computeKeypointOrientations(), IKThreeLink::computeSecondLinkRevolute(), VL::Detail::copyAndDownsample(), VL::Detail::copyAndUpsampleRows(), ListMemBuf< T_t, MAX, idx_t >::countb(), ListMemBuf< T_t, MAX, idx_t >::countf(), LoadSave::decode(), VL::Sift::detectKeypoints(), DualCoding::ShapeSLAMParticleEvaluator::determineDeletions(), VisualTargetCloseTrans::doEvent(), SmoothCompareTrans< T >::doEvent(), DualCoding::Pilot::PushObjectMachine::AdjustPush::doStart(), DualCoding::Pilot::PushObjectMachine::FetchObj::doStart(), BufferedImageGenerator::downsampleImage(), DRanNormalTail(), DRanNormalZig(), DRanNormalZig32(), DRanNormalZig32Vec(), DRanNormalZigVec(), PGMImg::drawKeypoint(), PGMImg::drawLine(), Graphics::drawLine(), LoadSave::encode(), CMVision::EncodeRuns(), CMVision::EncodeRunsUseEdges(), fmat::Matrix< 4, 2 >::exportTo(), fmat::SubMatrix< H, W, R >::exportTo(), fmat::SubVector< H, R >::exportTo(), fmat::Matrix< 4, 2 >::exportToNewmat(), fmat::SubMatrix< H, W, R >::exportToNewmat(), AprilTags::TagDetector::extractTags(), plist::Angle::get(), AprilTags::FloatImage::get(), EllipsoidObstacle::get2Support(), Wireless::getIPAddress(), Kodu::VisualNavErrMonTask::getMapBuilderRequest(), EllipticalObstacle::getOrientation(), SineMC::getPhase(), EllipticalObstacle::getPointOnEdge(), LoadSave::getSerializedSize(), EllipsoidObstacle::getSupport(), EllipticalObstacle::getSupport(), GaitedFootsteps::State::hash(), debuget::hexout(), fmat::Matrix< 4, 2 >::importFrom(), fmat::SubMatrix< H, W, R >::importFrom(), fmat::Matrix< 4, 2 >::importFromNewmat(), fmat::SubMatrix< H, W, R >::importFromNewmat(), OpticalFlow::initializePositions(), fmat::invert(), DualCoding::MapBuilder::isBadGazePoint(), OpticalFlow::iterativeLucasKanade(), AprilTags::Gridder< T >::Iterator::Iterator(), ListMemBuf< T_t, MAX, idx_t >::ListMemBuf(), RLEGenerator::loadBuffer(), AprilTags::GLine2D::lsqFitXYW(), EventBase::makeClassTypeID(), MotionManager::MotionManager(), fmat::fmat_internal::mvops< M, V >::multiply(), fmat::fmat_internal::mmops< T1, T2 >::multiply(), fmat::SubVector< H, R >::norm(), fmat::SubVector< H, R >::operator<(), fmat::operator<<(), fmat::SubVector< H, R >::operator<<(), operator>>(), RawImage::printImage(), RawCameraGenerator::reconstructImage(), WaypointWalkControl::refresh(), CMVision::RmapToRgb(), BoundingBox< 3 >::rotate(), GreedySampler::sample(), RLEGenerator::saveBuffer(), ArmController::sendReachablePoints(), plist::RGBColor< T >::set(), plist::NamedEnumeration< shutter_speeds >::set(), AprilTags::FloatImage::set(), MotionSequenceEngine::setOutputCmd(), HeadPointerMC::setWeight(), siftdriver(), RawImage::spatialGradientMatrix(), fmat::SubVector< H, R >::sumSq(), and SineMC::sync().

const Vx const Vy& least_squares::y

Definition at line 83 of file least_squares.h.

Referenced by Kinematics::baseToLocal(), RawImage::buildNextLayer(), InterleavedYUVGenerator::calcImage(), CMVision::CheckRuns(), SiftMatch::computeBoundingBox(), VL::Sift::computeKeypointDescriptor(), VL::Sift::computeKeypointOrientations(), VL::Detail::copyAndDownsample(), VL::Detail::copyAndUpsampleRows(), image_util::decodePNGToDepth(), VL::Sift::detectKeypoints(), DualCoding::ShapeSLAMParticleEvaluator::determineDeletions(), VisualTargetCloseTrans::doEvent(), DualCoding::Pilot::PushObjectMachine::AdjustPush::doStart(), DualCoding::Pilot::PushObjectMachine::FetchObj::doStart(), dProbN(), DRanNormalTail(), DRanNormalZig32(), DRanNormalZig32Vec(), PGMImg::drawKeypoint(), PGMImg::drawLine(), Graphics::drawLine(), CMVision::EncodeRuns(), CMVision::EncodeRunsUseEdges(), AprilTags::TagDetector::extractTags(), AprilTags::FloatImage::get(), Kodu::VisualNavErrMonTask::getMapBuilderRequest(), GaitedFootsteps::State::hash(), OpticalFlow::initializePositions(), DualCoding::MapBuilder::isBadGazePoint(), OpticalFlow::iterativeLucasKanade(), AprilTags::Gridder< T >::Iterator::Iterator(), RLEGenerator::loadBuffer(), AprilTags::GLine2D::lsqFitXYW(), VL::Sift::prepareGrad(), RawImage::printImage(), RawCameraGenerator::reconstructImage(), WaypointWalkControl::refresh(), CMVision::RmapToRgb(), RawCameraGenerator::saveBuffer(), CDTGenerator::saveBuffer(), BufferedImageGenerator::saveBuffer(), RawCameraGenerator::saveFileStream(), BufferedImageGenerator::saveFileStream(), ArmController::sendReachablePoints(), AprilTags::FloatImage::set(), siftdriver(), IKCalliope::solve(), and RawImage::spatialGradientMatrix().


Tekkotsu v5.1CVS
Generated Mon May 9 04:59:24 2016 by Doxygen 1.6.3