29# define DEBUG_BLOCK(x) bool debug_block = x;
33# define DEBUG_PRINT(x) do {if(debug_block) {Print x ;}} while(0)
34# define DEBUG_CMD(x) do {if(debug_block) {x;}} while(0)
35# define DEBUG_VAR(x) do {if(debug_block) {std::cout<<#x<<": "<<x<<std::endl;}} while(0)
36# define DEBUG_N(x) do {if(debug_block) {Print(#x);Print(": ");n_Print(x,coef);Print("\n");}} while(0)
37# define DEBUG_BIM(x) do {if(debug_block) {Print(#x);Print(": ");x->Print();Print("\n");}} while(0)
39# define DEBUG_BLOCK(x) do {} while (0)
40# define DEBUG_PRINT(x) do {} while (0)
41# define DEBUG_CMD(x) do {} while (0)
42# define DEBUG_VAR(x) do {} while (0)
43# define DEBUG_N(x) do {} while (0)
44# define DEBUG_BIM(x) do {} while (0)
55 n = basismatrix->
cols();
56 m = basismatrix->
rows();
66 for(
int i=1;
i<=
n;
i++) {
95 for(
int i=0;
i<=
n;
i++) {
102 for(
int i=0;
i<=
n;
i++) {
109 for(
int i=0;
i<=
n;
i++) {
135 number three = n_Init(3,
coef);
136 number four = n_Init(4,
coef);
137 number default_c = n_Div(three,four,
coef);
138 n_Delete(&three,
coef);
139 n_Delete(&four,
coef);
149 for(
int j=1;
j<=
n;
j++) {
154 for(
int j=1;
j<=
n;
j++) {
162 for(
int j=0;
j<=
n;
j++) {
166 for(
int j=0;
j<=
n;
j++) {
175 for(
int j=0;
j<=
n;
j++) {
241 if(n_Greater(n_Mult(n_Sub(
c, n_Mult(
my->
view(
k,
k-1),
my->
view(
k,
k-1),
coef),
coef),
B[
k-1],
coef),
B[
k],
coef)){
251 for(
int l=
k-2;
l>0;
l--){
281 number n_1div2 = n_Div(n_Init( 1,
coef),n_Init(2,
coef),
coef);
282 number n_neg1div2 = n_Div(n_Init(-1,
coef),n_Init(2,
coef),
coef);
287 if (n_Greater (my_kl,n_1div2,
coef) || n_Greater (n_neg1div2,my_kl,
coef)) {
289 number my_klplus1div2;
290 if(n_Greater (my_kl,n_Init(0,
coef),
coef)) {
291 my_klplus1div2 = n_Add(my_kl, n_1div2,
coef);
293 my_klplus1div2 = n_Add(my_kl, n_neg1div2,
coef);
296 number q = n_Div(n_GetNumerator(my_klplus1div2,
coef),n_GetDenom(my_klplus1div2,
coef),
coef);
308 for(
int i=1;
i<=
l-1;
i++){
316 DEBUG_PRINT((
"Start SWAP with k=%d and k_max=%d\n",
k,k_max));
326 for(
int j = 1;
j <=
k-2;
j++){
348 B[
k-1] = n_Copy(B_,
coef);
349 for(
int i =
k+1;
i <= k_max;
i++){
358 DEBUG_PRINT((
"Start SWAPG with k=%d and k_max=%d\n",
k,k_max));
368 for(
int j = 1;
j <=
k-2;
j++){
379 if(n_IsZero(my_,
coef)) {
380 number tempnumber =
B[
k];
388 for(
int i =
k+1;
i <= k_max;
i++){
389 number tempnumber =
my->
get(
i,
k);
394 B[
k-1] = n_Copy(B_,
coef);
400 for(
int i =
k+1;
i <= k_max;
i++){
405 number t = n_Div(
B[
k-1], B_,
coef);
419 B[
k-1] = n_Copy(B_,
coef);
421 for(
int i =
k+1;
i <= k_max;
i++){
436 for(
int j=1;
j<
k;
j++) {
445 Werror(
"did not form a basis\n");
457 for(
int j=1;
j<
k;
j++) {
467 for(
int j=1;
j<
k;
j++) {
529 number zero = n_Init(0,
coef);
530 number minusOne = n_Init(-1,
coef);
535 DEBUG_PRINT((
"Initialize vector and other variables\n"));
536 std::vector<std::pair<number,bigintmat*> > elementsvector;
554 for(
int i = 2;
i<
n+1;
i++){
570 for(
unsigned i=1;
i<elementsvector.size();
i++){
571 if(n_Greater(elementsvector[
i].first,
check,
coef)){
572 elementsvector.pop_back();
573 elementsvector.insert(elementsvector.begin()+
i,std::make_pair(n_Copy(
check,
coef),
bimCopy(
x)));
578 if(elementsvector.size() >= 1000000){
579 elementsvector.pop_back();
590 for(
unsigned i=1;
i<elementsvector.size();
i++){
594 for(
unsigned i=1;
i<elementsvector.size();
i++){
607 DEBUG_PRINT((
"Start enumerate_next number and bigintmat\n"));
648 for(
int j =
n;
j>1;
j--){
653 number minusOne = n_Init(-1,
coef);
680 Werror(
"no bound for elements given\n");
695 Werror(
"not initialized\n");
702 number minusOne = n_Init(-1,
coef);
703 number one = n_Init(1,
coef);
708 if(!n_Equal(minusOne,
x->
view(1,1),
coef)){
720 DEBUG_PRINT((
"enumerate_get_next\t\t\t\t\taaaaaaaaaaaaa\n"));
721 number one = n_Init(1,
coef);
722 number zero = n_Init(0,
coef);
723 number minusOne = n_Init(-1,
coef);
748 }
else if(index == 1){
785 number zero = n_Init(0,
coef);
811 for(
int j = 1;
j<
i;
j++){
815 n_Delete(&zero,
coef);
834 for(
int i=1;
i<=
n;
i++) {
835 for(
int j=1;
j<=
n;
j++) {
845 newNumber = n_Add(one,
x->
view(index,1),
coef);
847 newNumber = n_Sub(
x->
view(index,1),one,
coef);
852 n_Delete(&newNumber,
coef);
876 for(
int j=1;
j<=
n;
j++) {
884 for(
int j=1;
j<=
n;
j++) {
917 Werror(
"a->cols()!=1 in scalarproduct(a,b)\n");
921 Werror(
"b->cols()!=1 in scalarproduct(a,b)\n");
924 if(a->
rows()!=
b->rows()) {
925 Werror(
"b->cols()!=1 in scalarproduct(a,b)\n");
929 Werror(
"a->basecoeffs()!=b->basecoeffs() in scalarproduct(a,b)\n");
934 number
p = n_Init(0,coef);
935 for(
int i = 1;
i <=
b->rows();
i++){
936 number
prod = n_Mult(a->
view(
i,1),
b->view(
i,1), coef);
937 n_InpAdd(
p,
prod, coef);
938 n_Delete(&
prod,coef);
952 if(elementarray ==
NULL || poly ==
NULL || coef != elementarray[0]->basecoeffs()){
957 for(
int i=1;
i<size_elementarray;
i++){
958 if(coef != elementarray[0]->basecoeffs()){
967 WerrorS(
"Ground field not implemented!\n");
972 WerrorS(
"degree of polynomial to small\n");
985 char* n[] = {(
char*)
"i"};
986 ring newring =
rDefault(coef, 1, n);
991 rootcont->
solver( precision+12);
993 if(number_roots != deg){
994 WerrorS(
"something went wrong: \n\tnot all roots found\n");
998 paramComp.
float_len = si_min (precision+6, 32767);
999 paramComp.
float_len2 = si_min (precision+8, 32767);
1000 paramComp.
par_name=(
const char*)
"i";
1004 number* roots =
new number[deg+1];
1005 number* complexroots =
new number[deg+1];
1008 for(
int j=0;
j<deg;
j++){
1009 number a = n_Copy((number)(rootcont->
getRoot(
j)),
comp);
1011 roots[r1] = n_Copy(a,
comp);
1014 complexroots[r2] = n_Copy(a,
comp);
1026 for(
int j=0;
j<r2;
j++){
1027 roots[r1+
j]= n_Copy(complexroots[
j],
comp);
1028 n_Delete(&complexroots[
j],
comp);
1030 delete complexroots;
1033 for(
int i=0;
i<size_elementarray;
i++){
1039 for(
int i=1;
i<= r1;
i++){
1040 number pot = n_Init(1,
comp);
1041 for(
int l=0;
l< deg;
l++){
1042 for(
int j=0;
j<size_elementarray;
j++){
1043 number
mult = n_Mult(pot,elements[
j]->view(
l),
comp);
1047 n_InpMult(pot, roots[
i-1],
comp);
1049 n_Delete(&pot,
comp);
1052 number sqrt2 = n_Init(1,
comp);
1054 number two = n_Init(2,
comp);
1056 n_Delete(&two,
comp);
1057 for(
int i=1;
i<= r2;
i++){
1058 number pot = n_Init(1,
comp);
1059 for(
int l=0;
l< deg;
l++){
1060 for(
int j=0;
j<size_elementarray;
j++){
1061 number
mult = n_Mult(pot,elements[
j]->view(
l),
comp);
1065 n_InpMult(pot, roots[
i-1],
comp);
1067 n_Delete(&pot,
comp);
1068 for(
int j=1;
j<=size_elementarray;
j++){
1076 for(
int i=0;
i<size_elementarray;
i++){
1080 for(
int i=0;
i<r1+r2;
i++){
1081 n_Delete(&roots[
i],
comp);
1087 paramReal.
float_len = si_min (precision, 32767);
1088 paramReal.
float_len2 = si_min (precision, 32767);
1089 paramComp.
par_name=(
const char*)
"i";
1099 bool out = n_IsZero(imag,coef);
1100 n_Delete(&imag,coef);
1106 bool out = n_GreaterZero(imag,coef);
1107 n_Delete(&imag,coef);
1112 if(n_IsZero(a,coef)){
1115 if(!n_GreaterZero(a,coef)){
1116 return n_Init(0,coef);
1118 number two = n_Init(2,coef);
1119 number
xn = n_Copy(a,coef);
1121 for(
int i=0;
i<prec;
i++){
1122 xn1 = n_Div(a,
xn,coef);
1123 xn2 = n_Add(
xn,xn1,coef);
1125 xn = n_Div(xn2,two,coef);
1126 n_Delete(&xn1,coef);
1127 n_Delete(&xn2,coef);
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
bigintmat * bimCopy(const bigintmat *b)
same as copy constructor - apart from it being able to accept NULL as input
bigintmat * bimMult(bigintmat *a, bigintmat *b)
bigintmat * bimSub(bigintmat *a, bigintmat *b)
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? @Note: NULL as a result means an error (non-compati...
void Print()
IO: simply prints the matrix to the current output (screen?).
void zero()
Setzt alle Einträge auf 0.
void appendCol(bigintmat *a)
horizontally join the matrices, m <- m|a
void swap(int i, int j)
swap columns i and j
bool addcol(int i, int j, number a, coeffs c)
addiert a-faches der j-ten Spalte zur i-ten dazu
void setcol(int j, bigintmat *m)
Setzt j-te Spalte gleich übergebenem Vektor (Matrix) m.
bool skalmult(number b, coeffs c)
Multipliziert zur Matrix den Skalar b hinzu.
void getcol(int j, bigintmat *a)
copies the j-th column into the matrix a - which needs to be pre-allocated with the correct size.
number get(int i, int j) const
get a copy of an entry. NOTE: starts at [1,1]
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
void one()
Macht Matrix (Falls quadratisch) zu Einheitsmatrix.
void rawset(int i, number n, const coeffs C=NULL)
replace an entry with the given number n (only delete old). NOTE: starts at [0]. Should be named set_...
coeffs basecoeffs() const
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
bool sub(bigintmat *b)
Subtrahiert ...
bool quadratic_supplement()
void SWAP(int k, int k_max)
void SWAPG(int k, int k_max)
void increase_x(int index)
bigintmat * get_transformation_matrix()
lattice(bigintmat *basis)
void compute_gram_matrix()
bigintmat * enumerate_all(number a)
number enumerate_get_next()
number check_bound(int index)
bigintmat * enumerate_next(number a, bigintmat *x)
bigintmat * enumerate_next()
void gram_schmidt_MLLL(int k)
bigintmat * get_reduced_basis()
complex root finder for univariate polynomials based on laguers algorithm
gmp_complex * getRoot(const int i)
void fillContainer(number *_coeffs, number *_ievpoint, const int _var, const int _tdg, const rootType _rt, const int _anz)
bool solver(const int polishmode=PM_NONE)
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
@ n_long_R
real floating point (GMP) numbers
@ n_long_C
complex floating point (GMP) numbers
short float_len2
additional char-flags, rInit
const char * par_name
parameter name
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
short float_len
additional char-flags, rInit
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
number(*) nMapFunc(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
void WerrorS(const char *s)
bool IsReal(number a, coeffs coef)
number scalarproduct(bigintmat *a, bigintmat *b)
bigintmat * minkowksi(bigintmat **elementarray, int size_elementarray, number *poly, int deg, coeffs coef, int precision)
number squareroot(number a, coeffs coef, int prec)
bool ImagGreaterZero(number a, coeffs coef)
STATIC_VAR bool debug_block
number scalarproduct(bigintmat *a, bigintmat *b)
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
void setGMPFloatDigits(size_t digits, size_t rest)
Set size of mantissa digits - the number of output digits (basis 10) the size of mantissa consists of...
The main handler for Singular numbers which are suitable for Singular polynomials.
void rChangeCurrRing(ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void Werror(const char *fmt,...)
void rDelete(ring r)
unconditionally deletes fields in r
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)