User guide
9.10.10 Arrays of Matrices and Strings
Itispossibletoindexsetsofmatricesorstringsusingthevargetfunction.
Inthisexample,asetofmatrixnamesisassignedtomvec.Thenameyisindexedfrom
mvecandpassedtovargetwhichwillreturntheglobalmatrixy.Thereturnedmatrix
isinvertedandassignedtog:
mvec = { x y z a };
i = 2;
g = inv(varget(mvec[i]));
Thefollowingprocedurecanbeusedtoindexthematricesinmvecmoredirectly:
proc imvec(i);
retp(varget(mvec[i]));
endp;
Thenimvec(i)willequalthematrixwhosenameisinthe ithelementofmvec.
Intheexampleabove,theprocedureimvec()waswrittensothatitalwaysoperateson
thevectormvec.Thefollowingproceduremakesitpossibletopassinthevectorof
namesbeingused:
proc get(array,i);
retp(varget(array[i]));
endp;
Thenget(mvec,3)willreturnthe3rdmatrixlistedinmvec.
proc put(x,array,i);
retp(varput(x,array[i]));
endp;
Andput(x,mvec,3)willassignxtothe3rdmatrixlistedinmvecandreturna1ifsuc-
cessfulora0ifitfails.
9-48
GAUSSUser Guide
Language
Fundamentals










