- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
int rows=2;
int cols=3;
//matrix a little bigger to save result
float * a=new float[cols*cols];
a[0]=1; a[1]=0; a[2]=0;
a[3]=0; a[4]=1; a[5]=0;
//any values for the rest(not used for matrix)
a[6]=-2; a[7]=-2; a[8]=-2;
//create values as described in manual
//first dimension of a
int lda= rows;
//diagonal B
float * d=new float [min(rows,cols)];
//details of Q and P
float * tauq= new float[min(rows,cols)];
float * taup= new float[min(rows,cols)];
//off diagonal of B
float * e=new float[max(1,min(rows,cols)-1)];
//temp
float * work=new float[64*(rows+cols)];
int worksize=64*(rows+cols);
int info;
//void sgebrd(int *m,int *n,float *a,int *lda,float *d,float *e,float *tauq,float *taup,float *work,int *lwork,int *info);
sgebrd(&rows,&cols,a,&lda,d,e,tauq,taup,work,&worksize,&info);
if (info<0)
return info;
//lda=rows did not work either
lda=cols;
//read P
sorgbr ( "P", &cols, &cols, &rows, a, &lda, taup , work, &worksize, &info );
if (info<0)
return info;
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
http://www.netlib.org/lapack/
where you can find samples and all the information.
elementary reflectors H(i) or G(i) respectively. And if you call
where k< = rows.
is of order N:
if k < n, P**T = G(k) . . . G(2) G(1) and SORGBR returns the first m
rows of P**T, where n >= m >= k. "
So your code doesn't produce the kernel vectors.
There exist several ways to compute the kernel vectors using LAPACK routines. Let's us give an example. For example, it can be done through the LQ decomposition of the initial matrix A. If we have m by n matrix A andm < n, rank A = m, then Q**T Z give us the kernel vectors where Z is cols by n-m matrix which non-zero elements are defined as follows
a(j+m, j)=1. j=1,... n-m
Then A Z= L Q * (Q**T *Z)= 0. So if you replacethecalls to sgebrd and sorgbr with
vt[0]=0.;
vt[1]=0.;
vt[2]=1.;
printf("%f ", vt);
};
you obtain what you are looking for.
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite