# Path: ibench/benchmarks/bench.py
# class Bench:
#     _dtype = np.double
# 
#     def __init__(self, cmd):
#         self.name = self.__class__.__name__
#         self._cmd = cmd
# 
#     def _log(self, message):
#         if self._cmd.args.quiet:
#             return
#         print('%s: %s' % (self.name,message), file=sys.stderr)
# 
#     def _run(self, n):
#         self._make_args(n)
# 
#         # Disable garbage collector
#         gcold = gc.isenabled()
#         gc.disable()
# 
#         times = []
#         for i in range(self._cmd.args.runs):
#             t_start = time.time()
#             self._compute()
#             elapsed = time.time() - t_start
#             times.append(elapsed)
# 
#         if gcold:
#             gc.enable()
# 
#         return times
# 
#     def measure(self, n, args):
#         self._log('')
#         self._log('  N = %d' % n)
# 
#         times = self._run(n)
# 
#         ops = self._ops(n)
#         if args.gflops is False:
#             for elapsed in times:
#                 self._log('  elapsed %f' % (elapsed))
# 
#         else:
#             for elapsed in times:
#                 self._log('  elapsed %f gflops %f' % (elapsed,ops/elapsed))
# 
#         self._summarize(n, times, args)
# 
#     def _summarize(self, n, times, args):
#         t = np.asarray(times)
#         median = np.median(t)
#         ops = self._ops(n)
#         if args.gflops is False:
#             self._cmd.results['runs'].append({'name': self.name,
#                                               'N': n,
#                                               'times': times,
#                                               'stats': {'min': np.amin(t),
#                                                         'max': np.max(t),
#                                                         'median': median}})
#         else:
#             self._log('  gflops %f' % (ops/median))
#             self._cmd.results['runs'].append({'name': self.name,
#                                               'N': n,
#                                               'gflops': ops/median,
#                                               'ops': ops,
#                                               'times': times,
#                                               'stats': {'min': np.amin(t),
#                                                         'max': np.max(t),
#                                                         'median': median}})


import numpy as np
    import numpy.random_intel as rnd
    import numpy.random as rnd
from numpy import log, exp
from .bench import Bench
    from numpy import erf
    from scipy.special import erf
    from numpy import invsqrt

class Blacksch(Bench):
    sizes = {'large': 200000000, 'small': 100000000, 'tiny': 1000000, 'test': 100}

    def _gen_data(self, nopt):
        return (
            rnd.uniform(S0L, S0H, nopt),
            rnd.uniform(XL, XH, nopt),
            rnd.uniform(TL, TH, nopt),
        )

    def _black_scholes (self, nopt, price, strike, t, rate, vol ):
        mr = -rate
        sig_sig_two = vol * vol * 2

        P = price
        S = strike
        T = t

        a = log(P / S)
        b = T * mr

        z = T * sig_sig_two
        c = 0.25 * z
        y = invsqrt(z)

        w1 = (a - b + c) * y
        w2 = (a - b - c) * y

        d1 = 0.5 + 0.5 * erf(w1)

# Path: ibench/benchmarks/bench.py
# class Bench:
#     _dtype = np.double
# 
#     def __init__(self, cmd):
#         self.name = self.__class__.__name__
#         self._cmd = cmd
# 
#     def _log(self, message):
#         if self._cmd.args.quiet:
#             return
#         print('%s: %s' % (self.name,message), file=sys.stderr)
# 
#     def _run(self, n):
#         self._make_args(n)
# 
#         # Disable garbage collector
#         gcold = gc.isenabled()
#         gc.disable()
# 
#         times = []
#         for i in range(self._cmd.args.runs):
#             t_start = time.time()
#             self._compute()
#             elapsed = time.time() - t_start
#             times.append(elapsed)
# 
#         if gcold:
#             gc.enable()
# 
#         return times
# 
#     def measure(self, n, args):
#         self._log('')
#         self._log('  N = %d' % n)
# 
#         times = self._run(n)
# 
#         ops = self._ops(n)
#         if args.gflops is False:
#             for elapsed in times:
#                 self._log('  elapsed %f' % (elapsed))
# 
#         else:
#             for elapsed in times:
#                 self._log('  elapsed %f gflops %f' % (elapsed,ops/elapsed))
# 
#         self._summarize(n, times, args)
# 
#     def _summarize(self, n, times, args):
#         t = np.asarray(times)
#         median = np.median(t)
#         ops = self._ops(n)
#         if args.gflops is False:
#             self._cmd.results['runs'].append({'name': self.name,
#                                               'N': n,
#                                               'times': times,
#                                               'stats': {'min': np.amin(t),
#                                                         'max': np.max(t),
#                                                         'median': median}})
#         else:
#             self._log('  gflops %f' % (ops/median))
#             self._cmd.results['runs'].append({'name': self.name,
#                                               'N': n,
#                                               'gflops': ops/median,
#                                               'ops': ops,
#                                               'times': times,
#                                               'stats': {'min': np.amin(t),
#                                                         'max': np.max(t),
#                                                         'median': median}})


# Path: ibench/benchmarks/blacksch.py
import numpy as np
    import numpy.random_intel as rnd
    import numpy.random as rnd
from numpy import log, exp
from .bench import Bench
    from numpy import erf
    from scipy.special import erf
    from numpy import invsqrt


class Blacksch(Bench):
    sizes = {'large': 200000000, 'small': 100000000, 'tiny': 1000000, 'test': 100}

    def _gen_data(self, nopt):
        return (
            rnd.uniform(S0L, S0H, nopt),
            rnd.uniform(XL, XH, nopt),
            rnd.uniform(TL, TH, nopt),
        )

    def _black_scholes (self, nopt, price, strike, t, rate, vol ):
        mr = -rate
        sig_sig_two = vol * vol * 2

        P = price
        S = strike
        T = t

        a = log(P / S)
        b = T * mr

        z = T * sig_sig_two
        c = 0.25 * z
        y = invsqrt(z)

        w1 = (a - b + c) * y
        w2 = (a - b - c) * y

        d1 = 0.5 + 0.5 * erf(w1)

        d2 = 0.5 + 0.5 * erf(w2)