This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Gauss-Jordan

Tags: None
(comma "," separated)
pkohut
Registered Member
Posts
5
Karma
0

Gauss-Jordan

Fri Jun 04, 2010 4:15 pm
I'm trying to implement a function that maps a coordinate system to another coordinate system, and it was suggested to use Gauss-Jordan method to do this (they provided me some Lisp code as a working example).

I've tried figuring out how to do this with Eigen, but my knowledge of linear algebra is about nil. Any help would be appreciated.

As an example:
Code: Select all
From coordinate system:
m1 = 1.0, 3.0, 0.0,
     5.0, 7.0, 0.0,
     10.0, 10.0, 1.0;

To coordinate system:
m2 = 11.0, 13.0, 0.0,
     17.0, 19.0, 0.0,
     20.0, 5.0, 1.0;

Resulting mapped coordinate system from m1 to m2 -
Code: Select all
result = -3.25, 4.75, 5.0,
         -4.25, 5.75, -10.0,
          0.0,  0.0,  1.0;
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Gauss-Jordan

Sat Jun 05, 2010 10:34 pm
you just have to solve a linear system of equation m1 * result = m2. For instance you can do:

result = m1.inverse() * m2;

or:

result = m1.lu().solve(m2);

For 3x3 matrices I don't know which option is the fastest.

In both cases you need to #include <Eigen/LU>
pkohut
Registered Member
Posts
5
Karma
0

Re: Gauss-Jordan

Mon Jun 07, 2010 4:51 am
ggael, thanks. Worked like a charm. I'd tried those the other day prior to posting, but had stuffed the data arrays row major and hadn't realized my mistake.
vernal
Registered Member
Posts
37
Karma
0

Re: Gauss-Jordan

Fri Jul 02, 2010 11:38 am
Just out of interest:
I'd favour solution 2 with LU decomposition over solution 1 due to numerical stability. If the matrix is badly conditioned, the inverse will create more numerical issues than the solving via LU decomposition.
Is that view correct or do both solutions exhibit comparable numerical behaviour?


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]