ماتریس اکسپت
جمعه, ۲ آبان ۱۳۹۹، ۰۷:۲۸ ق.ظ
public class Matrix { private int row; private int column; private int[][] elements; public Matrix(int row, int column) { this.row=row; this.column=column; elements=new int[row][column]; //TODO } public Matrix(int length){ this(length,length); //TODO } public Matrix(int[][] elements){ this.elements=elements; for(int i=0;i<elements.length;i++) { column=Math.max(column, elements[i].length); } row=elements.length; //TODO } public int getRow() { return this.row; //TODO } public int getColumn() { return this.column; //TODO } public int[][] getElements() { return this.elements; //TODO } public boolean add(Matrix newMatrix) { if(newMatrix.getRow()==this.getRow()&& newMatrix.getColumn()==this.getColumn()) { // this.elements+=newMatrix; for(int i=0;i<row;i++)///?????????????????? for(int j=0;j<column;j++) elements[i][j]+=newMatrix.elements[i][j]; return true; } return false; //TODO } public void setElement(int i, int j, int value){ elements[i][j]=value; //TODO } public boolean isSquareMatrix() { return (row==column); //TODO } public void toLowerTriangular() { if(isSquareMatrix()) { for(int i=0;i<row;i++) { for(int j=i+1;j<column;j++) elements[i][j]=0; } } //TODO } public void toUpperTriangular() { if(isSquareMatrix()) { for(int i=0;i<row;i++) { for(int j=0;j<i;j++) elements[i][j]=0; } } //TODO } }
۹۹/۰۸/۰۲