CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
/****************************************************************************
2
**
3
*A convert.c ANUPQ source Eamonn O'Brien
4
**
5
*Y Copyright 1995-2001, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany
6
*Y Copyright 1995-2001, School of Mathematical Sciences, ANU, Australia
7
**
8
*/
9
10
#include "pq_defs.h"
11
#include "pcp_vars.h"
12
13
/* convert exponent vector with base address
14
cp to string whose base address is str */
15
16
void vector_to_string(int cp, int str, struct pcp_vars *pcp)
17
{
18
register int *y = y_address;
19
20
register int i;
21
register int length = 0;
22
register int lastg = pcp->lastg;
23
24
#include "access.h"
25
26
for (i = 1; i <= lastg; ++i) {
27
if (y[cp + i] != 0) {
28
++length;
29
y[str + 1 + length] = PACK2(y[cp + i], i);
30
}
31
}
32
33
y[str + 1] = length;
34
}
35
36
/* convert exponent-vector with base address cp
37
to word with base address ptr */
38
39
int vector_to_word(int cp, int ptr, struct pcp_vars *pcp)
40
{
41
register int *y = y_address;
42
43
int i, j;
44
register int length = 1;
45
register int lastg = pcp->lastg;
46
47
y[ptr + 1] = 1;
48
for (i = 1; i <= lastg; ++i) {
49
for (j = 1; j <= y[cp + i]; ++j) {
50
++length;
51
y[ptr + length] = i;
52
}
53
}
54
55
y[ptr] = length;
56
return length;
57
}
58
59
/* convert normal word with base address ptr and exponent 1
60
to string with base address str */
61
void word_to_string(int ptr, int str, struct pcp_vars *pcp)
62
{
63
register int *y = y_address;
64
65
register int i;
66
register int length = y[ptr];
67
/* register int exp = y[ptr + 1]; */
68
#include "access.h"
69
70
for (i = 1; i <= length; ++i)
71
y[str + 1 + i] = PACK2(1, y[ptr + 1 + i]);
72
73
y[str + 1] = length;
74
}
75
76
/* convert string with base address str to
77
exponent vector whose base address is cp */
78
79
void string_to_vector(int str, int cp, struct pcp_vars *pcp)
80
{
81
register int *y = y_address;
82
83
register int i;
84
register int length = y[str + 1];
85
86
#include "access.h"
87
88
for (i = 1; i <= pcp->lastg; ++i)
89
y[cp + i] = 0;
90
91
for (i = 1; i <= length; ++i)
92
y[cp + FIELD2(y[str + 1 + i])] = FIELD1(y[str + 1 + i]);
93
}
94
95