My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes
mp_permmatrix Class Reference

Public Member Functions

 mp_permmatrix ()
 
 mp_permmatrix (matrix, ring)
 
 mp_permmatrix (mp_permmatrix *)
 
 ~mp_permmatrix ()
 
int mpGetRow ()
 
int mpGetCol ()
 
int mpGetRdim ()
 
int mpGetCdim ()
 
int mpGetSign ()
 
void mpSetSearch (int s)
 
void mpSaveArray ()
 
poly mpGetElem (int, int)
 
void mpSetElem (poly, int, int)
 
void mpDelElem (int, int)
 
void mpElimBareiss (poly)
 
int mpPivotBareiss (row_col_weight *)
 
int mpPivotRow (row_col_weight *, int)
 
void mpToIntvec (intvec *)
 
void mpRowReorder ()
 
void mpColReorder ()
 

Private Member Functions

void mpInitMat ()
 
poly * mpRowAdr (int r)
 
poly * mpColAdr (int c)
 
void mpRowWeight (float *)
 
void mpColWeight (float *)
 
void mpRowSwap (int, int)
 
void mpColSwap (int, int)
 

Private Attributes

int a_m
 
int a_n
 
int s_m
 
int s_n
 
int sign
 
int piv_s
 
int * qrow
 
int * qcol
 
poly * Xarray
 
ring _R
 

Detailed Description

Definition at line 918 of file matpol.cc.

Constructor & Destructor Documentation

◆ mp_permmatrix() [1/3]

mp_permmatrix::mp_permmatrix ( )
inline

Definition at line 935 of file matpol.cc.

935: a_m(0) {}

◆ mp_permmatrix() [2/3]

mp_permmatrix::mp_permmatrix ( matrix  A,
ring  R 
)

Definition at line 956 of file matpol.cc.

956 : sign(1)
957{
958 a_m = A->nrows;
959 a_n = A->ncols;
960 this->mpInitMat();
961 Xarray = A->m;
962 _R=R;
963}
poly * m
Definition: matpol.h:18
poly * Xarray
Definition: matpol.cc:923
void mpInitMat()
Definition: matpol.cc:1078
#define R
Definition: sirandom.c:27
#define A
Definition: sirandom.c:24

◆ mp_permmatrix() [3/3]

mp_permmatrix::mp_permmatrix ( mp_permmatrix M)

Definition at line 965 of file matpol.cc.

966{
967 poly p, *athis, *aM;
968 int i, j;
969
970 _R=M->_R;
971 a_m = M->s_m;
972 a_n = M->s_n;
973 sign = M->sign;
974 this->mpInitMat();
975 Xarray = (poly *)omAlloc0(a_m*a_n*sizeof(poly));
976 for (i=a_m-1; i>=0; i--)
977 {
978 athis = this->mpRowAdr(i);
979 aM = M->mpRowAdr(i);
980 for (j=a_n-1; j>=0; j--)
981 {
982 p = aM[M->qcol[j]];
983 if (p)
984 {
985 athis[j] = p_Copy(p,_R);
986 }
987 }
988 }
989}
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
poly * mpRowAdr(int r)
Definition: matpol.cc:926
int j
Definition: facHensel.cc:110
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:844
#define M
Definition: sirandom.c:25

◆ ~mp_permmatrix()

mp_permmatrix::~mp_permmatrix ( )

Definition at line 991 of file matpol.cc.

992{
993 int k;
994
995 if (a_m != 0)
996 {
997 omFreeSize((ADDRESS)qrow,a_m*sizeof(int));
998 omFreeSize((ADDRESS)qcol,a_n*sizeof(int));
999 if (Xarray != NULL)
1000 {
1001 for (k=a_m*a_n-1; k>=0; k--)
1002 p_Delete(&Xarray[k],_R);
1003 omFreeSize((ADDRESS)Xarray,a_m*a_n*sizeof(poly));
1004 }
1005 }
1006}
void * ADDRESS
Definition: auxiliary.h:119
int k
Definition: cfEzgcd.cc:99
int * qrow
Definition: matpol.cc:922
int * qcol
Definition: matpol.cc:922
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define NULL
Definition: omList.c:12
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:899

Member Function Documentation

◆ mpColAdr()

