@comment $OpenXM: OpenXM/src/asir-doc/parts/risa.texi,v 1.15 2014/12/14 00:53:08 takayama Exp $ @node Risa/Asir,,, Top @chapter Risa/Asir @menu \BJP * Risa および Asir:: * Asir の特徴:: * Installation:: * コマンドラインオプション:: * 環境変数:: * 起動から終了まで:: * 割り込み:: * エラー処理:: * 計算結果および特殊な数:: \E \BEG * Risa and Asir:: * Features of Asir:: * Installation:: * Command line options:: * Environment variable:: * Starting and Terminating an Asir session:: * Interruption:: * Error handling:: * Referencing results and special numbers:: \E @end menu \BJP @node Risa および Asir,,, Risa/Asir @section Risa および Asir \E \BEG @node Risa and Asir,,, Risa/Asir @section @b{Risa} and @b{Asir} \E @noindent \BJP @b{Risa} は, 富士通研で開発中の数式処理システム/ライブラリの総称である. @b{Risa} の構成は次の通りである. \E \BEG @b{Risa} is the name of whole libraries of a computer algebra system which is under development at FUJITSU LABORATORIES LIMITED. The structure of @b{Risa} is as follows. \E @itemize @bullet @item \JP @code{基本演算部} \EG @b{The basic algebraic engine} @* \BJP これは, @b{Risa} の内部形式に変換されたオブジェクト (数, 多項式など) の間の演算を実行する部分であり, UNIX の @samp{libc.a} などと同様の, ライブラ リとして存在する. エンジンは, C および アセンブラで記述され, 後述する 言語インタフェース @b{Asir} の基本演算部として用いられている. @comment 一方, 数式計算を必要とするさまざまなプログラム中にリンクして用いることができる. \E \BEG This is the part which performs basic algebraic operations, such as arithmetic operations, to algebraic objects, e.g., numbers and polynomials, which are already converted into internal forms. It exists, like @samp{libc.a} of UNIX, as a library of ordinary UNIX system. The algebraic engine is written mainly in C language and partly in assembler. It serves as the basic operation part of @b{Asir}, a standard language interface of @b{Risa}. @comment It can also be linked to various programs that need some symbolic @comment and algebraic computation. \E @item \JP @code{メモリ管理部} \EG @b{Memory Manager} @* \BJP @b{Risa} では, メモリ管理部として, @code{[Boehm,Weiser]} によるフリー ソフトウェア (@code{gc-6.1alpha5}) を用いている. これはガーベジコレクション (以下 GC と呼ぶ) を自動的に行うメモリ割り当て機構を持ち, @b{Risa} の各 部分はすべてこれにより必要なメモリを得ている. \E \BEG @b{Risa} employs, as its memory management component (the memory manager), a free software distributed by Boehm (@code{gc-6.1alpha5}). It is proposed by @code{[Boehm,Weiser]}, and developed by Boehm and his colleagues. The memory manager has a memory allocator which automatically reclaims garbages, i.e., allocated but unused memories, and refreshes them for further use. The algebraic engine gets all its necessary memories through the memory manager. \E @item @b{Asir} @* \BJP @b{Asir} は, @b{Risa} の計算エンジンの言語インタフェースで ある. @b{Risa} では, 比較的容易にユーザ用の言語インタフェースを作る ことができる. @b{Asir} はその一つの例として作ったもので, C 言語に近 い文法をもつ. また, C のデバッガとして広く用いられている @code{dbx} 風 のデバッガも備えている. \E \BEG @b{Asir} is a standard language interface of @b{Risa}'s algebraic engine. It is one of the possible language interfaces, because one can develop one's own language interface easily on @b{Risa} system. @b{Asir} is an example of such language interfaces. @b{Asir} has very similar syntax and semantics as C language. Furthermore, it has a debugger that provide a subset of commands of @code{dbx}, a widely used debugger of C language. \E @end itemize \BJP @node Asir の特徴,,, Risa/Asir @section Asir の特徴 \E \BEG @node Features of Asir,,, Risa/Asir @section Features of @b{Asir} \E @noindent \BJP @b{Asir} は, 前述の通り, 計算エンジンの言語インタフェースであ る. 通常 @b{Asir} という名前の実行可能ファイルとして提供される. 現在サポートされている機能は概ね次の通りである. \E \BEG As mentioned in the previous section, @b{Asir} is a standard language interface for@b{Risa}'s algebraic engine. Usually, it is provided as an executable file named @code{asir}. Main features supported for the current version of Asir is as follows. \E @itemize @bullet \BJP @item C 言語風のユーザ言語 @item 数, 多項式, 有理式の加減乗(除) @item ベクトル, 行列の演算 @item 最小限のリスト処理 @item 組み込み函数 (因数分解, GCD, グレブナ基底など) @item ユーザ定義函数によるツール (代数体上の因数分解など) @item @code{dbx} 風のデバッガ @item 陰函数の描画 @item @b{PARI} (@pxref{pari}) による初等超越函数を含む式の評価 @item UNIX 上での分散計算機能 (Open XM) @comment @item @comment ヒストリ置換機能をもつ X11 インタフェース \E \BEG @item A C-like programming language @item Arithmetic operations (addition, subtraction, multiplication and division) on numbers, polynomials and rational expressions @item Operations on vectors and matrices @item List processing operations at the minimum @item Several Built-in functions (factorization, GCD computation, Groebner basis computation etc.) @item Useful user defined functions(e.g., factorization over algebraic number fields) @item A @code{dbx}-like debugger @item Plotting of implicit functions @item Numerical evaluation of mathematical expressions including elementary transcendental functions at arbitrary precision. This feature is in force only if @b{PARI} system (@pxref{pari}). @item Distributed computation over UNIX \E @end itemize @node Installation,,, Risa/Asir @section Installation \JP 以下の手続きで不明な点, 不都合な点があった場合の問い合わせは \BEG Any questions and any comments on this manual are welcome by e-mails to the following address. \E @example noro@@math.kobe-u.ac.jp @end example @noindent \JP 宛に e-mail でお願いします. @menu * UNIX binary version:: * UNIX source code version:: * Windows version:: @end menu @node UNIX binary version,,, Installation @subsection UNIX binary version @noindent \BJP ターゲット CPU/OS に対応する @samp{asir.tgz} が必要である. これらは全て @code{gzip} で圧縮してあるので, 入手後 @code{gzip} で 展開する. まず, インストールするディレクトリを決める. デフォルトでは @samp{/usr/local/lib} に @samp{asir} というディレクトリとして インストールされることを仮定している. 以下このディレクトリをライブラリ ディレクトリと呼ぶ. \E \BEG A file @samp{asir.tgz} suitable for the target machine/architecture is required. After getting it, you have to unpack it by @code{gzip}. First of all, determine a derectory where binaries and library files are installed. We call the directory the @b{library directory}. The following installs the files in @samp{/usr/local/lib/asir}. \E @example # gzip -dc asir.tgz | ( cd /usr/local/lib; tar xf - ) @end example \JP 個人的に使用する場合には, @samp{$HOME}などに置いてもよい. \BEG In this case you don't have to set any environment variable. You can install them elsewhere. \E @example % gzip -dc asir.tgz | ( cd $HOME; tar xf - ) @end example @noindent \BJP この場合, ライブラリディレクトリの名前を環境変数 @code{ASIR_LIBDIR} に設定する必要がある. \E \BEG In this case you have to set the name of the library directory to the environment variable @code{ASIR_LIBDIR}. \E @example % setenv ASIR_LIBDIR $HOME/asir @end example @noindent \BJP Asir 本体は, ライブラリディレクトリの @samp{asir} である. @samp{/usr/local/bin} あるいはユーザの実行ファイルサーチパス のどこかにシンボリックリンクを作ると便利である. \E \BEG @b{Asir} itself is in the library directory. It will be convenient to create a symbolic link to it from @samp{/usr/local/bin} or the user's search path. \E @example # ln -s /usr/local/lib/asir/asir /usr/local/bin/asir @end example @noindent \JP これで @samp{asir} が起動できる. \BEG Then you can start @samp{asir}. \E @example % /usr/local/bin/asir This is Risa/Asir, Version 20000821. Copyright (C) FUJITSU LABORATORIES LIMITED. 1994-2000. All rights reserved. [0] @end example @node UNIX source code version,,, Installation @subsection UNIX source code version \BEG First of all you have to determine the install directory. In the install directory, the following subdirectories are put: \E \BJP まず, インストール先のディレクトリを決める必要がある. ここには, 以下のサブディレクトリが置かれる. \E @itemize @bullet @item bin \EG executables of PARI and Asir \JP PARI および Asir の実行可能ファイル @item lib \EG library files of PARI and Asir \JP PARI および Asir のライブラリ @item include \EG header files of PARI \JP PARI のヘッダファイル @end itemize \BEG These subdirectories are created automatically if they does not exist. If you can be a root, it is recommended to set the install directory to @samp{/usr/local}. In the following the directory is denoted by TARGETDIR. \E \BJP これらのサブディレクトリは無ければ自動的に作られる. root 権限がある場合には, @samp{/usr/local} にインストールすることを お勧めする. 以下, このディレクトリを TARGETDIR と書く. \E \BEG Then, install PARI library. After getting @samp{pari.tgz}, unpack and install it as follows: \E \BJP まず PARI ライブラリをインストールする必要がある. @samp{pari.tgz} を入手後, 適当なディレクトリで展開, インストールする. \E @example % gzip -dc pari.tgz | tar xvf - % cd pari % ./Configure --prefix=TARGETDIR % make all % su # make install # make install-lib-sta @end example \BJP make 中にエラーで止まったら, 以下を実行する. \E \BEG While executing 'make install', the procedure may stop due to some error. Then try the following: \E @example % cd Oxxx % make lib-sta % su # make install-lib-sta # make install-include # exit % @end example \BEG In the above example, xxx denotes the name of the target operating system. Although GP is not built, the library necessary for building asir2000 will be generated. After getting @samp{asir2000.tgz}, unpack it and install necessary files as follows. \E \BJP 上の例で, xxx は現在ターゲットとなっている OS の名前を示す. GP はインストールされないが, asir2000 の作成に必要なファイルはインストール される. @samp{asir2000.tgz} を入手後, 適当なディレクトリで で展開し, 以下の手順でインストールする. \E @example % gzip -dc asir.tgz | tar xf - % cd asir2000 % ./configure --prefix=TARGETDIR --with-pari --enable-plot % make % su # make install # make install-lib # make install-doc # exit @end example @node Windows version,,, Installation @subsection Windows version @noindent \BJP @samp{asirwin32.msi} (32bit 版インストーラー) または @samp{asirwin64.msi} (64bit 版インストーラー)を用いてインストールする. このインストーラーは 環境変数 @samp{ASIR_ROOTDIR} にインストールしたフォルダを設定する. (zip 版は @samp{ASIR_ROOTDIR} を手動で設定する必要があり, またセキュリティブロックを解除してから展開しないといけない. zip版は開発者用.) デスクトップの asirgui をダブルクリックすれば asir がスタートする. テキストエディタとの連携機能を使うには, @samp{%ASIR_ROOTDIR%\share\editor} の指示に従い設定を行う. なおインストールフォルダー名やユーザーのホームフォルダ名がいわゆるダメ文字を含む場合は正常に動作しない機能がある. (|ダメ文字 チェッカー| で検索して自分のユーザー名が該当するか確認) \E \BEG The installers are @samp{asirwin32.msi} (32bit version) and @samp{asirwin64.msi} (64bit version). These installers set the installed folder to the environmental variable @samp{ASIR_ROOTDIR}. (If you install Risa/Asir by the zip version, you need to set the environmental variable @samp{ASIR_ROOTDIR} by hand. You also need to unlock the security block before unzipping. The zip version is for developpers.) Double click the ``asirgui'' on the desktop, then the asir starts. To use a unified environment with text editors, follow the instruction in @samp{%ASIR_ROOTDIR%\share\editor}. If the folder name to which you install asir or your home folder name contain non-ascii characters, some functions of asir may not work properly. For example, in the Japense locale, names which may cause troubles can be checked by ``damemoji checker''. \E \BJP @node コマンドラインオプション,,, Risa/Asir @section コマンドラインオプション \E \BEG @node Command line options,,, Risa/Asir @section Command line options \E @noindent \JP コマンドラインオプションは次の通り. \EG Command-line options for the command @samp{asir} are as follows. @table @code @item -heap @var{number} \BJP @code{Risa/Asir} では, 4KB のブロックをメモリ割り当ての単位として用いている. デフォルトでは, 初期 heap として, 16 ブロック (64KB) 割り当てるが, それ を変更する場合, @code{-heap} を用いる. 単位はブロックである. heap の大きさは, @code{heap()} 函数で調べることができる (単位はバイト). \E \BEG In @b{Risa/Asir}, 4KB is used as an unit, called block, for memory allocation. By default, 16 blocks (64KB) are allocated initially. This value can be changed by giving an option @code{-heap} a number parameter in unit block. Size of the heap area is obtained by a Built-in function heap(), the result of which is a number in Bytes. \E @item -adj @var{number} \BJP この値が大きいほど, 使用メモリ量は大きくなるが, GC 時間が少なくな る. @var{number} として 1 以上の整数が指定できる. デフォルトでは 3 であ る. この値が 1 以下になると GC をしない設定になるので要注意である. heap をなるべく伸ばさずに, GC を主体にしてメモリ管理したい場合には, この値を 大きく (例えば 8) 設定する. \E \BEG Heap area will be stretched by the memory manager, if the size of reclaimed memories is less than 1/@var{number} of currently allocated heap area. The default value for @var{number} is 3. If you do not prefer to stretch heap area by some reason, perhaps by restriction of available memories, but if prefer to resort to reclaiming garbages as far as possible, then a large value should be chosen for @var{number}, e.g., 8. \E @item -norc \JP 初期化ファイル @samp{$HOME/.asirrc} を読まない. \BEG When this option is specified, @b{Asir} does not read the initial file @samp{$HOME/.asirrc}. \E @item -quiet \JP 起動時の著作権表示を行わない. \BEG Be quiet at boot time. \E @item -f @var{file} \BJP 標準入力の代わりに, @var{file} から入力を読み込んで実行する. エラーの際にはただちに終了する. \E \BEG Instead of the standard input, @var{file} is used as the input. Upon an error, the execution immediately terminates. \E @item -paristack @var{number} \BJP @b{PARI} (@pxref{pari}) 専用の領域の大きさを指定する. 単位はバイト. デフォ ルトでは 1 MB. \E \BEG This option specifies the private memory size for @code{PARI} (@pxref{pari}). The unit is Bytes. By default, it is set to 1 MB. \E @item -maxheap @var{number} \BJP heap 領域の上限を指定する. 単位はバイト. デフォルトでは無制限. UNIX の 場合, 実際には @code{limit} コマンドで表示される @code{datasize} の値 に制限されているため, @code{-maxheap} の指定がなくても一定量以上に heap を獲得できない場合があるので注意.) \E \BEG This option sets an upper limit of the heap size. The unit is Bytes. Note that the size is already limited by the value of @code{datasize} displayed by the command @code{limit} on UNIX. \E @end table \BJP @node 環境変数,,, Risa/Asir @section 環境変数 \E \BEG @node Environment variable,,, Risa/Asir @section Environment variable \E @noindent \BJP @b{Asir} の実行に関するいくつかの環境変数が存在する. UNIX 上では環境変数 は shell のコマンドラインから直接設定するか, shell の rc ファイルで設定 する. Windows では, [環境変数の編集] で設定する. \E \BEG There exist several environment variables concerning with an execution of @b{Asir}. On UNIX, an environment variable is set from shells, or in rc files of shells. On Windows, it can be set from [Editing environmetal variables]. \E @itemize @bullet @item @code{ASIR_LIBDIR} @* \BJP この環境変数は廃止予定. \E \BEG This environmental variable is obsolete. \E @item @code{ASIR_CONTRIB_DIR} @* \BJP この環境変数は廃止予定. \E \BEG This environmental variable is obsolete. \E @item @code{ASIRLOADPATH} @* \BJP ロードされるファイルがあるディレクトリを UNIX の場合 ':', Windowsの場合 ';' で区切って並べる. ディレ クトリは左から順にサーチされる. この指定がない場合, および指定された ファイルが @code{ASIRLOADPATH} になかった場合, ライブラリディレクトリ もサーチされる. \E \BEG This environment specifies directories which contains files to be loaded by @b{Asir} command @code{load()}. Directories are separated by a `:' on UNIX, a ';' on Windows respectively. The search order is from the left to the right. After searching out all directories in @code{ASIRLOADPATH}, or in case of no specification at all, the library directory will be searched. \E \BJP unix 版のライブラリディレクトリは \E \BEG The library directories of the unix version are \E @samp{$OpenXM_HOME/lib/asir-contrib}, @samp{$OpenXM_HOME/lib/asir}, /usr/local/lib/asir-contrib, /usr/local/lib/asir. \BJP Windows 版のライブラリディレクトリは, @samp{OpenXM_HOME} が設定されていないときは, \E \BEG When @samp{OpenXM_HOME} is not set, the library directories of the Windows version are \E %ASIR_ROOTDIR%\lib\asir-contrib, %ASIR_ROOTDIR%\lib\asir. \BJP @samp{OpenXM_HOME} 設定されていれば, unix 版と同様. \E \BEG When @samp{OpenXM_HOME} is set, the library directories are same with the unix version. \E \BJP またWindows 版の場合, 個人領域 @samp{%APPDATA%\OpenXM\lib\asir-contrib} もライブラリディレクトリとなる. なお unix 版では上記のような個人領域を探索する仕組みはなく, OpenXM 版の asir では \samp{OpenXM/rc/} において @samp{ASIRLOADPATH} で @samp{$OpenXM_tmp/OpenXM/lib/asir-contrib} をサーチパスに加えている. asir_contrib_update を参照. which, ctrl("loadpath"), asir2000/parse/load.c も参照. \E \BEG In the Windows version, the private folder @samp{%APPDATA%\OpenXM\lib\asir-contrib} is also set to the library folders. In the unix version, there is no default private library folder. In the OpenXM/unix version, @samp{$OpenXM_tmp/OpenXM/lib/asir-contrib} is added to the @samp{ASIRLOADPATH} by a script in \samp{OpenXM/rc/}. See also asir_contrib_update. See which, ctrl("loadpath"), asir2000/parse/load.c. \E @item @code{HOME} @* \BJP @var{-norc} オプションつきで起動しない場合, @samp{$HOME/.asirrc}があれば, 予めこのファイルを実行する. @code{HOME} が設定されていない場合, UNIX 版 ではなにも読まないが, Windows 版では Asir メインディレクトリ (@code{get_rootdir()} で返されるディレクトリ) の @samp{.asirrc} を探し, あればそれを実行する. \E \BEG If @b{Asir} is invoked without @var{-norc}, @samp{$HOME/.asirrc}, if exists, is executed. If @code{HOME} is not set, nothing is done on UNIX. On Windows, @samp{.asirrc} in @b{Asir root directory} is executed if it exists. \E @end itemize \BJP @node 起動から終了まで,,, Risa/Asir @section 起動から終了まで \E \BEG @node Starting and Terminating an Asir session,,, Risa/Asir @section Starting and Terminating an @b{Asir} session \E @noindent \JP @b{Asir} を起動すると, \BEG Run @b{Asir}, then the copyright notice and the first prompt will appear on your screen, and a new @b{Asir} session will be started. \E @example [0] @end example @noindent \BJP なるプロンプトが表示され, セッションが開始する. @samp{$HOME/.asirrc} (Windows 版の場合, @code{HOME} 設定されていない場合には @code{get_rootdir()} で返されるディレクトリにある @samp{.asirrc}) が存在している場合, このファイルを @b{Asir} ユーザ言語でかかれた ファイルと見なし, 解釈実行する. \E \BEG When initialization file @samp{$HOME/.asirrc} exists, @b{Asir} interpreter executes it at first taking it as a program file written in @b{Asir}. \E @noindent \BJP プロンプトは入力の番号を表す. セッションは, @code{end;} または @code{quit;} を入力することにより終了する. 入力は, @samp{;} または @samp{$} までを一区切りとして評価される. @samp{;} のとき結果は表示され, @samp{$} のとき表示されない. \E \BEG The prompt indicates the sequential number of your input commands to @b{Asir}. The session will terminate when you input @code{end;} or @code{quit;} to @b{Asir}. Input commands are evaluated statement by statement. A statement normally ends with its terminator @samp{;} or @samp{$}. (There are some exceptions. See, syntax of @b{Asir}.) The result will be displayed when the command, i.e. statement, is terminated by a @samp{;}, and will not when terminated by a @samp{$}. \E @example % asir [0] A; 0 [1] A=(x+y)^5; x^5+5*y*x^4+10*y^2*x^3+10*y^3*x^2+5*y^4*x+y^5 [2] A; x^5+5*y*x^4+10*y^2*x^3+10*y^3*x^2+5*y^4*x+y^5 [3] a=(x+y)^5; evalpv : invalid assignment return to toplevel [3] a; a [4] fctr(A); [[1,1],[x+y,5]] [5] quit; % @end example @noindent \BJP この例では, @code{A}, @code{a}, @code{x}, @code{y} なる文字が使用されている. @code{A} はプログラムにおける変数で, @code{a}, @code{x}, @code{y} は数学的 な意味での不定元である. 一般にプログラム変数は大文字で始まり, 不定元は小文字で始まる. この例でわかるように, プログラム変数は, 数, 式などを格納しておくためのものであり, C 言語などにおける変数に対応する. 一方, 不定元はそれ自身で値を持つことはできず, 従って, 不定元に対する 代入は許されない. 後に示すが, 不定元に対する代入は, 組み込み函数 @code{subst()} により明示的に行われる. \E \BEG In the above example, names @code{A}, @code{a}, @code{x} and @code{y} are used to identify mathematical and programming objects. There, the name @code{A} denotes a program variable (some times called simply as a program variable.) while the other names, @code{a}, @code{x} and @code{y}, denote mathematical objects, that is, indeterminates. In general, program variables have names which begin with capital letters, while names of indeterminates begin with small letters. As you can see in the example, program variables are used to hold and keep objects, such as numbers and expressions, as their values, just like variables in C programming language. Whereas, indeterminates cannot have values so that assignment to indeterminates are illegal. If one wants to get a result by substituting a value for an indeterminate in an expression, it is achieved by the function @code{subst} as the value of the function. \E \BJP @node 割り込み,,, Risa/Asir @section 割り込み \E \BEG @node Interruption,,, Risa/Asir @section Interruption \E @noindent \BJP 計算を実行中に割り込みをかけたい場合, 割り込みキャラクタ(通常は @kbd{C-c}, Windows, DOS 版では @kbd{C-x} を入力する. \E \BEG To interrupt the @b{Asir} execution, input an interrupt character from the keyboard. A @kbd{C-c} is usually used for it. (Notice: @kbd{C-x} on Windows and DOS.) \E @example @@ (x+y)^1000; @kbd{C-c}interrupt ?(q/t/c/d/u/w/?) @end example @noindent \JP 各選択肢の意味は次の通り. \EG Here, the meaning of options are as follows. @table @code \BJP @item q @b{Asir} を終了する. (確認あり) @item t トップレベルに戻る. (確認あり) @item c 実行を継続する. @item d デバッグモードに入る. デバッガに関しては @xref{デバッガ}. @item u @code{register_handler()} (@pxref{ox_reset ox_intr register_handler}) で登録された 関数を実行後トップレベルに戻る. (確認あり) @item w 中断点までの函数の呼び出し列を表示する. @item ? 各選択肢の意味を説明する. \E \BEG @item q Terminates @b{Asir} session. (Confirmation requested.) @item t Returns to toplevel. (Confirmation requested.) @item c Resumes to continue the execution. @item d Enters debugging mode at the next statement of the @b{Asir} program, if @b{Asir} has been executing a program loaded from a file. Note that it will sometimes take a long time before entering debugging mode when @b{Asir} is executing basic functions in the algebraic engine, (e.g., arithmetic operation, factorization etc.) Detailed description about the debugger will be given in @ref{Debugger}. @item u After executing a function registered by @code{register_handler()} (@pxref{ox_reset ox_intr register_handler}), returns to toplevel. A confirmation is prompted. @item w Displays the calling sequence up to the interruption. @item ? Show a brief description of options. \E @end table \BJP @node エラー処理,,, Risa/Asir @section エラー処理 \E \BEG @node Error handling,,, Risa/Asir @section Error handling \E @noindent \BJP 組み込み函数に不正な型の引数を渡した場合などには実行が中断されるが, ユーザ函数の中でエラーが起きた場合にはトップレベルに戻る前に自動的にデバッグ モードに入る. この状態で エラーの場所, 直前の引数の値などを調べることができる. 表示されるエラーメッセージはさまざまであり, 内部の函数名に引き続いて メッセージが表示される. これは, 呼び出された組み込み函数 と必ずしも対応はしない. \E \BEG When arguments with illegal types are given to a built-in function, an error will be detected and the execution will be quit. In many cases, when an error is detected in a built-in function, @b{Asir} automatically enters debugging mode before coming back to toplevel. At that time, one can examine the state of the program, for example, inspect argument values just before the error occurred. Messages reported there are various depending on cases. They are reported after the internal function name. The internal function name sometimes differs from the built-in function name that is specified by the user program. \E @noindent \BJP その他, さまざまな原因により内部演算函数においてエラーが生ずることが ある. UNIX 版の場合, これは次のいずれかの @code{internal error} として報告され, 通常のエラーと同様に扱って, デバッグモードに入る. \E \BEG In the execution of internal functions, errors may happen by various reasons. The UNIX version of @b{Asir} will report those errors as one of the following @code{internal error}'s, and enters debugging mode just like normal errors. \E @table @code @item SEGV @itemx BUS ERROR @* \BJP 組み込み函数によっては, 引数の型を厳密にチェックせずに演算ルーチンに引 き渡してしまうものも存在している. このような状況において, 不正なポインタ, あるいは NULL ポインタによるアクセス違反があった場合, これら のエラーとなる. \E \BEG Some of the built-in functions transmit their arguments to internal operation routines without strict type-checking. In such cases, one of these two errors will be reported when an access violation caused by an illegal pointer or a NULL pointer is detected. \E @item BROKEN PIPE @* \BJP プロセス間通信において, 相手先のプロセスとの間のストリーム が既に存在していない場合 (例えば既に相手先のプロセスが終了している場合など) に, そのストリームに入出力しようとした場合にこのエラーとなる. \E \BEG In the process communication, this error will be reported if a process attempts to read from or to write onto the partner process when the stream to the partner process does not already exist, (e.g., terminated process.) \E @end table @noindent \BJP これらは実際には, 組み込み函数の入口において, 引数を完全にチェック することにより大部分は防げるが, 手間が多くかかることと, 場合に よっては効率を落すことにもなるため, あえて引数チェックはユーザ 任せにしてある. \E \BEG For UNIX version, even in such a case, the process itself does not terminate because such an error can be caught by @code{signal()} and recovered. To remove this weak point, complete type checking of all arguments are indispensable at the entry of a built-in function, which requires an enormous amount of re-making efforts. \E \BJP @node 計算結果および特殊な数,,, Risa/Asir @section 計算結果, 特殊な数 \E \BEG @node Referencing results and special numbers,,, Risa/Asir @section Referencing results and special numbers \E @noindent \JP @code{@@} はエスケープ文字として使用される. 現在次のような規定がある. \BEG An @code{@@} used for an escape character; rules currently in force are as follows. \E @table @code \BJP @item @@@var{n} @var{n} 番目の計算結果. @item @@@@ 直前の計算結果. @item @@i 虚数単位. @item @@pi 円周率. @item @@e 自然対数の底. @item @@ 2 元体 GF(2) 上の一変数多項式の変数 (不定元). @item @@>, @@<, @@>=, @@<=, @@==, @@&&, @@|| quantifier elimination における, 一階述語論理演算子 \E \BEG @item @@@var{n} The evaluated result of @var{n}-th input command @item @@@@ The evaluated result of the last command @item @@i The unit of imaginary number, square root of -1. @item @@pi The number pi, the ratio of a circumference of the circle and its diameter. @item @@e Napier's number, the base of natural logarithm. @item @@ A generator of GF(2^m), a finite field of characteristic 2, over GF(2). It is a root of an irreducible univariate polynomial over GF(2) which is set as the defining polynomial of GF(2^m). @item @@>, @@<, @@>=, @@<=, @@==, @@&&, @@|| Fist order logical operators. They are used in quantifier elimination. \E @end table @example [0] fctr(x^10-1); [[1,1],[x-1,1],[x+1,1],[x^4+x^3+x^2+x+1,1],[x^4-x^3+x^2-x+1,1]] [1] @@@@[3]; [x^4+x^3+x^2+x+1,1] [2] eval(sin(@@pi/2)); 1.000000000000000000000000000000000000000000000000000000000 [3] eval(log(@@e),20); 0.99999999999999999999999999998 [4] @@0[4][0]; x^4-x^3+x^2-x+1 [5] (1+@@i)^5; (-4-4*@@i) [6] eval(exp(@@pi*@@i)); -1.0000000000000000000000000000 [7] (@@+1)^9; (@@^9+@@^8+@@+1) @end example @noindent \BJP トップレベルで計算された値はこのようにヒストリとして取り出し可能であるが, このことは, ガベージコレクタにとっては負担をもたらす可能性がある. 特に, 大きな式をトップレベルで計算した場合, その後の GC 時間が急速に増大する可 能性がある. このような場合, @code{delete_history()} (@pxref{delete_history,,@code{delete_history}}) が有効である. \E \BEG As you can see in the above example, results of toplevel computation can be referred to by @code{@@} convention. This is convenient for users, while it sometimes imposes a heavy burden to the garbage collector. It may happen that GC time will rapidly increase after computing a very large expression at the toplevel. In such cases @code{delete_history()} (@pxref{delete_history,,@code{delete_history}}) takes effect. \E