My Project
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions | Variables
LinTree Namespace Reference

Data Structures

class  LinTree
 

Typedefs

typedef void(* LinTreeEncodeFunc) (LinTree &lintree, leftv val)
 
typedef leftv(* LinTreeDecodeFunc) (LinTree &lintree)
 
typedef void(* LinTreeRefFunc) (LinTree &lintree, int by)
 

Functions

void install (int typ, LinTreeEncodeFunc enc, LinTreeDecodeFunc dec, LinTreeRefFunc ref)
 
void set_needs_ring (int typ)
 
void encode (LinTree &lintree, leftv val)
 
leftv decode (LinTree &lintree)
 
void updateref (LinTree &lintree, int by)
 
leftv new_leftv (int code, void *data)
 
leftv new_leftv (int code, long data)
 
void encode_mpz (LinTree &lintree, const mpz_t num)
 
void decode_mpz (LinTree &lintree, mpz_t &num)
 
void encode_none (LinTree &lintree, leftv val)
 
leftv decode_none (LinTree &lintree)
 
void ref_none (LinTree &lintree, int by)
 
void encode_int (LinTree &lintree, leftv val)
 
leftv decode_int (LinTree &lintree)
 
void ref_int (LinTree &lintree, int by)
 
void encode_string (LinTree &lintree, leftv val)
 
leftv decode_string (LinTree &lintree)
 
void ref_string (LinTree &lintree, int by)
 
void encode_def (LinTree &lintree, leftv val)
 
leftv decode_def (LinTree &lintree)
 
void ref_def (LinTree &lintree, int by)
 
void encode_longrat_cf (LinTree &lintree, const number n)
 
number decode_longrat_cf (LinTree &lintree)
 
void encode_number_cf (LinTree &lintree, const number n, const coeffs cf)
 
number decode_number_cf (LinTree &lintree, const coeffs cf)
 
leftv decode_number (LinTree &lintree)
 
void encode_number (LinTree &lintree, leftv val)
 
void ref_number_cf (LinTree &lintree, coeffs cf, int by)
 
void ref_number (LinTree &lintree, int by)
 
void encode_bigint (LinTree &lintree, leftv val)
 
leftv decode_bigint (LinTree &lintree)
 
void ref_bigint (LinTree &lintree, int by)
 
leftv decode_intmat (LinTree &lintree)
 
void encode_intmat (LinTree &lintree, leftv val)
 
void ref_intmat (LinTree &lintree, int by)
 
void encode_poly (LinTree &lintree, int typ, poly p, const ring r)
 
void encode_poly (LinTree &lintree, int typ, poly p)
 
void encode_poly (LinTree &lintree, leftv val)
 
poly decode_poly (LinTree &lintree, const ring r)
 
leftv decode_poly (LinTree &lintree)
 
void ref_poly (LinTree &lintree, int by)
 
ideal decode_ideal (LinTree &lintree, int typ, const ring r)
 
void encode_ideal (LinTree &lintree, int typ, const ideal I, const ring R)
 
void encode_ideal (LinTree &lintree, int typ, const ideal I)
 
void encode_ideal (LinTree &lintree, leftv val)
 
leftv decode_ideal (LinTree &lintree)
 
void ref_ideal (LinTree &lintree, int by)
 
void encode_ring (LinTree &lintree, const ring r)
 
void encode_ring (LinTree &lintree, leftv val)
 
ring decode_ring_raw (LinTree &lintree)
 
leftv decode_ring (LinTree &lintree)
 
void ref_ring (LinTree &lintree, int by)
 
void encode_list (LinTree &lintree, leftv val)
 
leftv decode_list (LinTree &lintree)
 
void ref_list (LinTree &lintree, int by)
 
void encode_command (LinTree &lintree, leftv val)
 
leftv decode_command (LinTree &lintree)
 
void ref_command (LinTree &lintree, int by)
 
void dump_string (string str)
 
void encoding_error (const char *s)
 
void decoding_error (const char *s)
 
std::string to_string (leftv val)
 
leftv from_string (std::string &str)
 
void init ()
 

Variables

vector< LinTreeEncodeFuncencoders
 
vector< LinTreeDecodeFuncdecoders
 
vector< LinTreeRefFuncrefupdaters
 
vector< char > needs_ring
 

Typedef Documentation

◆ LinTreeDecodeFunc

typedef leftv(* LinTree::LinTreeDecodeFunc) (LinTree &lintree)

Definition at line 14 of file lintree.h.

◆ LinTreeEncodeFunc

typedef void(* LinTree::LinTreeEncodeFunc) (LinTree &lintree, leftv val)

Definition at line 13 of file lintree.h.

◆ LinTreeRefFunc

typedef void(* LinTree::LinTreeRefFunc) (LinTree &lintree, int by)

Definition at line 15 of file lintree.h.

Function Documentation

◆ decode()

leftv LinTree::decode ( LinTree lintree)

Definition at line 101 of file lintree.cc.

101 {
102 ring decode_ring_raw(LinTree &lintree);
103 int typ = lintree.get_int();
104 if (typ < 0) {
105 lintree.set_last_ring(decode_ring_raw(lintree));
106 typ = lintree.get_int();
107 }
108 LinTreeDecodeFunc fn = decoders[typ];
109 return fn(lintree);
110}
int get_int()
Definition: lintree.h:68
void set_last_ring(void *r)
Definition: lintree.cc:900
ring decode_ring_raw(LinTree &lintree)
Definition: lintree.cc:597

◆ decode_bigint()

leftv LinTree::decode_bigint ( LinTree lintree)

Definition at line 355 of file lintree.cc.

