My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
kernel
maps
find_perm.cc
Go to the documentation of this file.
1
/****************************************
2
* Computer Algebra System SINGULAR *
3
****************************************/
4
/***************************************************************
5
* File: find_perm.cc
6
* Purpose: is a map a permutation ?
7
* Author: hannes
8
* Created: 16/01
9
*******************************************************************/
10
11
12
13
#include "
kernel/mod2.h
"
14
#include "
polys/monomials/p_polys.h
"
15
#include "
kernel/ideals.h
"
16
#include "
polys/monomials/ring.h
"
17
#include "
kernel/maps/find_perm.h
"
18
19
static
int
*
find_perm_for_map
(
const
ring preimage_r,
const
ring image_r,
const
ideal image)
20
{
21
int
i
;
22
int
*perm=(
int
*)
omAlloc0
((preimage_r->N+1)*
sizeof
(
int
));
23
for
(
i
=si_min(
IDELEMS
(image),preimage_r->N)-1;
i
>=0;
i
--)
24
{
25
if
(image->m[
i
]!=
NULL
)
26
{
27
if
((
pNext
(image->m[
i
])==
NULL
)
28
&& (n_IsOne(pGetCoeff(image->m[
i
]),image_r->cf)))
29
{
30
int
v
=
p_IsUnivariate
(image->m[
i
],image_r);
31
if
(
v
<=0)
/*not univariate */
32
{
33
omFreeSize
(perm,(preimage_r->N+1)*
sizeof
(
int
));
34
return
NULL
;
35
}
36
else
if
(
v
>0)
/* image is univaritate */
37
{
38
if
(p_GetExp(image->m[
i
],
v
,image_r)==1)
39
{
40
perm[
i
+1]=
v
;
/* and of exp 1 */
41
}
42
else
43
{
44
omFreeSize
(perm,(preimage_r->N+1)*
sizeof
(
int
));
45
return
NULL
;
46
}
47
}
48
}
49
else
/* image is not a monomial */
50
{
51
omFreeSize
(perm,(preimage_r->N+1)*
sizeof
(
int
));
52
return
NULL
;
53
}
54
}
55
}
56
//Print("elms:%d, N:%d\n",IDELEMS(image),preimage_r->N);
57
//iiWriteMatrix((matrix)image,"_",1,image_r,0);
58
//PrintS("\npreimage:\n");rWrite(preimage_r);
59
//PrintS("image:\n");rWrite(image_r);
60
//PrintS("\nperm:");
61
//for (i=1; i<=preimage_r->N; i++)
62
//{
63
// Print(" %d",perm[i]);
64
//}
65
//PrintLn();
66
return
perm;
67
}
68
69
matrix
ma_ApplyPermForMap
(
const
matrix
to_map,
const
ring preimage_r,
70
const
ideal image,
const
ring image_r,
const
nMapFunc
nMap)
71
{
72
if
((rPar(preimage_r)>0)||(rPar(image_r)>0))
return
NULL
;
/* not applicable */
73
int
*perm=
find_perm_for_map
(preimage_r,image_r,image);
74
if
(perm==
NULL
)
return
NULL
;
/* could not find permutation */
75
int
C=to_map->
cols
();
76
int
R
=to_map->
rows
();
77
matrix
m
=
mpNew
(
R
,C);
78
for
(
int
i
=
R
*C-1;
i
>=0;
i
--)
79
{
80
if
(to_map->
m
[
i
]!=
NULL
)
81
{
82
m
->m[
i
]=
p_PermPoly
(to_map->
m
[
i
],perm,preimage_r,image_r, nMap,
NULL
,0);
83
p_Test
(
m
->m[
i
],image_r);
84
}
85
}
86
ideal ii=(ideal)
m
;
87
ii->rank=((ideal)to_map)->rank;
88
omFreeSize
(perm,(preimage_r->N+1)*
sizeof
(
int
));
89
return
m
;
90
}
91
m
int m
Definition
cfEzgcd.cc:128
i
int i
Definition
cfEzgcd.cc:132
ip_smatrix::m
poly * m
Definition
matpol.h:18
ip_smatrix::cols
int & cols()
Definition
matpol.h:24
ip_smatrix::rows
int & rows()
Definition
matpol.h:23
nMapFunc
number(*) nMapFunc(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition
coeffs.h:80
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition
facBivar.h:39
ma_ApplyPermForMap
matrix ma_ApplyPermForMap(const matrix to_map, const ring preimage_r, const ideal image, const ring image_r, const nMapFunc nMap)
helper function for maMapIdeal mapping ideal/matrix/module for the case of a permutation: maps the id...
Definition
find_perm.cc:69
find_perm_for_map
static int * find_perm_for_map(const ring preimage_r, const ring image_r, const ideal image)
Definition
find_perm.cc:19
find_perm.h
ideals.h
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition
matpol.cc:37
matrix
ip_smatrix * matrix
Definition
matpol.h:43
mod2.h
pNext
#define pNext(p)
Definition
monomials.h:36
omFreeSize
#define omFreeSize(addr, size)
Definition
omAllocDecl.h:260
omAlloc0
#define omAlloc0(size)
Definition
omAllocDecl.h:211
NULL
#define NULL
Definition
omList.c:12
p_PermPoly
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition
p_polys.cc:4269
p_IsUnivariate
int p_IsUnivariate(poly p, const ring r)
return i, if poly depends only on var(i)
Definition
p_polys.cc:1248
p_polys.h
p_Test
#define p_Test(p, r)
Definition
p_polys.h:161
ring.h
IDELEMS
#define IDELEMS(i)
Definition
simpleideals.h:23
R
#define R
Definition
sirandom.c:27
Generated on
for My Project by
doxygen 1.18.0
for
Singular