|
Boost Users : |
Subject: Re: [Boost-users] matrix_slice access, assignment, issues
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-06-22 17:06:46
On Mon, Jun 21, 2010 at 11:45 PM, Eric Shamay <eric.shamay_at_[hidden]> wrote:
> I've been trying to form a class based on the matrix_slice to ease some
> operations. Thus far I have: http://codepad.org/EepVDx2C
>
> The compiler complains about the line where I form a matrix_slice (line 21
> in the paste), and specifically with the first argument. I'm lost as to why
> I can't submit a matrix<double> as the first argument in the manner I've
> tried.
>
> Any help would be greatly appreciated.
Hi!
The matrix_slice constructor takes either a "matrix_type&" or a
"matrix_closure_type const&" as first parameter.
In case of the "matrix_closure_type const&" version, this is translated into
const matrix_reference<matrix<double> const>
for the "matrix_t" type.
On line 21, you're passing a "const Tensor&", so the compiler is
unable to find a good match.
I think a possible solution (maybe not the better one) is to replace
line 21 with the following:
return submatrix(*const_cast<Tensor*>(this), slice(s1, 1, e1),
slice(s2, 1, e2));
Substantially, you remove the constness from "this" and pass to the
"matrix_slice" ctor a "matrix_t&" parameter.
-- Marco
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net