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

Compilation errors with SparseMatrix and SparseLU

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

I'm trying to solve a linear equation system using SparseMatrix and SparseLu, as I might end up with rather large tridiagonal matrices. However, I cannot get the code to compile, gives me a bunch of "conversion from '__int64' to 'int', possible loss of data" errors, when I try to extract the result:
Code: Select all
1>\.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(733): error C2220: warning treated as error - no 'object' file generated
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(239): note: see reference to function template instantiation 'void Eigen::SparseLUMatrixUReturnType<Eigen::internal::MappedSuperNodalMatrix<double,int>,Eigen::MappedSparseMatrix<double,0,int>>::solveInPlace<Derived>(Eigen::MatrixBase<Derived> &) const' being compiled
1>          with
1>          [
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(239): note: see reference to function template instantiation 'void Eigen::SparseLUMatrixUReturnType<Eigen::internal::MappedSuperNodalMatrix<double,int>,Eigen::MappedSparseMatrix<double,0,int>>::solveInPlace<Derived>(Eigen::MatrixBase<Derived> &) const' being compiled
1>          with
1>          [
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(786): note: see reference to function template instantiation 'bool Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>::_solve<Derived,Derived>(const Eigen::MatrixBase<Derived> &,Eigen::MatrixBase<Derived> &) const' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(786): note: see reference to function template instantiation 'bool Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>::_solve<Derived,Derived>(const Eigen::MatrixBase<Derived> &,Eigen::MatrixBase<Derived> &) const' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/misc/Solve.h(51): note: see reference to function template instantiation 'void Eigen::internal::solve_retval<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Derived>::evalTo<Dest>(Dest &) const' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>,
1>              Dest=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/misc/Solve.h(51): note: see reference to function template instantiation 'void Eigen::internal::solve_retval<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Derived>::evalTo<Dest>(Dest &) const' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>,
1>              Dest=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/Core/ReturnByValue.h(61): note: see reference to function template instantiation 'void Eigen::internal::solve_retval_base<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Rhs>::evalTo<Dest>(Dest &) const' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Rhs=Eigen::Matrix<double,-1,1,0,-1,1>,
1>              Dest=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/Core/ReturnByValue.h(61): note: see reference to function template instantiation 'void Eigen::internal::solve_retval_base<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Rhs>::evalTo<Dest>(Dest &) const' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Rhs=Eigen::Matrix<double,-1,1,0,-1,1>,
1>              Dest=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/Core/Matrix.h(311): note: see reference to function template instantiation 'void Eigen::ReturnByValue<Eigen::internal::solve_retval_base<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Rhs>>::evalTo<Eigen::Matrix<double,-1,1,0,-1,1>>(Dest &) const' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Rhs=Eigen::Matrix<double,-1,1,0,-1,1>,
1>              Dest=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/Core/Matrix.h(311): note: see reference to function template instantiation 'void Eigen::ReturnByValue<Eigen::internal::solve_retval_base<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Rhs>>::evalTo<Eigen::Matrix<double,-1,1,0,-1,1>>(Dest &) const' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Rhs=Eigen::Matrix<double,-1,1,0,-1,1>,
1>              Dest=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \lib\math\spline.cpp(75): note: see reference to function template instantiation 'Eigen::Matrix<double,-1,1,0,-1,1>::Matrix<Eigen::internal::solve_retval_base<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Rhs>>(const Eigen::ReturnByValue<Eigen::internal::solve_retval_base<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Rhs>> &)' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Rhs=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \lib\math\spline.cpp(75): note: see reference to function template instantiation 'Eigen::Matrix<double,-1,1,0,-1,1>::Matrix<Eigen::internal::solve_retval_base<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Rhs>>(const Eigen::ReturnByValue<Eigen::internal::solve_retval_base<Eigen::SparseLU<Eigen::SparseMatrix<Scalar,0,int>,Eigen::COLAMDOrdering<int>>,Rhs>> &)' being compiled
1>          with
1>          [
1>              Scalar=double,
1>              Rhs=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>\.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(733): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
1>\.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(734): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
1>\.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU_SupernodalMatrix.h(236): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(715): note: see reference to function template instantiation 'void Eigen::internal::MappedSuperNodalMatrix<double,int>::solveInPlace<Derived>(Eigen::MatrixBase<Derived> &) const' being compiled
1>          with
1>          [
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1> \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(715): note: see reference to function template instantiation 'void Eigen::internal::MappedSuperNodalMatrix<double,int>::solveInPlace<Derived>(Eigen::MatrixBase<Derived> &) const' being compiled
1>          with
1>          [
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1>  \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(238): note: see reference to function template instantiation 'void Eigen::SparseLUMatrixLReturnType<Eigen::internal::MappedSuperNodalMatrix<double,int>>::solveInPlace<Derived>(Eigen::MatrixBase<Derived> &) const' being compiled
1>          with
1>          [
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]
1> \.conan\data\eigen\3.2.8\mlm\testing\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen\src/SparseLU/SparseLU.h(238): note: see reference to function template instantiation 'void Eigen::SparseLUMatrixLReturnType<Eigen::internal::MappedSuperNodalMatrix<double,int>>::solveInPlace<Derived>(Eigen::MatrixBase<Derived> &) const' being compiled
1>          with
1>          [
1>              Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1>          ]


The code looks as follows:
Code: Select all
int n = (int) h.size() + 1;
SparseMatrix<double, ColMajor, int> A;

A.resize(n, n);

// Construct Ax = b
A.setFromTriplets(triplets.begin(), triplets.end());
A.makeCompressed();

SparseLU<SparseMatrix<double, ColMajor, int>, COLAMDOrdering<int>> solver;
// fill A and b;
// Compute the ordering permutation vector from the structural pattern of A
solver.analyzePattern(A);
// Compute the numerical factorization
solver.factorize(A);
//Use the factors to solve the linear system
VectorXd z = solver.solve(b);
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Those are warnings that you turned as errors with -Werror. Either remove this flag for this unit or update Eigen (3.2.8 is pretty old).


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]