Loading...
Searching...
No Matches
eigenval_ip.h File Reference
`#include "kernel/linear_algebra/eigenval.h"`

Go to the source code of this file.

## Functions

BOOLEAN | evSwap (leftv res, leftv h)
BOOLEAN | evRowElim (leftv res, leftv h)
BOOLEAN | evHessenberg (leftv res, leftv h)
lists | evEigenvals (matrix M)
BOOLEAN | evEigenvals (leftv res, leftv h)

## Function Documentation

## evEigenvals() [1/2]

BOOLEAN evEigenvals | ( | leftv | res,
|  | leftv | h )

Definition at line 269 of file eigenval_ip.cc.

{
if(currRing)
{
if(h&&h->Typ()==MATRIX_CMD)
{
matrix M=(matrix)h->CopyD();
res->rtyp=LIST_CMD;
res->data=(void *)evEigenvals(M);
return FALSE;
}
WerrorS("<matrix> expected");
return TRUE;
}
WerrorS("no ring active");
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
evEigenvals
lists evEigenvals(matrix M)
Definition eigenval_ip.cc:120
res
CanonicalForm res
Definition facAbsFact.cc:60
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
MATRIX_CMD
@ MATRIX_CMD
Definition grammar.cc:287
h
STATIC_VAR Poly * h
Definition janet.cc:971
matrix
ip_smatrix * matrix
Definition matpol.h:43
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
M
#define M
Definition sirandom.c:25
LIST_CMD
@ LIST_CMD
Definition tok.h:118

## evEigenvals() [2/2]

lists evEigenvals | ( | matrix | M | ) |

Definition at line 120 of file eigenval_ip.cc.

{
lists l=(lists)omAllocBin(slists_bin);
if(MATROWS(M)!=MATCOLS(M))
{
l->Init(0);
return(l);
}
M=evHessenberg(M);
int n=MATCOLS(M);
ideal e=idInit(n,1);
intvec *m=new intvec(n);
poly t=pOne();
pSetExp(t,1,1);
pSetm(t);
for(int j0=1,j=2,k=0;j<=n+1;j0=j,j++)
{
while(j<=n&&MATELEM(M,j,j-1)!=NULL)
j++;
if(j==j0+1)
{
e->m[k]=pHead(MATELEM(M,j0,j0));
(*m)[k]=1;
k++;
}
else
{
int n0=j-j0;
matrix M0=mpNew(n0,n0);
j0--;
for(int i=1;i<=n0;i++)
for(int j=1;j<=n0;j++)
MATELEM(M0,i,j)=pCopy(MATELEM(M,j0+i,j0+j));
for(int i=1;i<=n0;i++)
MATELEM(M0,i,i)=pSub(MATELEM(M0,i,i),pCopy(t));
intvec *m0;
ideal e0=singclap_factorize(mp_DetBareiss(M0,currRing),&m0,2, currRing);
if (e0==NULL)
{
l->Init(0);
return(l);
}
for(int i=0;i<IDELEMS(e0);i++)
{
if(pNext(e0->m[i])==NULL)
{
(*m)[k]=(*m0)[i];
k++;
}
else
if(pGetExp(e0->m[i],1)<2&&pGetExp(pNext(e0->m[i]),1)<2&&
pNext(pNext(e0->m[i]))==NULL)
{
number e1=nCopy(pGetCoeff(e0->m[i]));
e1=nInpNeg(e1);
if(pGetExp(pNext(e0->m[i]),1)==0)
e->m[k]=pNSet(nDiv(pGetCoeff(pNext(e0->m[i])),e1));
else
e->m[k]=pNSet(nDiv(e1,pGetCoeff(pNext(e0->m[i]))));
nDelete(&e1);
pNormalize(e->m[k]);
(*m)[k]=(*m0)[i];
k++;
}
else
{
e->m[k]=e0->m[i];
pNormalize(e->m[k]);
e0->m[i]=NULL;
(*m)[k]=(*m0)[i];
k++;
}
}
delete(m0);
idDelete(&e0);
}
}
pDelete(&t);
idDelete((ideal *)&M);
for(int i0=0;i0<n-1;i0++)
{
for(int i1=i0+1;i1<n;i1++)
{
if(pEqualPolys(e->m[i0],e->m[i1]))
{
(*m)[i0]+=(*m)[i1];
(*m)[i1]=0;
}
else
{
if((e->m[i0]==NULL&&!nGreaterZero(pGetCoeff(e->m[i1])))||
(e->m[i1]==NULL&&
(nGreaterZero(pGetCoeff(e->m[i0]))||pNext(e->m[i0])!=NULL))||
e->m[i0]!=NULL&&e->m[i1]!=NULL&&
((pNext(e->m[i0])!=NULL&&pNext(e->m[i1])==NULL)||
(pNext(e->m[i0])==NULL&&pNext(e->m[i1])==NULL&&
nGreater(pGetCoeff(e->m[i0]),pGetCoeff(e->m[i1])))))
{
poly e1=e->m[i0];
e->m[i0]=e->m[i1];
e->m[i1]=e1;
int m1=(*m)[i0];
(*m)[i0]=(*m)[i1];
(*m)[i1]=m1;
}
}
}
}
int n0=0;
for(int i=0;i<n;i++)
if((*m)[i]>0)
n0++;
ideal e0=idInit(n0,1);
intvec *m0=new intvec(n0);
for(int i=0,i0=0;i<n;i++)
if((*m)[i]>0)
{
e0->m[i0]=e->m[i];
e->m[i]=NULL;
(*m0)[i0]=(*m)[i];
i0++;
}
idDelete(&e);
delete(m);
l->Init(2);
l->m[0].rtyp=IDEAL_CMD;
l->m[0].data=e0;
l->m[1].rtyp=INTVEC_CMD;
l->m[1].data=m0;
return(l);
}
l
int l
Definition cfEzgcd.cc:100
m
int m
Definition cfEzgcd.cc:128
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
singclap_factorize
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition clapsing.cc:983
intvec
Definition intvec.h:24
evHessenberg
BOOLEAN evHessenberg(leftv res, leftv h)
Definition eigenval_ip.cc:101
j
int j
Definition facHensel.cc:110
IDEAL_CMD
@ IDEAL_CMD
Definition grammar.cc:285
idDelete
#define idDelete(H)
delete an ideal
Definition ideals.h:29
slists_bin
VAR omBin slists_bin
Definition lists.cc:23
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
mp_DetBareiss
poly mp_DetBareiss(matrix a, const ring r)
returns the determinant of the matrix m; uses Bareiss algorithm
Definition matpol.cc:1670
MATELEM
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
MATROWS
#define MATROWS(i)
Definition matpol.h:26
MATCOLS
#define MATCOLS(i)
Definition matpol.h:27
pNext
#define pNext(p)
Definition monomials.h:36
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
lists
slists * lists
Definition mpr_numeric.h:146
nDiv
#define nDiv(a, b)
Definition numbers.h:32
nDelete
#define nDelete(n)
Definition numbers.h:16
nInpNeg
#define nInpNeg(n)
Definition numbers.h:21
nCopy
#define nCopy(n)
Definition numbers.h:15
nGreater
#define nGreater(a, b)
Definition numbers.h:28
nGreaterZero
#define nGreaterZero(n)
Definition numbers.h:27
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
NULL
#define NULL
Definition omList.c:12
pDelete
#define pDelete(p_ptr)
Definition polys.h:187
pHead
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
pSetm
#define pSetm(p)
Definition polys.h:272
pNSet
#define pNSet(n)
Definition polys.h:314
pSub
#define pSub(a, b)
Definition polys.h:288
pGetExp
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
pNormalize
#define pNormalize(p)
Definition polys.h:318
pEqualPolys
#define pEqualPolys(p1, p2)
Definition polys.h:400
pSetExp
#define pSetExp(p, i, v)
Definition polys.h:43
pCopy
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
pOne
#define pOne()
Definition polys.h:316
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
INTVEC_CMD
@ INTVEC_CMD
Definition tok.h:101

## evHessenberg()

BOOLEAN evHessenberg | ( | leftv | res,
|  | leftv | h )

Definition at line 101 of file eigenval_ip.cc.

{
if(currRing)
{
if(h&&h->Typ()==MATRIX_CMD)
{
matrix M=(matrix)h->Data();
res->rtyp=MATRIX_CMD;
res->data=(void *)evHessenberg(mp_Copy(M, currRing));
return FALSE;
}
WerrorS("<matrix> expected");
return TRUE;
}
WerrorS("no ring active");
return TRUE;
}
mp_Copy
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57

## evRowElim()

BOOLEAN evRowElim | ( | leftv | res,
|  | leftv | h )

Definition at line 51 of file eigenval_ip.cc.

{
if(currRing)
{
const short t[]={4,MATRIX_CMD,INT_CMD,INT_CMD,INT_CMD};
if (iiCheckTypes(h,t,1))
{
matrix M=(matrix)h->CopyD();
h=h->next;
int i=(int)(long)h->Data();
h=h->next;
int j=(int)(long)h->Data();
h=h->next;
int k=(int)(long)h->Data();
res->rtyp=MATRIX_CMD;
res->data=(void *)evRowElim(M,i,j,k);
return FALSE;
}
return TRUE;
}
WerrorS("no ring active");
return TRUE;
}
evRowElim
BOOLEAN evRowElim(leftv res, leftv h)
Definition eigenval_ip.cc:51
iiCheckTypes
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition ipshell.cc:6576
INT_CMD
@ INT_CMD
Definition tok.h:96

## evSwap()

BOOLEAN evSwap | ( | leftv | res,
|  | leftv | h )

Definition at line 29 of file eigenval_ip.cc.

{
if(currRing)
{
const short t[]={3,MATRIX_CMD,INT_CMD,INT_CMD};
if (iiCheckTypes(h,t,1))
{
matrix M=(matrix)h->Data();
h=h->next;
int i=(int)(long)h->Data();
h=h->next;
int j=(int)(long)h->Data();
res->rtyp=MATRIX_CMD;
res->data=(void *)evSwap(mp_Copy(M, currRing),i,j);
return FALSE;
}
return TRUE;
}
WerrorS("no ring active");
return TRUE;
}
evSwap
BOOLEAN evSwap(leftv res, leftv h)
Definition eigenval_ip.cc:29