@comment $OpenXM: OpenXM/src/asir-doc/int-parts/macro.texi,v 1.2 2003/04/19 10:36:29 noro Exp $ \JP @chapter マクロ, 大域変数 \EG @chapter Macros and global variables @section macro \JP @samp{ca.h} で定義される主なマクロは次の通りである. \EG @samp{ca.h} \JP @subsection 一般マクロ \EG @subsection General macros @table @code @item MAX(a,b) @code{((a) > (b) ? (a) : (b) )} @item MIN(a,b) @code{((a) > (b) ? (b) : (a) )} @item ABS(a) @code{((a)>0?(a):-(a))} @item ID(p) @code{((p)->id)} @item BDY(p) @code{((p)->body)} @item NEXT(p) @code{((p)->next)} @item VR(p) @code{((p)->v)} @item NM(q) @code{((q)->nm)} @item DN(q) @code{((q)->dn)} @item SGN(q) @code{((q)->sgn)} @item PL(n) @code{((n)->p)} @item BD(n) @code{((n)->b)} @end table \JP @subsection 述語 \EG @subsection Predicates @table @code @item NUM(a) @code{ID(a)==O_Q} @item INT(a) @code{(!DN(a))} @item UNIQ(a) \JP @code{a} が有理数の 1 に等しい \EG @code{a} is equal to 1 as a rational number. @item MUNIQ(a) \JP @code{a} が有理数の -1 に等しい \EG @code{a} is equal to -1 as a rational number. @item UNIN(a) \JP @code{a} が自然数の 1 に等しい \EG @code{a} is equal to 1 as a natural number. @end table \JP @subsection メモリ割り当て器 \EG @subsection Memory allocators @table @code @item (char *) MALLOC(d) \JP @code{d} bytes の領域を割り当てる. \EG allocates a byte array of length @code{d} bytes. @item (char *) CALLOC(d,e) \JP @code{d * e} bytes の領域を割り当てて, 0 で初期化する. \EG allocates a byte array of @code{d * e} bytes, and sets all that region to 0. @item (N) NALLOC(d) \JP @code{d} 桁の自然数用の領域を割り当てる. \EG allocates a region for a natural number of @code{d} digits. @end table @noindent \JP これらはすべて領域の先頭ポインタを返す. \EG These macros return a pointer to the allocate memory. @subsection cell allocators @table @code @item NEWQ(q) \JP @code{q} に \code{Q} 用の領域を割り当てる. \EG @item NEWP(p) \JP @code{p} に \code{P} 用の領域を割り当てる. \EG @item NEWR(r) \JP @code{r} に \code{R} 用の領域を割り当てる. \EG @item NEWNODE(a) \JP @code{a} に \code{NODE} 用の領域を割り当てる. \EG @item NEWDC(dc) \JP @code{dc} に \code{DCP} 用の領域を割り当てる. \EG @item NEWV(v) \JP @code{v} に \code{V} 用の領域を割り当てる. \EG @item NEWVL(vl) \JP @code{vl} に \code{VL} 用の領域を割り当てる. \EG @end table @noindent \BJP @code{NEWP()}, @code{NEWQ()}, @code{NEWR()} においては, メンバ @code{id} もしかるべき値に初期化される. \E \BEG \E \JP @section 主な大域変数 \EG @section Global variables @table @code @item VL CO; \JP 現在の変数順序. \EG @item Q ONE; \JP 有理数の 1. \EG @item N ONEN; \JP 自然数の 1. \EG @item int prime[]; \JP 4 桁までの素数(小->大). \EG @item int lprime[]; \JP 8 桁程度の素数 1000 個(大->小). \EG @end table @noindent \BJP @code{CO} は, ユーザが初期化, および新たに変数が出現した場合に更新する必 要がある. また, @code{ONER}, @code{ONE}, @code{ONEN}は, 起動時に函数 @code{nglob_init()} により初期化する必要がある. \E \BEG \E