Maple -> C translation of solving for square root of a matrix?

Discussion in 'Maple' started by huhua, Mar 26, 2008.

  1. huhua

    huhua Guest

    Hi all,

    I am trying to use Maple -> C translation facility for a special use:

    I need a matrix square root function in C/C++.

    I only need it for 3x3 matrix, so I decide to find some hard-coded piece of
    program, instead of using some numerical library, because then I have to
    learn some new API and how to link and how to use stuff.

    To avoid the trouble, I think a 3x3 hard-coded program is sufficient for me.
    That's to say, given M a 3x3 matrix, I want to find M^(0.5) in C/C++.

    I tried Maple, but it seems strange:

    I gave it a simple 3x3 matrix, and used "MatrixPower" function.

    After half an our or more, it says "output exceed 1000000 lines".

    So I didn't continue, I am afraid that even I get it translated to C/C++, it
    will be a huge piece of the code and actually a mess...

    Any thoughts on that?

    Thanks!
     
    huhua, Mar 26, 2008
    #1
    1. Advertisements

  2. The problem is probably the datatype.

    The following works fine.

    with(LinearAlgebra);
    A:=RandomMatrix(3,outputoptions=[datatype=float[8]]);
    MatrixPower(A,0.5);
    MatrixPower(A,1/2);

    and so does this,

    A:=RandomMatrix(3);
    MatrixPower(evalf(A),1/2);


    Preben Alsholm
     
    Preben Alsholm, Mar 26, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.