Example #1
0
    if options.tb_num:
        akxconfig.threadcounts = [options.tb_num]
    import akx
    print >> sys.stderr, "done"

    if not options.sejits:
        akxobj = akx.AkxObjectPy(matrix)
    else:
        tune_time = time.time()
        akxobj = akx.tune(matrix,
                          options.k,
                          True,
                          show=sys.stdout,
                          use_exp=not (options.i),
                          use_imp=not (options.x))
        tune_time = time.time() - tune_time
        print "tuning time =", tune_time

    import cacg
    for i in xrange(5):
        cg_time = time.time()
        #x = cacg.cg3_ca(akxobj, b, s=options.k, maxiter=options.m, tol=0, show_times=sys.stdout)
        x = cacg.cg3_ca(akxobj, b, s=options.k, maxiter=options.m, tol=0)
        cg_time = time.time() - cg_time
        calc_time += cg_time
        print("time = " + str(cg_time))
residual = (matrix * x) - b
print "|r|^2 =", numpy.dot(residual, residual)
print "gradient =", .5 * numpy.dot(x, residual - b)
print('total calculation time = ' + str(calc_time))
Example #2
0
        calc_time += cg_time
        print("mul_time = " + str(cg_time))
else:
    print >>sys.stderr, "Initializing akx...",
    import akxconfig
    if options.tb_num:
        akxconfig.threadcounts = [options.tb_num]
    import akx
    print >>sys.stderr, "done"

    if not options.sejits:
        akxobj = akx.AkxObjectPy(matrix)
    else:
        tune_time = time.time()
        akxobj = akx.tune(matrix, options.k, True, show=sys.stdout, use_exp=not(options.i), use_imp=not(options.x))
        tune_time = time.time() - tune_time
        print "tuning time =", tune_time

    import cacg
    for i in xrange(5):
        cg_time = time.time()
        #x = cacg.cg3_ca(akxobj, b, s=options.k, maxiter=options.m, tol=0, show_times=sys.stdout)
        x = cacg.cg3_ca(akxobj, b, s=options.k, maxiter=options.m, tol=0)
        cg_time = time.time() - cg_time
        calc_time += cg_time
        print("time = " + str(cg_time))
residual = (matrix * x) - b
print "|r|^2 =", numpy.dot(residual, residual)
print "gradient =", .5 * numpy.dot(x, residual - b)
print('total calculation time = ' + str(calc_time))
Example #3
0
		cg_time = time.time()
		for j in xrange(options.m):
			dummy = matrix * x
		cg_time = time.time() - cg_time
		print "mul_time =", cg_time
else:
	print >>sys.stderr, "Initializing akx...",
	import akxconfig
	if options.tb_num:
		akxconfig.threadcounts = [options.tb_num]
	import akx
	print >>sys.stderr, "done"

	if not options.sejits:
		akxobj = akx.AkxObjectPy(matrix)
	else:
		tune_time = time.time()
		akxobj = akx.tune(matrix, options.k, True, show=sys.stdout, use_exp=not(options.i), use_imp=not(options.x))
		tune_time = time.time() - tune_time
		print "tuning time =", tune_time

	import cacg
	for i in xrange(5):
		cg_time = time.time()
		x = cacg.cg3_ca(akxobj, b, s=options.k, maxiter=options.m, tol=0, show_times=sys.stdout)
		cg_time = time.time() - cg_time
		print "time =", cg_time
residual = (matrix * x) - b
print "|r|^2 =", numpy.dot(residual, residual)
print "gradient =", .5 * numpy.dot(x, residual - b)