[BACK]Return to ox.h CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_math

Annotation of OpenXM/src/ox_math/ox.h, Revision 1.6

1.1       ohara       1: /* -*- mode: C; coding: euc-japan -*- */
1.6     ! ohara       2: /* $OpenXM: OpenXM/src/ox_math/ox.h,v 1.5 1999/11/03 10:56:40 ohara Exp $ */
1.1       ohara       3:
                      4: #ifndef _OX_H_
                      5:
                      6: #define _OX_H_
                      7:
                      8: #include <gmp.h>
                      9: #include "oxtag.h"
                     10:
                     11: /*
                     12: 関数の名前付け規約(その2)
                     13: (1) receive_cmo 関数はCMOタグとデータ本体を受信する. この関数は CMOタグの
                     14: 値が事前に分からないときに使用する. 返り値として、cmo へのポインタを返す。
                     15: (2) receive_cmo_XXX 関数は, CMOタグを親の関数で受信してから呼び出される関
                     16: 数で、データ本体のみを受信し、cmo_XXX へのポインタを返す。しかも、
                     17: 関数内部で new_cmo_XXX 関数を呼び出す。
                     18: (3) send_cmo 関数はCMOタグとデータ本体を送信する.
                     19: (4) send_cmo_XXX 関数はCMOタグを親の関数で送信してから呼び出される関数で、
                     20: データ本体のみを送信する.
                     21:
                     22: ----
                     23: (5) receive_ox_XXX 関数は存在しない(作らない).  receive_cmo を利用する.
                     24: (6) send_ox_XXX 関数は OX タグを含めて送信する.
                     25: (7) ox_XXX 関数は一連の送受信を含むより抽象的な操作を表現する.
                     26: ox_XXX 関数は、第一引数として、ox_file_t型の変数 sv をとる.
                     27:
                     28: (8) YYY_cmo 関数と YYY_cmo_XXX 関数の関係は次の通り:
                     29: まず YYY_cmo 関数で cmo のタグを処理し、タグを除いた残りの部分を
                     30: YYY_cmo_XXX 関数が処理する。cmo の内部に cmo_ZZZ へのポインタが
                     31: あるときには、その種類によらずに YYY_cmo 関数を呼び出す
                     32: */
                     33:
1.5       ohara      34: #define DEFAULT_LOGFILE  "/tmp/result"
                     35:
                     36: /* Open Xm File Descripter */
                     37: typedef int oxfd;
1.1       ohara      38:
1.5       ohara      39: #if 0
                     40: /* そのうちこちらに移行したい... */
                     41: typedef struct {
                     42:        int fd_read;
                     43:        int fd_write;
                     44:        int byteorder;
                     45: } oxfile;
                     46: typedef oxfile *oxfd;
                     47: #endif
1.1       ohara      48:
                     49: /* サーバーとの通信路に用いるファイルディスクリプタのペア. */
                     50: typedef struct {
1.5       ohara      51:     oxfd stream;
                     52:     oxfd control;
1.1       ohara      53: } __ox_file_struct;
                     54:
                     55: typedef __ox_file_struct *ox_file_t;
                     56:
                     57: /*
                     58: 警告:
                     59: cmo_list 型のリストには破壊的な代入をしてはいけない.
                     60: cmo_list の各メンバに直接アクセスしてはいけない.
                     61: メソッド(..._cmo_list 関数)を用いること.
                     62: */
                     63:
                     64: /* ここからは新しい定義 */
                     65: typedef struct {
                     66:     int tag;
                     67: } cmo;
                     68:
                     69: typedef cmo cmo_null;
1.2       ohara      70: typedef cmo cmo_zero;
                     71: typedef cmo cmo_dms_generic;
1.1       ohara      72:
                     73: typedef struct {
                     74:     int tag;
                     75:     int i;
                     76: } cmo_int32;
                     77:
                     78: typedef struct {
                     79:     int tag;
1.2       ohara      80:        int size;
                     81:     char *body;
                     82: } cmo_datum;
                     83:
                     84: typedef struct {
                     85:     int tag;
1.1       ohara      86:     char *s;
                     87: } cmo_string;
                     88:
                     89: typedef struct {
                     90:     int tag;
1.2       ohara      91:     cmo *ob;
                     92: } cmo_mathcap;
                     93:
                     94: typedef cmo_mathcap cmo_error2;
                     95: typedef cmo_mathcap cmo_ring_by_name;
                     96: typedef cmo_mathcap cmo_indeterminate;
1.1       ohara      97:
                     98: typedef struct cell {
                     99:     struct cell *next;
                    100:     cmo *cmo;
                    101: } cell;
                    102:
                    103: typedef struct {
                    104:     int tag;
                    105:     int length;   /* リストの長さ(必要??) */
1.6     ! ohara     106:     cell head[1];
1.1       ohara     107: } cmo_list;
                    108:
1.6     ! ohara     109:
1.1       ohara     110: typedef struct {
1.2       ohara     111:        int tag;
                    112:        int length;
                    113:        int *exps;
                    114:        cmo *coef;
                    115: } cmo_monomial32;
                    116:
                    117: typedef struct {
1.1       ohara     118:     int tag;
1.2       ohara     119:     mpz_t mpz;
                    120: } cmo_zz;
