Helper function for creating a RiemannianRelaxation class.
483708
def run_riemannian_relaxation(laplacian, initial_guess,
                              intrinsic_dim, relaxation_kwds):
    """"""
    n, s = initial_guess.shape
    relaxation_kwds = initialize_kwds(relaxation_kwds, n, s, intrinsic_dim)
    if relaxation_kwds['save_init']:
        directory = relaxation_kwds['backup_dir']
        np.save(os.path.join(directory, 'Y0.npy'),initial_guess)
        sp.io.mmwrite(os.path.join(directory, 'L_used.mtx'),
                      sp.sparse.csc_matrix(laplacian))

    lossf = relaxation_kwds['lossf']
    return RiemannianRelaxation.init(lossf, laplacian, initial_guess,
                                     intrinsic_dim, relaxation_kwds)
152287
def eval_jacobian(self, *args, **kwargs):
        
        eval_jac_dict = self.jacobian_model(*args, **kwargs)._asdict()
        # Take zero for component which are not present, happens for Constraints
        jac = [[np.broadcast_to(eval_jac_dict.get(D(var, param), 0),
                                eval_jac_dict[var].shape)
                for param in self.params]
            for var in self
        ]

        # Use numpy to broadcast these arrays together and then stack them along
        # the parameter dimension. We do not include the component direction in
        # this, because the components can have independent shapes.
        for idx, comp in enumerate(jac):
            jac[idx] = np.stack(np.broadcast_arrays(*comp))

        Ans = variabletuple('Ans', self.keys())
        return Ans(*jac)