poly * mp_permmatrix::mpColAdr ( int  c)
inlineprivate

Definition at line 928 of file matpol.cc.

929 { return &(Xarray[qcol[c]]); }

◆ mpColReorder()

void mp_permmatrix::mpColReorder ( )

Definition at line 1091 of file matpol.cc.

1092{
1093 int k, j, j1, j2;
1094
1095 if (a_n > a_m)
1096 k = a_n - a_m;
1097 else
1098 k = 0;
1099 for (j=a_n-1; j>=k; j--)
1100 {
1101 j1 = qcol[j];
1102 if (j1 != j)
1103 {
1104 this->mpColSwap(j1, j);
1105 j2 = 0;
1106 while (qcol[j2] != j) j2++;
1107 qcol[j2] = j1;
1108 }
1109 }
1110}
void mpColSwap(int, int)
Definition: matpol.cc:1064

◆ mpColSwap()

void mp_permmatrix::mpColSwap ( int  j1,
int  j2 
)
private

Definition at line 1064 of file matpol.cc.

1065{
1066 poly p, *a1, *a2;
1067 int i, k = a_n*a_m;
1068
1069 a1 = &(Xarray[j1]);
1070 a2 = &(Xarray[j2]);
1071 for (i=0; i< k; i+=a_n)
1072 {
1073 p = a1[i];
1074 a1[i] = a2[i];
1075 a2[i] = p;
1076 }
1077}

◆ mpColWeight()

void mp_permmatrix::mpColWeight ( float *  wcol)
private

Definition at line 1010 of file matpol.cc.

1011{
1012 poly p, *a;
1013 int i, j;
1014 float count;
1015
1016 for (j=s_n; j>=0; j--)
1017 {
1018 a = this->mpColAdr(j);
1019 count = 0.0;
1020 for(i=s_m; i>=0; i--)
1021 {
1022 p = a[a_n*qrow[i]];
1023 if (p)
1024 count += mp_PolyWeight(p,_R);
1025 }
1026 wcol[j] = count;
1027 }
1028}
poly * mpColAdr(int c)
Definition: matpol.cc:928
static float mp_PolyWeight(poly p, const ring r)
Definition: matpol.cc:1295
int status int void size_t count
Definition: si_signals.h:59

◆ mpDelElem()

void mp_permmatrix::mpDelElem ( int  ,
int   
)

◆ mpElimBareiss()

void mp_permmatrix::mpElimBareiss ( poly  div)

Definition at line 1237 of file matpol.cc.

1238{
1239 poly piv, elim, q1, q2, *ap, *a;
1240 int i, j, jj;
1241
1242 ap = this->mpRowAdr(s_m);
1243 piv = ap[qcol[s_n]];
1244 for(i=s_m-1; i>=0; i--)
1245 {
1246 a = this->mpRowAdr(i);
1247 elim = a[qcol[s_n]];
1248 if (elim != NULL)
1249 {
1250 elim = p_Neg(elim,_R);
1251 for (j=s_n-1; j>=0; j--)
1252 {
1253 q2 = NULL;
1254 jj = qcol[j];
1255 if (ap[jj] != NULL)
1256 {
1257 q2 = SM_MULT(ap[jj], elim, div,_R);
1258 if (a[jj] != NULL)
1259 {
1260 q1 = SM_MULT(a[jj], piv, div,_R);
1261 p_Delete(&a[jj],_R);
1262 q2 = p_Add_q(q2, q1, _R);
1263 }
1264 }
1265 else if (a[jj] != NULL)
1266 {
1267 q2 = SM_MULT(a[jj], piv, div, _R);
1268 }
1269 if ((q2!=NULL) && div)
1270 SM_DIV(q2, div, _R);
1271 a[jj] = q2;
1272 }
1273 p_Delete(&a[qcol[s_n]], _R);
1274 }
1275 else
1276 {
1277 for (j=s_n-1; j>=0; j--)
1278 {
1279 jj = qcol[j];
1280 if (a[jj] != NULL)
1281 {
1282 q2 = SM_MULT(a[jj], piv, div, _R);
1283 p_Delete(&a[jj], _R);
1284 if (div)
1285 SM_DIV(q2, div, _R);
1286 a[jj] = q2;
1287 }
1288 }
1289 }
1290 }
1291}
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm div(const CanonicalForm &, const CanonicalForm &)
Definition: ap.h:40
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1105
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:934
#define SM_DIV
Definition: sparsmat.h:24
#define SM_MULT
Definition: sparsmat.h:23

