@Override
	public IMatrix nInvert() {
		/*
		 * inverz se računa kao umnožak inverza determinante matrice i 
		 * transponirane adjungirane matrice početne matrice;
		 * ukoliko je determinanta 0, tada inverz ne postoji i takva matrica
		 * naziva se singularna matrica
		 */
		double determinant = this.determinant();
		if (determinant == 0) {
			throw new IncompatibleOperandException("Matrix is singular.");
		}
		IMatrix cofactorMatrix = new Matrix(this.getRowsCount(), this.getColsCount());
		for (int row = 0; row < this.getRowsCount(); row++) {
			for (int col = 0; col < this.getColsCount(); col++) {
				cofactorMatrix.set(
						row, 
						col, 
						(row+col)%2==0 ? 
								//ako je (i+j)%2 neparno, rezultat množimo s -1
								subMatrix(row, col, true).determinant() : 
									-1*subMatrix(row, col, true).determinant());
			}
		}
		return cofactorMatrix.nTranspose(true).scalarMultiply(1.0/determinant);
	}