Reply to topic

SparseMatrix::block not writable

alexanderwerner
Registered Member
Posts
8
Karma
0

SparseMatrix::block not writable

Mon Jul 22, 2013 3:43 pm
Hello,

in the current development version of Eigen the documentation says that Eigen::SparseMatrixBase
contrains implementations of blocks which are non-const. Why does the following code fail to compile:

Code: Select all
#include <Eigen/Dense>
#include <Eigen/Sparse>

int main(){
        Eigen::SparseMatrix<double> m(2,2);
        m.block(0,0,1,1) = m.block(1,1,1,1);
}


with the error messages:
Code: Select all
g++ -Wall -I/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/ test.cpp
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/util/XprHelper.h: In member function ‘Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>& Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>::operator=(const Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>&)’:
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h:100:   instantiated from ‘Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>& Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::operator=(const Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>&) [with XprType = Eigen::SparseMatrix<double, 0, int>, int BlockRows = -0x000000001, int BlockCols = -0x000000001, bool InnerPanel = false]’
test.cpp:6:   instantiated from here
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/util/XprHelper.h:35: error: ‘Eigen::internal::no_assignment_operator& Eigen::internal::no_assignment_operator::operator=(const Eigen::internal::no_assignment_operator&)’ is private
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h:100: error: within this context
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h:100: error: non-static reference member ‘const Eigen::SparseMatrix<double, 0, int>& Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>::m_matrix’, can't use default assignment operator
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h:100: error: non-static const member ‘const Eigen::internal::variable_if_dynamic<int, -0x000000001> Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>::m_startRow’, can't use default assignment operator
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h:100: error: non-static const member ‘const Eigen::internal::variable_if_dynamic<int, -0x000000001> Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>::m_startCol’, can't use default assignment operator
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h:100: error: non-static const member ‘const Eigen::internal::variable_if_dynamic<int, -0x000000001> Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>::m_blockRows’, can't use default assignment operator
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h:100: error: non-static const member ‘const Eigen::internal::variable_if_dynamic<int, -0x000000001> Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>::m_blockCols’, can't use default assignment operator
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h: In member function ‘Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>& Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::operator=(const Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>&) [with XprType = Eigen::SparseMatrix<double, 0, int>, int BlockRows = -0x000000001, int BlockCols = -0x000000001, bool InnerPanel = false]’:
/home/wern_al/local/foreign_packages/eigen/build/install/include/eigen3/Eigen/src/Core/Block.h:110: note: synthesized method ‘Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>& Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>::operator=(const Eigen::BlockImpl<Eigen::SparseMatrix<double, 0, int>, -0x000000001, -0x000000001, false, Eigen::Sparse>&)’ first required here
User avatar ggael
Moderator
Posts
2193
Karma
15
OS

Re: SparseMatrix::block not writable

Tue Jul 23, 2013 11:31 pm
oh, then maybe the documentation has to be clarified. Only special blocks are writeable. This includes .col(), .leftCols(), .middleCols(), .rightCols() for a column major matrix and the row versions for a row major matrix. This limitation is to prevent writing completely inefficient code.
alexanderwerner
Registered Member
Posts
8
Karma
0
I see and understand. Just my two cents:

(1) Even though the performance critical part of my code uses SparseMatrix
in a read-only manner, an easy initialization of this matrix is not
straight forward.

(2) It would be very desirable to have a clearly defined common interface
to sparse and dense matrices. This is especially useful in templated code
which can otherwise be seamlessly switched from Dense to Sparse.


Alex
User avatar ggael
Moderator
Posts
2193
Karma
15
OS
yes, I kind of agree with you and we are moving slowly towards this goal.

 
Reply to topic

Bookmarks



Who is online

Registered users: alake, Baidu [Spider], Bing [Bot], boudewijn, brandy_000, bshah, cristian.onet, Exabot [Bot], garthecho, Google [Bot], GreatEmerald, Horus, ken300, koriun, Majestic-12 [Bot], mgraesslin, parzt, peje, Tuukka, vomus, Yahoo [Bot]