Hallo Leute, habe eine Aufgabe, und zwar soll ich eine symmetrische, quadratische Matrix und einen Vektor erstellen, die Einträge habe ich.
desweitern sollen die Klassen SymMatrix und Vektor über eine Methode zum Setzen und Holen eines Koeffizienten verfügen.
Zum Schluss soll ich die Matrix noch mit dem Vektor multiplizieren.
Bisher habe ich das hier gemacht, bekomme aber keine Ausgabe, was mache ich falsch? Bitte helft mir :(((
public class SymMatrix {
public double [][] Matrix = null;
public double i , j;
public SymMatrix(double [][] Matrix) {
for(int j=1; j< Matrix.length + 1; j++){
for(int i=1; i< Matrix.length + 1; i++){
if (j <= i){
this.Matrix = new double**[j];
}
else{
Matrix**[j] = Matrix [j]**;
}
}
}
}
public double get(int zeile, int spalte) {
return Matrix [zeile][spalte];
}
public void set(int zeile, int spalte, double wert){
this.Matrix [zeile][spalte] = wert;
}
}
import mathe.SymMatrix;
public class Vektor {
public double [][] Vektor = null;
public double [][] Vektor2 = null;
public int i;
public int j ;
public Vektor(double [][] Vektor) {
for(int i=1; i < Vektor.length +1; i++){
this.Vektor = new double **[1];
}
}
public void Vektor2(double [][] Vektor2) {
for(int j=1; j < Vektor2.length +1; j++){
this.Vektor2 = new double **[1] ;
}
}
public double get( int zeile) {
return Vektor [zeile][1];
}
public void set(int zeile, double wert){
this.Vektor [zeile][1] = wert;
}
double multiMatVek(int [][] Vektor, int [][] Vektor2){
for(int i = 0; i < Vektor.length; i++);
{
for(int j = 0; j < Vektor2.length; j++);
{
Vektor2** += this.Matrix**[j]*this.Vektor[j];
}
}
return i;
}
}
import mathe.*;
public class Test {
public static void main(String args[]) {
double[][] Matrix = {
{ 1.0, -1.0, 0.0, 0.0},
{ -1.0, 2.0, -1.0, 0.0},
{ 0.0, -1.0, 2.0, -1.0},
{ 0.0, 0.0, -1.0, 2.0}
};
}
public static void main1(String args[]) {
double[][] Vektor = {
{0.3},
{0.2},
{0.1},
{0.0}
};
}
}