355 {
356 return new_leftv(BIGINT_CMD,
358}
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50
leftv new_leftv(int code, void *data)
Definition: lintree.cc:118
number decode_number_cf(LinTree &lintree, const coeffs cf)
Definition: lintree.cc:292
@ BIGINT_CMD
Definition: tok.h:38

◆ decode_command()

leftv LinTree::decode_command ( LinTree lintree)

Definition at line 779 of file lintree.cc.

779 {
780 command cmd = (command)omAlloc0(sizeof(*cmd));
781 int op = lintree.get_int();
782 int argc = lintree.get_int();
783 cmd->op = op;
784 cmd->argc = argc;
785 if (argc >= 1) {
786 leftv val = decode(lintree);
787 memcpy(&cmd->arg1, val, sizeof(*val));
788 omFreeBin(val, sleftv_bin);
789 }
790 if (argc < 4) {
791 if (argc >= 2) {
792 leftv val = decode(lintree);
793 memcpy(&cmd->arg2, val, sizeof(*val));
794 omFreeBin(val, sleftv_bin);
795 }
796 if (argc >= 3) {
797 leftv val = decode(lintree);
798 memcpy(&cmd->arg3, val, sizeof(*val));
799 omFreeBin(val, sleftv_bin);
800 }
801 }
803 int error = result->Eval();
804 if (error) {
805 lintree.mark_error("error in eval");
806 }
807 return result;
808}
void mark_error(const char *s)
Definition: lintree.h:38
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
return result
Definition: facAbsBiFact.cc:75
EXTERN_VAR omBin sleftv_bin
Definition: ipid.h:145
ip_command * command
Definition: ipid.h:23
#define error(a)
Definition: mpr_numeric.cc:966
leftv decode(LinTree &lintree)
Definition: lintree.cc:101
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define COMMAND
Definition: tok.h:29

◆ decode_def()

leftv LinTree::decode_def ( LinTree lintree)

Definition at line 207 of file lintree.cc.

207 {
208 size_t len = lintree.get<size_t>();
209 const char *p = lintree.get_bytes(len);
210 leftv result = new_leftv(DEF_CMD, (void *)NULL);
211 char *name = (char *) omAlloc0(len+1);
212 result->name = name;
213 result->rtyp = 0;
214 memcpy(name, p, len);
215 int error = result->Eval();
216 if (error) {
217 lintree.mark_error("error in name lookup");
218 }
219 return result;
220}
int p
Definition: cfModGcd.cc:4078
const char * get_bytes(size_t n)
Definition: lintree.h:80
#define NULL
Definition: omList.c:12
int name
New type name for int.
Definition: templateForC.h:21
@ DEF_CMD
Definition: tok.h:58

◆ decode_ideal() [1/2]

leftv LinTree::decode_ideal ( LinTree lintree)

Definition at line 513 of file lintree.cc.

513 {
514 ideal I = decode_ideal(lintree, IDEAL_CMD, (ring) lintree.get_last_ring());
515 return new_leftv(IDEAL_CMD, I);
516}
void * get_last_ring()
Definition: lintree.h:124
@ IDEAL_CMD
Definition: grammar.cc:284
ideal decode_ideal(LinTree &lintree, int typ, const ring r)
Definition: lintree.cc:462

◆ decode_ideal() [2/2]

ideal LinTree::decode_ideal ( LinTree lintree,
int  typ,
const ring  r 
)

Definition at line 462 of file lintree.cc.

462 {
463 int n = lintree.get_int();
464 ideal I = idInit(n, 1);
465 for (int i=0; i<IDELEMS(I); i++)
466 I->m[i] = decode_poly(lintree, r);
467 return I;
468}
int i
Definition: cfEzgcd.cc:132
poly decode_poly(LinTree &lintree, const ring r)
Definition: lintree.cc:420
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ decode_int()

leftv LinTree::decode_int ( LinTree lintree)

Definition at line 166 of file lintree.cc.

166 {
167 long data = lintree.get<long>();
168 return new_leftv(INT_CMD, data);
169}
@ INT_CMD
Definition: tok.h:96

◆ decode_intmat()

leftv LinTree::decode_intmat ( LinTree lintree)

Definition at line 366 of file lintree.cc.

366 {
367 int rows = lintree.get_int();
368 int cols = lintree.get_int();
369 int len = rows * cols;
370 intvec *v = new intvec(rows, cols, 0);
371 for (int i = 0; i < len; i++) {
372 (*v)[i] = lintree.get_int();
373 }
374 return new_leftv(INTMAT_CMD, v);
375}
Definition: intvec.h:23
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
@ INTMAT_CMD
Definition: grammar.cc:279

◆ decode_list()

leftv LinTree::decode_list ( LinTree lintree)

Definition at line 744 of file lintree.cc.

744 {
745 int n = lintree.get_int();
746 lists l = (lists)omAlloc(sizeof(*l));
747 l->Init(n+1);
748 for (int i=0; i<=n; i++) {
749 leftv val = decode(lintree);
750 memcpy(&l->m[i], val, sizeof(*val));
751 omFreeBin(val, sleftv_bin);
752 }
753 return new_leftv(LIST_CMD, l);
754}
int l
Definition: cfEzgcd.cc:100
Definition: lists.h:24
slists * lists
Definition: mpr_numeric.h:146
#define omAlloc(size)
Definition: omAllocDecl.h:210
@ LIST_CMD
Definition: tok.h:118

◆ decode_longrat_cf()

number LinTree::decode_longrat_cf ( LinTree lintree)

Definition at line 246 of file lintree.cc.

246 {
247 number result;
248 int subtype = lintree.get_int();
249 if (subtype < 0)
250 result = INT_TO_SR(lintree.get<long>());
251 else if (subtype < 2) {
252 result = nlRInit(0);
253 mpz_init(result->n);
254 decode_mpz(lintree, result->z);
255 decode_mpz(lintree, result->n);
256 result->s = subtype;
257 } else {
258 result = nlRInit(0);
259 decode_mpz(lintree, result->z);
260 result->s = subtype;
261 }
262 return result;
263}
number nlRInit(long)
Definition: longrat.cc:2530
#define INT_TO_SR(INT)
Definition: longrat.h:68
void decode_mpz(LinTree &lintree, mpz_t &num)
Definition: lintree.cc:140

◆ decode_mpz()

void LinTree::decode_mpz ( LinTree lintree,
mpz_t &  num 
)

Definition at line 140 of file lintree.cc.

140 {
141 size_t nbytes = lintree.get<size_t>();
142 const char *p = lintree.get_bytes(nbytes);
143 mpz_import(num, nbytes, 1, 1, 0, 0, p);
144}
CanonicalForm num(const CanonicalForm &f)

◆ decode_none()

leftv LinTree::decode_none ( LinTree lintree)

Definition at line 151 of file lintree.cc.

151 {
152 return new_leftv(NONE, 0L);
153}
#define NONE
Definition: tok.h:221

◆ decode_number()

leftv LinTree::decode_number ( LinTree lintree)

Definition at line 315 of file lintree.cc.

315 {
316 return new_leftv(NUMBER_CMD,
317 decode_number_cf(lintree, ((ring)lintree.get_last_ring())->cf));
318}
@ NUMBER_CMD
Definition: grammar.cc:288

◆ decode_number_cf()

number LinTree::decode_number_cf ( LinTree lintree,
const coeffs  cf 
)

Definition at line 292 of file lintree.cc.

292 {
293 poly decode_poly(LinTree &lintree, const ring r);
295 switch (ct) {
296 case n_transExt:
297 {
298 fraction f= (fraction) n_Init(1, cf);
299 NUM(f) = decode_poly(lintree, cf->extRing);
300 DEN(f) = decode_poly(lintree, cf->extRing);
301 return (number) f;
302 }
303 case n_algExt:
304 return (number) decode_poly(lintree, cf->extRing);
305 case n_Zp:
306 return (number) (lintree.get<long>());
307 case n_Q:
308 return decode_longrat_cf(lintree);
309 default:
310 lintree.mark_error("coefficient type not supported");
311 return NULL;
312 }
313}
CanonicalForm cf
Definition: cfModGcd.cc:4083
FILE * f
Definition: checklibs.c:9
n_coeffType
Definition: coeffs.h:27
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:30
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:35
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:535

◆ decode_poly() [1/2]

leftv LinTree::decode_poly ( LinTree lintree)

Definition at line 445 of file lintree.cc.

445 {
446 ring r = (ring) lintree.get_last_ring();
447 return new_leftv(POLY_CMD, decode_poly(lintree, r));
448}
@ POLY_CMD
Definition: grammar.cc:289

◆ decode_poly() [2/2]

poly LinTree::decode_poly ( LinTree lintree,
const ring  r 
)

Definition at line 420 of file lintree.cc.

420 {
421 int len = lintree.get_int();
422 poly p;
423 poly ret = NULL;
424 poly prev = NULL;
425 for (int l = 0; l < len; l++) {
426 p = p_Init(r);
427 pSetCoeff0(p, decode_number_cf(lintree, r->cf));
428 int d;
429 d = lintree.get_int();
430 p_SetComp(p, d, r);
431 for(int i=1;i<=rVar(r);i++)
432 {
433 d=lintree.get_int();
434 p_SetExp(p,i,d,r);
435 }
436 p_Setm(p,r);
437 p_Test(p,r);
438 if (ret==NULL) ret=p;
439 else pNext(prev)=p;
440 prev=p;
441 }
442 return ret;
443}
#define pNext(p)
Definition: monomials.h:36
#define pSetCoeff0(p, n)
Definition: monomials.h:59
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:486
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:245
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1318
#define p_Test(p, r)
Definition: p_polys.h:159
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592

◆ decode_ring()

leftv LinTree::decode_ring ( LinTree lintree)

Definition at line 693 of file lintree.cc.

693 {
694 return new_leftv(RING_CMD, decode_ring_raw(lintree));
695}
@ RING_CMD
Definition: grammar.cc:281

◆ decode_ring_raw()

ring LinTree::decode_ring_raw ( LinTree lintree)

Definition at line 597 of file lintree.cc.

597 {
598 int ch = lintree.get_int();
599 int N = lintree.get_int();
600 coeffs cf = NULL;
601 char **names = NULL;
602 switch (ch) {
603 case -1:
604 case -2:
605 case -3:
606 {
607 const char *cf_name = lintree.get_cstring();
608 cf = nFindCoeffByName((char *)cf_name);
609 if (cf == NULL) {
610 lintree.mark_error("cannot find coeffient name");
611 return NULL;
612 }
613 }
614 break;
615 case -4:
616 return NULL;
617 break;
618 case -5:
619 return (ring) lintree.get_last_ring();
620 break;
621 }
622 if (N != 0) {
623 names = (char **)omAlloc(N*sizeof(char *));
624 for (int i=0; i<N; i++)
625 names[i] = omStrDup(lintree.get_cstring());
626 }
627 int num_ord;
628 num_ord = lintree.get_int();
629 rRingOrder_t *ord =
630 (rRingOrder_t *)omAlloc0((num_ord + 1)*sizeof(rRingOrder_t));
631 int *block0 = (int *)omAlloc0((num_ord + 1)*sizeof(int));
632 int *block1 = (int *)omAlloc0((num_ord + 1)*sizeof(int));
633 int **wvhdl = (int **)omAlloc0((num_ord + 1)*sizeof(int*));
634 for (int i=0; i<num_ord; i++)
635 {
636 ord[i] = (rRingOrder_t) lintree.get_int();
637 block0[i] = lintree.get_int();
638 block1[i] = lintree.get_int();
639 switch (ord[i]) {
640 case ringorder_a:
641 case ringorder_wp:
642 case ringorder_Wp:
643 case ringorder_ws:
644 case ringorder_Ws:
645 case ringorder_aa:
646 wvhdl[i] = (int *)omAlloc((block1[i]-block0[i]+1)*sizeof(int));
647 for (int j=block0[i]; j<=block1[i]; j++)
648 wvhdl[i][j-block0[i]] = lintree.get_int();
649 break;
650 case ringorder_a64:
651 case ringorder_M:
652 case ringorder_L:
653 case ringorder_IS:
654 lintree.mark_error("ring oder not implemented for lintrees");
655 break;
656 default:
657 break;
658 }
659 }
660 if (N == 0) {
661 omFree(ord);
662 omFree(block0);
663 omFree(block1);
664 omFree(wvhdl);
665 return NULL;
666 } else {
667 ring r = NULL;
668 if (ch >= 0)
669 r = rDefault(ch, N, names, num_ord, ord, block0, block1, wvhdl);
670 else if (ch == -1) {
672 T.r = decode_ring_raw(lintree);
673 if (T.r == NULL) return NULL;
675 r = rDefault(cf, N, names, num_ord, ord, block0, block1, wvhdl);
676 } else if (ch == -2) {
678 T.r = decode_ring_raw(lintree);
679 if (T.r == NULL) return NULL;
680 cf = nInitChar(n_algExt, &T);
681 r = rDefault(cf, N, names, num_ord, ord, block0, block1, wvhdl);
682 } else if (ch == -3) {
683 r = rDefault(cf, N, names, num_ord, ord, block0, block1, wvhdl);
684 }
685 lintree.set_last_ring(r);
686 if (lintree.get_int()) {
687 r->qideal = decode_ideal(lintree, IDEAL_CMD, r);
688 }
689 return r;
690 }
691}
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
const char * get_cstring()
Definition: lintree.h:104
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:413
int j
Definition: facHensel.cc:110
STATIC_VAR jList * T
Definition: janet.cc:30
The main handler for Singular numbers which are suitable for Singular polynomials.
coeffs nFindCoeffByName(char *cf_name)
find an existing coeff by its "CoeffName"
Definition: numbers.cc:645
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omFree(addr)
Definition: omAllocDecl.h:261
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition: ring.cc:102
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_a
Definition: ring.h:70
@ ringorder_a64
for int64 weights
Definition: ring.h:71
@ ringorder_L
Definition: ring.h:89
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:91
@ ringorder_Wp
Definition: ring.h:82
@ ringorder_ws
Definition: ring.h:86
@ ringorder_Ws
Definition: ring.h:87
@ ringorder_IS
Induced (Schreyer) ordering.
Definition: ring.h:93
@ ringorder_wp
Definition: ring.h:81
@ ringorder_M
Definition: ring.h:74
struct for passing initialization parameters to naInitChar
Definition: transext.h:88

◆ decode_string()

leftv LinTree::decode_string ( LinTree lintree)

Definition at line 184 of file lintree.cc.

184 {
185 size_t len = lintree.get<size_t>();
186 const char *p = lintree.get_bytes(len);
188 result->data = omAlloc0(len+1);
189 memcpy(result->data, p, len);
190 return result;
191}
@ STRING_CMD
Definition: tok.h:185

◆ decoding_error()

void LinTree::decoding_error ( const char *  s)

Definition at line 838 of file lintree.cc.

838 {
839 Werror("libthread decoding error: %s", s);
840}
const CanonicalForm int s
Definition: facAbsFact.cc:51
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ dump_string()

void LinTree::dump_string ( string  str)

Definition at line 821 of file lintree.cc.

821 {
822 printf("%d: ", (int)str.size());
823 for (int i=0; i<str.size(); i++) {
824 char ch = str[i];
825 if (ch < ' ' || ch >= 0x7f)
826 printf("#%02x", (int) ch & 0xff);
827 else
828 printf("%c", ch);
829 }
830 printf("\n");
831 fflush(stdout);
832}

◆ encode()

void LinTree::encode ( LinTree lintree,
leftv  val 
)

Definition at line 78 of file lintree.cc.

78 {
79 void encode_ring(LinTree &lintree, const ring r);
80 int typ = val->Typ();
81 char enc_ring = 0;
83 if (typ < encoders.size()) {
84 fn = encoders[typ];
85 enc_ring = needs_ring[typ];
86 }
87 else
88 fn = NULL;
89 if (fn) {
90 if (enc_ring && !lintree.has_last_ring()) {
91 lintree.put_int(-1);
92 encode_ring(lintree, currRing);
93 lintree.set_last_ring(currRing);
94 }
95 lintree.put_int(typ);
96 fn(lintree, val);
97 } else
98 lintree.mark_error("trying to share unsupported data type");
99}
void put_int(int code)
Definition: lintree.h:74
int has_last_ring()
Definition: lintree.h:121
int Typ()
Definition: subexpr.cc:1019
vector< char > needs_ring
Definition: lintree.cc:49
void encode_ring(LinTree &lintree, const ring r)
Definition: lintree.cc:527
vector< LinTreeEncodeFunc > encoders
Definition: lintree.cc:46
void(* LinTreeEncodeFunc)(LinTree &lintree, leftv val)
Definition: lintree.h:13
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13

◆ encode_bigint()

void LinTree::encode_bigint ( LinTree lintree,
leftv  val 
)

Definition at line 351 of file lintree.cc.

351 {
352 encode_number_cf(lintree, (number) val->Data(), coeffs_BIGINT);
353}
void * Data()
Definition: subexpr.cc:1162
void encode_number_cf(LinTree &lintree, const number n, const coeffs cf)
Definition: lintree.cc:265

◆ encode_command()

void LinTree::encode_command ( LinTree lintree,
leftv  val 
)

Definition at line 765 of file lintree.cc.

765 {
766 command cmd = (command) val->Data();
767 lintree.put_int(cmd->op);
768 lintree.put_int(cmd->argc);
769 if (cmd->argc >= 1)
770 encode(lintree, &cmd->arg1);
771 if (cmd->argc < 4) {
772 if (cmd->argc >= 2)
773 encode(lintree, &cmd->arg2);
774 if (cmd->argc >= 3)
775 encode(lintree, &cmd->arg3);
776 }
777}
void encode(LinTree &lintree, leftv val)
Definition: lintree.cc:78

◆ encode_def()

void LinTree::encode_def ( LinTree lintree,
leftv  val 
)

Definition at line 200 of file lintree.cc.

200 {
201 char *p = (char *)val->Name();
202 size_t len = strlen(p);
203 lintree.put(len);
204 lintree.put_bytes(p, len);
205}
void put_bytes(char *p, size_t n)
Definition: lintree.h:88
void put(T data)
Definition: lintree.h:61
const char * Name()
Definition: subexpr.h:120

◆ encode_ideal() [1/3]

void LinTree::encode_ideal ( LinTree lintree,
int  typ,
const ideal  I 
)

Definition at line 491 of file lintree.cc.

491 {
492 encode_ideal(lintree, typ, I, (ring) lintree.get_last_ring());
493}
void encode_ideal(LinTree &lintree, int typ, const ideal I, const ring R)
Definition: lintree.cc:470

◆ encode_ideal() [2/3]

void LinTree::encode_ideal ( LinTree lintree,
int  typ,
const ideal  I,
const ring  R 
)

Definition at line 470 of file lintree.cc.

470 {
471 matrix M = (matrix) I;
472 int mn;
473 if (typ == MATRIX_CMD)
474 {
475 mn = MATROWS(M) * MATCOLS(M);
476 lintree.put_int(MATROWS(M));
477 lintree.put_int(MATCOLS(M));
478 } else {
479 mn = IDELEMS(I);
480 lintree.put_int(IDELEMS(I));
481 }
482 int tt;
483 if (typ == MODUL_CMD)
484 tt = VECTOR_CMD;
485 else
486 tt = POLY_CMD;
487 for (int i=0; i<mn; i++)
488 encode_poly(lintree, tt, I->m[i], R);
489}
@ MATRIX_CMD
Definition: grammar.cc:286
@ MODUL_CMD
Definition: grammar.cc:287
@ VECTOR_CMD
Definition: grammar.cc:292
ip_smatrix * matrix
Definition: matpol.h:43
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27
void encode_poly(LinTree &lintree, int typ, poly p, const ring r)
Definition: lintree.cc:400
#define R
Definition: sirandom.c:27
#define M
Definition: sirandom.c:25

◆ encode_ideal() [3/3]

void LinTree::encode_ideal ( LinTree lintree,
leftv  val 
)

Definition at line 495 of file lintree.cc.

495 {
496 void encode_ring(LinTree &lintree, const ring r);
497 int typ = val->Typ();
498 void *data = val->Data();
499 switch (typ) {
500 case IDEAL_CMD:
501 case MATRIX_CMD:
502 break;
503 case MODUL_CMD:
504 {
505 ideal M = (ideal) data;
506 lintree.put_int((int) M->rank);
507 }
508 break;
509 }
510 encode_ideal(lintree, typ, (ideal) data);
511}

◆ encode_int()

void LinTree::encode_int ( LinTree lintree,
leftv  val 
)

Definition at line 161 of file lintree.cc.

161 {
162 long data = (long)(val->Data());
163 lintree.put(data);
164}

◆ encode_intmat()

void LinTree::encode_intmat ( LinTree lintree,
leftv  val 
)

Definition at line 377 of file lintree.cc.

377 {
378 intvec *v = (intvec *)(val->Data());
379 int rows = v->rows();
380 int cols = v->cols();
381 int len = v->length();
382 lintree.put_int(rows);
383 lintree.put_int(cols);
384 for (int i = 0; i < len; i++) {
385 lintree.put_int((*v)[i]);
386 }
387}

◆ encode_list()

void LinTree::encode_list ( LinTree lintree,
leftv  val 
)

Definition at line 735 of file lintree.cc.

735 {
736 lists l = (lists) val->Data();
737 int n = lSize(l);
738 lintree.put_int(n);
739 for (int i=0; i<=n; i++) {
740 encode(lintree, &l->m[i]);
741 }
742}
int lSize(lists L)
Definition: lists.cc:25

◆ encode_longrat_cf()

void LinTree::encode_longrat_cf ( LinTree lintree,
const number  n 
)

Definition at line 230 of file lintree.cc.

230 {
231 if (SR_HDL(n) & SR_INT) {
232 long nn = SR_TO_INT(n);
233 lintree.put<int>(-1);
234 lintree.put<long>(nn);
235 } else {
236 lintree.put<int>(n->s);
237 if (n->s < 2) {
238 encode_mpz(lintree, n->z);
239 encode_mpz(lintree, n->n);
240 } else {
241 encode_mpz(lintree, n->z);
242 }
243 }
244}
#define SR_INT
Definition: longrat.h:67
#define SR_TO_INT(SR)
Definition: longrat.h:69
void encode_mpz(LinTree &lintree, const mpz_t num)
Definition: lintree.cc:132
#define SR_HDL(A)
Definition: tgb.cc:35

◆ encode_mpz()

void LinTree::encode_mpz ( LinTree lintree,
const mpz_t  num 
)

Definition at line 132 of file lintree.cc.

132 {
133 size_t nbytes = (mpz_sizeinbase(num, 2) + 7UL) / 8UL;
134 char *p = (char *) alloca(nbytes);
135 mpz_export(p, &nbytes, 1, 1, 0, 0, num);
136 lintree.put(nbytes);
137 lintree.put_bytes(p, nbytes);
138}

◆ encode_none()

void LinTree::encode_none ( LinTree lintree,
leftv  val 
)

Definition at line 148 of file lintree.cc.

148 {
149}

◆ encode_number()

void LinTree::encode_number ( LinTree lintree,
leftv  val 
)

Definition at line 320 of file lintree.cc.

320 {
321 encode_number_cf(lintree, (number)val->Data(),
322 ((ring) lintree.get_last_ring())->cf);
323}

◆ encode_number_cf()

void LinTree::encode_number_cf ( LinTree lintree,
const number  n,
const coeffs  cf 
)

Definition at line 265 of file lintree.cc.

265 {
266 void encode_poly(LinTree &lintree, int typ, poly p, const ring r);
268 // lintree.put_int((int)ct);
269 switch (ct) {
270 case n_transExt:
271 {
272 fraction f= (fraction) n;
273 encode_poly(lintree, POLY_CMD, NUM(f), cf->extRing);
274 encode_poly(lintree, POLY_CMD, DEN(f), cf->extRing);
275 }
276 break;
277 case n_algExt:
278 encode_poly(lintree, POLY_CMD, (poly) n, cf->extRing);
279 break;
280 case n_Zp:
281 lintree.put<long>((long) n);
282 break;
283 case n_Q:
284 encode_longrat_cf(lintree, n);
285 break;
286 default:
287 lintree.mark_error("coefficient type not supported");
288 break;
289 }
290}

◆ encode_poly() [1/3]

void LinTree::encode_poly ( LinTree lintree,
int  typ,
poly  p 
)

Definition at line 412 of file lintree.cc.

412 {
413 encode_poly(lintree, typ, p, (ring) lintree.get_last_ring());
414}

◆ encode_poly() [2/3]

void LinTree::encode_poly ( LinTree lintree,
int  typ,
poly  p,
const ring  r 
)

Definition at line 400 of file lintree.cc.

400 {
401 lintree.put_int(pLength(p));
402 while (p != NULL) {
403 encode_number_cf(lintree, pGetCoeff(p), r->cf);
404 lintree.put_int(p_GetComp(p, r));
405 for (int j=1; j<=rVar(r); j++) {
406 lintree.put_int(p_GetExp(p, j, r));
407 }
408 pIter(p);
409 }
410}
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
static int pLength(poly a)
Definition: p_polys.h:188
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:467

◆ encode_poly() [3/3]

void LinTree::encode_poly ( LinTree lintree,
leftv  val 
)

Definition at line 416 of file lintree.cc.

416 {
417 encode_poly(lintree, val->Typ(), (poly) val->Data());
418}

◆ encode_ring() [1/2]

void LinTree::encode_ring ( LinTree lintree,
const ring  r 
)

Definition at line 527 of file lintree.cc.

527 {
528 if (r == NULL) {
529 lintree.put_int(-4);
530 return;
531 }
532 if (r == lintree.get_last_ring()) {
533 lintree.put_int(-5);
534 return;
535 }
536 if (rField_is_Q(r) || rField_is_Zp(r)) {
537 lintree.put_int(n_GetChar(r->cf));
538 lintree.put_int(r->N);
539 } else if (rFieldType(r) == n_transExt) {
540 lintree.put_int(-1);
541 lintree.put_int(r->N);
542 } else if (rFieldType(r) == n_algExt) {
543 lintree.put_int(-2);
544 lintree.put_int(r->N);
545 } else {
546 lintree.put_int(-3);
547 lintree.put_int(r->N);
548 lintree.put_cstring(nCoeffName(r->cf));
549 }
550 for (int i=0; i<r->N; i++) {
551 lintree.put_cstring(r->names[i]);
552 }
553 int i = 0;
554 if (r->order) while (r->order[i] != 0) i++;
555 lintree.put_int(i);
556 i = 0;
557 if (r->order) while (r->order[i] != 0) {
558 lintree.put_int(r->order[i]);
559 lintree.put_int(r->block0[i]);
560 lintree.put_int(r->block1[i]);
561 switch (r->order[i]) {
562 case ringorder_a:
563 case ringorder_wp:
564 case ringorder_Wp:
565 case ringorder_ws:
566 case ringorder_Ws:
567 case ringorder_aa:
568 for (int j = r->block0[i]; j <= r->block1[i]; j++)
569 lintree.put_int(r->wvhdl[i][j-r->block0[i]]);
570 break;
571 case ringorder_a64:
572 case ringorder_M:
573 case ringorder_L:
574 case ringorder_IS:
575 lintree.mark_error("ring order not implemented");
576 break;
577 default:
578 break;
579 }
580 i++;
581 }
582 if (rFieldType(r) == n_transExt || rFieldType(r) == n_algExt) {
583 encode_ring(lintree, r->cf->extRing);
584 }
585 if (r->qideal) {
586 lintree.put_int(IDEAL_CMD);
587 encode_ideal(lintree, IDEAL_CMD, r->qideal, r);
588 } else {
589 lintree.put_int(0);
590 }
591}
void put_cstring(char *p)
Definition: lintree.h:99
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:441
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:960
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:500
static n_coeffType rFieldType(const ring r)
the type of the coefficient filed of r (n_Zp, n_Q, etc)
Definition: ring.h:556
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:506

◆ encode_ring() [2/2]

void LinTree::encode_ring ( LinTree lintree,
leftv  val 
)

Definition at line 593 of file lintree.cc.

593 {
594 encode_ring(lintree, (ring) val->Data());
595}

◆ encode_string()

void LinTree::encode_string ( LinTree lintree,
leftv  val 
)

Definition at line 177 of file lintree.cc.

177 {
178 char *p = (char *)val->Data();
179 size_t len = strlen(p);
180 lintree.put(len);
181 lintree.put_bytes(p, len);
182}

◆ encoding_error()

void LinTree::encoding_error ( const char *  s)

Definition at line 834 of file lintree.cc.

834 {
835 Werror("libthread encoding error: %s", s);
836}

◆ from_string()

leftv LinTree::from_string ( std::string &  str)

Definition at line 854 of file lintree.cc.

854 {
855 LinTree lintree(str);
856 leftv result = decode(lintree);
857 if (lintree.has_error()) {
858 decoding_error(lintree.error_msg());
859 result = new_leftv(NONE, 0L);
860 }
861 return result;
862}
void decoding_error(const char *s)
Definition: lintree.cc:838

◆ init()

void LinTree::init ( )

Definition at line 864 of file lintree.cc.

864 {
865 install(NONE, encode_none, decode_none, ref_none);
866 install(INT_CMD, encode_int, decode_int, ref_int);
867 install(LIST_CMD, encode_list, decode_list, ref_list);
868 install(STRING_CMD, encode_string, decode_string, ref_string);
869 install(COMMAND, encode_command, decode_command, ref_command);
870 install(DEF_CMD, encode_def, decode_def, ref_def);
871 install(NUMBER_CMD, encode_number, decode_number, ref_number);
872 install(BIGINT_CMD, encode_bigint, decode_bigint, ref_bigint);
873 install(INTMAT_CMD, encode_intmat, decode_intmat, ref_intmat);
875 install(RING_CMD, encode_ring, decode_ring, ref_ring);
876 install(POLY_CMD, encode_poly, decode_poly, ref_poly);
878 install(IDEAL_CMD, encode_ideal, decode_ideal, ref_ideal);
880}
void set_needs_ring(int typ)
Definition: lintree.cc:74
void install(int typ, LinTreeEncodeFunc enc, LinTreeDecodeFunc dec, LinTreeRefFunc ref)
Definition: lintree.cc:51

◆ install()

void LinTree::install ( int  typ,
LinTreeEncodeFunc  enc,
LinTreeDecodeFunc  dec,
LinTreeRefFunc  ref 
)

Definition at line 51 of file lintree.cc.

55{
56 size_t n;
57 for (;;) {
58 n = encoders.size();
59 if (n > typ) break;
60 if (n == 0)
61 n = 256;
62 else
63 n = n * 2;
64 encoders.resize(n);
65 decoders.resize(n);
66 refupdaters.resize(n);
67 needs_ring.resize(n);
68 }
69 encoders[typ] = enc;
70 decoders[typ] = dec;
71 refupdaters[typ] = ref;
72}
vector< LinTreeDecodeFunc > decoders
Definition: lintree.cc:47
vector< LinTreeRefFunc > refupdaters
Definition: lintree.cc:48

◆ new_leftv() [1/2]

leftv LinTree::new_leftv ( int  code,
long  data 
)

Definition at line 125 of file lintree.cc.

125 {
127 result->rtyp = code;
128 result->data = (char *)data;
129 return result;
130}
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
sleftv * leftv
Definition: structs.h:57

◆ new_leftv() [2/2]

leftv LinTree::new_leftv ( int  code,
void *  data 
)

Definition at line 118 of file lintree.cc.

118 {
120 result->rtyp = code;
121 result->data = (char *)data;
122 return result;
123}

◆ ref_bigint()

void LinTree::ref_bigint ( LinTree lintree,
int  by 
)

Definition at line 360 of file lintree.cc.

360 {
361 ref_number_cf(lintree, coeffs_BIGINT, by);
362}
void ref_number_cf(LinTree &lintree, coeffs cf, int by)
Definition: lintree.cc:325

◆ ref_command()

void LinTree::ref_command ( LinTree lintree,
int  by 
)

Definition at line 810 of file lintree.cc.

810 {
811 int op = lintree.get_int();
812 int argc = lintree.get_int();
813 if (argc >= 1)
814 updateref(lintree, by);
815 if (argc < 4) {
816 if (argc >= 2) updateref(lintree, by);
817 if (argc >= 3) updateref(lintree, by);
818 }
819}
void updateref(LinTree &lintree, int by)
Definition: lintree.cc:112

◆ ref_def()

void LinTree::ref_def ( LinTree lintree,
int  by 
)

Definition at line 222 of file lintree.cc.

222 {
223 size_t len = lintree.get<size_t>();
224 lintree.skip_bytes(len);
225}
void skip_bytes(size_t n)
Definition: lintree.h:114

◆ ref_ideal()

void LinTree::ref_ideal ( LinTree lintree,
int  by 
)

Definition at line 518 of file lintree.cc.

518 {
519 int n = lintree.get_int();
520 for (int i=0; i<n; i++)
521 ref_poly(lintree, by);
522}
void ref_poly(LinTree &lintree, int by)
Definition: lintree.cc:450

◆ ref_int()

void LinTree::ref_int ( LinTree lintree,
int  by 
)

Definition at line 171 of file lintree.cc.

171 {
172 lintree.skip<long>();
173}
void skip()
Definition: lintree.h:65

◆ ref_intmat()

void LinTree::ref_intmat ( LinTree lintree,
int  by 
)

Definition at line 389 of file lintree.cc.

389 {
390 int rows = lintree.get_int();
391 int cols = lintree.get_int();
392 int len = rows * cols;
393 for (int i = 0; i < len; i++) {
394 (void) lintree.get_int();
395 }
396}

◆ ref_list()

void LinTree::ref_list ( LinTree lintree,
int  by 
)

Definition at line 756 of file lintree.cc.

756 {
757 int n = lintree.get_int();
758 for (int i = 0; i < n; i++) {
759 updateref(lintree, by);
760 }
761}

◆ ref_none()

void LinTree::ref_none ( LinTree lintree,
int  by 
)

Definition at line 155 of file lintree.cc.

155 {
156}

◆ ref_number()

void LinTree::ref_number ( LinTree lintree,
int  by 
)

Definition at line 344 of file lintree.cc.

344 {
345 coeffs cf = ((ring) lintree.get_last_ring())->cf;
346 ref_number_cf(lintree, cf, by);
347}

◆ ref_number_cf()

void LinTree::ref_number_cf ( LinTree lintree,
coeffs  cf,
int  by 
)

Definition at line 325 of file lintree.cc.

325 {
326 void ref_poly(LinTree &lintree, int by);
327 switch (getCoeffType(cf)) {
328 case n_transExt:
329 ref_poly(lintree, by);
330 ref_poly(lintree, by);
331 break;
332 case n_algExt:
333 ref_poly(lintree, by);
334 break;
335 case n_Zp:
336 lintree.skip<long>();
337 break;
338 default:
339 abort(); // should never happen
340 break;
341 }
342}

◆ ref_poly()

void LinTree::ref_poly ( LinTree lintree,
int  by 
)

Definition at line 450 of file lintree.cc.

450 {
451 ring r = (ring) lintree.get_last_ring();
452 int len = lintree.get_int();
453 for (int l = 0; l <len; l++) {
454 ref_number(lintree, by);
455 lintree.skip_int();
456 for (int i=1; i<=rVar(r); i++)
457 lintree.skip_int();
458 }
459}
void skip_int()
Definition: lintree.h:77
void ref_number(LinTree &lintree, int by)
Definition: lintree.cc:344

◆ ref_ring()

void LinTree::ref_ring ( LinTree lintree,
int  by 
)

Definition at line 697 of file lintree.cc.

697 {
698 int ch = lintree.get_int();
699 int N = lintree.get_int();
700 switch (ch) {
701 case -3:
702 lintree.skip_cstring();
703 case -4:
704 case -5:
705 return;
706 }
707 for (int i=0; i<N; i++)
708 lintree.skip_cstring();
709 int num_ord = lintree.get_int();
710 for (int i=0; i<N; i++) {
711 int ord = lintree.get_int();
712 int block0 = lintree.get_int();
713 int block1 = lintree.get_int();
714 switch (ord) {
715 case ringorder_a:
716 case ringorder_wp:
717 case ringorder_Wp:
718 case ringorder_ws:
719 case ringorder_Ws:
720 case ringorder_aa:
721 for (int j=block0; j<=block1; j++)
722 lintree.skip_int();
723 break;
724 }
725 }
726 if (N != 0) {
727 if (ch == -1 || ch == -2) {
728 ref_ring(lintree, by);
729 }
730 }
731}
void skip_cstring()
Definition: lintree.h:110
void ref_ring(LinTree &lintree, int by)
Definition: lintree.cc:697

◆ ref_string()

void LinTree::ref_string ( LinTree lintree,
int  by 
)

Definition at line 193 of file lintree.cc.

193 {
194 size_t len = lintree.get<size_t>();
195 lintree.skip_bytes(len);
196}

◆ set_needs_ring()

void LinTree::set_needs_ring ( int  typ)

Definition at line 74 of file lintree.cc.

74 {
75 needs_ring[typ] = 1;
76}

◆ to_string()

std::string LinTree::to_string ( leftv  val)

Definition at line 843 of file lintree.cc.

843 {
844 LinTree lintree;
845 encode(lintree, val);
846 if (lintree.has_error()) {
847 encoding_error(lintree.error_msg());
848 lintree.clear();
849 lintree.put_int(NONE);
850 }
851 return lintree.to_string();
852}
std::string & to_string()
Definition: lintree.h:117
void clear()
Definition: lintree.h:37
int has_error()
Definition: lintree.h:41
const char * error_msg()
Definition: lintree.h:44
void encoding_error(const char *s)
Definition: lintree.cc:834

◆ updateref()

void LinTree::updateref ( LinTree lintree,
int  by 
)

Definition at line 112 of file lintree.cc.

112 {
113 int typ = lintree.get_int();
114 LinTreeRefFunc fn = refupdaters[typ];
115 fn(lintree, by);
116}
void(* LinTreeRefFunc)(LinTree &lintree, int by)
Definition: lintree.h:15

Variable Documentation

◆ decoders

std::vector< LinTreeDecodeFunc > LinTree::decoders

Definition at line 47 of file lintree.cc.

◆ encoders

std::vector< LinTreeEncodeFunc > LinTree::encoders

Definition at line 46 of file lintree.cc.

◆ needs_ring

vector<char> LinTree::needs_ring

Definition at line 49 of file lintree.cc.

◆ refupdaters

std::vector< LinTreeRefFunc > LinTree::refupdaters

Definition at line 48 of file lintree.cc.