From e3a50cbd65fd463fbd393d37ba5ee541c6cc19f0 Mon Sep 17 00:00:00 2001 From: Tim Daly Date: Wed, 21 Jan 2015 08:26:27 -0500 Subject: books/bookvol10.3 add Hex String to Integer conversion The toint: String -> Integer changes a String of Hex Characters into an Integer; useful for cryptographic work. --- Makefile | 2 + Makefile.pamphlet | 1 + books/bookvol10.3.pamphlet | 254 +++++++++++++++++++++++++++++++--------- changelog | 4 + patch | 6 +- src/axiom-website/patches.html | 2 + src/input/Makefile.pamphlet | 1 + 7 files changed, 212 insertions(+), 58 deletions(-) diff --git a/Makefile b/Makefile index 1963c37..7087481 100644 --- a/Makefile +++ b/Makefile @@ -140,6 +140,7 @@ all: rootdirs tanglec libspad ( echo s4 starting serial make of input files ; \ cd ${MNT}/${SYS}/doc/src/input ; \ cp ${BOOKS}/axiom.sty . ; \ + cp ${SRC}/input/*.eps . ; \ for i in `ls ${SRC}/input/*.input.pamphlet` ; do \ if [ .${NOISE} = . ] ; \ then \ @@ -288,6 +289,7 @@ clean: @ rm -f books/Makefile @ rm -f books/Makefile.dvi @ rm -f books/Makefile.pdf + @ rm -f books/axiom.bib @ rm -f lsp/axiom.sty @ rm -f lsp/Makefile lsp/Makefile.dvi lsp/Makefile.pdf @ rm -rf lsp/gcl* diff --git a/Makefile.pamphlet b/Makefile.pamphlet index 23f54d9..a591d85 100644 --- a/Makefile.pamphlet +++ b/Makefile.pamphlet @@ -103,6 +103,7 @@ all: rootdirs tanglec libspad ( echo s4 starting serial make of input files ; \ cd ${MNT}/${SYS}/doc/src/input ; \ cp ${BOOKS}/axiom.sty . ; \ + cp ${SRC}/input/*.eps . ; \ for i in `ls ${SRC}/input/*.input.pamphlet` ; do \ if [ .${NOISE} = . ] ; \ then \ diff --git a/books/bookvol10.3.pamphlet b/books/bookvol10.3.pamphlet index 202729c..fc0a266 100644 --- a/books/bookvol10.3.pamphlet +++ b/books/bookvol10.3.pamphlet @@ -62948,20 +62948,63 @@ o )show HexadecimalExpansion ++ hexadecimal expansions. HexadecimalExpansion(): Exports == Implementation where + INT ==> Integer + CHAR ==> Character Exports ==> QuotientFieldCategory(Integer) with + coerce: % -> Fraction Integer ++ coerce(h) converts a hexadecimal expansion to a rational number. + coerce: % -> RadixExpansion(16) ++ coerce(h) converts a hexadecimal expansion to a radix expansion ++ with base 16. + fractionPart: % -> Fraction Integer - ++ fractionPart(h) returns the fractional part of a hexadecimal expansion. + ++ fractionPart(h) returns the fractional part of a hexadecimal expansion + hex: Fraction Integer -> % ++ hex(r) converts a rational number to a hexadecimal expansion. + toint: String -> Integer + ++ toint(s) converts a hex string to integer + ++ + ++X toint("FE") + ++X toint("BFD25E8C") + Implementation ==> RadixExpansion(16) add - hex r == r :: % - coerce(x:%): RadixExpansion(16) == x pretend RadixExpansion(16) + + hex r == + r :: % + + coerce(x:%):RadixExpansion(16) == + x pretend RadixExpansion(16) + + toint(s) == + dec:Integer := 0 + for i in 1..#s repeat + if (s.i = char "0")$CHAR then dec := 16*dec + if (s.i = char "1")$CHAR then dec := 16*dec+1 + if (s.i = char "2")$CHAR then dec := 16*dec+2 + if (s.i = char "3")$CHAR then dec := 16*dec+3 + if (s.i = char "4")$CHAR then dec := 16*dec+4 + if (s.i = char "5")$CHAR then dec := 16*dec+5 + if (s.i = char "6")$CHAR then dec := 16*dec+6 + if (s.i = char "7")$CHAR then dec := 16*dec+7 + if (s.i = char "8")$CHAR then dec := 16*dec+8 + if (s.i = char "9")$CHAR then dec := 16*dec+9 + if (s.i = char "A")$CHAR then dec := 16*dec+10 + if (s.i = char "a")$CHAR then dec := 16*dec+10 + if (s.i = char "B")$CHAR then dec := 16*dec+11 + if (s.i = char "b")$CHAR then dec := 16*dec+11 + if (s.i = char "C")$CHAR then dec := 16*dec+12 + if (s.i = char "c")$CHAR then dec := 16*dec+12 + if (s.i = char "D")$CHAR then dec := 16*dec+13 + if (s.i = char "d")$CHAR then dec := 16*dec+13 + if (s.i = char "E")$CHAR then dec := 16*dec+14 + if (s.i = char "e")$CHAR then dec := 16*dec+14 + if (s.i = char "F")$CHAR then dec := 16*dec+15 + if (s.i = char "f")$CHAR then dec := 16*dec+15 + dec \end{chunk} \begin{chunk}{HEXADEC.dotabb} @@ -128927,7 +128970,7 @@ SparseMultivariatePolynomial(R: Ring,VarSet: OrderedSet): C == T where )set message auto off )clear all ---S 1 of 10 +--S 1 of 12 xts:=x::TaylorSeries Fraction Integer --R --R @@ -128935,7 +128978,7 @@ xts:=x::TaylorSeries Fraction Integer --R Type: TaylorSeries(Fraction(Integer)) --E 1 ---S 2 of 10 +--S 2 of 12 yts:=y::TaylorSeries Fraction Integer --R --R @@ -128943,7 +128986,7 @@ yts:=y::TaylorSeries Fraction Integer --R Type: TaylorSeries(Fraction(Integer)) --E 2 ---S 3 of 10 +--S 3 of 12 zts:=z::TaylorSeries Fraction Integer --R --R @@ -128951,7 +128994,7 @@ zts:=z::TaylorSeries Fraction Integer --R Type: TaylorSeries(Fraction(Integer)) --E 3 ---S 4 of 10 +--S 4 of 12 t1:=sin(xts) --R --R @@ -128961,7 +129004,7 @@ t1:=sin(xts) --R Type: TaylorSeries(Fraction(Integer)) --E 4 ---S 5 of 10 +--S 5 of 12 coefficient(t1,3) --R --R @@ -128971,7 +129014,7 @@ coefficient(t1,3) --R Type: Polynomial(Fraction(Integer)) --E 5 ---S 6 of 10 +--S 6 of 12 coefficient(t1,monomial(3,x)$IndexedExponents Symbol) --R --R @@ -128981,7 +129024,7 @@ coefficient(t1,monomial(3,x)$IndexedExponents Symbol) --R Type: Fraction(Integer) --E 6 ---S 7 of 10 +--S 7 of 12 t2:=sin(xts + yts) --R --R @@ -129016,7 +129059,7 @@ t2:=sin(xts + yts) --R Type: TaylorSeries(Fraction(Integer)) --E 7 ---S 8 of 10 +--S 8 of 12 coefficient(t2,3) --R --R @@ -129026,7 +129069,7 @@ coefficient(t2,3) --R Type: Polynomial(Fraction(Integer)) --E 8 ---S 9 of 10 +--S 9 of 12 coefficient(t2,monomial(3,x)$IndexedExponents Symbol) --R --R @@ -129036,7 +129079,7 @@ coefficient(t2,monomial(3,x)$IndexedExponents Symbol) --R Type: Fraction(Integer) --E 9 ---S 10 of 10 +--S 10 of 12 polynomial(t2,5) --R --R @@ -129051,6 +129094,14 @@ polynomial(t2,5) --R Type: Polynomial(Fraction(Integer)) --E 10 +--S 11 of 12 +t3:=coefficients(t2) +--E 11 + +--S 12 of 12 +t4:=series(t3) +--E 12 + )spool )lisp (bye) \end{chunk} @@ -129281,13 +129332,24 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ ++X t1:=sin(xts) ++X coefficient(t1,3) + coefficients: % -> StS + ++ \space{coefficients(s)) gives a stream of coefficients of s, + ++ e.g. [coefficient(s,0), coefficient(s,1), ...] + + series : StS -> % + ++ \space(series(st)) creates a series from a stream of + ++ coefficients + coerce: Var -> % ++ \spad{coerce(var)} converts a variable to a Taylor series + coerce: SMP -> % ++ \spad{coerce(poly)} regroups the terms by total degree and forms ++ a series. + "*":(SMP,%)->% ++\spad{smp*ts} multiplies a TaylorSeries by a monomial SMP. + csubst:(L Var,L StS) -> (SMP -> StS) ++\spad{csubst(a,b)} is for internal use only @@ -129303,9 +129365,21 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ Implementation ==> PS add Rep := StS -- Below we use the fact that Rep of PS is Stream SMP. - extend(x,n) == extend(x,n + 1)$Rep - complete x == complete(x)$Rep - stream(x:%):Rep == x @ Rep + + coefficientes(s:%):StS == + s::Rep + + series(st:StS):% == + st + + extend(x,n) == + extend(x,n + 1)$Rep + + complete x == + complete(x)$Rep + + stream(x:%):Rep == + x @ Rep evalstream:(%,L Var,L SMP) -> StS evalstream(s:%,lv:(L Var),lsmp:(L SMP)):(ST SMP) == @@ -129319,7 +129393,8 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ ints,s pretend ST Coef)$ST3(NNI,Coef,SMP) -- We can extract a polynomial giving the terms of given total degree - coefficient(s,n) == elt(s,n + 1)$Rep -- 1-based indexing for streams + coefficient(s,n) == + elt(s,n + 1)$Rep -- 1-based indexing for streams -- Here we have to take into account that we reduce the degree of each -- term of the stream by a constant @@ -129335,10 +129410,18 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ --% creation of series - coerce(r:Coef) == monom(r::SMP,0)$STT - smp:SMP * p:% == (((smp) * (p @ Rep))$STT) @ % - r:Coef * p:% == (((r::SMP) * (p @ Rep))$STT) @ % - p:% * r:Coef == (((r::SMP) * (p @ Rep))$STT) @ % + coerce(r:Coef) == + monom(r::SMP,0)$STT + + smp:SMP * p:% == + (((smp) * (p @ Rep))$STT) @ % + + r:Coef * p:% == + (((r::SMP) * (p @ Rep))$STT) @ % + + p:% * r:Coef == + (((r::SMP) * (p @ Rep))$STT) @ % + mts(p:SMP):% == (uv := mainVariable p) case "failed" => monom(p,0)$STT v := uv :: Var @@ -129349,8 +129432,11 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ up := reductum up s - coerce(p:SMP) == mts p - coerce(v:Var) == v :: SMP :: % + coerce(p:SMP) == + mts p + + coerce(v:Var) == + v :: SMP :: % monomial(r:%,v:Var,n:NNI) == r * monom(monomial(1,v,n)$SMP,n)$STT @@ -129378,7 +129464,8 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ nq : L % := [q position$(L Var) (i,vl) for i in nlv] substvar(p,nlv,nq) - csubst(vl,q) == (p1:SMP):StS+->sortmfirst(p1,vl,q pretend L(%)) pretend StS + csubst(vl,q) == + (p1:SMP):StS+->sortmfirst(p1,vl,q pretend L(%)) pretend StS restCheck(s:StS):StS == -- checks that stream is null or first element is 0 @@ -129430,42 +129517,92 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ if Coef has Algebra Fraction Integer then - (x:%) ** (r:RN) == powern(r,stream x)$STT + (x:%) ** (r:RN) == + powern(r,stream x)$STT + (r:RN) * (x:%) == map((z1:SMP):SMP +-> r*z1,stream x)$ST2(SMP,SMP) @ % + (x:%) * (r:RN) == map((z1:SMP):SMP +-> z1*r,stream x)$ST2(SMP,SMP) @ % - exp x == exp(stream x)$STF - log x == log(stream x)$STF - - sin x == sin(stream x)$STF - cos x == cos(stream x)$STF - tan x == tan(stream x)$STF - cot x == cot(stream x)$STF - sec x == sec(stream x)$STF - csc x == csc(stream x)$STF - - asin x == asin(stream x)$STF - acos x == acos(stream x)$STF - atan x == atan(stream x)$STF - acot x == acot(stream x)$STF - asec x == asec(stream x)$STF - acsc x == acsc(stream x)$STF - - sinh x == sinh(stream x)$STF - cosh x == cosh(stream x)$STF - tanh x == tanh(stream x)$STF - coth x == coth(stream x)$STF - sech x == sech(stream x)$STF - csch x == csch(stream x)$STF - - asinh x == asinh(stream x)$STF - acosh x == acosh(stream x)$STF - atanh x == atanh(stream x)$STF - acoth x == acoth(stream x)$STF - asech x == asech(stream x)$STF - acsch x == acsch(stream x)$STF + exp x == + exp(stream x)$STF + + log x == + log(stream x)$STF + + sin x == + sin(stream x)$STF + + cos x == + cos(stream x)$STF + + tan x == + tan(stream x)$STF + + cot x == + cot(stream x)$STF + + sec x == + sec(stream x)$STF + + csc x == + csc(stream x)$STF + + asin x == + asin(stream x)$STF + + acos x == + acos(stream x)$STF + + atan x == + atan(stream x)$STF + + acot x == + acot(stream x)$STF + + asec x == + asec(stream x)$STF + + acsc x == + acsc(stream x)$STF + + sinh x == + sinh(stream x)$STF + + cosh x == + cosh(stream x)$STF + + tanh x == + tanh(stream x)$STF + + coth x == + coth(stream x)$STF + + sech x == + sech(stream x)$STF + + csch x == + csch(stream x)$STF + + asinh x == + asinh(stream x)$STF + + acosh x == + acosh(stream x)$STF + + atanh x == + atanh(stream x)$STF + + acoth x == + acoth(stream x)$STF + + asech x == + asech(stream x)$STF + + acsch x == + acsch(stream x)$STF intsmp(v:Var,p: SMP): SMP == up := univariate(p,v) @@ -129479,6 +129616,7 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ fintegrate(f,v,r) == concat(r::SMP,delay map((z1:SMP):SMP +-> intsmp(v,z1),f() pretend StS)) + integrate(s,v,r) == concat(r::SMP,map((z1:SMP):SMP +-> intsmp(v,z1),s pretend StS)) @@ -129488,8 +129626,8 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ monomial? p => pe paren pe - showAll?: () -> Boolean -- check a global Lisp variable + showAll?: () -> Boolean showAll?() == true coerce(s:%):OUT == @@ -129511,7 +129649,9 @@ SparseMultivariateTaylorSeries(Coef,Var,SMP):_ concat(prefix("O" :: OUT,[n :: OUT]),l) empty? l => (0$SMP) :: OUT reduce("+",reverse_! l) + if Coef has Field then + SF2==> StreamFunctions2 p:% / r:Coef == (map((z1:SMP):SMP +-> z1/$SMP r,stream p)$SF2(SMP,SMP)) @ % @@ -159995,7 +160135,7 @@ Note that this code is not included in the generated catdef.spad file. (|CDRwithIncrement| G102102)) ('T (UNWIND-PROTECT - (PROG1 (APPLY (|function| |IndexedList;|) G102101) + (PROG1 (APPLY #'|IndexedList;| G102101) (LETT G102102 T |IndexedList|)) (COND ((NOT G102102) diff --git a/changelog b/changelog index e6efdbd..6d7a616 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +20150121 tpd src/axiom-website/patches.html 20150121.02.tpd.patch +20150121 tpd books/bookvol10.3 add Hex String to Integer conversion +20150121 tpd src/input/Makefile copy .eps files to doc +20150121 tpd Makefile copy .eps files to doc 20150121 tpd src/axiom-website/patches.html 20150121.01.tpd.patch 20150121 tpd src/input/bitcoin.input add additional information 20150119 tpd src/axiom-website/patches.html 20150119.02.tpd.patch diff --git a/patch b/patch index 4c66917..cd9b6bd 100644 --- a/patch +++ b/patch @@ -1,2 +1,6 @@ -src/input/bitcoin.input add additional information +books/bookvol10.3 add Hex String to Integer conversion + +The toint: String -> Integer changes a String of Hex Characters +into an Integer; useful for cryptographic work. + diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 5efc192..30807d0 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -4964,6 +4964,8 @@ bug 7296: connect from VIEW2D is not graph specific
src/input/bitcoin.input demonstrate finite fields and graphics 20150121.01.tpd.patch src/input/bitcoin.input add additional information
+20150121.02.tpd.patch +books/bookvol10.3 add Hex String to Integer conversion
diff --git a/src/input/Makefile.pamphlet b/src/input/Makefile.pamphlet index d898407..09ae62f 100644 --- a/src/input/Makefile.pamphlet +++ b/src/input/Makefile.pamphlet @@ -76,6 +76,7 @@ ${DOC}/%.input.dvi: ${IN}/%.input.pamphlet ${DOC}/axiom.sty @ if [ "${BUILD}" = "full" ] ; then \ ( cd ${DOC} ; \ cp ${IN}/$*.input.pamphlet ${DOC} ; \ + cp ${IN}/$*.eps ${DOC} ; \ latex $*.input.pamphlet ; \ dvipdf $*.input.dvi ; \ rm -f ${DOC}/$*.input.pamphlet ; \ -- 1.7.5.4