#include #include "matrix.h" #include "complex.h" using namespace std; int main(int argc, char** argv) { /* Beispiel: Matrix(3, 5) m n h w 0 1 2 3 4 5 6 7 8 9 => get(1,2) 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 0 1 2 3 4 ^ | 1*5 + 2 i*w + j */ Matrix m35(3,5); m35.setEntry(0,0, 0); m35.setEntry(0,1, 1); m35.setEntry(0,2, 2); m35.setEntry(0,3, 3); m35.setEntry(0,4, 4); m35.setEntry(1,0, 5); m35.setEntry(1,1, 6); m35.setEntry(1,2, 7); m35.setEntry(1,3, 8); m35.setEntry(1,4, 9); m35.setEntry(2,0, 10); m35.setEntry(2,1, 11); m35.setEntry(2,2, 12); m35.setEntry(2,3, 13); m35.setEntry(2,4, 14); Matrix m23(2,3); m23.setEntry(0,0, 1); m23.setEntry(0,1, 2); m23.setEntry(0,2, 3); m23.setEntry(1,0, 4); m23.setEntry(1,1, 5); m23.setEntry(1,2, 6); cout << "Teste Vergleichsoperator (Programm sollte jetzt auf keinen Fall stoppen): "< m23_leer(2,3); m23_leer.setEntry(0,0, 0); if (m23 == m23_leer) { cout << "Vergleichsoperator failed!"< m23_bak(m23); if (m23_bak == m23) { cout << "Copykonstruktor OK!"< m23_2(2,3); m23_2 = m23_bak; if (m23_bak == m23_2) { cout << "Zuweisungsoperator OK!"< m32(3,2); m32.setEntry(0,0, 6); m32.setEntry(0,1, -1); m32.setEntry(1,0, 3); m32.setEntry(1,1, 2); m32.setEntry(2,0, 0); m32.setEntry(2,1, -3); Matrix m32_bak(m32); Matrix mult_erg(2,2); mult_erg.setEntry(0,0, 12.0); mult_erg.setEntry(0,1, -6.0); mult_erg.setEntry(1,0, 39.0); mult_erg.setEntry(1,1, -12.0); Matrix mult_erg_bak(mult_erg); cout << "Teste Matrixmultiplikation: "< skal_erg(2,2); skal_erg.setEntry(0,0, 24.0); skal_erg.setEntry(0,1, -12.0); skal_erg.setEntry(1,0, 78.0); skal_erg.setEntry(1,1, -24.0); cout << "Teste Skalarmultiplikation: "<" < c32(3,2); c32.setEntry(0,0, *(new Complex(1,1))); c32.setEntry(0,1, *(new Complex(123,2))); c32.setEntry(1,0, *(new Complex(3,3))); c32.setEntry(1,1, *(new Complex(4,4))); c32.setEntry(2,0, *(new Complex(5,5))); c32.setEntry(2,1, *(new Complex(6,6))); Matrix c23(2,3); c23.setEntry(0,0, *(new Complex(1,1))); c23.setEntry(0,2, *(new Complex(321,2))); c23.setEntry(1,0, *(new Complex(3,3))); c23.setEntry(1,1, *(new Complex(4,4))); c23.setEntry(1,2, *(new Complex(5,5))); Matrix c_erg(2,2); c_erg.setEntry(0,0, *(new Complex(1595,1617))); c_erg.setEntry(0,1, *(new Complex(2035,2063))); c_erg.setEntry(1,0, *(new Complex(0,80))); c_erg.setEntry(1,1, *(new Complex(363,467))); Matrix m3 = (c23 * c32); if (m3 == c_erg) { cout << "Very Nice ;)" << endl;; } else { cout << "Error: Komplexe Zahlen sind wohl zu komplex :-P" << endl;; return -1; } return 0; }