Compute the norm^2 w.r.t. to a given scalar product.
434493
def norm_squared(x, Mx=None, inner_product=ip_euclid):
    ''''''
    assert(len(x.shape) == 2)
    if Mx is None:
        rho = inner_product(x, x)
    else:
        assert(len(Mx.shape) == 2)
        rho = inner_product(x, Mx)

    if rho.shape == (1, 1):
        if abs(rho[0, 0].imag) > abs(rho[0, 0])*1e-10 or rho[0, 0].real < 0.0:
            raise InnerProductError(('<x,Mx> = %g. Is the inner product '
                                     'indefinite?') % rho[0, 0])

    return numpy.linalg.norm(rho, 2)
871113
def Norm2(self):
    
    sum = self.x * self.x + self.y * self.y + self.z * self.z
    return math.sqrt(float(sum))
1008427
def rsdl_s(self, Yprev, Y):
        """"""

        return self.rho*np.linalg.norm(self.cnst_AT(self.U))
251908
def norm_array(q):
        
        assert(len(q) == 4)
        return np.sqrt(np.dot(q, q))
383531
def project(v, n):
    
    return v - matmul(v, n) * n / (norm(n) ** 2.0)
530557
def norm_coefs(self):
        """"""
        sum_coefs = self.sum_coefs
        self.ar_coefs /= sum_coefs
        self.ma_coefs /= sum_coefs
1118004
def norm(self) -> bk.BKTensor:
        """"""
        return bk.absolute(bk.inner(self.tensor, self.tensor))
1002440
def _low_dim_sim(self, v, w, normalize=False, Y=None, idx=0):
        """"""

        sim = (1 + np.linalg.norm(v - w) ** 2) ** -1

        if normalize:
            return sim / sum(map(lambda x: x[1], self._knn(idx, Y, high_dim=False)))
        else:
            return sim
908688
def _tf_squared_euclidean(X, Y):
        
        return tf.reduce_sum(tf.pow(tf.subtract(X, Y), 2), axis=1)
909770
def orthonormality(V, ip_B=None):
    
    return norm(numpy.eye(V.shape[1]) - inner(V, V, ip_B=ip_B))
321489
def _compute_value(power, wg):
    """"""
    if power not in wg:
        p1, p2 = power
        # y power
        if p1 == 0:
            yy = wg[(0, -1)]
            wg[power] = numpy.power(yy, p2 / 2).sum() / len(yy)
        # x power
        else:
            xx = wg[(-1, 0)]
            wg[power] = numpy.power(xx, p1 / 2).sum() / len(xx)
    return wg[power]
980677
public static double norm(double[] a) {
    double squaredSum = 0;
    for (double anA : a) {
      squaredSum += anA * anA;
    }
    return Math.sqrt(squaredSum);
  }
271692
def _calc_norm_coeff(h, J, bias_range, quadratic_range, ignored_variables,
                     ignored_interactions):
    """"""

    if ignored_variables is None or ignored_interactions is None:
        raise ValueError('ignored interactions or variables cannot be None')

    def parse_range(r):
        if isinstance(r, Number):
            return -abs(r), abs(r)
        return r

    def min_and_max(iterable):
        if not iterable:
            return 0, 0
        return min(iterable), max(iterable)

    if quadratic_range is None:
        linear_range, quadratic_range = bias_range, bias_range
    else:
        linear_range = bias_range

    lin_range, quad_range = map(parse_range, (linear_range,
                                              quadratic_range))

    lin_min, lin_max = min_and_max([v for k, v in h.items()
                                    if k not in ignored_variables])
    quad_min, quad_max = min_and_max([v for k, v in J.items()
                                      if not check_isin(k,
                                                        ignored_interactions)])

    inv_scalar = max(lin_min / lin_range[0], lin_max / lin_range[1],
                     quad_min / quad_range[0], quad_max / quad_range[1])

    if inv_scalar != 0:
        return 1. / inv_scalar
    else:
        return 1.
236809
def sample_norm(x):
    
    original = x
    # square
    x = x ** 2
    # feature-map-wise sum
    x = torch.sum(x, dim=1)
    # scale by number of feature maps
    x *= 1.0 / original.shape[1]
    x += 10e-8
    x = torch.sqrt(x)
    return original / x.view(-1, 1, x.shape[-1])
396093
function norm(arr, p) {
    var nnorm = 0,
    i = 0;
    // check the p-value of the norm, and set for most common case
    if (isNaN(p)) p = 2;
    // check if multi-dimensional array, and make vector correction
    if (isUsable(arr[0])) arr = arr[0];
    // vector norm
    for (; i < arr.length; i++) {
      nnorm += Math.pow(Math.abs(arr[i]), p);
    }
    return Math.pow(nnorm, 1 / p);
  }
1165405
def _norm(self, x):
        
        return float(np.sqrt(self.inner(x, x).real))
353352
def norm(a, ref1, ref2):
    
    ref = ref1[valid(ref1, ref2)]
    return (a-ref.min())/(ref.max()-ref.min())