Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

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

563667 views
1
#include "typedef.h"
2
#include "gmp.h"
3
#include "matrix.h"
4
5
/****************************************************************************
6
@
7
@----------------------------------------------------------------------------
8
@
9
@ static matrix_TYP *reverse_valuation(MP_INT *val,matrix_TYP *D)
10
@
11
@ The value of val will not be changed !
12
@----------------------------------------------------------------------------
13
@
14
*****************************************************************************/
15
matrix_TYP *reverse_valuation(MP_INT *val,matrix_TYP *D)
16
{
17
int i,
18
first,
19
last;
20
21
matrix_TYP *erg;
22
23
MP_INT tmp,
24
copy;
25
26
mpz_init(&tmp);
27
mpz_init_set(&copy,val);
28
29
/* set first and last */
30
for (first = 0;first<D->cols && D->array.SZ[first][first] == 1;first++);
31
for (last = 0;last<D->cols && D->array.SZ[last][last] != 0;last++);
32
33
erg = init_mat(last-first,1,"");
34
35
for (i=first;i<last;i++){
36
mpz_mod_ui(&tmp,&copy,(unsigned long) D->array.SZ[i][i]);
37
erg->array.SZ[i-first][0] = mpz_get_si(&tmp);
38
mpz_sub_ui(&copy,&copy,(unsigned long) erg->array.SZ[i-first][0]);
39
mpz_div_ui(&copy,&copy,(unsigned long) D->array.SZ[i][i]);
40
}
41
42
mpz_clear(&tmp);
43
mpz_clear(&copy);
44
45
return erg;
46
}
47
48