Strengthening C ++ with the extension ublas + units

I am looking for design / general idea advice on how to enforce matrix dimension constraints on an ublas matrix / vector, possibly using boost blocks.

For example, let the matrix A have the dimensions of the time force x (for example)

// does not have dimensions, time x force and force x time are not distinguished.
matrix<double> A;

//something like?
dimension<time, force, matrix<double> > A;
dimension<force, time, matrix<double> > B = trans(A);

// or maybe custom layouts, although ensuring dimension becomes harder between matrixes?
matrix<double, dimension<time, force> > A;

Have you done something like this, or do you have a good idea on how to organize such restrictions? I'm more looking for a syntax / semantics suggestion rather than an implementation.

I went through the ublas archives, there is a discussion, but nothing concrete.

thank

+3
source share
1 answer

Check out this good Boost tutorial, which introduces the ability to analyze dimensions using a metaprogramming template:

http://www.boost.org/doc/libs/1_35_0/libs/mpl/doc/tutorial/representing-dimensions.html

, , - .

+1

Source: https://habr.com/ru/post/1749844/


All Articles