Does anyone know how to interpret the permutation vector in GMatrix.LUD()?
I have passed it blindly into GVector.LUDBackSolve() and it appears to work
fine, but I would like to know how to form the permutation matrix P from the
permutation vector generated by GMatrix.LUD().

For example, how does the permutation vector {1.0 1.0 2.0 } imply the
following permutation matrix?
0 1 0
1 0 0
0 0 1
(see full example below)

Thanks much.
Sincerely,
Dave

=======================================

Here is an example...(I don't know how to interpret the { 1, 1, 2 }
permutation vector.  My understanding of a permutation matrix is that it is
an identity matrix with interchanged rows.  I understand that the
permutation vector encodes this row interchange, but I can't figure out how.

original matrix (A):
0.0     -2.0    2.0
1.0     2.0     -1.0
3.0     5.0     -8.0
count=-1

LUD matrix as output from GMatrix.LUD():
1.0     2.0     -1.0
0.0     -2.0    2.0
3.0     0.5     -6.0

LUD matrix (L | U):
1       0       0       |       1.0     2.0     -1.0
0.0     1       0       |       0       -2.0    2.0
3.0     0.5     1       |       0       0       -6.0

Permutation vector:
1.0 1.0 2.0

Since I know that PA = LU and LU =
1.0     2.0     -1.0
0.0     -2.0    2.0
3.0     5.0     -8.0
I can infer that P =
0 1 0
1 0 0
0 0 1
(which is correct, since this is the permutation matrix that permutes A into
LU).

But, how the heck does a permutation vector { 1, 1, 2 } imply the
aforementioned permutation matrix?

FYI, this is the same matrix used at
http://www.cs.ut.ee/~toomas_l/linalg/lin2/node4.html#permutationmatrix for
those who want to see the math behind this example.

=======================================

The code below was used to generate the previous output.

    void jMenuItemGMatrixTest_actionPerformed(ActionEvent e)
    {
        final int SIZE = 3;
        GMatrix matrix = new GMatrix(SIZE, SIZE);
        matrix.setElement(0, 0, 0); // see Note2 above
        matrix.setElement(0, 1, -2);
        matrix.setElement(0, 2, 2);
        matrix.setElement(1, 0, 1);
        matrix.setElement(1, 1, 2);
        matrix.setElement(1, 2, -1);
        matrix.setElement(2, 0, 3);
        matrix.setElement(2, 1, 5);
        matrix.setElement(2, 2, -8);

        System.out.println("original matrix:");
        trace(matrix);

        GMatrix LUD = new GMatrix(SIZE,SIZE);
        GVector permutation = new GVector(SIZE); // see Note1 above
        int count = matrix.LUD(LUD, permutation);
        System.out.println("count=" + count);

        System.out.println("LUD matrix:");
        trace(LUD);

        System.out.println("LUD matrix:");
        traceLUD(LUD);

        System.out.println("Permutation vector:");
        J3DOps.trace(permutation);
    } // end jMenuItemGMatrixTest_actionPerformed()

=======================================

The following description explains what a permutation matrix is (source:
http://www.cs.rochester.edu/u/www/u/pawlicki/PROJECT2.htm).

Permutation Matrix

A permutation matrix is a square matrix with exactly one 1 in each row and
column and zeros elsewhere (i.e. and identity matrix with its rows and
columns permuted). Multiplying a permutation matrix P, by any matrix A will
yield the same A matrix, with rows swapped.

Consider multiplying matrixP x matrixA if defined as follows:

double matrixA[][] = {{1,2,3,4},{4,5,6,7},{7,8,9,10}};

double matrixP[][] = {{1,0,0},{0,0,1},{0,1,0}};

It can be shown that the resultant matrix C will be
{{1,2,3,4},{7,8,9,10},{4,5,6,7}};

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to