◆ mpGetCdim()

int mp_permmatrix::mpGetCdim ( )
inline

Definition at line 942 of file matpol.cc.

942{ return s_n; }

◆ mpGetCol()

int mp_permmatrix::mpGetCol ( )

◆ mpGetElem()

poly mp_permmatrix::mpGetElem ( int  r,
int  c 
)

Definition at line 1229 of file matpol.cc.

1230{
1231 return Xarray[a_n*qrow[r]+qcol[c]];
1232}

◆ mpGetRdim()

int mp_permmatrix::mpGetRdim ( )
inline

Definition at line 941 of file matpol.cc.

941{ return s_m; }

◆ mpGetRow()

int mp_permmatrix::mpGetRow ( )

◆ mpGetSign()

int mp_permmatrix::mpGetSign ( )
inline

Definition at line 943 of file matpol.cc.

943{ return sign; }

◆ mpInitMat()

void mp_permmatrix::mpInitMat ( )
private

Definition at line 1078 of file matpol.cc.

1079{
1080 int k;
1081
1082 s_m = a_m;
1083 s_n = a_n;
1084 piv_s = 0;
1085 qrow = (int *)omAlloc(a_m*sizeof(int));
1086 qcol = (int *)omAlloc(a_n*sizeof(int));
1087 for (k=a_m-1; k>=0; k--) qrow[k] = k;
1088 for (k=a_n-1; k>=0; k--) qcol[k] = k;
1089}
#define omAlloc(size)
Definition: omAllocDecl.h:210

◆ mpPivotBareiss()

int mp_permmatrix::mpPivotBareiss ( row_col_weight C)

Definition at line 1152 of file matpol.cc.

1153{
1154 poly p, *a;
1155 int i, j, iopt, jopt;
1156 float sum, f1, f2, fo, r, ro, lp;
1157 float *dr = C->wrow, *dc = C->wcol;
1158
1159 fo = 1.0e20;
1160 ro = 0.0;
1161 iopt = jopt = -1;
1162
1163 s_n--;
1164 s_m--;
1165 if (s_m == 0)
1166 return 0;
1167 if (s_n == 0)
1168 {
1169 for(i=s_m; i>=0; i--)
1170 {
1171 p = this->mpRowAdr(i)[qcol[0]];
1172 if (p)
1173 {
1174 f1 = mp_PolyWeight(p,_R);
1175 if (f1 < fo)
1176 {
1177 fo = f1;
1178 if (iopt >= 0)
1179 p_Delete(&(this->mpRowAdr(iopt)[qcol[0]]),_R);
1180 iopt = i;
1181 }
1182 else
1183 p_Delete(&(this->mpRowAdr(i)[qcol[0]]),_R);
1184 }
1185 }
1186 if (iopt >= 0)
1187 mpReplace(iopt, s_m, sign, qrow);
1188 return 0;
1189 }
1190 this->mpRowWeight(dr);
1191 this->mpColWeight(dc);
1192 sum = 0.0;
1193 for(i=s_m; i>=0; i--)
1194 sum += dr[i];
1195 for(i=s_m; i>=0; i--)
1196 {
1197 r = dr[i];
1198 a = this->mpRowAdr(i);
1199 for(j=s_n; j>=0; j--)
1200 {
1201 p = a[qcol[j]];
1202 if (p)
1203 {
1204 lp = mp_PolyWeight(p,_R);
1205 ro = r - lp;
1206 f1 = ro * (dc[j]-lp);
1207 if (f1 != 0.0)
1208 {
1209 f2 = lp * (sum - ro - dc[j]);
1210 f2 += f1;
1211 }
1212 else
1213 f2 = lp-r-dc[j];
1214 if (f2 < fo)
1215 {
1216 fo = f2;
1217 iopt = i;
1218 jopt = j;
1219 }
1220 }
1221 }
1222 }
1223 if (iopt < 0)
1224 return 0;
1225 mpReplace(iopt, s_m, sign, qrow);
1226 mpReplace(jopt, s_n, sign, qcol);
1227 return 1;
1228}
void mpColWeight(float *)
Definition: matpol.cc:1010
void mpRowWeight(float *)
Definition: matpol.cc:1029
float * wcol
Definition: matpol.cc:886
float * wrow
Definition: matpol.cc:886
static void mpReplace(int j, int n, int &sign, int *perm)
Definition: matpol.cc:1137

