light-matrix icon indicating copy to clipboard operation
light-matrix copied to clipboard

Expression class reflection

Open lindahua opened this issue 13 years ago • 0 comments

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();  

lindahua avatar Jul 28 '12 18:07 lindahua