in

.NET Opensource

Community for opensource projects by Christoph Rüegg

Possible Bug? Matrix Multiplication wrong result

Last post 04-03-2009 19:50 by Threnodia. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-03-2009 14:44

    Possible Bug? Matrix Multiplication wrong result

    I'm using Math.NET mainly to do some matrix operations, but I got a wrong result with Multiply() one time. Unfortunately, I'm unable to reproduce it with other figures, therefor I post the original ones.

    Using: Math.NET.Iridium-2008.8.16.470, Microsoft Visual Studio 2005 Version 8.0.50727-4200

         Matrix GiT = Gi.Clone();
         GiT.Transpose();
         Matrix GiTG = GiT.Multiply(G);

    where is (copied from Maple)

    Gi[8, 4] = G[8, 4] = [[0, 1, 10697.1947, 1461.7830], [1, 0, 1461.7830, -10697.1947], [0, 1, 8654.9602, -1702.5531], [1, 0, -1702.5531, -8654.9602], [0, 1, 0., 0.], [1, 0, 0., 0.], [0, 1, -8092.7594, -2750.6773], [1, 0, -2750.6773, 8029.7594]]

    GiTG should be (source: Maple and Calculator):

    GiTG[4, 4] =  [[4, 0, -2991.4474, -11322.3955], [0, 4, 11259.3955, -2991.4474], [-2991.4474, 11259.3955, 267432787.4, 173292.67], [-11322.3955, -2991.4474, 173292.67, 266417068.7]]

    but is:

    GiTG[4, 4] = [[4, 0, -2991.4474, -11322.3955], [0, 4, 11322.3955, -2991.4474], [-2991.4474, 11322.3955, 266417068.7, 0], [-11322.3955, -2991.4474, 0, 266417068.7]]

     

    Is there a mistake on my side?

    For more information, please ask or write an email, preferred in german. (I suppose the head of this forum is able to get the address.)

    Thank you for help/clarification.

    Threnodia

  • 04-03-2009 16:43 In reply to

    Re: Possible Bug? Matrix Multiplication wrong result

    Answer

    I can't confirm that, I get the first result (which according to you is verified by Maple). Here my code:

    Matrix Gi = new Matrix(new double[[ {
                    new double[ { 0, 1, 10697.1947, 1461.7830 },
                    new double[ { 1, 0, 1461.7830, -10697.1947 },
                    new double[ { 0, 1, 8654.9602, -1702.5531 },
                    new double[ { 1, 0, -1702.5531, -8654.9602 },
                    new double[ { 0, 1, 0.0, 0.0 },
                    new double[ { 1, 0, 0.0, 0.0 },
                    new double[ { 0, 1, -8092.7594, -2750.6773 },
                    new double[ { 1, 0, -2750.6773, 8029.7594 }
                    });

    Matrix GiT = Gi.Clone();
    GiT.TransposeInplace();
    Matrix GiTGi = GiT.Multiply(Gi);

    I tested it on a local git branch, with a newer code base than on your side. However, although the method name was changed (the older one will remain for now, but marked as obsolete and redirect to TransposeInplace) I don't think i've touched the method body of TransposeInplace. I'll have to check the repository history (and test with the release you used) if the problem remains.

  • 04-03-2009 19:50 In reply to

    Re: Possible Bug? Matrix Multiplication wrong result

    You are perfectly right. The difference came from my mistake.

    Sorry for the disturbance. :-/

Page 1 of 1 (3 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems