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

SparseMatrix::block not writable

Tags: None
(comma "," separated)
alexanderwerner
Registered Member
Posts
11
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
3447
Karma
19
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
11
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
3447
Karma
19
OS
yes, I kind of agree with you and we are moving slowly towards this goal.


Bookmarks



Who is online

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