⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 description of calc.htm

📁 calc大数库
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://www.numbertheory.org/calc/krm_calc.html -->
<HTML><HEAD><TITLE>DESCRIPTION OF CALC</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<STYLE type=text/css>BODY {
	FONT-FAMILY: Helvetia, sans-serif
}
A:visited {
	TEXT-DECORATION: none
}
A:link {
	TEXT-DECORATION: none
}
A:hover {
	TEXT-DECORATION: underline
}
</STYLE>

<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<H2>CALC</H2>CALC is a number theory calculator program which uses arbitrary 
precision integer arithmetic. It would be useful in a first course in number 
theory.<BR>It is written in ANSI C and Yacc, along the lines of the calculator 
programs hoc1,2,3, Kernighan and Pike, <EM>The Unix Programming 
Environment</EM>, 233-254, 1984. <BR><!--There is a DOS version which runs on 386/486/586 machinesand which is compiled on a Pentium machine using the <a href="http://www.delorie.com/djgpp/">djgpp</a> C compiler (version 2). <br>To run under windows2000+ from a dos window, the user should first download a dos emulator from <a href="http://dosbox.sourceforge.net/">http://dosbox.sourceforge.net/</a>.-->The 
source comes with two makefiles, one for Unix and one for Windows XP.<BR>The 
Windows XP version and C source can be downloaded <A 
href="http://www.numbertheory.org/calc/Readme.html"><EM>here</EM></A>. <BR>The 
author is grateful to Jean-Jacques Delgove for making changes to my code, so as 
to allow compilation under Visual C++ 2005. He also pointed out that CALC now 
can utilise <A href="http://www.gnu.org/software/gawk/">GAWK</A> scripts such as 
the following, invoked by say <TT>calc &gt; gawk -f calc.awk</TT>: <PRE>==== calc.awk ===========
 
BEGIN {
 
  for(i=1;i &lt; 8;i++){
    cmd=sprintf("calc.exe \"(X+1)^%d\"",i)
      while (((cmd) | getline a) &gt; 0){
      print a
    }
    close(cmd)
  }
}
 
</PRE>with output: <PRE>X + 1
X^2 + 2X + 1
X^3 + 3X^2 + 3X + 1
X^4 + 4X^3 + 6X^2 + 4X + 1
X^5 + 5X^4 + 10X^3 + 10X^2 + 5X + 1
X^6 + 6X^5 + 15X^4 + 20X^3 + 15X^2 + 6X + 1
X^7 + 7X^6 + 21X^5 + 35X^4 + 35X^3 + 21X^2 + 7X + 1
</PRE><BR>
<HR>

<UL>
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#list_of_functions">CALC 
  functions</A> 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#examples">Examples</A> of 
  CALC calculations 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#bibliography">Bibliography</A> 

  <LI><A href="http://www.numbertheory.org/calc/calc_bugfix.html">Bugfixes and 
  additions</A> to CALC 
  <LI><A href="http://www.numbertheory.org/calc/calc_doc.html">Detailed 
  description</A> of some CALC functions </LI></UL>
