|
Ublas : |
From: Max Weinberg (max.weinberg_at_[hidden])
Date: 2005-06-01 16:06:53
Hi,
here is some workaround I have written to get around the begin/end issue. It
helps to avoid cluttering the code with nasty ifdefs when coding for
multiple compilers. Maybe someone finds it useful.
To use it, you have to write:
for ( typename Matr::iterator1 it1 = a.begin1(); it1 != a.end1(); ++it1 )
{
for ( typename Matr::iterator2 it2 = getBegin<Matr>(it1) ; it2 !=
it1.getEnd<Matr>(it2); ++it2 )
{...}
}
Additional performance hint: When iterating over a constant matrix, don't
use a call to end() in the conditional expression of the for statement. The
position of end() would be re-calculated every time the condition is
checked, although it never changes. Write instead:
const typename Matr::const_iterator1 aend1 = a.end1();
for ( typename Matr::const_iterator1 it1 = a.begin1(); it1 != aend1;
++it1 )
{...}
Regards, Max
begin 666 begin_end_wrapper.h
M(VEF;F1E9B!"14=)3E]%3D1?5U)!4%!%4E](#0HC9&5F:6YE($)%1TE.7T5.
M1%]74D%04$527T_at_-"B-I;F-L=61E(")B;V]S="]N=6UE<FEC+W5B;&%S+V1E
M=&%I;"]C;VYF:6<N:'!P(@T*#0HO+V)E9VEN#0HO+W)O=U]M86IO<@T*=&5M
M<&QA=&4\='EP96YA;64_at_36%T<FEX5#X-"FEN;&EN90T*='EP96YA;64_at_36%T
M<FEX5#HZ8V]N<W1?:71E<F%T;W(R(&=E=$)E9VEN*&-O;G-T('1Y<&5N86UE
M($UA=')I>%0Z.F-O;G-T7VET97)A=&]R,28@:71E<B I#0I[#0HC:69N9&5F
M($)/3U-47U5"3$%37TY/7TY%4U1%1%]#3$%34U]214Q!5$E/3_at_T*"7)E='5R
M;B!I=&5R+F)E9VEN*"D["0D)"0T*(V5L<V4-"@ER971U<FX_at_8F5G:6XH:71E
M<BP@:71E<F%T;W(Q7W1A9R_at_I("D[#0HC96YD:68-"GT-"@T*=&5M<&QA=&4\
M='EP96YA;64_at_36%T<FEX5#X-"FEN;&EN90T*='EP96YA;64_at_36%T<FEX5#HZ
M:71E<F%T;W(R(&=E=$)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;W(R(&=E=$5N9"AC;VYS="!T>7!E;F%M92!-871R:7A4.CIC;VYS
M=%]I=&5R871O<C$F(&ET97(@*0T*>PT*(VEF;F1E9B!"3T]35%]50DQ!4U].
M3U].15-4141?0TQ!4U-?4D5,051)3TX-"@ER971U<FX@:71E<BYE;F0H*3L)
M"0D)#0HC96QS90T*"7)E='5R;B!E;F0H:71E<BP@:71E<F%T;W(Q7W1A9R_at_I
M("D[#0HC96YD:68-"GT-"@T*=&5M<&QA=&4\='EP96YA;64_at_36%T<FEX5#X-
M"FEN;&EN90T*='EP96YA;64_at_36%T<FEX5#HZ:71E<F%T;W(R(&=E=$5N9"AC
M;VYS="!T>7!E;F%M92!-871R:7A4.CII=&5R871O<C$F(&ET97(@*0T*>PT*
M(VEF;F1E9B!"3T]35%]50DQ!4U].3U].15-4141?0TQ!4U-?4D5,051)3TX-
M"@ER971U<FX@:71E<BYE;F0H*3L)"0D)#0HC96QS90T*"7)E='5R;B!E;F0H
M:71E<BP@:71E<F%T;W(Q7W1A9R_at_I("D[#0HC96YD:68-"GT-"@T*+R]C;VQU
M;6Y?;6%J;W(-"G1E;7!L871E/'1Y<&5N86UE($UA=')I>%0^#0II;FQI;F4-
M"G1Y<&5N86UE($UA=')I>%0Z.F-O;G-T7VET97)A=&]R,2!G971%;F0H8V]N
M<W0@='EP96YA;64_at_36%T<FEX5#HZ8V]N<W1?:71E<F%T;W(R)B!I=&5R("D-
M"GL-"B-I9FYD968_at_0D]/4U1?54),05-?3D]?3D535$5$7T-,05-37U)%3$%4
M24].#0H)<F5T=7)N(&ET97(N96YD*"D["0D)"0T*(V5L<V4-"@ER971U<FX@
M96YD*&ET97(L(&ET97)A=&]R,E]T86<H*2 I.PT*(V5N9&EF#0I]#0H-"G1E
M;7!L871E/'1Y<&5N86UE($UA=')I>%0^#0II;FQI;F4-"G1Y<&5N86UE($UA
M=')I>%0Z.FET97)A=&]R,2!G971%;F0H8V]N<W0@='EP96YA;64_at_36%T<FEX
M5#HZ:71E<F%T;W(R)B!I=&5R("D-"GL-"B-I9FYD968_at_0D]/4U1?54),05-?
M3D]?3D535$5$7T-,05-37U)%3$%424].#0H)<F5T=7)N(&ET97(N96YD*"D[
M"0D)"0T*(V5L<V4-"@ER971U<FX_at_96YD*&ET97(L(&ET97)A=&]R,E]T86<H
9*2 I.PT*(V5N9&EF#0I]#0H-"B-E;F1I9@``
`
end