1.1       ohara     121:
                    122: typedef struct {
                    123:     int tag;
1.2       ohara     124:        cmo *num;  /* 分子 (cmo_zz) */
                    125:        cmo *den;  /* 分母 (cmo_zz) */
                    126: } cmo_qq;
1.3       ohara     127:
                    128: /* cmo_list の派生. append_cmo_list を使ってよい. */
                    129: typedef struct {
                    130:     int tag;
1.6     ! ohara     131:     int length;    /* number of monomials */
        !           132:     cell head[1];  /* a list of monomials */
1.3       ohara     133:        cmo *ringdef;
                    134: } cmo_distributed_polynomial;
1.1       ohara     135:
                    136: typedef cmo ox;
                    137:
                    138: typedef struct {
                    139:     int tag;
                    140:     int command;
                    141: } ox_command;
                    142:
                    143: typedef struct {
                    144:     int tag;
                    145:     cmo *cmo;
                    146: } ox_data;
                    147:
1.2       ohara     148: cmo_null*     new_cmo_null();
1.1       ohara     149: cmo_int32*    new_cmo_int32(int i);
1.2       ohara     150: cmo_string*   new_cmo_string(char* s);
                    151: cmo_mathcap*  new_cmo_mathcap(cmo* ob);
1.1       ohara     152: cmo_list*     new_cmo_list();
1.2       ohara     153: cmo_monomial32* new_cmo_monomial32();
                    154: cmo_monomial32* new_cmo_monomial32_size(int size);
1.1       ohara     155: cmo_zz*       new_cmo_zz();
                    156: cmo_zz*       new_cmo_zz_size(int size);
                    157: cmo_zz*       new_cmo_zz_set_si(int integer);
                    158: cmo_zz*       new_cmo_zz_noinit();
1.2       ohara     159: cmo_zero*     new_cmo_zero();
1.6     ! ohara     160: cmo_distributed_polynomial* new_cmo_distributed_polynomial();
1.2       ohara     161: cmo_dms_generic* new_cmo_dms_generic();
                    162: cmo_ring_by_name* new_cmo_ring_by_name(cmo* ob);
                    163: cmo_indeterminate* new_cmo_indeterminate(cmo* ob);
                    164: cmo_error2*   new_cmo_error2(cmo* ob);
                    165:
1.1       ohara     166: ox_data*      new_ox_data(cmo* c);
                    167: ox_command*   new_ox_command(int sm_code);
                    168:
1.2       ohara     169: cmo_error2*   gen_error_object(int err_code);
1.1       ohara     170: cmo*          make_mathcap_object(int version, char *id_string);
                    171:
                    172: void          resize_mpz(mpz_ptr mpz, int size);
                    173: cmo*          receive_cmo(int fd);
                    174: cmo*          receive_cmo2(int fd);
                    175: int           receive_int32(int fd);
                    176: int           receive_ox_tag(int fd);
                    177:
                    178: int           send_cmo(int fd, cmo* m);
                    179: int           send_int32(int fd, int integer);
                    180: int           send_ox(ox_file_t s, ox* m);
                    181: int           send_ox_cmo(int fd, cmo* m);
                    182: void          send_ox_command(int fd, int sm_command);
                    183: int           send_ox_tag(int fd, int tag);
                    184:
                    185: int           append_cmo_list(cmo_list* this, cmo *newcmo);
                    186: int           length_cmo_list(cmo_list* this);
                    187: cell*         next_cell(cell *this);
                    188: int           cmolen_cmo(cmo* m);
                    189:
                    190: void          ox_close(ox_file_t sv);
                    191: void          ox_executeStringByLocalParser(ox_file_t sv, char* str);
                    192: cmo_mathcap*  ox_mathcap(ox_file_t sv);
                    193: char*         ox_popString(ox_file_t sv, int fd);
                    194: cmo*          ox_pop_cmo(ox_file_t sv, int fd);
                    195: void          ox_reset(ox_file_t sv);
                    196: ox_file_t     ox_start(char* host, char* prog1, char* prog2);
                    197:
1.4       ohara     198: int           init_dump_buff(char *buff);
                    199: int           dump_cmo(cmo* m);
                    200: int           dump_ox_command(ox_command* m);
                    201: int           dump_ox_data(ox_data* m);
1.1       ohara     202:
                    203: int           print_cmo(cmo* c);
                    204: int           print_cmo_int32(cmo_int32* c);
                    205: int           print_cmo_list(cmo_list* li);
                    206: int           print_cmo_mathcap(cmo_mathcap* c);
                    207: int           print_cmo_string(cmo_string* c);
                    208:
1.5       ohara     209: int           decideByteOrderClient(oxfd fd, int order);
                    210: int           decideByteOrderServer(oxfd fd, int order);
1.1       ohara     211: int           next_serial();
                    212: void          setCmotypeDisable(int type);
                    213:
                    214: cmo_zz*       new_cmo_zz_set_string(char *s);
1.5       ohara     215: char*         convert_zz_to_string(cmo_zz *c);
                    216: char*         convert_cmo_to_string(cmo *m);
                    217: char*         convert_null_to_string();
                    218: char*         convert_int_to_string(int integer);
1.1       ohara     219:
                    220: #endif /* _OX_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>