Loading...
Searching...
No Matches
lattice.h File Reference

Go to the source code of this file.

## Data Structures

class | lattice

## Functions

number | scalarproduct (bigintmat *a, bigintmat *b)
bigintmat * | minkowksi (bigintmat **elementarray, int size_elementarray, number *poly, int deg, coeffs coef, int precision)
bool | IsReal (number a, coeffs coef)
bool | ImagGreaterZero (number a, coeffs coef)
number | squareroot (number a, coeffs coef, int iteration)

## Function Documentation

## ImagGreaterZero()

bool ImagGreaterZero | ( | number | a,
|  | coeffs | coef )

Definition at line 1104 of file lattice.cc.

{ //Im(a)>0
number imag = n_ImPart(a, coef);
bool out = n_GreaterZero(imag,coef);
n_Delete(&imag,coef);
return out;
}
n_GreaterZero
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition coeffs.h:500
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
n_ImPart
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition coeffs.h:788

## IsReal()

bool IsReal | ( | number | a,
|  | coeffs | coef )

Definition at line 1097 of file lattice.cc.

{ //Im(a)==0
number imag = n_ImPart(a, coef);
bool out = n_IsZero(imag,coef);
n_Delete(&imag,coef);
return out;
}
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470

## minkowksi()

bigintmat * minkowksi | ( | bigintmat ** | elementarray,
|  | int | size_elementarray,
|  | number * | poly,
|  | int | deg,
|  | coeffs | coef,
|  | int | precision )

Definition at line 948 of file lattice.cc.

