#!/usr/bin/python -Wall # ================================================================ # John Kerl # kerl.john.r@gmail.com # 2008-02-06 # ================================================================ # This software is released under the terms of the GNU GPL. # Please see LICENSE.txt in the same directory as this file. # ================================================================ from __future__ import division # 1/2 = 0.5, not 0. import sys from sackmat_m import * # ---------------------------------------------------------------- argc = len(sys.argv) if (argc == 1): A = sackmat([ [ -2, 1, 0, 0, 0, 0, 0, 1], [ 1, -2, 1, 0, 0, 0, 0, 0], [ 0, 1, -2, 1, 0, 0, 0, 0], [ 0, 0, 1, -2, 1, 0, 0, 0], [ 0, 0, 0, 1, -2, 1, 0, 0], [ 0, 0, 0, 0, 1, -2, 1, 0], [ 0, 0, 0, 0, 0, 1, -2, 1], [ 1, 0, 0, 0, 0, 0, 1, -2]]) elif (argc == 2): file_name = sys.argv[1] A = read_matrix(float, file_name) else: print >> sys.stderr, "Usage: %s [file name].\n" % (sys.argv[0]) print >> sys.stderr, "Use \"-\" as file name if input is stdin." sys.exit(1) # ---------------------------------------------------------------- nr = A.square_dim() [L, V] = rs_eigensystem(A) for j in range(0, nr): ell = L[j] v = V.get_column(j) Av = A*v ellv = vecsmul(v, ell) diff = vecsub(Av, ellv) print "ell: ",; print_row_vector([ell]) print "v: ",; print_row_vector(v) print "A v: ",; print_row_vector(Av) print "ell v: ",; print_row_vector(ellv) print "Diff: ",; print_row_vector(diff) print