Ejemplo n.º 1
0
def setUp() :
	rowSize = 0
	colSize = 0
	
	matrixLocation = input("What's the filename of the test file? (please have the file in the same directory as the code)")

	matrix = common.matrix_from_file(matrixLocation)

	return matrix
Ejemplo n.º 2
0
            if j >= i:
                # if not at position pertaining to current x (i.e. a diagonal entry)
                if i != j:
                    d[i] = d[i] - (r[i, j] * d[j])
                elif i == j:
                    x[i] = d[i] / r[i, j]

    return (x, common.error(common.mult_mat(a, x), b))


if __name__ == "__main__":
    invalid = True
    while invalid:
        fname = raw_input("Please enter a filename: ")
        try:
            matrix = common.matrix_from_file(fname)
            invalid = False
        except:
            print "Invalid filename, please try again"

    print "Householder Xsol:"
    result = solve_qr_b_househ(matrix[:, :-1], matrix[:, -1])
    print result[0]
    print "\nHouseholder Error:"
    print result[1]

    print "\nGivens Xsol:"
    result = solve_qr_b_househ(matrix[:, :-1], matrix[:, -1])
    print result[0]
    print "\nGivens Error:"
    print result[1]