<HR>
<A name=examples></A>
<P>To run CALC, type <TT>calc</TT>. One can then perform standard arithmetical 
calculations such as the following (the answer is written underneath the 
corresponding expression):<BR>&gt; 
54321+12345<BR>&nbsp;&nbsp;&nbsp;66666<BR>&gt; 
54321-12345<BR>&nbsp;&nbsp;&nbsp;41976<BR>&gt; 
54321*12345<BR>&nbsp;&nbsp;&nbsp;670592745<BR>&gt; 
54321^10<BR>&nbsp;&nbsp;&nbsp;223705964292712579004593047803650384459784511201<BR>&gt; 
54321/12345<BR>&nbsp;&nbsp;&nbsp;4<BR>&gt; 
54321%12345<BR>&nbsp;&nbsp;&nbsp;4941<BR>&gt; x=12;y=13<BR>&gt; 
x*y<BR>&nbsp;&nbsp;&nbsp;156<BR><BR>Arrays can be entered in two main ways: 
<BR>(i) with an array identifer and a subscript:<BR>&gt; a[0] = 1;a[1] = 2;a[2] 
= 3;a[3] = 4;a[4] = 5<BR>(ii) or in the following manner:<BR>&gt; a[&nbsp;] = 
{1, 2, 3, 4, 5, 6}<BR><BR>Note: Any previous values for the array will be erased 
and a new array will be created with the values in the curly braces. <BR>&nbsp; 
When one wishes to output the array a[&nbsp;], all that must be typed 
is:<BR>&gt; a[&nbsp;]<BR><BR>alone on a line. <BR>&nbsp; If one uses the former 
method, the size of the array will be set to the largest subscript 
entered.&nbsp; Any subscripts that have not been defined and which are less than 
this subscript, are initialised to zero. eg.<BR>&gt; a[1]=2<BR>&gt; 
a[2]=3<BR>&gt; a[4]=10<BR>&gt; a[ 
]<BR>&nbsp;&nbsp;&nbsp;[0]:0<BR>&nbsp;&nbsp;&nbsp;[1]:2<BR>&nbsp;&nbsp;&nbsp;[2]:3<BR>&nbsp;&nbsp;&nbsp;[3]:0<BR>&nbsp;&nbsp;&nbsp;[4]:10<BR>
<P>Some functions require an mxn integer matrix to be entered, either at the 
keyboard, or from a file. The format of such a file is as follows:<BR>m 
n<BR>a<SUB>11</SUB> ... a<SUB>1n</SUB> <BR>...<BR>a<SUB>m1</SUB> ... 
a<SUB>mn</SUB> <BR>In other words, the first line contains the row and column 
size, separated by a space, while the entries on each row are separated by 
spaces and each row is terminated by a newline. 
<P><BR>Calc is now capable of parsing polynomials.&nbsp; A polynomial can be 
entered using the reserved symbol X (capital x) in the following manner: <BR>
<DL>
  <DD>&gt; (X+2)^20<BR>
  <DD>&nbsp;&nbsp;&nbsp; X^20 + 40X^19 + 760X^18 + 9120X^17 + 77520X^16 + 
  496128X^15 + 2480640X^14 + 9922560X^13 + 32248320X^12 + 85995520X^11 + 
  189190144X^10 + 343982080X^9 + 515973120X^8<BR>
  <DD>+ 635043840X^7 + 635043840X^6 + 508035072X^5 + 317521920X^4 + 149422080X^3 
  + 49807360X^2 + 10485760X + 1048576.<BR></DD></DL>
<P><BR>Once a polynomial has been assigned to a variable, it is also possible to 
evaluate that polynomial at a specified integer value. <BR>
<DL>
  <DD>&gt; z=(X+2)^20<BR>
  <DD>&gt; z(2)<BR>
  <DD>1099511627776 </DD></DL>
<P>Polynomial division and remaindering are available as p/q and p%q. Here p is 
initially multiplied by c<SUP>deg(p)-deg(q)</SUP> (if deg(p)-deg(q) is not 
negative), where c is the leading coefficient of q. 
<DL>
  <DD>&gt; p=X^2+3X+7; q=2X+5<BR>
  <DD>&gt; p/q<BR>
  <DD>&gt; 2X+1<BR>
  <DD>&gt; p%q<BR>
  <DD>&gt; 23 </DD></DL>
