/*------------------------------------------------------------- Copyright (C) 2000 Rolf Backofen, Peter Clote, Sebastian Will. All Rights Reserved. written by Rolf Backofen modified by Sebastian Will Permission to use, copy, modify, and distribute this software and its documentation for NON-COMMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies. THE AUTHOR AND PUBLISHER MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -------------------------------------------------------------*/ /* Liest eine Matrix M und einen Vektor b aus Dateien und loest das Gleichungssystem Mx=b nach x auf. Gibt x aus. die Datei für die Matrix enthalte zunächst die beiden Dimensionen und dann zeilenweise die Matrixdaten die Vektor Datei enthalte zunächst die Vektordimension und dann die Vektordaten die Dimensionen werden also aus den Dateien bestimmt */ #include #include #include #include /* LEDA Libraries */ #include #include main(int argc, char *argv[]) { if (argc != 3) { cout << "Usage: " << argv[0] << " M b" << endl; } else { matrix M; vector b; vector x; ifstream matrfile(argv[1]); ifstream vecfile(argv[2]); /* Einlesen der Martix und des Vektors. */ cout << endl; cout << "Matrix M wird gelesen ... "; matrfile >> M; cout << "DONE. Verwendete Matrix:"; M.print(); cout << "Vektor b wird gelesen ..."; vecfile >> b; cout << "DONE. Verwendeter Vektor:" << endl; b.print(); cout << endl; /* Inverse und Determinante */ /* cout << "Inverse of M:"; */ /* (M.inv()).print(); */ /* cout << endl; */ /* cout << "Determinant of M: " << M.det() << endl; */ /* Lösen der Gleichung Mx=b */ x = M.solve(b); cout << "Lösung der Gleichung Mx=b nach x:" << endl; x.print(); cout << endl; } }