int operator()()
        {
            if ( make_preprocessing() )                                                                                 { assert( !"Failed to make preprocessing." );                       return 1; }

            if( make_initialization_preprocessing() )                                                                   { assert( !"Failed to make initialization preprocessing." );        return 1; }

            unknown_parameters = make_unknown_parameters(); if( !unknown_parameters )                                   { assert( !"Failed to make unknown parameters." );                  return 1; }

            fitting_array = make_fitting_array_initial_guess(); if ( fitting_array.size() != unknown_parameters  )      { assert( !"Failed to make initial guess." );                       return 1; }

            max_iteration = make_max_iteration(); if( !max_iteration )                                                  { assert( !"Failed to make max iteration." );                       return 1; }

            eps = make_eps();if( eps < value_type{0} )                                                                  { assert( !"Failed to make eps." );                                 return 1; }

            if ( make_initialization_postprocessing() )                                                                 { assert( !"Failed to make initialization postprocessing." );       return 1; }

            merit_function = make_merit_function(); if( !merit_function )                                               { assert( !"Failed to make merit function." );                      return 1; }

            jacobian_matrix_function.resize( 1, unknown_parameters );
            for ( size_type index = 0; index != unknown_parameters; ++index )
            {
                jacobian_matrix_function[0][index] = make_jacobian_matrix_function( index );
                if ( !jacobian_matrix_function[0][index] )                                                              { assert( "Failed to make jacobian matrix function." );             return 1; }
            }

            hessian_matrix_function.resize( unknown_parameters, unknown_parameters );
            for ( size_type index = 0; index != unknown_parameters; ++index )
                for ( size_type jndex = 0; jndex <= index; ++jndex )
                {
                    hessian_matrix_function[index][jndex] = make_hessian_matrix_function( index, jndex );
                    if ( !hessian_matrix_function[index][jndex] )                                                        { assert( "Failed to make jacobian matrix function." );             return 1; }
                    if ( index != jndex )
                    {
                        hessian_matrix_function[jndex][index] = hessian_matrix_function[index][jndex];
                    }
                }

            if ( make_iteration_preprocessing() )                                                                       { assert( !"Failed to make iteration preprocessing." );             return 1; }

            for ( size_type step_index = 0; step_index != max_iteration; ++step_index )
            {
                if ( make_every_iteration_preprocessing() )                                                             { assert( !"Failed to make every iteration preprocessing." );       return 1; }

                if ( make_iteration() )                                                                                 { assert( !"Failed to make iteration" );                            return 1; }

                if ( ! make_fitting_flag() )                                                                            {                                                        /*eps reached*/break;}

                if ( make_every_iteration_postprocessing() )                                                            { assert( !"Failed to make every iteration postprocessing." );      return 1; }
            }

            if ( make_iteration_postprocessing() )                                                                      { assert( !"Failed to make iteration postprocessing." );            return 1; }

            if ( make_postprocessing() )                                                                                { assert( !"Failed to make postprocessing. " );                    return 1; }

            return 0;
        }
Exemplo n.º 2
0
array<int>
edit_main_rep::print_snippet (url name, tree t, bool conserve_preamble) {
  tree buft= subtree (et, rp);
  if (conserve_preamble)
    if (is_document (buft) && is_compound (buft[0], "hide-preamble"))
      t= tree (SURROUND, buft[0], "", t);

  string s= suffix (name);
  bool ps= (s == "ps" || s == "eps");
  if (use_pdf ()) ps= (ps || s == "pdf");
  typeset_prepare ();
  int dpi= as_int (printing_dpi);
  //if (!ps) t= tree (WITH, MAGNIFICATION, "2", PAGE_WIDTH, "40cm", t);
  //if (!ps) t= tree (WITH, MAGNIFICATION, "1.6", PAGE_WIDTH, "40cm", t);
  double mag= ( 1.0 * dpi) / 600;
  double wid= (25.0 * dpi) / 600;
  if (!ps) {
    mag *= 1.6;
    wid *= 1.6;
  }
  t= tree (WITH, MAGNIFICATION, as_string (mag),
           PAGE_WIDTH, as_string (wid) * "cm", t);
  box b= typeset_as_box (env, t, path ());
  if (b->x4 - b->x3 >= 5*PIXEL && b->y4 - b->y3 >= 5*PIXEL) {
    if (ps) make_eps (name, b, dpi);
    else {
      url temp= url_temp (use_pdf ()? ".pdf": ".eps");
      make_eps (temp, b, dpi);
      ::remove (name);
      if (!call_scm_converter (temp, name)) {
        call_imagemagick_convert (temp, name);
        if (!exists (name))
          convert_error << "could not convert snippet " << temp
                        << " into :" << name << "\n";
      }
      ::remove (temp);
    }
  }
  array<int> a;
  a << b->x3 << b->y3 << b->x4 << b->y4;
  return a;
}
Exemplo n.º 3
0
array<int>
edit_main_rep::print_snippet (url name, tree t) {
  bool ps= suffix (name) == "ps" || suffix (name) == "eps";
  typeset_prepare ();
  int dpi= as_int (printing_dpi);
  //if (!ps) t= tree (WITH, MAGNIFICATION, "2", PAGE_WIDTH, "40cm", t);
  if (!ps) t= tree (WITH, MAGNIFICATION, "1.6", PAGE_WIDTH, "40cm", t);
  box b= typeset_as_box (env, t, path ());
  if (b->x4 - b->x3 >= 5*PIXEL && b->y4 - b->y3 >= 5*PIXEL) {
    if (ps) make_eps (name, b, dpi);
    else {
      url temp= url_temp (".eps");
      make_eps (temp, b, dpi);
      ::remove (name);
      system ("convert", temp, name);
      if (!exists (name))
        cout << "TeXmacs] warning, failed to create image " << name << "\n";
      ::remove (temp);
    }
  }
  array<int> a;
  a << b->x3 << b->y3 << b->x4 << b->y4;
  return a;
}