// Rascal, the Advanced Scientific CALculator // Copyright (C) 2001, Sebastian Ritterbusch (Rascal@Ritterbusch.de) // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more detauls. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // #include #include // Polynomial evaluation valuematrix rpolyeval(const valuepoly &p,double t) { RPolynomial rp(p.N); string err; int i; for(i=0;i0) erg.a[1][0]=iy; else erg.a[1][0]=_double(mid(iy)); erg.a[2][0]=No; erg.a[3][0]=string(RPolyEvalErrMsg(Err)+err); return erg; } #include valuematrix cpolyzero(valuepoly p,valuecomplex t) { CPolynomial cp(p.N); string err; int i; for(i=0;i0 || diam(Im(ci[i]))>0) p.a[i]=valuecomplex(Re(ci[i]),Im(ci[i])); else p.a[i]=valuecomplex(_double(mid(Re(ci[i]))),_double(mid(Im(ci[i])))); erg.a[1][0]=p; erg.a[2][0]=CPolyZeroErrMsg(Err)+err; return erg; } #include valuematrix linsolve(const valuematrix & a,const valuematrix & b) { string err; int n=a.N; if(a.N!=a.M) { err=" Argument matrix not square matrix!"; if(a.Mb.M && b.Nb.N && b.Mb.N && n>b.M) { err=" Argument vector too small!"; if(b.N>b.M && b.Nb.N && b.Mb.N) x=b.a[0][i]; else x=b.a[i][0]; if((x*1.0).isDOUBLE()) B[i+1]=(x*1.0).asDOUBLE(); else { B[i+1]=0; err=" Not all vector entries are real!"; } for(j=0;j0) ev.a[i][0]=X[i+1]; else ev.a[i][0]=_double(mid(X[i+1])); } erg.a[0][0]=ev; erg.a[1][0]=_double(Cond); erg.a[2][0]=LinSolveErrMsg(Err)+err; return erg; } valuematrix boothroyd(int n) { valuematrix A(n,n); int i,j; for(i=0;i valuematrix revsimplex(const valuematrix &a) { valuematrix iA(0,0),ib(0,0),ic(0,0); string err; if((a.N>=a.M && (a.N<3 || !a.a[0][0].isMATRIX() || !a.a[1][0].isMATRIX() || !a.a[2][0].isMATRIX())) ||(a.N=a.M) { iA=a.a[0][0].asMATRIX();ib=a.a[1][0].asMATRIX();ic=a.a[2][0].asMATRIX(); } else { iA=a.a[0][0].asMATRIX();ib=a.a[0][1].asMATRIX();ic=a.a[0][2].asMATRIX(); } int n=iA.N; int m=iA.M; if(ib.M>ib.N) ib=transpose(ib); if(ic.M>ic.N) ic=transpose(ic); if(ib.N valuematrix linopt(const valuematrix &a) { valuematrix iA(0,0),ib(0,0),ic(0,0),iBStart(0,0); string err; if((a.N>=a.M && (a.N<4 || !a.a[0][0].isMATRIX() || !a.a[1][0].isMATRIX() || !a.a[2][0].isMATRIX() || !a.a[3][0].isMATRIX())) ||(a.N=a.M) { iA=a.a[0][0].asMATRIX();ib=a.a[1][0].asMATRIX();ic=a.a[2][0].asMATRIX(); iBStart=a.a[3][0].asMATRIX(); } else { iA=a.a[0][0].asMATRIX();ib=a.a[0][1].asMATRIX();ic=a.a[0][2].asMATRIX(); iBStart=a.a[0][3].asMATRIX(); } int n=iA.N; int m=iA.M; if(ib.M>ib.N) ib=transpose(ib); if(ic.M>ic.N) ic=transpose(ic); if(iBStart.M>iBStart.N) iBStart=transpose(iBStart); if(ib.N