Classes var_lens_other_form and con_lens_other_form cause a matrix to appear to have a different form. They differ from the matrix member function assign_form which genuinely changes a matrix.
With these lenses, the sequence of the elements will not appear to be changed; thus subscripting by sign_int will not be affected, but subscripting by vec_si will reflect a change.
This example program:
#include "SOME_DIRECTORY/mat_gen_dim.h"
using namespace mat_gen_dim;
int main () {
form const frm_a {blt{2,5},blt{1,3},blt{4,8}};
cout << "\nfrm_a: " << frm_a;
cout << "\nfrm_a.count: " << frm_a.count();
con_matrix<double> mat_a {sub_matrix_linear (frm_a, 5.0)};
cout << "\nmat_a: " << mat_a;
form const frm_b {blt{0,6},blt{3,7}};
cout << "\nfrm_b: " << frm_b;
cout << "\nfrm_b.count: " << frm_b.count();
con_lens_other_form<double> aof_b {mat_a, frm_b};
cout << "\naof_b: " << aof_b;
form const frm_c {blt{22,46}};
cout << "\nfrm_c: " << frm_c;
cout << "\nfrm_c.count: " << frm_c.count();
con_lens_other_form<double> aof_c {aof_b, frm_c};
cout << "\naof_c: " << aof_c;
cout << "\nmat_a (3 1 6) = " << mat_a.get (vec_si {3,1,6});
cout << "\naof_b (2 4) = " << aof_b.get (vec_si {2,4});
cout << "\naof_c (32) = " << aof_c.get (vec_si {32});
return 0;
}
will produce this output:
frm_a: ( 2 =< 5, 1 =< 3, 4 =< 8 )
frm_a.count: 24
mat_a:
( 2 1 4 ) = 5.214 ( 2 1 5 ) = 5.215 ( 2 1 6 ) = 5.216 ( 2 1 7 ) = 5.217
( 2 2 4 ) = 5.224 ( 2 2 5 ) = 5.225 ( 2 2 6 ) = 5.226 ( 2 2 7 ) = 5.227
( 3 1 4 ) = 5.314 ( 3 1 5 ) = 5.315 ( 3 1 6 ) = 5.316 ( 3 1 7 ) = 5.317
( 3 2 4 ) = 5.324 ( 3 2 5 ) = 5.325 ( 3 2 6 ) = 5.326 ( 3 2 7 ) = 5.327
( 4 1 4 ) = 5.414 ( 4 1 5 ) = 5.415 ( 4 1 6 ) = 5.416 ( 4 1 7 ) = 5.417
( 4 2 4 ) = 5.424 ( 4 2 5 ) = 5.425 ( 4 2 6 ) = 5.426 ( 4 2 7 ) = 5.427
frm_b: ( 0 =< 6, 3 =< 7 )
frm_b.count: 24
aof_b:
( 0 3 ) = 5.214 ( 0 4 ) = 5.215 ( 0 5 ) = 5.216 ( 0 6 ) = 5.217
( 1 3 ) = 5.224 ( 1 4 ) = 5.225 ( 1 5 ) = 5.226 ( 1 6 ) = 5.227
( 2 3 ) = 5.314 ( 2 4 ) = 5.315 ( 2 5 ) = 5.316 ( 2 6 ) = 5.317
( 3 3 ) = 5.324 ( 3 4 ) = 5.325 ( 3 5 ) = 5.326 ( 3 6 ) = 5.327
( 4 3 ) = 5.414 ( 4 4 ) = 5.415 ( 4 5 ) = 5.416 ( 4 6 ) = 5.417
( 5 3 ) = 5.424 ( 5 4 ) = 5.425 ( 5 5 ) = 5.426 ( 5 6 ) = 5.427
frm_c: ( 22 =< 46 )
frm_c.count: 24
aof_c:
( 22 ) = 5.214 ( 23 ) = 5.215 ( 24 ) = 5.216 ( 25 ) = 5.217
( 26 ) = 5.224 ( 27 ) = 5.225 ( 28 ) = 5.226 ( 29 ) = 5.227
( 30 ) = 5.314 ( 31 ) = 5.315 ( 32 ) = 5.316 ( 33 ) = 5.317
( 34 ) = 5.324 ( 35 ) = 5.325 ( 36 ) = 5.326 ( 37 ) = 5.327
( 38 ) = 5.414 ( 39 ) = 5.415 ( 40 ) = 5.416 ( 41 ) = 5.417
( 42 ) = 5.424 ( 43 ) = 5.425 ( 44 ) = 5.426 ( 45 ) = 5.427
mat_a (3 1 6) = 5.316
aof_b (2 4) = 5.315
aof_c (32) = 5.316