首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >使用求解器SparseLU并获取错误C2664

使用求解器SparseLU并获取错误C2664
EN

Stack Overflow用户
提问于 2018-07-21 07:35:12
回答 0查看 149关注 0票数 1

我正在尝试使用特征来解决c++中的稀疏线性系统,我也在使用Microsoft Visual Studio2017。

使用Eigen的代码行如下:

代码语言:javascript
代码运行次数:0
运行
复制
        Eigen::VectorXd x(sizeM), b(sizeM);
        Eigen::SparseMatrix<double> A(sizeM, sizeM);
        Eigen::SparseLU<Eigen::SparseMatrix<double, Eigen::ColMajor>, Eigen::COLAMDOrdering<Eigen::Index> > solver;
        // M is my coefficient array and B is my independent vector.
        for (int i = 0; i < sizeM; i++)
        {
            b(i) = B[i];
        }
        A.reserve(Eigen::VectorXi::Constant(sizeM, 6));
        for (int i = 0; i < sizeM; i++)
        {
            for (int j = 0; j < sizeM; j++)
            {
                if (M[i][j] != 0)
                {
                    A.insert(i,j) = M[i][j];
                }

            }
        }
        A.makeCompressed();
        // 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 .
        x = solver.solve(b);

代码错误是这样的:

代码语言:javascript
代码运行次数:0
运行
复制
c:\users\bruno\desktop\c++ apps\eigen\eigen\src\sparselu\sparselu.h(421): error C2664: 'void Eigen::COLAMDOrdering<Eigen::Index>::operator ()<Eigen::SparseMatrix<double,0,int>>(const MatrixType &,Eigen::PermutationMatrix<-1,-1,StorageIndex> &)': cannot convert argument 2 from 'Eigen::PermutationMatrix<-1,-1,int>' to 'Eigen::PermutationMatrix<-1,-1,StorageIndex> &'
1>        with
1>        [
1>            MatrixType=Eigen::SparseMatrix<double,0,int>,
1>            StorageIndex=Eigen::Index
1>        ]
1>        and
1>        [
1>            StorageIndex=Eigen::Index
1>        ]
1>c:\users\bruno\desktop\c++ apps\eigen\eigen\src\sparselu\sparselu.h(412): note: while compiling class template member function 'void Eigen::SparseLU<Eigen::SparseMatrix<double,0,int>,Eigen::COLAMDOrdering<Eigen::Index>>::analyzePattern(const Eigen::SparseMatrix<double,0,int> &)'
1>c:\users\bruno\desktop\c++ apps\project1\project1\main.cpp(386): note: see reference to function template instantiation 'void Eigen::SparseLU<Eigen::SparseMatrix<double,0,int>,Eigen::COLAMDOrdering<Eigen::Index>>::analyzePattern(const Eigen::SparseMatrix<double,0,int> &)' being compiled
1>c:\users\bruno\desktop\c++ apps\project1\project1\main.cpp(367): note: see reference to class template instantiation 'Eigen::SparseLU<Eigen::SparseMatrix<double,0,int>,Eigen::COLAMDOrdering<Eigen::Index>>' being compiled
1>Done building project "Project1.vcxproj" -- FAILED.

我对Eigen和C++都是新手,所以我不完全确定问题出在哪里。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51451555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档