package jasymca; /* Jasymca - - Symbolic Calculator for Mobile Devices This version is written for J2ME, CLDC 1.1, MIDP 2, JSR 75 or J2SE Copyright (C) 2006 - Helmut Dersch der@hs-furtwangen.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, 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 details. 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /*------------------------------------------------------------*/ // Gauss Elimination // Stöcker, S.392 import java.util.Vector; public class LambdaLINSOLVE extends Lambda{ public Object lambda(Object x) throws ParseException, JasymcaException{ Vector args = getArgs(car(x)); if(args.size()!=2) throw new ParseException("linsolve requires 2 arguments."); Vektor expr = (Vektor)((Algebraic)Jasymca.evalPrefix(args.elementAt(0), true, env)).rat(); Vektor vars = (Vektor)Jasymca.evalPrefix(args.elementAt(1), true, env); if(expr.coord.length != vars.coord.length) throw new ParseException("Number of vars != Number of equations"); Algebraic an[][] = new Algebraic[expr.coord.length][vars.coord.length]; Algebraic cn[] = new Algebraic[vars.coord.length]; for(int i=0; imaxa){ maxa=dummy; pivot=i; } } if(pivot!=k){ for(int j=k;j=0; i--){ Algebraic sum = Zahl.ZERO; for(int j=i+1; j