makemat(n)

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

makemat(n)

Message par compsystems » mar. janv. 29, 2019 10:50 pm

Hi BP, just to bring the matlab style in the makemat function, add please the following

makemat (n) returns a zeros square matrix of dimension (n * n)


makemat(0,s,s); == makemat(s);

Code : Tout sélectionner

hilbert_( s ):={
local h, c, r;
h := makemat(0,s,s);
for c from 1 to s do
    for r from 1 to s do
        h[[r,c]] := 1/(r+c-1);
    end;
end;
return h;
}
or

Code : Tout sélectionner

hilbert_( s ):={
local h, c, r;
h := makemat(s);
for c from 1 to s do
    for r from 1 to s do
        h[[r,c]] := 1/(r+c-1);
    end;
end;
return h;
}
hilbert_( 3 )
[[1,1/2,1/3],
[1/2,1/3,1/4],
[1/3,1/4,1/5]]

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: makemat(n)

Message par parisse » mer. janv. 30, 2019 12:11 pm

Ok, adding makemat(n) as a synonym for matrix(n,n).

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: makemat(n)

Message par compsystems » mer. févr. 06, 2019 7:16 pm

also for the matrix(n) equal to the matrix(n, n) the square matrices are the most used =)

Répondre