{
DEBUG_BLOCK(true);
DEBUG_PRINT(("Begin Minkowski map\n"));
DEBUG_PRINT(("Input check\n"));
if(elementarray == NULL || poly == NULL || coef != elementarray[0]->basecoeffs()){
WerrorS("wrong input!\n");
return NULL;
}
for(int i=1;i<size_elementarray;i++){
if(coef != elementarray[0]->basecoeffs()){
WerrorS("wrong input!\n");
return NULL;
}
}
//char = 0
if ( !(nCoeff_is_Z(coef) || nCoeff_is_R(coef) || nCoeff_is_Q(coef) ||
nCoeff_is_long_R(coef) || nCoeff_is_long_C(coef)) ){
WerrorS("Ground field not implemented!\n");
return NULL;
}
if(deg<2){
WerrorS("degree of polynomial to small\n");
return NULL;
}
//check and define precision for Q
if(precision<6){
precision = 6;
}
if ( !(nCoeff_is_R(coef) || nCoeff_is_long_R(coef) || nCoeff_is_long_C(coef)) ){
setGMPFloatDigits( precision+6,precision+6);
}
DEBUG_PRINT(("find roots\n"));
ring CurrOldRing = rCopy(currRing);//need to change currRing, because rootContainer uses the coef of it
char* n[] = {(char*)"i"};
ring newring = rDefault(coef, 1, n);
rChangeCurrRing(newring);
DEBUG_PRINT(("initialize rootContainer\n"));
rootContainer * rootcont= new rootContainer();
rootcont->fillContainer( poly, NULL, 1, deg, rootContainer::onepoly, 1 );///
rootcont->solver( precision+12);
int number_roots = rootcont ->getAnzRoots();
if(number_roots != deg){
WerrorS("something went wrong: \n\tnot all roots found\n");
return NULL;
}
LongComplexInfo paramComp;
paramComp.float_len = si_min (precision+6, 32767);
paramComp.float_len2 = si_min (precision+8, 32767);
paramComp.par_name=(const char*)"i";
coeffs comp = nInitChar(n_long_C, &paramComp);
number* roots = new number[deg+1];
number* complexroots = new number[deg+1];
int r1 = 0;
int r2 = 0;
for(int j=0; j<deg; j++){
number a = n_Copy((number)(rootcont->getRoot(j)),comp);
if( IsReal(a,comp)){
roots[r1] = n_Copy(a,comp);
r1++;
}else if(ImagGreaterZero(a, comp)){
complexroots[r2] = n_Copy(a,comp);
r2++;
}
n_Delete(&a,comp);
}
rChangeCurrRing(CurrOldRing);
DEBUG_PRINT(("delete some variables\n"));
rDelete(newring);
delete &n;
//delete rootcont;DEBUG_PRINT(("can't delete rootcontainer rootcont\n"));
DEBUG_VAR(r1);
DEBUG_VAR(r2);
for(int j=0;j<r2;j++){
roots[r1+j]= n_Copy(complexroots[j],comp);
n_Delete(&complexroots[j],comp);
}
delete complexroots;
DEBUG_PRINT(("map elementarray to complex\n"));
bigintmat ** elements = new bigintmat*[size_elementarray];
for(int i=0;i<size_elementarray;i++){
elements[i] = bimChangeCoeff(elementarray[i],comp);
}
DEBUG_PRINT(("generate output matrix\n"));
DEBUG_PRINT(("real part\n"));
bigintmat * complexmat = new bigintmat(r1+2*r2,size_elementarray,comp);
for(int i=1; i<= r1; i++){
number pot = n_Init(1,comp);
for(int l=0; l< deg; l++){
for(int j=0; j<size_elementarray;j++){
number mult = n_Mult(pot,elements[j]->view(l),comp);
complexmat->rawset(i,j+1,n_Add(complexmat->view(i,j+1),mult,comp),comp);
n_Delete(&mult,comp);
}
n_InpMult(pot, roots[i-1],comp);
}
n_Delete(&pot,comp);
}
DEBUG_PRINT(("imaginary part\n"));
number sqrt2 = n_Init(1,comp);
if(r2>0){
number two = n_Init(2,comp);
number sqrt2 = squareroot(two,comp,precision+10);
n_Delete(&two,comp);
for(int i=1; i<= r2; i++){
number pot = n_Init(1,comp);
for(int l=0; l< deg; l++){
for(int j=0; j<size_elementarray;j++){
number mult = n_Mult(pot,elements[j]->view(l),comp);
complexmat->rawset(r1+2*i,j+1,n_Add(complexmat->view(r1+2*i,j+1),mult,comp),comp);
n_Delete(&mult,comp);
}
n_InpMult(pot, roots[i-1],comp);
}
n_Delete(&pot,comp);
for(int j=1;j<=size_elementarray;j++){
complexmat->set(r1+2*i,j,n_Mult(complexmat->view(r1+2*i,j),sqrt2,comp),comp);
complexmat->set(r1+2*i-1,j,n_RePart(complexmat->view(r1+2*i,j),comp),comp);
complexmat->set(r1+2*i,j,n_ImPart(complexmat->view(r1+2*i,j),comp),comp);
}
}
}
DEBUG_PRINT(("delete Variables\n"));
for(int i=0;i<size_elementarray;i++){
delete elements[i];
}
delete elements;
for(int i=0;i<r1+r2;i++){
n_Delete(&roots[i],comp);
}
delete roots;
DEBUG_PRINT(("to real\n"));
LongComplexInfo paramReal;
paramReal.float_len = si_min (precision, 32767);
paramReal.float_len2 = si_min (precision, 32767);
paramComp.par_name=(const char*)"i";
coeffs real = nInitChar(n_long_R, &paramReal);
//setGMPFloatDigits( precision, precision);
bigintmat * realmat = bimChangeCoeff(complexmat,real);
delete complexmat;
return realmat;
}
si_min
static int si_min(const int a, const int b)
Definition auxiliary.h:126
bimChangeCoeff
bigintmat * bimChangeCoeff(bigintmat *a, coeffs cnew)
Liefert Kopier von Matrix a zurück, mit coeffs cnew statt den ursprünglichen.
Definition bigintmat.cc:1797
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
bigintmat::view
number view(int i, int j) const
view an entry an entry. NOTE: starts at [1,1]
Definition bigintmat.cc:125
bigintmat::rawset
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_...
Definition bigintmat.h:196
bigintmat::set
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]
Definition bigintmat.cc:93
rootContainer
complex root finder for univariate polynomials based on laguers algorithm
Definition mpr_numeric.h:66
rootContainer::getRoot
gmp_complex * getRoot(const int i)
Definition mpr_numeric.h:88
rootContainer::fillContainer
void fillContainer(number *_coeffs, number *_ievpoint, const int _var, const int _tdg, const rootType _rt, const int _anz)
Definition mpr_numeric.cc:300
rootContainer::onepoly
@ onepoly
Definition mpr_numeric.h:68
rootContainer::getAnzRoots
int getAnzRoots()
Definition mpr_numeric.h:97
rootContainer::solver
bool solver(const int polishmode=PM_NONE)
Definition mpr_numeric.cc:437
n_Mult
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:639
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:457
n_Add
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition coeffs.h:653
nCoeff_is_Z
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition coeffs.h:811
nCoeff_is_long_R
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition coeffs.h:886
n_long_R
@ n_long_R
real floating point (GMP) numbers
Definition coeffs.h:33
n_long_C
@ n_long_C
complex floating point (GMP) numbers
Definition coeffs.h:41
LongComplexInfo::float_len2
short float_len2
additional char-flags, rInit
Definition coeffs.h:109
LongComplexInfo::par_name
const char * par_name
parameter name
Definition coeffs.h:110
n_RePart
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition coeffs.h:785
nCoeff_is_Q
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition coeffs.h:801
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
n_Init
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:541
n_InpMult
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
Definition coeffs.h:644
LongComplexInfo::float_len
short float_len
additional char-flags, rInit
Definition coeffs.h:108
nCoeff_is_R
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition coeffs.h:831
nCoeff_is_long_C
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition coeffs.h:889
LongComplexInfo
Definition coeffs.h:107
j
int j
Definition facHensel.cc:110
comp
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
Definition facSparseHensel.h:25
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
IsReal
bool IsReal(number a, coeffs coef)
Definition lattice.cc:1097
DEBUG_VAR
#define DEBUG_VAR(x)
Definition lattice.cc:35
squareroot
number squareroot(number a, coeffs coef, int prec)
Definition lattice.cc:1111
DEBUG_BLOCK
#define DEBUG_BLOCK(x)
Definition lattice.cc:29
ImagGreaterZero
bool ImagGreaterZero(number a, coeffs coef)
Definition lattice.cc:1104
DEBUG_PRINT
#define DEBUG_PRINT(x)
Definition lattice.cc:33
mult
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:647
setGMPFloatDigits
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...
Definition mpr_complex.cc:60
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
NULL
#define NULL
Definition omList.c:12
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition polys.cc:16
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
rDefault
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
rCopy
ring rCopy(ring r)
Definition ring.cc:1737
view
static void view(const intvec *v)
Definition mod_main.cc:164

