Пример #1
0
 def test_chi_vectorized(self):
     """This function checks the return type of this function."""
     n = 8
     N = 2**int(n / 2)
     s = random_input(n)
     inputs = random_inputs(n, N)
     chi_arr = chi_vectorized(s, inputs)
     self.assertEqual(len(chi_arr), N,
                      'The array must contain {0} arrays.'.format(N))
     self.assertEqual(chi_arr.dtype, BIT_TYPE,
                      'The array must be of type {0}'.format(BIT_TYPE))
Пример #2
0
 def eval(self, challenges):
     """
     Evaluates a given array of inputs.
     :param challenges: array of int shape(N,n)
                    {-1,1}-valued inputs to be evaluated.
     :return: array of float
              real valued responses
     """
     vals = np.array([
         coefficient.val * tools.chi_vectorized(coefficient.s, challenges)
         for coefficient in self.fourier_coefficients
     ]).T
     return np.sum(vals, axis=1)
Пример #3
0
 def eval(self, inputs):
     vals = np.array(
         [coefficient.val * tools.chi_vectorized(coefficient.s, inputs)
          for coefficient in self.fourier_coefficients]
     ).T
     return np.sum(vals, axis=1)