=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/exp/exp-ja.texi,v retrieving revision 1.12 retrieving revision 1.19 diff -u -p -r1.12 -r1.19 --- OpenXM/src/asir-doc/exp/exp-ja.texi 2004/07/07 02:58:45 1.12 +++ OpenXM/src/asir-doc/exp/exp-ja.texi 2005/05/04 00:08:38 1.19 @@ -1,4 +1,4 @@ -%% $OpenXM: OpenXM/src/asir-doc/exp/exp-ja.texi,v 1.11 2004/06/30 09:30:44 ohara Exp $ +%% $OpenXM: OpenXM/src/asir-doc/exp/exp-ja.texi,v 1.18 2004/11/24 23:00:23 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 @@ -120,6 +120,14 @@ ChangeLog の項目は www.openxm.org の cvswe * 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:: @end menu @comment --- ◯◯◯◯ 関数 quotetotex, quotetotex_env の説明 ◯◯◯◯ @@ -1067,17 +1075,403 @@ http://members.jcom.home.ne.jp/yokolabo/asirlib/ @end table @comment --- ChangeLog を書く. 動機. ソースコードの位置. 変更日時 など CVSサーバを見るため +@noindent +ChangeLog +@itemize @bullet +@item この関数の由来は不明. +@end itemize + + +@node quote_flatten,,, 実験的仕様の関数 +@subsection @code{quote_flatten} +@findex quote_flatten + +@comment --- 関数の簡単な説明 --- +@table @t +@item quote_flatten(@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 と表現されている. + つまり + 演算子は左結合的である. +@end itemize + +@example +[1288] flatten_quote(quote((1+2)+(3+4*(x+3))),"+"); +quote(1+2+3+4*(x+3)) +[1289] flatten_quote(quote( (x*y)*(p*3)-(x*y)*z),"*"); +quote(x*y*p*3-x*y*z) +[1290] quotetolist(quote(1+2+3)); +[b_op,+,[b_op,+,[internal,1],[internal,2]],[internal,3]] +@end example + +@table @t +@item 参照 +@ref{quotetolist}, @ref{print_tex_form}(contrib) +@end table + +@comment --- ChangeLog を書く. 動機. ソースコードの位置. 変更日時 など CVSサーバを見るため +@noindent +ChangeLog +@itemize @bullet +@item + この関数は 2004-7-7 から 2004-7-8 にかけて + quote に関する操作を研究するために実験的に書かれた. + OpenXM/fb で蓄積された公式の不要な括弧をとりはずし, tex 形式に変換するのに + 応用. +@item + 変更をうけたソースコードは + builtin/strobj.c 1.47, + parse/eval.c 1.35, + parse/parse.h 1.31, + parse/quote.c 1.14--1.16. +@end itemize + +@node assoc,,, 実験的仕様の関数 +@subsection @code{assoc} +@findex assoc + +@comment --- 関数の簡単な説明 --- +@table @t +@item assoc(@var{a},@var{b}) +:: 連想リストをつくる +@end table + +@table @var +@item return +List +@item a +List +@item b +List +@end table + +@itemize @bullet +@item リスト @var{a}, @var{b} より +[[@var{a}[0],@var{b}[0]], [@var{a}[1],@var{b}[1]], ...] +なる新しいリストを生成する. +@end itemize + +下の例では @code{A} に動物の名前が, +@code{B} に足の本数が入っている. +@code{assoc(A,B)} で動物と足の本数をペアにしたリストを生成する. + +@example +[1192] A=["dog","cat","snake"]; +[dog,cat,snake] +[1193] B=[4,4,0]; +[4,4,0] +[1194] assoc(A,B); +[[dog,4],[cat,4],[snake,0]] +@end example + +@table @t +@item 参照 +@ref{cons}, @ref{append} +@end table + +@comment --- ChangeLog を書く. 動機. ソースコードの位置. 変更日時 など CVSサーバを見るため +@noindent +ChangeLog +@itemize @bullet +@item + この関数は 2004-6-28 に書かれた. + 変更をうけたソースコードは + builtin/list.c 1.9 + parse/eval.c 1.35, + parse/parse.h 1.31, + parse/quote.c 1.14--1.16. +@end itemize + + +@node sprintf,,, 実験的仕様の関数 +@subsection @code{sprintf} +@findex sprintf + +@table @t +@item sprintf(@var{format}[,@var{args}]) +:: C に似たプリント関数 +@end table + +@table @var +@item return +文字列 +@item format +文字列 +@item args +オブジェクト +@end table + +@itemize @bullet +@item +フォーマット文字列 @var{format } にしたがい @var{args} を文字列に変換する. +@item +フォーマット文字列の中に @code{%a} (any) が利用可能. +@var{args} の個数はフォーマット文字列の中の @code{%a} の個数に等しくすること. +@end itemize + +@example +[0] sprintf("%a: rat = %a",10,x^2-1); + 10: rat = x^2-1 +@end example + +@table @t +@item 参照 +@ref{rtostr} +@end table + +@comment --- ChangeLog を書く. 動機. ソースコードの位置. 変更日時 など CVSサーバを見るため @comment --- openxm の外部からの寄与も述べる. Credit. @noindent ChangeLog @itemize @bullet -@item この関数は 2004-3-1 から 2004-3-14 にかけて アルゴリズム xyz (論文 - http://www.afo.org/xyz.pdf ) を用いて書き直された. - 変更をうけたソースコードは xxxyy.rr, ppp.c である. -@item この関数は 2000 頃にはじめてのバージョンが書かれた. ソースは ppp.c である. +@item + この関数は 2004-7-13 にコミットされた. + 変更をうけたソースコードは builtin/strobj (1.50) である. +@item + @code{%a} は Maple の sprintf の真似か. @end itemize -@comment --- ◯◯◯◯ 以下他の関数について真似して記述する. ◯◯◯◯ + +@node quote_to_funargs,,, 実験的仕様の関数 +@subsection @code{quote_to_funargs}, @code{funargs_to_quote}, @code{remove_paren} +@findex quote_to_funargs +@findex funargs_to_quote +@findex remove_paren + +@table @t +@item quote_to_funargs(@var{q}) +:: quote を funarg 形式(リスト) へ. +@item funargs_to_quote(@var{f}) +:: funarg 形式を quote へ. +@item get_function_name(@var{f}) +:: funarg 形式の op を文字列へ. +@item remove_paren(@var{q}) +:: 上の関数を用いて書かれた余分な括弧を取り去る simplifier (asir-contrib マニュアルへ: todo) +@end table + +@table @var +@item return +quote(funargs_to_quote, remove_paren) か リスト(quote_to_funargs) +@item q +quote +@item f +リスト +@end table + +@itemize @bullet +@item + @code{quote_to_funargs} は quote 型のデータ (内部的には FNODE) を +quote への復元可能な形でリストへ変換する. +@code{quotetolist} は quote をリストへ変換するが, 一部の情報を捨てるため +もとの quote の復元はできない. +@item + @code{quote_to_funargs} の戻り値は [fid, op, arg1, arg2, ...] +なる形式をしている. +ここで op は node の名前であり, +関数 @code{get_function_name} を用いて人間が読める形式 +で取りだせる. +たとえば @code{get_function_name(quote_to_funargs(quote(1+2))[1])} +は "+" を戻す. +@item + 名前@code{get_function_name} はそのうち変更されるだろう. +@item + 下の例で + quote_to_funargs(FA[2]); +[34,[b_op,+,[internal,x],[internal,1]]] +となる. +34 は @code{I_PAREN} を意味する. +数と意味の対応表は @code{OpenXM/src/asir-contrib/packages/src/noro_simplify.rr} +または @code{OpenXM_contrib2/asir2000/parse/parse.h} を見よ. +以下の fid が 0, 1, 2, ... に対応づけられている. + I_BOP, I_COP, I_AND, I_OR, I_NOT, I_CE, + I_PRESELF, I_POSTSELF, + I_FUNC, I_FUNC_OPT, I_IFUNC, I_MAP, I_RECMAP, I_PFDERIV, + I_ANS, I_PVAR, I_ASSPVAR, + I_FORMULA, I_LIST, I_STR, I_NEWCOMP, I_CAR, I_CDR, I_CAST, + I_INDEX, I_EV, I_TIMER, I_GF2NGEN, I_GFPNGEN, I_GFSNGEN, + I_LOP, I_OPT, I_GETOPT, I_POINT, I_PAREN, I_MINUS, + I_NARYOP +@end itemize + +次の例では (x+1)+(x+2) の括弧をはずして x+1+x+2 に変換している. +@example +[0] ctrl("print_quote",1) $ + +[1] Q=quote((x+1)+(x+2)); +[b_op,+,[u_op,(),[b_op,+,[internal,x],[internal,1]]], + [u_op,(),[b_op,+,[internal,x],[internal,2]]]] + +[2] FA=quote_to_funargs(Q); +[0,<...quoted...>, + [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 + +@comment **************************************************************** +@comment --- ◯◯◯◯ 以下他の関数について真似して記述する. ◯◯◯◯ @comment 新しい関数の説明を書くためのテンプレートである. 消すな. @comment --- ◯◯◯◯ 関数 syz_pqr, xyz_stu の説明 ◯◯◯◯ @comment --- 複数の関数をまとめて説明する例 --- @@ -1138,6 +1532,7 @@ ChangeLog 変更をうけたソースコードは xxxyy.rr, ppp.c である. @item この関数は 2000 頃にはじめてのバージョンが書かれた. ソースは ppp.c である. @end itemize +@comment **************************************************************** @comment --- おまじない --- @node Index,,, Top