如何在Eigen中扩展矩阵?

时间:2016-08-31 14:09:18

标签: matrix eigen matrix-multiplication

假设我有一个矩阵 'mysql' => [ 'strict' => false, //behave like 5.6 //'strict' => true //behave like 5.7 ], ,其条目为

    void visualisierung(int M,int L, float p,float q,float r,int n,
int step,int stepm, char dateiname3[]){
            FILE *fp,*fp2;
            zelle **liste,*listehilf;
            int i,j,anz,teilchenmax,teilchenneu,nt,me;
            time_t zeit;
            double multiplier,dichte;
            double fluss[101];
            char dateiname[100],dateiname2[100];
            zeit=time(NULL);
            //erstellen eines neuen Ordners
            mkdir("currentvids",0755);
            chdir("currentvids");
            strcpy(dateiname,dateiname3);
            strcpy(dateiname2,dateiname3);
            strcat(dateiname2,".txt");
            mkdir(dateiname,0755);
            chdir(dateiname);
            fp=fopen(dateiname2,"w");
                printf("No SegFault yet\n");

                fprintf(fp, "#Matrix %ix%i\n", M,L);
                fprintf(fp, "#Particle Size: %ix%i\n", n,n);
                fprintf(fp, "#p: %f\n", p);
                fprintf(fp, "#q: %f\n", q);
                fprintf(fp, "#v: %f\n", 1-(p+q+r));
                fprintf(fp, "#steps before measurement: %i\n", step);
                fprintf(fp, "#number of measured steps: %i\n", stepm);

如何将其扩展为

Eigen::Matrix<double, 3, 3>

我需要将3D仿射/投影变换(4乘4,在Eigen :: Transform类型下)与3D旋转矩阵(3乘3)相乘。

1 个答案:

答案 0 :(得分:3)

您想要conservativeResize

Eigen::MatrixXf mat;
mat.resize(3,3);
mat << 1, 2, 3, 4, 5, 6, 7, 8, 9;
std::cout << mat << "\n\n";
mat.conservativeResize(4,4);
mat.col(3).setZero();
mat.row(3).setZero();
mat(3, 3) = 1;
std::cout << mat << "\n\n";