Re: [eigen] Permuted Matrix

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Gael Guennebaud wrote:
> it appears this would be welcome for Reverse, SwapWrapper and
> SelfCwiseBinaryOp... The later ones are internal only, so it was fine
> to have DirectAccessBit for them. For Reverse, well it could sometime
> have DirectAccessBit with a negative inner stride, but not always.
> 
> Do you confirm this requires a new WritableBit flag?

I would support a writable flag (which should be independent from direct
Access e.g. for const maps).

Actually I would even suggest having a writable flag even in MatrixBase
(automatically deduced from Derived), thus replacing long and strange
error messages generated from this:

template<class Derived>
void access_test(const MatrixBase<Derived>& m1) {
	m1 += m1; // just fails due to constness?
	MatrixBase<Derived> m2 = m1;
	m2 += m1;
}

int main(void) {
	Matrix3d A, B;
	access_test(A*B);
}

by a simple:
error: no match for ‘operator+=’ in ‘m2 += m1’

BTW: Making the copy constructor of MatrixBase protected or private
would avoid the rather silly:
	MatrixBase<Derived> m2 = m1;

which could happen accidentally, if you pass m1 to another function:

template<class T>
void foo(const T& t) {
	T u = t;
	// do sth with u ...
}


I have no idea if any of this would break API compatibility somewhere ...


Christoph



-- 
----------------------------------------------
Dipl.-Inf. Christoph Hertzberg
Cartesium 0.051
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: (+49) 421-218-64252
----------------------------------------------



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/