Re: [eigen] generic argument declaration taking a matrix, vector or expression |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] generic argument declaration taking a matrix, vector or expression*From*: Bernhard Zeisl <bzeisl@xxxxxxxxxxxxxxxx>*Date*: Wed, 11 Jan 2012 15:00:56 -0800

Christoph, thanks a lot for your hint. That solved the problem.

Best, Bernhard On 01/10/2012 10:55 PM, Christoph Hertzberg wrote:

On 11.01.2012 07:19, Bernhard Zeisl wrote:If we understand the tutorial correctly, foo should look like template <typename TypeT> void foo (const Eigen::MatrixBase<TypeT> &mat); where a const cast needs to be used to write data back to mat.Yes, the const_cast is indeed not very nice. The problem is that youcan't pass a temporary object (such as A.col(i)) as a non-constreference (unless you use C++11's RValue references).Of course this bears the problem that you can also pass a constMatrix<...> to foo and modify it -- which actually should be prohibited.Another problem in my opinion is that you can't easily achieve typesafety of foo, i.e. if you only want to allow Matrices of a certainsize or scalar type (but you can achieve this by static assertions).I attached a an example, which should make more clear what we are trying to achieve.You need to give every matrix a different template parameter, e.g.: template <typename Type_A, typename Type_b, typename Type_x> voidsolveLeastSquares (const Eigen::MatrixBase<Type_A> &A, constEigen::MatrixBase<Type_b> &b, Eigen::MatrixBase<Type_x> const &x_,LEAST_SQUARES_METHOD method = SVD)Maybe the documentation could point that out more explicitly.Especially in the quoted tutorial parameters x and y should getdifferent template arguments (in the last two examples)HTH Christoph

**Follow-Ups**:

**References**:**[eigen] generic argument declaration taking a matrix, vector or expression***From:*Bernhard Zeisl

**Re: [eigen] generic argument declaration taking a matrix, vector or expression***From:*Christoph Hertzberg

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Fwd: [Bug 391331] dev-cpp/eigen-2.0.13 fails tests** - Next by Date:
**[eigen] Two performance regressions from Eigen2 to Eigen3 with bisected changes** - Previous by thread:
**Re: [eigen] generic argument declaration taking a matrix, vector or expression** - Next by thread:
**Re: [eigen] generic argument declaration taking a matrix, vector or expression**

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