Пример #1
0
 def testCarlenCase(self):
   carl_arr = array([2,1,1,1,2,1,1,1,2]).reshape(3,3)
   result = jacobi_math.jacobi_diagonalize(carl_arr, 10**-6)
   assert_array_almost_equal(array([4,0,0,0,1,0,0,0,1]).reshape(3,3),
       result[1], 5)
   assert_array_almost_equal(carl_arr, reduce(dot, result,
     eye(3)))
Пример #2
0
parser.add_option("-n", "--nummats", dest="num_mats", help="(int) The number of nxn matrices to diagonalize", type="int")
parser.add_option("-p", "--plot", dest="plot", help="Indicates whether or not to plot the data", action="store_true")
parser.add_option("-e", "--error", dest="error", help="The offset at which to stop running the iterations", type="float")
parser.add_option("-f", "--filenamebase", dest="filename_base", help="Prefix to attatch to the output files.")
parser.add_option("-m", "--max", dest="max", help="The maximum element size of the matrix...Elements of the matrix will range from +/- this.",type="int")
(options, args) = parser.parse_args()
filename_base = options.filename_base
filename_end = options.extension
num_mats = options.num_mats
show_plot = options.plot
dim = options.dim
max_mat_elem = options.max
max_offset = options.error

def file_of(i):
  return filename_base + str(i) + filename_end

print "-------JACOBI MATRIX DIAGONALIZATION-------------"
print "Diagonalizing " + str(num_mats) + " randomly generated " +str(dim) + "x"+ str(dim) +" symmetric matrices..."

for i in range(num_mats):
  filename = file_of(i) 
  jrec = jplot.Recorder(filename)
  jmath.jacobi_diagonalize(jmath.random_diagonal_matrix(dim, max_mat_elem), max_offset, jrec.record, jrec.start, jrec.stop)

if show_plot:
  filenames = map(file_of, range(num_mats)) 
  jplotter = jplot.MultiPlotter(filenames)
  jplotter.plot()
  jplotter.show()
Пример #3
0
 def testCarlenCase(self):
     carl_arr = array([2, 1, 1, 1, 2, 1, 1, 1, 2]).reshape(3, 3)
     result = jacobi_math.jacobi_diagonalize(carl_arr, 10**-6)
     assert_array_almost_equal(
         array([4, 0, 0, 0, 1, 0, 0, 0, 1]).reshape(3, 3), result[1], 5)
     assert_array_almost_equal(carl_arr, reduce(dot, result, eye(3)))
Пример #4
0
    type="int")
(options, args) = parser.parse_args()
filename_base = options.filename_base
filename_end = options.extension
num_mats = options.num_mats
show_plot = options.plot
dim = options.dim
max_mat_elem = options.max
max_offset = options.error


def file_of(i):
    return filename_base + str(i) + filename_end


print "-------JACOBI MATRIX DIAGONALIZATION-------------"
print "Diagonalizing " + str(num_mats) + " randomly generated " + str(
    dim) + "x" + str(dim) + " symmetric matrices..."

for i in range(num_mats):
    filename = file_of(i)
    jrec = jplot.Recorder(filename)
    jmath.jacobi_diagonalize(jmath.random_diagonal_matrix(dim, max_mat_elem),
                             max_offset, jrec.record, jrec.start, jrec.stop)

if show_plot:
    filenames = map(file_of, range(num_mats))
    jplotter = jplot.MultiPlotter(filenames)
    jplotter.plot()
    jplotter.show()