public static double [] lowerSolve(double [][] matrix, double [] vector, double diag){
		int	dimension, i;
		double [] out = new double [vector.length];
		if(matrix.length<matrix[0].length)
			dimension = matrix.length;
		else
			dimension=matrix[0].length;
		if ( vector.length < dimension ){
			System.out.println("error in LSolve, problem with vector length");
			System.exit(0);
		}
		if (out.length < dimension )
			out = new double [matrix.length];
		double [][] mat_ent = matrix;
		double [] vector_ent = vector;	
		double [] out_ent = out;
		for ( i=0; i<dimension; i++ ){
			if ( vector_ent[i] != 0.0 )
			    break;
			else
			    out_ent[i] = 0.0;
		}
		int i_lim = i;
		for (  ; i<dimension; i++ ){
			double sum = vector_ent[i];
			for ( int j=i_lim; j<i; j++ ){
				sum -= mat_ent[i][j]*out_ent[j];
			}
			if ( diag==0.0 ){
				if ( mat_ent[i][i]==0.0 ){
					System.out.println("error in LSolve, error in matrix");
					System.exit(0);
				}
				else
					out_ent[i] = sum/mat_ent[i][i];
			}
			else
				out_ent[i] = sum/diag;
		}
		return out;
	}