Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-12-01 17:51:01


nisha kannookadan schrieb:
>
> zer.resize(N,s2,true);
> cfe1 = zer;
> cfe2 = zer;
>
Here you assign full zero matrices.

>
> (subrange(cfe1, 0,N-1, 0,s2)).assign(cfe);
> (subrange(cfe2, 1,N, 0,s2)).assign(cfe);
> d = cfo-(cfe1+cfe2)*0.5;
Here you assign new values to the same locations. (Except for the last
row of cfe1 and the first row of cfe2). You would gain less operations
if you compute the matrix d in three steps: 1) first row, 2) row 2 to
N-1, 3) last row.

// untested
row(d, 0) .assign( row(cfo,0) - 0.5 * row(cfe,0) );
subrange(d, 1, N-1, 0, s2) .assign( subrange(cfo, 1, N-1, 0, s2) - 0.5 *
( subrange(cfe, 0, N-2, 0, s2) + subrange(cfe, 1, N-1, 0, s2) );
row(d, N-1) .assign( row(cfo, N-1) - 0.5 * row(cfe, N-1) );

Next - you should avoid temporary matrices.

@eclipse: there is usually a console available that shows the compiler
output.

mfg
Gunter