641217
def Jacobian_re_im(self, pars):
        
        """
        partials = []

        # partials.append(self.dre_dlog10rho0(pars)[:, np.newaxis, :])
        partials.append(self.dre_drho0(pars)[:, np.newaxis])
        partials.append(self.dre_dm(pars))
        # partials.append(self.dre_dlog10tau(pars))
        partials.append(self.dre_dtau(pars))
        partials.append(self.dre_dc(pars))
        # partials.append(self.dim_dlog10rho0(pars)[:, np.newaxis, :])
        partials.append(self.dim_drho0(pars)[:, np.newaxis])
        partials.append(self.dim_dm(pars))
        # partials.append(self.dim_dlog10tau(pars))
        partials.append(self.dim_dtau(pars))
        partials.append(self.dim_dc(pars))

        print('SHAPES')
        for x in partials:
            print(x.shape)

        J = np.concatenate(partials, axis=1)
        return J
585702
def hessian(self, x, y, coeffs, beta, center_x=0, center_y=0):
        
        shapelets = self._createShapelet(coeffs)
        r, phi = param_util.cart2polar(x, y, center=np.array([center_x, center_y]))
        kappa_shapelets=self._kappaShapelets(shapelets, beta)
        gamma1_shapelets, gamma2_shapelets=self._gammaShapelets(shapelets, beta)
        kappa_value=self._shapeletOutput(r, phi, beta, kappa_shapelets)
        gamma1_value=self._shapeletOutput(r, phi, beta, gamma1_shapelets)
        gamma2_value=self._shapeletOutput(r, phi, beta, gamma2_shapelets)
        f_xx = kappa_value + gamma1_value
        f_xy = gamma2_value
        f_yy = kappa_value - gamma1_value
        return f_xx, f_yy, f_xy
401077
private void createSolution( DMatrixRMaj W , DMatrixRMaj U , Vector3D_F64 u ,
								 DMatrixRMaj H ,
								 Se3_F64 se , Vector3D_F64 N )
	{
		CommonOps_DDRM.multTransB(W,U,se.getR());
		GeometryMath_F64.cross(v2,u,N);

		CommonOps_DDRM.subtract(H, se.getR(), tempM);
		GeometryMath_F64.mult(tempM,N,se.getT());
	}
417071
def hessian(self, x, y, amp, sigma_x, sigma_y, center_x = 0, center_y = 0):
        
        f_ = self.function(x, y, amp, sigma_x, sigma_y, center_x, center_y)
        f_xx = f_ * ( (-1./sigma_x**2) + (center_x-x)**2/sigma_x**4 )
        f_yy = f_ * ( (-1./sigma_y**2) + (center_y-y)**2/sigma_y**4 )
        f_xy = f_ * (center_x-x)/sigma_x**2 * (center_y-y)/sigma_y**2
        return f_xx, f_yy, f_xy
896933
def create(lr, epochs, optimizer):
    
    return GenericPhase(
        lr=lr,
        epochs=epochs,
        optimizer_factory=optimizer,
    )
96761
public static <I extends ImageGray<I>, D extends ImageGray<D>>
	GeneralFeatureIntensity<I,D> hessian(HessianBlobIntensity.Type type, Class<D> derivType) {
		return new WrapperHessianBlobIntensity<>(type, derivType);
	}
1168296
def symmetrize(self, method=None, copy=False):
    ''''''
    if copy:
      return SymmEdgePairGraph(self._pairs.copy(),
                               num_vertices=self._num_vertices)
    shape = (self._num_vertices, self._num_vertices)
    flat_inds = np.union1d(np.ravel_multi_index(self._pairs.T, shape),
                           np.ravel_multi_index(self._pairs.T[::-1], shape))
    self._pairs = np.transpose(np.unravel_index(flat_inds, shape))
    return self
687079
def _dK_dR(self, R):
        """"""
        return -self._ns * self._N / R**2 / self._sin_alpha
1269229
def relax_isometry(self):
        """"""
        for ii in range(self.relaxation_kwds['niter']):
            self.H = self.compute_dual_rmetric()

            self.loss = self.rieman_loss()
            self.trace_var.update(ii,self.H,self.Y,self.eta,self.loss)
            self.trace_var.print_report(ii)
            self.trace_var.save_backup(ii)

            self.compute_gradient()

            self.make_optimization_step(first_iter=(ii == 0))

        self.H = self.compute_dual_rmetric()

        self.trace_var.update(-1,self.H,self.Y,self.eta,self.loss)
        self.trace_var.print_report(ii)
        tracevar_path = os.path.join(self.trace_var.backup_dir, 'results.pyc')
        TracingVariable.save(self.trace_var,tracevar_path)
526909
def _JRAxiIntegrand(r,E,L,pot):
    """"""
    return nu.sqrt(2.*(E-potentialAxi(r,pot))-L**2./r**2.)
636848
function QuaternionLinearInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {

	Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer );

}
507198
function computeIntersection(rootRect, targetRect) {
    const left      = Math.max(targetRect.left, rootRect.left);
    const right     = Math.min(targetRect.right, rootRect.right);
    const top       = Math.max(targetRect.top, rootRect.top);
    const bottom    = Math.min(targetRect.bottom, rootRect.bottom);

    const width = right - left;
    const height = bottom - top;

    return createRectangle(left, top, width, height);
}
784751
def beta_r(self, r, kwargs):
        
        if self._type == 'const':
            return self.const_beta(kwargs)
        elif self._type == 'OsipkovMerritt':
            return self.ospikov_meritt(r, kwargs)
        elif self._type == 'Colin':
            return self.colin(r, kwargs)
        elif self._type == 'isotropic':
            return self.isotropic()
        elif self._type == 'radial':
            return self.radial()
        else:
            raise ValueError('anisotropy type %s not supported!' % self._type)
677721
def create(model, trust_region, entropy_coefficient, q_coefficient, max_grad_norm, discount_factor,
           rho_cap=10.0, retrace_rho_cap=1.0, average_model_alpha=0.99, trust_region_delta=1.0):
    
    return AcerPolicyGradient(
        trust_region=trust_region,
        model_factory=model,
        entropy_coefficient=entropy_coefficient,
        q_coefficient=q_coefficient,
        rho_cap=rho_cap,
        retrace_rho_cap=retrace_rho_cap,
        max_grad_norm=max_grad_norm,
        discount_factor=discount_factor,
        average_model_alpha=average_model_alpha,
        trust_region_delta=trust_region_delta
    )
561195
protected void createLinearSystem( List<AssociatedTriple> observations ) {
		int N = observations.size();

		A.reshape(4*N,27);
		A.zero();

		for( int i = 0; i < N; i++ ) {
			AssociatedTriple t = observations.get(i);

			N1.apply(t.p1,p1_norm);
			N2.apply(t.p2,p2_norm);
			N3.apply(t.p3,p3_norm);

			insert(i,0 , p1_norm.x); // tensor 1
			insert(i,1 , p1_norm.y); // tensor 2
			insert(i,2 ,1); // tensor 3
		}
	}