Skip to content

symamd is not comparable with OCTAVE/MATLAB #60

@VikasChidananda

Description

@VikasChidananda

I have been trying to convert some code from MATLAB to Julia. But I observe that symamd operation is not very comparable to MATLAB's.
I am pasting the whole code snippet for comparison:

Julia Code

H   =   2;                                 #Height of the container
L   =   5;                                 #Length of the container

nx    =   10;
ny    =   7; 

dx  =   L/(nx-1);                         #Width of space step(x)
dy  =   H/(ny-1);                         #Width of space step(y)
dt   = 0.01

e       =   ones(nx-2);
i       =   ones(ny-2);

Tx      =   spdiagm(-1 => e[1:end-1], 0 => -2*e, 1 => e[1:end-1]);      
Ty      =   spdiagm(-1 => i[1:end-1], 0 => -2*i, 1 => i[1:end-1]);

Tx[1,1] =   -1; 
Tx[end,end]=-1;

Tt      =   kron(Ty/dy^2,   sparse(I, nx-2, nx-2))    +   kron(sparse(I, ny-2, ny-2),   Tx/dx^2);
N       =   (nx-2)*(ny-2)
Tt      =   sparse(I, N, N)     -   dt*Tt/Pe;
pt      =   symamd(Tt);

Output in Julia:

pt = [1, 8, 33, 40, 39, 32, 34, 25, 16, 7, 9, 2, 4, 36, 37, 5, 10, 15, 26, 31, 19, 21, 24, 23, 30, 14, 22, 29, 38, 13, 6, 28, 12, 20, 27, 35, 18, 17, 11, 3]

Output in OCTAVE:

debug> pt
pt =

 Columns 1 through 11:

    1    9    2   10   33   34   25   26   19    4    5

 Columns 12 through 22:

   36   37   21    8   16    7   15   40   39   32   31

 Columns 23 through 33:

   24   23   30   14   22   29   38   13    6   28   12

 Columns 34 through 40:

   20   27   35   18   17   11    3

Any help/suggestion/insight is greatly appreciated,
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions