C++ A^T*稀疏积,结果存储在稠密矩阵/特征库中
作为将来的参考,如果你能准备一份工作,人们会更容易帮助你(你也可以帮助自己),我在下面做了。对我来说,这有助于我理解你想问什么。对你来说,这将帮助你更好地理解你的问题,甚至解决它C++ A^T*稀疏积,结果存储在稠密矩阵/特征库中,c++,eigen,eigen3,C++,Eigen,Eigen3,作为将来的参考,如果你能准备一份工作,人们会更容易帮助你(你也可以帮助自己),我在下面做了。对我来说,这有助于我理解你想问什么。对你来说,这将帮助你更好地理解你的问题,甚至解决它 jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h: In function 'void Eigen::internal::sparse_sparse_product_with_pruning_impl(const Lhs&, const Rhs&
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h: In function 'void Eigen::internal::sparse_sparse_product_with_pruning_impl(const Lhs&, const Rhs&, ResultType&, const typename ResultType::RealScalar&) [with Lhs = Eigen::SparseMatrix<double>, Rhs = Eigen::SparseMatrix<double>, ResultType = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, typename ResultType::RealScalar = double]':
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:91:5: instantiated from 'static void Eigen::internal::sparse_sparse_product_with_pruning_selector<Lhs, Rhs, ResultType, 0, 0, 0>::run(const Lhs&, const Rhs&, ResultType&, const RealScalar&) [with Lhs = Eigen::SparseMatrix<double>, Rhs = Eigen::SparseMatrix<double>, ResultType = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, Eigen::internal::sparse_sparse_product_with_pruning_selector<Lhs, Rhs, ResultType, 0, 0, 0>::RealScalar = double]'
jni/Eigen/src/SparseCore/SparseProduct.h:121:9: instantiated from 'void Eigen::SparseSparseProduct<Lhs, Rhs>::evalTo(Dest&) const [with Dest = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, LhsNested = Eigen::SparseMatrix<double>, RhsNested = const Eigen::SparseMatrix<double>&]'
jni/Eigen/src/Core/Assign.h:522:101: instantiated from 'static Derived& Eigen::internal::assign_selector<Derived, OtherDerived, false, false>::evalTo(ActualDerived&, const ActualOtherDerived&) [with ActualDerived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, ActualOtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>, Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, OtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>]'
jni/Eigen/src/Core/Assign.h:571:98: instantiated from 'Derived& Eigen::MatrixBase<Derived>::operator=(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>, Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>]'
jni/Eigen/src/Core/PlainObjectBase.h:453:7: instantiated from 'Derived& Eigen::PlainObjectBase<Derived>::operator=(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>, Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>]'
jni/Eigen/src/Core/Matrix.h:184:35: instantiated from 'Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::operator=(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>, _Scalar = double, int _Rows = -0x00000000000000001, int _Cols = -0x00000000000000001, int _Options = 0, int _MaxRows = -0x00000000000000001, int _MaxCols = -0x00000000000000001, Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>]'
jni/After.cpp:429:36: instantiated from here
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:50:3: error: 'class Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>' has no member named 'reserve'
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:69:5: error: 'class Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>' has no member named 'startVec'
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:71:7: error: 'class Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>' has no member named 'insertBackByOuterInner'
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:73:3: error: 'class Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>' has no member named 'finalize'
make.exe: *** [obj/local/armeabi-v7a/objs/com_jp_algi_CoreC/After.o] Error 1
**** Build Finished ****
intmain(intargc,char*argv[])
{
SparseMatrix a(3,3),ata;
a、 系数ref(1,2)=0。;
a、 系数ref(1,1)=2。;
a、 系数ref(1,0)=6。;
a、 系数ref(0,1)=1。;
难道pruned返回的错误是什么吗?我切断了命令。pruned()和错误是一样的:看起来EIgen不支持这个,或者可能有一些对pruned双范围限制的攻击。?好的,我不理解,我没有那么多时间,但是谢谢你的帮助“当我只想存储下三角部分时…?dense.triangularView();??简言之,不。它在中几乎是明确的。而且,您可以轻松创建一个MCVE进行检查。因此,好处只是,您可以存储其他数据,以使其静止在三角部分…?我不知道您在问什么。制定一个(好的)问题并发布它。”。
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h: In function 'void Eigen::internal::sparse_sparse_product_with_pruning_impl(const Lhs&, const Rhs&, ResultType&, const typename ResultType::RealScalar&) [with Lhs = Eigen::SparseMatrix<double>, Rhs = Eigen::SparseMatrix<double>, ResultType = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, typename ResultType::RealScalar = double]':
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:91:5: instantiated from 'static void Eigen::internal::sparse_sparse_product_with_pruning_selector<Lhs, Rhs, ResultType, 0, 0, 0>::run(const Lhs&, const Rhs&, ResultType&, const RealScalar&) [with Lhs = Eigen::SparseMatrix<double>, Rhs = Eigen::SparseMatrix<double>, ResultType = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, Eigen::internal::sparse_sparse_product_with_pruning_selector<Lhs, Rhs, ResultType, 0, 0, 0>::RealScalar = double]'
jni/Eigen/src/SparseCore/SparseProduct.h:121:9: instantiated from 'void Eigen::SparseSparseProduct<Lhs, Rhs>::evalTo(Dest&) const [with Dest = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, LhsNested = Eigen::SparseMatrix<double>, RhsNested = const Eigen::SparseMatrix<double>&]'
jni/Eigen/src/Core/Assign.h:522:101: instantiated from 'static Derived& Eigen::internal::assign_selector<Derived, OtherDerived, false, false>::evalTo(ActualDerived&, const ActualOtherDerived&) [with ActualDerived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, ActualOtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>, Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>, OtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>]'
jni/Eigen/src/Core/Assign.h:571:98: instantiated from 'Derived& Eigen::MatrixBase<Derived>::operator=(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>, Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>]'
jni/Eigen/src/Core/PlainObjectBase.h:453:7: instantiated from 'Derived& Eigen::PlainObjectBase<Derived>::operator=(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>, Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>]'
jni/Eigen/src/Core/Matrix.h:184:35: instantiated from 'Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::operator=(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::SparseSparseProduct<Eigen::SparseMatrix<double>, const Eigen::SparseMatrix<double>&>, _Scalar = double, int _Rows = -0x00000000000000001, int _Cols = -0x00000000000000001, int _Options = 0, int _MaxRows = -0x00000000000000001, int _MaxCols = -0x00000000000000001, Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>]'
jni/After.cpp:429:36: instantiated from here
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:50:3: error: 'class Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>' has no member named 'reserve'
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:69:5: error: 'class Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>' has no member named 'startVec'
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:71:7: error: 'class Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>' has no member named 'insertBackByOuterInner'
jni/Eigen/src/SparseCore/SparseSparseProductWithPruning.h:73:3: error: 'class Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>' has no member named 'finalize'
make.exe: *** [obj/local/armeabi-v7a/objs/com_jp_algi_CoreC/After.o] Error 1
**** Build Finished ****
int main(int argc, char *argv[])
{
SparseMatrix<double> a(3,3), ata;
a.coeffRef(1,2) = 0.;
a.coeffRef(1,1) = 2.;
a.coeffRef(1,0) = 6.;
a.coeffRef(0,1) = 1.;
cout << a << endl;
ata = (a.transpose() * a).pruned();
cout << ata << endl;
ata = (SparseMatrix<double>(a.transpose()) * a).pruned();
cout << ata << endl;
MatrixXd dense = ata.toDense();
cout << dense << endl;
/*****************************************************/
// Everything works fine until this point
/*****************************************************/
//dense = (SparseMatrix<double>(a.transpose()) * a).pruned(); // Doesn't compile
// Would compile if written as the following line
dense = SparseMatrix<double>((SparseMatrix<double>(a.transpose()) * a).pruned()).toDense(); // Works
cout << dense << endl;
return 0;
}