## scalarproduct()

number scalarproduct | ( | bigintmat * | a,
|  | bigintmat * | b )

inline

Definition at line 915 of file lattice.cc.

{
if(a->cols()!=1) {
Werror("a->cols()!=1 in scalarproduct(a,b)\n");
return NULL;
}
if(b->cols()!=1) {
Werror("b->cols()!=1 in scalarproduct(a,b)\n");
return NULL;
}
if(a->rows()!=b->rows()) {
Werror("b->cols()!=1 in scalarproduct(a,b)\n");
return NULL;
}
if(a->basecoeffs()!=b->basecoeffs()) {
Werror("a->basecoeffs()!=b->basecoeffs() in scalarproduct(a,b)\n");
return NULL;
}
coeffs coef = a->basecoeffs();
number p = n_Init(0,coef);
for(int i = 1; i <= b->rows(); i++){
number prod = n_Mult(a->view(i,1), b->view(i,1), coef);
n_InpAdd(p, prod, coef);
n_Delete(&prod,coef);
}
return p;
}
p
int p
Definition cfModGcd.cc:4086
b
CanonicalForm b
Definition cfModGcd.cc:4111
bigintmat::cols
int cols() const
Definition bigintmat.h:144
bigintmat::rows
int rows() const
Definition bigintmat.h:145
bigintmat::basecoeffs
coeffs basecoeffs() const
Definition bigintmat.h:146
n_InpAdd
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of 'a' and 'b'; replacement of 'a' by the sum a+b
Definition coeffs.h:649
prod
fq_nmod_poly_t prod
Definition facHensel.cc:100
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189

## squareroot()

number squareroot | ( | number | a,
|  | coeffs | coef,
|  | int | iteration )

Definition at line 1111 of file lattice.cc.

{
if(n_IsZero(a,coef)){
return a;
}
if(!n_GreaterZero(a,coef)){
return n_Init(0,coef);
}
number two = n_Init(2,coef);
number xn = n_Copy(a,coef);
number xn1,xn2;
for(int i=0;i<prec;i++){
xn1 = n_Div(a,xn,coef);
xn2 = n_Add(xn,xn1,coef);
n_Delete(&xn,coef);
xn = n_Div(xn2,two,coef);
n_Delete(&xn1,coef);
n_Delete(&xn2,coef);
}
return xn;
}
n_Div
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:618
xn
VAR int xn
Definition walk.cc:4509