light-matrix
light-matrix copied to clipboard
Expression class reflection
Devices to inspect the structure of an expression
The implementation should be non-instrusive, relying on external template class with specializations.
// some declarations
template<class Expr>
class matexpr_typeinfo;
template<typename T, class Expr>
matexpr_typeinfo<Expr> get_matexpr_type(const IMatrixXpr<Expr, T>& )
{
return matexpr_typeinfo<Expr>();
}
// some usage: let a be an matrix expression instance
// return a type name (e.g. "unary_expr", "dense", etc) as std::string
get_matexpr_type( a ).name();
// return a short string (e.g. "add(dense, sqr(dense))") as std::string
get_matexpr_type( a ).short_repr();