section 6F
X_lens_less_range

home

Classes var_lens_less_range and con_lens_less_range cause the subscript ranges of a matrix to appear reduced, while the number of dimensions appears the same. Thus some components are not longer accessible.

Employed the example program below, function alone_non_var will be fully described later. However, a brief explanation is that it performs the same operation on every element of a matrix.

#include "SOME_DIRECTORY/mat_gen_dim.h"
using namespace mat_gen_dim;

struct add_5 {
    void operator () (double & a) { a += 5.0; }
};

int main () {
    form const frm_a {blt{1,3},blt{2,6},blt{5,8}};
    cout << "\nfrm_a: " << frm_a;
    var_matrix<double> mat_a {sub_matrix_linear (frm_a,2.0)};
    cout << "\nmat_a before: " << mat_a;

    form const frm_b {blt{1,3},blt{3,6},blt{5,7}};
    cout << "\nfrm_b: " << frm_b;
    var_lens_less_range<double> adr_b {mat_a, frm_b};
    cout << "\nadr_b before: " << adr_b;

    alone_non_var<add_5,double> (adr_b);
    cout << "\nadr_b after: " << adr_b;
    cout << "\nmat_a after: " << mat_a;

    return 0;
}
delivers this result:
frm_a: ( 1 =< 3, 2 =< 6, 5 =< 8 )
mat_a before: 
    ( 1 2 5 ) = 2.125    ( 1 2 6 ) = 2.126    ( 1 2 7 ) = 2.127
    ( 1 3 5 ) = 2.135    ( 1 3 6 ) = 2.136    ( 1 3 7 ) = 2.137
    ( 1 4 5 ) = 2.145    ( 1 4 6 ) = 2.146    ( 1 4 7 ) = 2.147
    ( 1 5 5 ) = 2.155    ( 1 5 6 ) = 2.156    ( 1 5 7 ) = 2.157
    ( 2 2 5 ) = 2.225    ( 2 2 6 ) = 2.226    ( 2 2 7 ) = 2.227
    ( 2 3 5 ) = 2.235    ( 2 3 6 ) = 2.236    ( 2 3 7 ) = 2.237
    ( 2 4 5 ) = 2.245    ( 2 4 6 ) = 2.246    ( 2 4 7 ) = 2.247
    ( 2 5 5 ) = 2.255    ( 2 5 6 ) = 2.256    ( 2 5 7 ) = 2.257
frm_b: ( 1 =< 3, 3 =< 6, 5 =< 7 )
adr_b before: 
    ( 1 3 5 ) = 2.135    ( 1 3 6 ) = 2.136    ( 1 4 5 ) = 2.145    ( 1 4 6 ) = 2.146
    ( 1 5 5 ) = 2.155    ( 1 5 6 ) = 2.156    ( 2 3 5 ) = 2.235    ( 2 3 6 ) = 2.236
    ( 2 4 5 ) = 2.245    ( 2 4 6 ) = 2.246    ( 2 5 5 ) = 2.255    ( 2 5 6 ) = 2.256
adr_b after: 
    ( 1 3 5 ) = 7.135    ( 1 3 6 ) = 7.136    ( 1 4 5 ) = 7.145    ( 1 4 6 ) = 7.146
    ( 1 5 5 ) = 7.155    ( 1 5 6 ) = 7.156    ( 2 3 5 ) = 7.235    ( 2 3 6 ) = 7.236
    ( 2 4 5 ) = 7.245    ( 2 4 6 ) = 7.246    ( 2 5 5 ) = 7.255    ( 2 5 6 ) = 7.256
mat_a after: 
    ( 1 2 5 ) = 2.125    ( 1 2 6 ) = 2.126    ( 1 2 7 ) = 2.127
    ( 1 3 5 ) = 7.135    ( 1 3 6 ) = 7.136    ( 1 3 7 ) = 2.137
    ( 1 4 5 ) = 7.145    ( 1 4 6 ) = 7.146    ( 1 4 7 ) = 2.147
    ( 1 5 5 ) = 7.155    ( 1 5 6 ) = 7.156    ( 1 5 7 ) = 2.157
    ( 2 2 5 ) = 2.225    ( 2 2 6 ) = 2.226    ( 2 2 7 ) = 2.227
    ( 2 3 5 ) = 7.235    ( 2 3 6 ) = 7.236    ( 2 3 7 ) = 2.237
    ( 2 4 5 ) = 7.245    ( 2 4 6 ) = 7.246    ( 2 4 7 ) = 2.247
    ( 2 5 5 ) = 7.255    ( 2 5 6 ) = 7.256    ( 2 5 7 ) = 2.257