◆ mpPivotRow()

int mp_permmatrix::mpPivotRow ( row_col_weight ,
int   
)

◆ mpRowAdr()

poly * mp_permmatrix::mpRowAdr ( int  r)
inlineprivate

Definition at line 926 of file matpol.cc.

927 { return &(Xarray[a_n*qrow[r]]); }

◆ mpRowReorder()

void mp_permmatrix::mpRowReorder ( )

Definition at line 1112 of file matpol.cc.

1113{
1114 int k, i, i1, i2;
1115
1116 if (a_m > a_n)
1117 k = a_m - a_n;
1118 else
1119 k = 0;
1120 for (i=a_m-1; i>=k; i--)
1121 {
1122 i1 = qrow[i];
1123 if (i1 != i)
1124 {
1125 this->mpRowSwap(i1, i);
1126 i2 = 0;
1127 while (qrow[i2] != i) i2++;
1128 qrow[i2] = i1;
1129 }
1130 }
1131}
void mpRowSwap(int, int)
Definition: matpol.cc:1049

◆ mpRowSwap()

void mp_permmatrix::mpRowSwap ( int  i1,
int  i2 
)
private

Definition at line 1049 of file matpol.cc.

1050{
1051 poly p, *a1, *a2;
1052 int j;
1053
1054 a1 = &(Xarray[a_n*i1]);
1055 a2 = &(Xarray[a_n*i2]);
1056 for (j=a_n-1; j>= 0; j--)
1057 {
1058 p = a1[j];
1059 a1[j] = a2[j];
1060 a2[j] = p;
1061 }
1062}

◆ mpRowWeight()

void mp_permmatrix::mpRowWeight ( float *  wrow)
private

Definition at line 1029 of file matpol.cc.

1030{
1031 poly p, *a;
1032 int i, j;
1033 float count;
1034
1035 for (i=s_m; i>=0; i--)
1036 {
1037 a = this->mpRowAdr(i);
1038 count = 0.0;
1039 for(j=s_n; j>=0; j--)
1040 {
1041 p = a[qcol[j]];
1042 if (p)
1043 count += mp_PolyWeight(p,_R);
1044 }
1045 wrow[i] = count;
1046 }
1047}

◆ mpSaveArray()

void mp_permmatrix::mpSaveArray ( )
inline

Definition at line 945 of file matpol.cc.

945{ Xarray = NULL; }

◆ mpSetElem()

void mp_permmatrix::mpSetElem ( poly  ,
int  ,
int   
)

◆ mpSetSearch()

void mp_permmatrix::mpSetSearch ( int  s)

◆ mpToIntvec()

void mp_permmatrix::mpToIntvec ( intvec )

Field Documentation

◆ _R

ring mp_permmatrix::_R
private

Definition at line 924 of file matpol.cc.

◆ a_m

int mp_permmatrix::a_m
private

Definition at line 921 of file matpol.cc.

◆ a_n

int mp_permmatrix::a_n
private

Definition at line 921 of file matpol.cc.

◆ piv_s

int mp_permmatrix::piv_s
private

Definition at line 921 of file matpol.cc.

◆ qcol

int * mp_permmatrix::qcol
private

Definition at line 922 of file matpol.cc.

◆ qrow

int* mp_permmatrix::qrow
private

Definition at line 922 of file matpol.cc.

◆ s_m

int mp_permmatrix::s_m
private

Definition at line 921 of file matpol.cc.

◆ s_n

int mp_permmatrix::s_n
private

Definition at line 921 of file matpol.cc.

◆ sign

int mp_permmatrix::sign
private

Definition at line 921 of file matpol.cc.

◆ Xarray

poly* mp_permmatrix::Xarray
private

Definition at line 923 of file matpol.cc.


The documentation for this class was generated from the following file: