This forum has been archived. All content is frozen. Please use KDE Discuss instead.

## can't compute least squares

Tags: None
(comma "," separated) rafaelscatena
Registered Member Posts
1
Karma
0

### can't compute least squares

Wed Feb 22, 2023 11:50 pm
hi this is my first time with eigen.
I am trying to compute the solution of an homogeneous system. It is the implicit equation of a plane through a set of points in 3d. It is not going well.

Code: Select all
`Eigen::MatrixXf Data_Matrix(i_for_geo_roi,3);                                    Eigen::VectorXf  Coef_Vector(3);            Eigen::VectorXf  B_vector(3);                       for(int i = 1; i <4; i++){B_vector[i] = 0.0;Coef_Vector[i]=0.0;}                              int i_for_geo_roi_data = 0;                         // PUT IN DATA MATRIX AND SOLVE                                            while (pointIterator_transfer_roi != end_transfer_roi){                      InternalImageType::IndexType index_roi;           PointType_Geo_Simp p_value_roi;                      p_value_roi = pointIterator_transfer_roi.Value();           p_value_roi = pointIterator_transfer_roi.Value();                                                                  int roi_transf_x; int roi_transf_y; int roi_transf_z;                               roi_transf_x = p_value_roi*spacing -centre_of_gravity_lungs;                roi_transf_y = p_value_roi*spacing -centre_of_gravity_lungs;                                 Data_Matrix(i_for_geo_roi_data,1) = 1;                Data_Matrix(i_for_geo_roi_data,2) = roi_transf_x;                Data_Matrix(i_for_geo_roi_data,3) = roi_transf_y;                                                          pointIterator_transfer_roi++;                                               i_for_geo_roi_data++;                  }                                                   std::cout << "The least-squares solution is:\n"        << Data_Matrix.template bdcSvd<Eigen::ComputeThinU | Eigen::ComputeThinV>().solve(B_vector) << std::endl;`

I get the following error:
Code: Select all
`    error: ‘Eigen::MatrixBase<Derived>::bdcSvd(unsigned int) const [with Derived = Eigen::Matrix<float, -1, -1>; typename Eigen::DenseBase<Derived>::PlainObject =                                              Eigen::Matrix<float, -1, -1>]’ is not a template [-fpermissive]      |         << Data_Matrix.template bdcSvd<Eigen::ComputeThinU | Eigen::ComputeThinV>().solve(B_vector) << std::endl;      |                                 ^~~~~~        /home/3484681/Área de Trabalho/scr (2)/teste243.cxx:18300:9: error: invalid use of non-static member function ‘Eigen::BDCSVD<typename Eigen::DenseBase<Derived>::PlainObject> Eigen::MatrixBase<Derived>::bdcSvd(unsigned int) const [with Derived = Eigen::Matrix<float, -1, -1>; typename Eigen::DenseBase<Derived>::PlainObject = Eigen::Matrix<float, -1, -1>]’   |           std::cout << "The least-squares solution is:\n"      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   |         << Data_Matrix.template bdcSvd<Eigen::ComputeThinU | Eigen::ComputeThinV>().solve(B_vector) << std::endl;      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In file included from /usr/local/include/ITK-5.3/itkeigen/Eigen/SVD:38,                 from /usr/local/include/ITK-5.3/itkeigen/Eigen/Geometry:13,                 from /usr/local/include/ITK-5.3/itkeigen/Eigen/Eigenvalues:17,                 from /usr/local/include/ITK-5.3/itkSymmetricEigenAnalysis.h:23,                 from /usr/local/include/ITK-5.3/itkSymmetricSecondRankTensor.h:29,                 from /usr/local/include/ITK-5.3/itkImageIOBase.h:30,                 from /usr/local/include/ITK-5.3/itkGDCMImageIO.h:32,                 from /home/3484681/Área de Trabalho/scr (2)/teste243.cxx:1:/usr/local/include/ITK-5.3/itkeigen/Eigen/src/SVD/BDCSVD.h:1363:1: note: declared here    | MatrixBase<Derived>::bdcSvd(unsigned int computationOptions) const      | ^~~~~~~~~~~~~~~~~~~/home/3484681/Área de Trabalho/scr (2)/teste243.cxx:18300:83: error: expected primary-expression before ‘)’ token   |         << Data_Matrix.template bdcSvd<Eigen::ComputeThinU | Eigen::ComputeThinV>().solve(B_vector) << std::endl;      |                                                                                   ^/home/3484681/Área de Trabalho/scr (2)/teste243.cxx:18302:48: error: ‘Eigen::MatrixBase<Derived>::bdcSvd(unsigned int) const [with Derived = Eigen::Matrix<float, -1, -1>; typename Eigen::DenseBase<Derived>::PlainObject = Eigen::Matrix<float, -1, -1>]’ is not a template [-fpermissive]   |             Coef_Vector = Data_Matrix.template bdcSvd<Eigen::ComputeThinU | Eigen::ComputeThinV>()dec.solve(B_vector)      |                                                ^~~~~~/home/3484681/Área de Trabalho/scr (2)/teste243.cxx:18302:54: error: invalid use of non-static member function ‘Eigen::BDCSVD<typename Eigen::DenseBase<Derived>::PlainObject> Eigen::MatrixBase<Derived>::bdcSvd(unsigned int) const [with Derived = Eigen::Matrix<float, -1, -1>; typename Eigen::DenseBase<Derived>::PlainObject = Eigen::Matrix<float, -1, -1>]’   |             Coef_Vector = Data_Matrix.template bdcSvd<Eigen::ComputeThinU | Eigen::ComputeThinV>()dec.solve(B_vector)      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~In file included from /usr/local/include/ITK-5.3/itkeigen/Eigen/SVD:38,                 from /usr/local/include/ITK-5.3/itkeigen/Eigen/Geometry:13,                 from /usr/local/include/ITK-5.3/itkeigen/Eigen/Eigenvalues:17,                 from /usr/local/include/ITK-5.3/itkSymmetricEigenAnalysis.h:23,                 from /usr/local/include/ITK-5.3/itkSymmetricSecondRankTensor.h:29,                 from /usr/local/include/ITK-5.3/itkImageIOBase.h:30,                 from /usr/local/include/ITK-5.3/itkGDCMImageIO.h:32,                 from /home/3484681/Área de Trabalho/scr (2)/teste243.cxx:1:/usr/local/include/ITK-5.3/itkeigen/Eigen/src/SVD/BDCSVD.h:1363:1: note: declared here    | MatrixBase<Derived>::bdcSvd(unsigned int computationOptions) const`     