=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/exp/exp-ja.texi,v retrieving revision 1.10 retrieving revision 1.21 diff -u -p -r1.10 -r1.21 --- OpenXM/src/asir-doc/exp/exp-ja.texi 2004/06/27 17:44:55 1.10 +++ OpenXM/src/asir-doc/exp/exp-ja.texi 2005/07/25 12:23:05 1.21 @@ -1,4 +1,4 @@ -%% $OpenXM: OpenXM/src/asir-doc/exp/exp-ja.texi,v 1.9 2004/06/27 10:08:56 takayama Exp $ +%% $OpenXM: OpenXM/src/asir-doc/exp/exp-ja.texi,v 1.20 2005/05/04 11:06:55 takayama Exp $ \input texinfo @iftex @catcode`@#=6 @@ -38,9 +38,9 @@ @title 実験的仕様の関数 @subtitle Risa/Asir 実験的仕様関数説明書 @subtitle 1.0 版 -@subtitle 2004 年 6 月 +@subtitle 2005 年 5 月 -@author by Risa/Asir comitters +@author by Risa/Asir committers @page @vskip 0pt plus 1filll Copyright @copyright{} Risa/Asir committers @@ -119,6 +119,16 @@ ChangeLog の項目は www.openxm.org の cvswe * list:: * mapat:: * set_print_function:: +* small_jacobi:: +* flatten_quote:: +* sprintf:: +* quote_to_funargs:: +* funargs_to_quote:: +* get_function_name:: +* remove_paren:: +* set_secure_mode:: +* set_secure_flag:: +* double_quote:: @end menu @comment --- ◯◯◯◯ 関数 quotetotex, quotetotex_env の説明 ◯◯◯◯ @@ -457,15 +467,15 @@ Sugar strategy を適用するときの weight vector.  dp_gr_main $B$N?7$7$$%$%s%?%U%'!<%9$G$O=g=x$r$"$kJ8K!$K=>$$;XDj$9$k. @comment ~taka/this03/misc-2003/A2/dp @item 順序 order は次の文法で定義する. @{, @} は 0 回以上の繰り返しを意味する. -@verbatim +@example order : '[' orderElement { ',' orderElement } ']' orderElement : weightVec | builtinOrder weightVec : '[' weightElement { ',' weightElement } ']' builtiniOrder : '[' orderName ',' setOfVariables ']' weightElement : NUMBER | setOfVariables ',' NUMBER setOfVariables: V | range(V,V) - orderName : @grlex | @glex | @lex -@end verbatim + orderName : @@grlex | @@glex | @@lex +@end example ここで @code{V} は 変数名, @code{NUMBER} は整数をあわらす. 例1: @code{v=[x,y,z,u,v], order=[[x,10,y,5,z,1],[@@grlex,range(x,v)]]} は @code{x},@code{y},@code{z} がそれぞれ weight 10, 5, 1 をもつ @@ -520,11 +530,6 @@ Gr\"obner Deformations of Hypergeometric Differential [-y^4+y^2-1,x+y^3-y] @end example -@table @t -@item 参照 -@ref{xyz_abc} -@end table - @comment --- ChangeLog を書く. 動機. ソースコードの位置. 変更日時 など CVSサーバを見るため @noindent ChangeLog @@ -1030,8 +1035,550 @@ ChangeLog @end itemize -@comment --- ◯◯◯◯ 以下他の関数について真似して記述する. ◯◯◯◯ +@node small_jacobi,,, 実験的仕様の関数 +@subsection @code{small_jacobi} +@findex small_jacobi +@comment --- 関数の簡単な説明 --- +@table @t +@item small_jacobi(@var{a},@var{m}) +:: Jacobi 記号の計算 +@end table + +@table @var +@item return +整数 +@item arg1, arg2 +整数 +@end table + +@itemize @bullet +@item + @var{m} が素数のときは Legendre 記号とよばれ, + x^2 = @var{a} mod @var{m} に解があるとき 1, 解がないとき -1 をもどす. +@item +Jacobi 記号は Legendre 記号の積で定義される (初等整数論の本参照). +@item + この関数は machine int の範囲で jacobi 記号を計算する. +@end itemize + +@example +[1286] small_jacobi(2,3); +-1 +[1287] small_jacobi(2,7); +1 +@end example + +@table @t +@item 参照 +http://members.jcom.home.ne.jp/yokolabo/asirlib/ +も見てね. +@end table + +@comment --- ChangeLog を書く. 動機. ソースコードの位置. 変更日時 など CVSサーバを見るため +@noindent +ChangeLog +@itemize @bullet +@item この関数の由来は不明. +@end itemize + + +@node flatten_quote,,, 実験的仕様の関数 +@subsection @code{flatten_quote} +@findex flatten_quote + +@comment --- 関数の簡単な説明 --- +@table @t +@item flatten_quote(@var{q},@var{op}) +:: quote の括弧をとりさる. +@end table + +@table @var +@item return +Quote +@item q +Quote +@item op +演算子を表す文字列. +@end table + +@itemize @bullet +@item +Quote 型のデータは木構造をしている +( quotetolist 参照 ). +@code{quote_flatten()} は, @var{q} の中にあられる演算子 @var{op} +の子供ノードを平等にする. +つまり演算子 @var{op} に関する括弧づけがあった場合それをすべてとりさる. +たとえば (1+2)+(3+4) という表現を 1+2+3+4 に変換する. +@item + 現在の実装では n-ary の演算子は定義されていないので, + 1+2+3 は実は 1+(2+3) と表現されている. + つまり + 演算子は右結合的である. +@item R=0; for (I=0; I, + [u_op,(),[b_op,+,[internal,x],[internal,1]]], + [u_op,(),[b_op,+,[internal,x],[internal,2]]]] + +[3] FA2=quote_to_funargs(FA[2])[1]; +[b_op,+,[internal,x],[internal,1]] + +[4] FA3=quote_to_funargs(FA[3])[1]; +[b_op,+,[internal,x],[internal,2]] + +[5] funargs_to_quote([FA[0],FA[1],FA2,FA3]); +[b_op,+,[b_op,+,[internal,x],[internal,1]], + [b_op,+,[internal,x],[internal,2]]] +@end example + +次の例は OpenXM/asir-contrib 版の asir で実行. +@example +[1287] load("noro_simplify.rr"); +1 +[1293] noro_simplify.remove_paren(quote( f(1-(x)))); +quote(f(1-x)) +@end example + +funargs_to_quote を用いて既存の quote の子供を置き換えて +新しい quote をつくり出せる. +@example +[1184] R=quote_to_funargs(quote(a+(b+c))); +[0,<...quoted...>,<...quoted...>,<...quoted...>] +[1185] T=quote_to_funargs(quote(1+2)); +[0,<...quoted...>,<...quoted...>,<...quoted...>] +[1186] funargs_to_quote([0,R[1],R[2],T[2]]); +quote(a+1) +@end example + +@table @t +@item 参照 +@ref{quotetolist} +@end table + + +@noindent +ChangeLog +@itemize @bullet +@item + これらの関数は 2004-7-8 から開発のはじまっている quote の simplification 関連 + の実験的関数である. + 変更をうけたソースコードは多岐にわたるのでまだ書かない. +@item + 括弧を取り去る問題は OpenXM/fb が蓄えている公式を tex で綺麗に表示するのが動機の一つ. +@item + 2004-6-26 の計算代数セミナーにおいて, 中川さんが simplifier についていろいろ問題提起 +をした (計算代数セミナービデオ参照). +@item parse/quote.c の {\tt strcut fid_spec fid_spec_tab[] } +の部分に書いてある形式に @code{funargs_to_quote} は変換する. +@end itemize + +@node set_secure_flag,,, 実験的仕様の関数 +@subsection @code{set_secure_flag}, @code{set_secure_mode} +@findex set_secure_flag +@findex set_secure_mode + +@comment --- 関数の簡単な説明 --- +@comment --- @itemx は複数に対して説明を一つつける場合に使う --- +@table @t +@item set_secure_flag(@var{fname},@var{m}) +@itemx set_secure_mode(@var{m}) +:: 関数の実行権限を設定する. (web サービス用) +@end table + +@table @var +@item return +整数 +@item fname +文字列 +@item m +整数 +@end table + +@itemize @bullet +@item @code{set_secure_flag}, @code{set_secure_mode} は +asir を web サーバ等で公開するために加えられた関数. +@code{set_secure_flag} で公開する関数を指定する. +@code{secure_mode} が 1 の場合は @code{set_secure_flag} で指定された +関数しか実行できない. +関数の実行途中では @code{secure_mode} が 0 となっているので, +任意の関数を実行できる. +またエラーの時等は, @code{secure_mode} は 1 に自動的に復帰する. +ただし @code{def} は実行できない. +公開する関数では, その処理中は任意の関数が実行できるので, +security に十分注意した実装をする必要がある. +@item +@code{set_secure_flag} は, @var{fname} の secure flag を @var{m} +にする. +公開する命令は 1 に設定する. +@item +@var{set_secure_mode(1)} で @code{secure_mode} が 1 となり, +公開された関数しか実行できなくなる. +quit 等も実行できないので注意. +@item @code{ timer } の引数として secure_flag を設定していない関数を +指定して実行してもエラーが表示されない. +このときは, @code{ ctrl("error_in_timer",1) } を実行しておく. +@end itemize + +@example +[1194] set_secure_flag("print_input_form_",1); +1 +[1195] set_secure_flag("fctr",1); +1 +[220] set_secure_mode(1); +1 +[1197] fctr((x-1)^3); +[[1,1],[x-1,3]] +[1198] fctr(shell("ls")); +evalf : shell not permitted +return to toplevel +@end example + +@table @t +@item 参照 +@ref{timer} +@end table + +@noindent +ChangeLog +@itemize @bullet +@item @code{set_secure_flag}, @code{set_secure_mode} は asir を +web サーバ等で公開するために加えられた関数. +sm1 の同様な関数 RestrictedMode で採用された方法を用いている. +つまり, @code{set_secure_flag} で公開する関数を指定する. +@code{secure_mode} が 1 の場合は @code{set_secure_flag} で指定された +関数しか実行できない. +v関数の実行途中では @code{secure_mode} が 0 となっているので, +任意の関数を実行できる. +@item この関数は 2004-10-27 から 2004-11-22 にかけて開発された. +@item cgiasir.sm1, cgi-asir.sh と組み合わせて cgi サービスを提供するために +利用する. +cgi-asir.sh では +@code{CGI_ASIR_ALLOW} 環境変数で公開するコマンドを指定する. +@item + 1.24--1.25 OpenXM_contrib2/asir2000/builtin/miscf.c +@item + 1.36--1.38 OpenXM_contrib2/asir2000/parse/eval.c +@item + 1.6--1.7 OpenXM_contrib2/asir2000/parse/function.c +@item + 1.33 OpenXM_contrib2/asir2000/parse/parse.h +@end itemize + +@node double_quote,,, 実験的仕様の関数 +@subsection @code{double_quote} +@findex double_quote + + +@comment --- 説明 --- +@table @t +@item double_quote, double quote の取扱や static 変数の初期化の問題点. +@end table + + +@itemize @bullet +@item double quote の取扱. 下のようなプログラムで parse error が生じる. +野呂曰く: "TeXmacs 用に, 添字の自動変換などをやっているときに, ox_asir が受け取った +文字列のバックスラッシュが1 個の場合に 2 個に増やすという関数が追加 +されています. 試しにこれを外すと OK のようです. でもきっと他でおかしな +ことが起きるでしょうね. +思い出してきました. TeX を送るときに, バックスラッシュだらけに +なるのを避けるためだったような... " +@item static 変数の取扱. +下の例を参照のこと. +@end itemize + +@example +if (1) @{ + S="\"hoge\""; + print(S); +@}else@{ @}; +を ファイル t.rr に格納. + +[1207] S=util_read_file_as_a_string("/home/nobuki/t.rr"); +if (1) @{ + S="\"hoge\""; + print(S); +@}else@{ @}; + +[1208] eval_str(S); +exprparse : parse error +0 + +t.rr を +if (1) @{ + S=" "+asciitostr([34])+"hoge"+asciitostr([34])+" "; + print(S); +@}else@{ @}; +と変更. S に読み込む. +[1212] eval_str(S); +exprparse : parse error +0 +S="" がなくても if (1) だとエラーのようだ. + +[1213] ox_launch(0,"ox_asir"); +0 +[1214] ox_execute_string(0,S); +0 しかしこちらは正しく動作. + +@end example + +@example +if (1) @{ + module abc; + static A; + A=1; + endmodule; +@} else @{ @}; + +end$ +を t.rr とするとき, + +[6] load("./t.rr"); +1 +internal error (SEGV) +となる. + +t.rr を +if (1) @{ + module abc; + static A; + localf initA; + localf foo; + def initA() @{ + A=1; + @} + initA(); + def foo() @{ + return A; + @} + endmodule; +@} else @{ @}; + +end$ +とすると正しく初期化される. +@end example + +@comment --- ChangeLog +@noindent +ChangeLog +@itemize @bullet +@item oxasir-win.rr の取扱で問題点として浮上. 2005.07.25. +@item ox_asir に計算を依頼する時は if (1) @{ ... @}で囲む. +@end itemize + + +@comment **************************************************************** +@comment --- ◯◯◯◯ 以下他の関数について真似して記述する. ◯◯◯◯ @comment 新しい関数の説明を書くためのテンプレートである. 消すな. @comment --- ◯◯◯◯ 関数 syz_pqr, xyz_stu の説明 ◯◯◯◯ @comment --- 複数の関数をまとめて説明する例 --- @@ -1092,6 +1639,7 @@ ChangeLog 変更をうけたソースコードは xxxyy.rr, ppp.c である. @item この関数は 2000 頃にはじめてのバージョンが書かれた. ソースは ppp.c である. @end itemize +@comment **************************************************************** @comment --- おまじない --- @node Index,,, Top