// 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // #include #include #include #include #include int showlicence(void) { cout << " Rascal, the Advanced Scientific CALculator" << endl; cout << " Copyright (C) 2001, Sebastian Ritterbusch (Rascal@Ritterbusch.de)" << endl; cout << "" << endl; cout << " This program is free software; you can redistribute it and/or" << endl; cout << " modify it under the terms of the GNU General Public License" << endl; cout << " as published by the Free Software Foundation; either version 2" << endl; cout << " of the License, or (at your option) any later version." << endl; cout << "" << endl; cout << " This program is distributed in the hope that it will be useful," << endl; cout << " but WITHOUT ANY WARRANTY; without even the implied warranty of" << endl; cout << " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" << endl; cout << " GNU General Public License for more details." << endl; cout << "" << endl; cout << " You should have received a copy of the GNU General Public License" << endl; cout << " along with this program; if not, write to the Free Software" << endl; cout << " Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA." << endl; cout << endl; return 0; } string showversion(void) { string b; #ifdef VERSION #ifdef VALUE_CONFIGURATION if(VALUE_CONFIGURATION!=string("full")) b=string("Rascal-")+string(VALUE_CONFIGURATION)+string("-")+string(VERSION); else b=string("Rascal-")+string(VERSION); #else b=string("Rascal-")+string(VERSION); #endif #else b=string("Rascal-undefined"); #endif return b; } string showconfiguration(void) { #ifdef VALUE_CONFIGURATION return string(VALUE_CONFIGURATION); #else return string("custom"); #endif } #ifndef STANDALONE_VALUE #ifndef PARSERvariable #include "../y.tab.h" #endif #include "../symtab.h" #endif int showvariables(void) { #ifdef STANDALONE_VALUE cout << "sorry, show variables not supported in standalone version." << endl; return 1; #else symrec * current; current=sym_table; while(current) { char *p=current->name; int type=current->type; if(type==PARSERvariable && current->var!=value(0)) cout << p << "=" << current->var << endl; current=current->next; } return 0; #endif } int showfunctions(void) { #ifdef STANDALONE_VALUE cout << "sorry, show functions not supported in standalone version." << endl; return 1; #else symrec * current; current=sym_table; while(current) { char *p=current->name; int type=current->type; if(type==PARSERuserfunction) cout << p << current->ivalue.body << endl; else if(type==PARSERprocedure) cout << p << "\t(builtin)" << endl; else if(type==PARSERfunction) cout << p << "(.)\t(builtin)" << endl; else if(type==PARSERfunction2) cout << p << "(.,.)\t(builtin)" << endl; current=current->next; } return 0; #endif } int showmodules(void) { int i; for(i=0;rascal_module_indices[i];i++) { cout << rascal_module_indices[i] << endl; } cout << endl << "Enter 'help ' for more information." << endl; return 0; } int quit_program(void) { exit(0); return 0; } string output(const valuematrix &a) { int i,j; string out("["); for(i=0;i=0 && precision2>=0) { sprintf(prec,"%%%d.%dlg",precision1,precision2); sprintf(buffer,prec,a); } else { int s1=precision1; int s2=precision2; precision2=0; sprintf(prec,"%%%d.%dlg",precision1,precision2); sprintf(buffer,prec,a); string beststring=string(buffer); double bestdistance=fabs(a-stringtodouble(beststring).asDOUBLE()); for(precision2=1;precision2<=-s2;precision2++) { sprintf(prec,"%%%d.%dlg",precision1,precision2); sprintf(buffer,prec,a); double now=fabs(a-stringtodouble(buffer).asDOUBLE()); if(now0)&&(cell(b,2)<=a.M&&cell(b,2)>0)) { if(size(b)<=2) return a(Integer(cell(b,1)).asINTEGER()-1,Integer(cell(b,2)).asINTEGER()-1); valuematrix c(1,size(b).asINTEGER()-2); int i; for(i=1;i<=size(b).asINTEGER()-2;i++) c(0,i-1)=cell(b,i+2); return cell(a(Integer(cell(b,1)).asINTEGER()-1,Integer(cell(b,2)).asINTEGER()-1),c); } else return value(); } valuematrix randommatrix(int i,int j) { int k,l; valuematrix a(i,j); for(k=0;k