/[dtapublic]/projs/dtats/trunk/projs/2018/20180707_cgi_web_tools/active/num_theory/pfact18digit/index.php
ViewVC logotype

Diff of /projs/dtats/trunk/projs/2018/20180707_cgi_web_tools/active/num_theory/pfact18digit/index.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 185 by dashley, Wed Jul 11 23:39:43 2018 UTC revision 186 by dashley, Thu Jul 12 00:09:52 2018 UTC
# Line 1  Line 1 
1  <?php  <?php
2  if (!$STDNWPSTYLE_INCLUDED)  require_once("style/std/stdwpstyle.inc");
3     {  //----------------------------------------------------------------------------------------------------
4     include("stdnwpstyle.inc");  //Copyright (c) 2003, 2018 David T. Ashley.
5     $STDNWPSTYLE_INCLUDED=1;  //
6     }  //Permission is hereby granted, free of charge, to any person obtaining a copy
7  ?>  //of this software and associated documentation files (the "Software"), to deal
8  <?php  //in the Software without restriction, including without limitation the rights
9  //********************************************************************************  //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  //Copyright (C) 2003 David T. Ashley  //copies of the Software, and to permit persons to whom the Software is
11  //********************************************************************************  //furnished to do so, subject to the following conditions:
12  //This program or source file is free software; you can redistribute it and/or  //
13  //modify it under the terms of the GNU General Public License as published by  //The above copyright notice and this permission notice shall be included in all
14  //the Free Software Foundation; either version 2 of the License, or (at your  //copies or substantial portions of the Software.
15  //option) any later version.  //
16  //  //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  //This program or source file is distributed in the hope that it will  //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of  //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  //GNU General Public License for more details.  //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  //  //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  //You may have received a copy of the GNU General Public License  //SOFTWARE.
23  //along with this program; if not, write to the Free Software  //----------------------------------------------------------------------------------------------------
 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
 //********************************************************************************  
24  //  //
25  //Returns TRUE if the passed argument is a digit, or FALSE otherwise.  If the  //Returns TRUE if the passed argument is a digit, or FALSE otherwise.  If the
26  //passed string has length > 1, only the least significant digit is  //passed string has length > 1, only the least significant digit is
# Line 287  function pfact18_commanate(&$arg) Line 285  function pfact18_commanate(&$arg)
285    
286  function do_header(&$style)  function do_header(&$style)
287     {     {
288     $style->header_title("[Attempted] Prime Factorization Of An Integer (18 Or Fewer Digits)",     $style->static_page_header_title_std("[Attempted] Prime Factorization Of An Integer (18 Or Fewer Digits)",
289                          "Prime Factorization Of An Integer (18 Or Fewer Digits)",                          "Prime Factorization Of An Integer (18 Or Fewer Digits)",
290                          "This utility attempts to factor an integer of 18 or fewer digits into its " .                          "This utility attempts to factor an integer of 18 or fewer digits into its " .
291                          "prime components.");                          "prime components.");
# Line 295  function do_header(&$style) Line 293  function do_header(&$style)
293    
294  function do_footer(&$style)  function do_footer(&$style)
295     {     {
296     $style->hrule_std();  //   $style->static_page_hrule_std();
297     echo "<p align=\"center\">This utility is powered by the ";  //   echo "<p align=\"center\">This utility is powered by the ";
298     echo "<a href=\"http://www.swox.com/gmp\"><img hspace=\"5\" vspace=\"5\" src=\"../genimages/gmplogo1.png\" width=\"232\" height=\"104\" align=\"absmiddle\"></a>.&nbsp; All source code is available ";  //   echo "<a href=\"http://www.swox.com/gmp\"><img hspace=\"5\" vspace=\"5\" src=\"../genimages/gmplogo1.png\" width=\"232\" height=\"104\" align=\"absmiddle\"></a>.&nbsp; All source code is available ";
299     echo "<a href=\"../howtos/nth_web_gmp_src_code_dist/obtain_all_source.htm\">here</a>.</p>\n";  //   echo "<a href=\"../howtos/nth_web_gmp_src_code_dist/obtain_all_source.htm\">here</a>.</p>\n";
300     $style->footer_std();     $style->static_page_footer_std();
301     }     }
302    
303  function do_form($N_refresh, $Buttontext)  function do_form($N_refresh, $Buttontext)
304     {     {
305     echo "<form method=get action=\"pfact18digit.php\" width=\"100%\">\n";     echo "<form method=get action=\"index.php\" width=\"100%\">\n";
306     echo "<table align=\"center\">\n";     echo "<table align=\"center\">\n";
307     echo "<tr>\n";     echo "<tr>\n";
308     echo "  <td width=\"10%\">\n";     echo "  <td width=\"10%\">\n";
# Line 454  function pfact18_print_tabular_results(& Line 452  function pfact18_print_tabular_results(&
452     //Print the table if demanded.     //Print the table if demanded.
453     if ($print_table)     if ($print_table)
454        {        {
455        $style->hrule_std();          $style->static_page_hrule_std();  
456    
457        //Assign the table column widths.  They are centralized here for easy change.        //Assign the table column widths.  They are centralized here for easy change.
458        $width[0] = 10;        $width[0] = 10;
# Line 526  function pfact18_print_tabular_results(& Line 524  function pfact18_print_tabular_results(&
524        echo $mr_pcntprime . "% certainty, and <b>C</b>=composite established by Miller-Rabin test ";        echo $mr_pcntprime . "% certainty, and <b>C</b>=composite established by Miller-Rabin test ";
525        echo "with absolute certainty, but not factorable in the time allowed.</p>\n";        echo "with absolute certainty, but not factorable in the time allowed.</p>\n";
526    
527        $style->hrule_std();          $style->static_page_hrule_std();  
528        pfact18_algorithm_notes($cgi_max);        pfact18_algorithm_notes($cgi_max);
529        }        }
530     }     }
# Line 549  $miller_rabin_residual_real          = Line 547  $miller_rabin_residual_real          =
547  $miller_rabin_residual_percent       =  "0.000000000000088818";  $miller_rabin_residual_percent       =  "0.000000000000088818";
548  $miller_rabin_residual_lt_reciprocal =  "1,125,899,906,842,624";  $miller_rabin_residual_lt_reciprocal =  "1,125,899,906,842,624";
549  //  //
550  $style = new Stdnwpstyle;  $style = new StdWpStyle;
551  //Assign the current style in force.  Also, starts the CPU  //Assign the current style in force.  Also, starts the CPU
552  //usage clock.  //usage clock.
553    
554  //Do the header unconditionally.  The header is always used on this page.  //Do the header unconditionally.  The header is always used on this page.
555  do_header($style);  do_header($style);
556  //  //
557    if (isset($_GET['N']))
558       $N = $_GET['N'];
559  //  //
560  //If N was supplied, decommanate it and be sure it is a string.  //If N was supplied, decommanate it and be sure it is a string.
561  if (isset($N))  if (isset($N))
# Line 573  elseif (!pfact18_issimpleint($N)) Line 573  elseif (!pfact18_issimpleint($N))
573     {     {
574     //N is supplied, but is malformed.  Need to advise.     //N is supplied, but is malformed.  Need to advise.
575     do_err_msg("N is a malformed integer. &nbsp;Choose a new value for N and try again.");     do_err_msg("N is a malformed integer. &nbsp;Choose a new value for N and try again.");
576     $style->hrule_std();       $style->static_page_hrule_std();  
577     pfact18_commanate($N2);     pfact18_commanate($N2);
578     do_form($N, "Attempt To Factor Integer");     do_form($N, "Attempt To Factor Integer");
579     }       }  
# Line 581  elseif (strlen($N) > 18) Line 581  elseif (strlen($N) > 18)
581     {     {
582     //N is supplied, but is too long.  Need to advise.     //N is supplied, but is too long.  Need to advise.
583     do_err_msg("N is too long (the maximum is 18 digits). &nbsp;Choose a new value for N and try again.");     do_err_msg("N is too long (the maximum is 18 digits). &nbsp;Choose a new value for N and try again.");
584     $style->hrule_std();       $style->static_page_hrule_std();  
585     pfact18_commanate($N);     pfact18_commanate($N);
586     do_form($N, "Attempt To Factor Integer");     do_form($N, "Attempt To Factor Integer");
587     }     }
# Line 600  else Line 600  else
600       $N = (string)"2";       $N = (string)"2";
601    
602     //We can now run the external program to do the calculation.     //We can now run the external program to do the calculation.
603     $cgi_command_string = "./arith_large_cgi pfact_18 " . $N . " " . $miller_rabin_nrounds . " " . $max_cgi_time;     $cgi_command_string = "/hl/cgibin/aux_progs/dtats_cgi_aux_arith_large pfact_18 " . $N . " " . $miller_rabin_nrounds . " " . $max_cgi_time;
604     //echo "CGI command string is : " . $cgi_command_string . "<br>\n";     //echo "CGI command string is : " . $cgi_command_string . "<br>\n";
605    
606     exec($cgi_command_string, $cgi_result);     exec($cgi_command_string, $cgi_result);
# Line 634  else Line 634  else
634     if (!$cgi_output_is_sane)     if (!$cgi_output_is_sane)
635        {        {
636        do_err_msg("An unspecified error occurred when interacting with the CGI-BIN program.&nbsp; Please advise the webmaster.");        do_err_msg("An unspecified error occurred when interacting with the CGI-BIN program.&nbsp; Please advise the webmaster.");
637        $style->hrule_std();          $style->static_page_hrule_std();  
638        pfact18_commanate($N);        pfact18_commanate($N);
639        do_form($N, "Attempt To Factor Integer");        do_form($N, "Attempt To Factor Integer");
640        }        }
# Line 647  else Line 647  else
647                                      $miller_rabin_p_percent,                                      $miller_rabin_p_percent,
648                                      $miller_rabin_residual_lt_reciprocal,                                      $miller_rabin_residual_lt_reciprocal,
649                                      $max_cgi_time);                                      $max_cgi_time);
650        $style->hrule_std();          $style->static_page_hrule_std();  
651    
652        pfact18_commanate($N);        pfact18_commanate($N);
653        do_form($N, "Attempt To Factor Another Integer");        do_form($N, "Attempt To Factor Another Integer");

Legend:
Removed from v.185  
changed lines
  Added in v.186

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25