/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author LH */ public class Matrix { private double[][] matrixdata; public Matrix(int height, int width) { matrixdata = new double[height][width]; } public double getEntry(int height,int width) { return matrixdata[height-1][width-1]; } public void setEntry(int height,int width,double value) { matrixdata[height-1][width-1]=value; } public int getHeight() { return matrixdata.length; } public int getWidth() { if(getHeight()>0) { return matrixdata[0].length; } return 0;//wenn keine zeilen dann auch keine spalten.... } public Matrix add(Matrix m2) { if(m2.getHeight()==getHeight()&&m2.getWidth()==getWidth()) { int height = getHeight(); int width = getWidth(); int cells = height*width; Matrix o = new Matrix(height,width); for (int i = 0; i < cells; i++) { int row = i/width+1; int col = i%width+1; o.setEntry(row,col, m2.getEntry(row, col)+getEntry(row, col)); } return o; } return null;//keine add mögl } public Matrix multiply(Matrix m2) { if(m2.getHeight()==getWidth()) { int height = getHeight(); int width = m2.getWidth(); Matrix o = new Matrix(height,m2.getWidth()); for (int i = 0; i < height; i++) { for (int j = 0; j