本文整理汇总了C++中mat::eye方法的典型用法代码示例。如果您正苦于以下问题:C++ mat::eye方法的具体用法?C++ mat::eye怎么用?C++ mat::eye使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat
的用法示例。
在下文中一共展示了mat::eye方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Kalman
// constructor, sets up data structures
Kalman() : dt(1.0) {
A.eye(6,6);
A(0,2) = A(1,3) = A(2,4) = A(3,5) = dt;
H.zeros(2,6);
H(0,0) = H(1,1) = 1.0;
Q.eye(6,6);
R = 1000 * eye(2,2);
xest.zeros(6,1);
pest.zeros(6,6);
}
示例2: for_Algo
void for_Algo(mat &A, mat &R, double h, int N, double tolerance,int max){
int counter=0;
int col = 0;
int row = 1;
Matrix2(A,h,N);
R.eye();
cout<<"--------------JACOBI ROTATION ALGORITHM--------------"<<endl;
clock_t start, finish;
start = clock();
maximum(A,N,col,row);
while (fabs(A(row,col))>tolerance && counter<max){
jacobi(A,R,N,col,row);
counter++;
maximum(A,N,col,row);
//TEST_MAX(A,N);
}
finish = clock();
float time=((float)finish - (float)start) / CLOCKS_PER_SEC;
cout<<counter<<" ripetitions and "<< time <<" seconds."<<endl;
minimumEigenvalues(A,N);
// cout<<"post-algorithm"<<endl;
// cout<<A<<endl;
return;
}
示例3: exit_test
void exit_test(mat &A, mat &R, double h, int N){
Matrix2(A,h,N);
R.eye();
vec eigval(N);
Matrix2(A,h,N);
eig_sym(eigval, R, A);
A=diagmat(eigval);
//cout<<A<<endl;
//position of first eigenvalue
//out of ro
double ro=h;
for (int i=0;i<N;i++){
cout<<ro<<endl;
ro+=h;
}
cout<<"change"<<endl;
//out of first eigenvector
ro=h;
for(int i=0; i<N;i++){
cout<<R(i,0)*R(i,0)<<endl;
ro+=h;
}
cout<<"change"<<endl;
//out second eigenvector;
ro=h;
for(int i=0; i<N;i++){
cout<<R(i,1)*R(i,1)<<endl;
ro+=h;
}
cout<<"change"<<endl;
//out second eigenvector;
ro=h;
for(int i=0; i<N;i++){
cout<<R(i,2)*R(i,2)<<endl;
ro+=h;
}
cout<<"change"<<endl;
cout<<"break"<<endl;
}
示例4: for_rotation
void for_rotation(mat &A, mat &R, double h, int N, double tolerance,int max){
int counter=0;
int col = N-1;
int row = N-2;
Matrix(A,h,N);
R.eye();
cout<<"--------------JACOBI ROTATION MATRIX--------------"<<endl;
clock_t start, finish;
start = clock();
maximum(A,N,col,row);
while (fabs(A(row,col))>tolerance && counter<max){
jacobi_matrix(A,R,N,col,row);
counter++;
maximum(A,N,col,row);
}
finish = clock();
float time=((float)finish - (float)start) / CLOCKS_PER_SEC;
cout<<counter<<" ripetitions and "<< time <<" seconds."<<endl;
minimumEigenvalues(A,N);
return;
}
示例5: exit
void exit(mat &A, mat &R, double h, int N, double tolerance,int max){
int counter=0;
int col = 0;
int row = 1;
Matrix2(A,h,N);
R.eye();
maximum(A,N,col,row);
while (fabs(A(row,col))>tolerance && counter<max){
jacobi(A,R,N,col,row);
counter++;
maximum(A,N,col,row);
}
// vec eigval(N);
// Matrix2(A,h,N);
// eig_sym(eigval, R, A);
//position of first eigenvalue
int m=0;
for (int i=0;i<N;i++){
if (fabs(A(i,i))<fabs(A(m,m))){m=i;}
}
//out of ro
double ro=h;
for (int i=0;i<N;i++){
cout<<ro<<endl;
ro+=h;
}
cout<<"change"<<endl;
//out of first eigenvector
ro=h;
for(int i=0; i<N;i++){
cout<<R(i,m)*R(i,m)<<endl;
ro+=h;
}
cout<<"change"<<endl;
//position second eigenvalue
int k=0;
for (int i=0;i<N;i++){
if (fabs(A(i,i))<fabs(A(k,k))&& A(i,i)!=A(m,m)){k=i;}
}
//out second eigenvector;
ro=h;
for(int i=0; i<N;i++){
cout<<R(i,k)*R(i,k)<<endl;
ro+=h;
}
cout<<"change"<<endl;
//position third eigenvalue
int l=0;
for (int i=0;i<N;i++){
if (fabs(A(i,i))<fabs(A(l,l))&& A(i,i)!=A(m,m)&&A(i,i)!=A(k,k)){l=i;}
}
//out second eigenvector;
ro=h;
for(int i=0; i<N;i++){
cout<<R(i,l)*R(i,l)<<endl;
ro+=h;
}
cout<<"change"<<endl;
cout<<"break"<<endl;
}