<H3>Some more examples</H3>
<HR>
To find z = gcd(4,6), type<BR><BR>&gt; z = gcd(4,6)<BR>Then z is stored and its 
value is printed: <BR>&gt; z<BR>&nbsp;&nbsp;&nbsp;2<BR>
<HR>
To find z = gcd(4,6) together with integers u,v satisfying z = 4u+6v, 
type<BR><BR>&gt;z = gcdv(4,6,&amp;u,&amp;v)<BR>The values of u,v are stored and 
their values printed by 
typing<BR><BR>&gt;u<BR>&nbsp;&nbsp;&nbsp;-1<BR>&gt;v<BR>&nbsp;&nbsp;&nbsp;1<BR>
<HR>
To find z=gcd(4,6,9), type <BR><BR>&gt;x[0]=4;x[1]=6;x[2]=9 <BR>&gt;z=gcda(x[]) 
<BR>
<HR>
To find z=gcd(4,6,9), together with integers b[0],b[1],b[2] satisfying 
z=4*b[0]+6*b[1]+9*b[2], type 
<BR><BR>&gt;x[0]=4;x[1]=6;x[2]=9<BR>&gt;z=gcdav(x[],&amp;b[&nbsp;])<BR>The 
values of b[0],b[1],b[2] are stored and their values printed by 
typing:<BR><BR>&gt;b[ ]<BR>&nbsp;&nbsp;&nbsp;[0]: 4<BR>&nbsp;&nbsp;&nbsp;[1]: 
-4<BR>&nbsp;&nbsp;&nbsp;[2]: 1<BR><A name=list_of_functions></A>
<P>
<HR>

<H3>LIST OF FUNCTIONS</H3>
<OL>
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#absmod">z=absmod</A>(a,b) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[56]">euclid</A>(a,b,&amp;q[&nbsp;],&amp;r[&nbsp;],&amp;s[&nbsp;],&amp;t[&nbsp;],&amp;n) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[1]">z=gcd</A>(x,y) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[2]">z=gcdv</A>(x,y,&amp;u,&amp;v) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[3]">z=gcda</A>(a[&nbsp;]) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[4]">z=gcdav</A>(a[&nbsp;], 
  &amp;b[&nbsp;]) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[5]">egcd</A>(&nbsp;) 
  <LI><A href="http://www.numbertheory.org/calc/krm_calc.html#[6]">sgcd</A>(N) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[49]">lllgcd</A>(&nbsp;) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[53]">lllgcd0</A>(&nbsp;) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[50]">jacobigcd</A>(&nbsp;) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[7]">z=lcm</A>(x,y) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[8]">z=lcma</A>(a[&nbsp;]) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[9]">z=length</A>(n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[10]">z=pollard</A>(x) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[11]">z=nprime</A>(x) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[12]">z=nprimeap</A>(a,b,m) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[13]">z=jacobi</A>(x,y) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[14]">z=peralta</A>(a,p) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[15]">x=congr</A>(a,b,m,&amp;n) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[16]">x=chinese</A>(a,b,m,n,&amp;l) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[17]">x=chinesea</A>(a[&nbsp;],m[&nbsp;],&amp;l) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[18]">z=mthroot</A>(x,m) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[19]">mthrootr</A>(x,y,m,r) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[20]">z=fund</A>(d,&amp;x,&amp;y) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[21]">z=pell</A>(d,e,&amp;x,&amp;y) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[23]">z=mpower</A>(a,b,c) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[24]">z=inv</A>(a,m) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[59]">z=elliptic</A>(n,m,p) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[25]">z=factor</A>(n) 
  <LI><A href="http://www.numbertheory.org/calc/krm_calc.html#[26]">z=tau</A>(n) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[27]">z=sigma</A>(n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[28]">z=mobius</A>(n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[29]">z=euler</A>(n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[30]">z=lprimroot</A>(n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[31]">z=orderm</A>(a,n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[32]">z=lucas</A>(n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[33]">serret</A>(p,&amp;x,&amp;y) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[34]">collatz</A>(x,n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[35]">miller</A>(m,b) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[36]">hermite</A>(&nbsp;) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[51]">lllhermite</A>(&nbsp;) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[52]">shermite</A>(N) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[38]">smith</A>(&nbsp;) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[39]">mlll</A>(&nbsp;) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[40]">fp</A>(&nbsp;) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[42]">slv</A>(&nbsp;) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[54]">cycle</A>(&nbsp;) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[41]">inhomfp</A>(&nbsp;) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[44]">e=rsae</A>(p,q) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[45]">encode</A>(e,n) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[46]">decode</A>(e,p,q) 
  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[47]">addcubicr</A>(&nbsp;) 

  <LI><A 
  href="http://www.numbertheory.org/calc/krm_calc.html#[48]">powercubicr</A>(&nbsp;) 

  <LI><A 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -