Code quality: More renaming
This commit is contained in:
@@ -84,11 +84,11 @@ private:
|
|||||||
class filter_elements_fun : public traversal_functor
|
class filter_elements_fun : public traversal_functor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
filter_elements_fun(node_type subtype, std::vector<lhs_rhs_element> & out);
|
filter_elements_fun(node_type subtype, std::vector<tree_node> & out);
|
||||||
void operator()(isaac::math_expression const & math_expression, size_t root_idx, leaf_t) const;
|
void operator()(isaac::math_expression const & math_expression, size_t root_idx, leaf_t) const;
|
||||||
private:
|
private:
|
||||||
node_type subtype_;
|
node_type subtype_;
|
||||||
std::vector<lhs_rhs_element> & out_;
|
std::vector<tree_node> & out_;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<size_t> filter_nodes(bool (*pred)(math_expression::node const & node),
|
std::vector<size_t> filter_nodes(bool (*pred)(math_expression::node const & node),
|
||||||
@@ -96,7 +96,7 @@ std::vector<size_t> filter_nodes(bool (*pred)(math_expression::node const & node
|
|||||||
size_t root,
|
size_t root,
|
||||||
bool inspect);
|
bool inspect);
|
||||||
|
|
||||||
std::vector<lhs_rhs_element> filter_elements(node_type subtype,
|
std::vector<tree_node> filter_elements(node_type subtype,
|
||||||
isaac::math_expression const & math_expression);
|
isaac::math_expression const & math_expression);
|
||||||
const char * evaluate(operation_type type);
|
const char * evaluate(operation_type type);
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ class math_expression_representation_functor : public traversal_functor{
|
|||||||
private:
|
private:
|
||||||
static void append_id(char * & ptr, unsigned int val);
|
static void append_id(char * & ptr, unsigned int val);
|
||||||
void append(driver::Buffer const & h, numeric_type dtype, char prefix) const;
|
void append(driver::Buffer const & h, numeric_type dtype, char prefix) const;
|
||||||
void append(lhs_rhs_element const & lhs_rhs, bool is_assigned) const;
|
void append(tree_node const & lhs_rhs, bool is_assigned) const;
|
||||||
public:
|
public:
|
||||||
math_expression_representation_functor(symbolic_binder & binder, char *& ptr);
|
math_expression_representation_functor(symbolic_binder & binder, char *& ptr);
|
||||||
void append(char*& p, const char * str) const;
|
void append(char*& p, const char * str) const;
|
||||||
|
@@ -162,9 +162,9 @@ enum node_type
|
|||||||
FOR_LOOP_INDEX_TYPE
|
FOR_LOOP_INDEX_TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lhs_rhs_element
|
struct tree_node
|
||||||
{
|
{
|
||||||
lhs_rhs_element();
|
tree_node();
|
||||||
node_type subtype;
|
node_type subtype;
|
||||||
numeric_type dtype;
|
numeric_type dtype;
|
||||||
union
|
union
|
||||||
@@ -178,20 +178,20 @@ struct lhs_rhs_element
|
|||||||
|
|
||||||
struct invalid_node{};
|
struct invalid_node{};
|
||||||
|
|
||||||
void fill(lhs_rhs_element &x, for_idx_t index);
|
void fill(tree_node &x, for_idx_t index);
|
||||||
void fill(lhs_rhs_element &x, invalid_node);
|
void fill(tree_node &x, invalid_node);
|
||||||
void fill(lhs_rhs_element & x, std::size_t node_index);
|
void fill(tree_node & x, std::size_t node_index);
|
||||||
void fill(lhs_rhs_element & x, array_base const & a);
|
void fill(tree_node & x, array_base const & a);
|
||||||
void fill(lhs_rhs_element & x, value_scalar const & v);
|
void fill(tree_node & x, value_scalar const & v);
|
||||||
|
|
||||||
class math_expression
|
class math_expression
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct node
|
struct node
|
||||||
{
|
{
|
||||||
lhs_rhs_element lhs;
|
tree_node lhs;
|
||||||
op_element op;
|
op_element op;
|
||||||
lhs_rhs_element rhs;
|
tree_node rhs;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<node> container_type;
|
typedef std::vector<node> container_type;
|
||||||
|
@@ -8,7 +8,7 @@ namespace isaac
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::string to_string(node_type const & f);
|
std::string to_string(node_type const & f);
|
||||||
std::string to_string(lhs_rhs_element const & e);
|
std::string to_string(tree_node const & e);
|
||||||
std::ostream & operator<<(std::ostream & os, math_expression::node const & s_node);
|
std::ostream & operator<<(std::ostream & os, math_expression::node const & s_node);
|
||||||
std::string to_string(isaac::math_expression const & s);
|
std::string to_string(isaac::math_expression const & s);
|
||||||
|
|
||||||
|
@@ -21,10 +21,10 @@ public:
|
|||||||
{
|
{
|
||||||
args(): A(NULL), B(NULL), C(NULL), type(INVALID_EXPRESSION_TYPE){ }
|
args(): A(NULL), B(NULL), C(NULL), type(INVALID_EXPRESSION_TYPE){ }
|
||||||
value_scalar alpha;
|
value_scalar alpha;
|
||||||
lhs_rhs_element const * A;
|
tree_node const * A;
|
||||||
lhs_rhs_element const * B;
|
tree_node const * B;
|
||||||
value_scalar beta;
|
value_scalar beta;
|
||||||
lhs_rhs_element const * C;
|
tree_node const * C;
|
||||||
expression_type type;
|
expression_type type;
|
||||||
|
|
||||||
operator bool() const
|
operator bool() const
|
||||||
|
@@ -139,7 +139,7 @@ std::vector<size_t> filter_nodes(bool (*pred)(math_expression::node const & node
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
filter_elements_fun::filter_elements_fun(node_type subtype, std::vector<lhs_rhs_element> & out) :
|
filter_elements_fun::filter_elements_fun(node_type subtype, std::vector<tree_node> & out) :
|
||||||
subtype_(subtype), out_(out)
|
subtype_(subtype), out_(out)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -153,9 +153,9 @@ void filter_elements_fun::operator()(isaac::math_expression const & math_express
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<lhs_rhs_element> filter_elements(node_type subtype, isaac::math_expression const & math_expression)
|
std::vector<tree_node> filter_elements(node_type subtype, isaac::math_expression const & math_expression)
|
||||||
{
|
{
|
||||||
std::vector<lhs_rhs_element> res;
|
std::vector<tree_node> res;
|
||||||
traverse(math_expression, math_expression.root(), filter_elements_fun(subtype, res), true);
|
traverse(math_expression, math_expression.root(), filter_elements_fun(subtype, res), true);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -415,7 +415,7 @@ void math_expression_representation_functor::append_id(char * & ptr, unsigned in
|
|||||||
// append_id(ptr_, binder_.get(h, is_assigned));
|
// append_id(ptr_, binder_.get(h, is_assigned));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void math_expression_representation_functor::append(lhs_rhs_element const & lhs_rhs, bool is_assigned) const
|
void math_expression_representation_functor::append(tree_node const & lhs_rhs, bool is_assigned) const
|
||||||
{
|
{
|
||||||
if(lhs_rhs.subtype==DENSE_ARRAY_TYPE)
|
if(lhs_rhs.subtype==DENSE_ARRAY_TYPE)
|
||||||
{
|
{
|
||||||
|
@@ -79,7 +79,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_arguments(lhs_rhs_element const & lhs_rhs, bool is_assigned) const
|
void set_arguments(tree_node const & lhs_rhs, bool is_assigned) const
|
||||||
{
|
{
|
||||||
switch(lhs_rhs.subtype)
|
switch(lhs_rhs.subtype)
|
||||||
{
|
{
|
||||||
|
@@ -42,7 +42,7 @@ class map_functor : public traversal_functor
|
|||||||
return std::shared_ptr<mapped_object>(new mapped_array(dtype, id, type));
|
return std::shared_ptr<mapped_object>(new mapped_array(dtype, id, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<mapped_object> create(lhs_rhs_element const & lhs_rhs, bool is_assigned = false) const
|
std::shared_ptr<mapped_object> create(tree_node const & lhs_rhs, bool is_assigned = false) const
|
||||||
{
|
{
|
||||||
switch(lhs_rhs.subtype)
|
switch(lhs_rhs.subtype)
|
||||||
{
|
{
|
||||||
|
@@ -13,7 +13,7 @@ namespace isaac
|
|||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
typedef std::vector<std::pair<expression_type, lhs_rhs_element*> > breakpoints_t;
|
typedef std::vector<std::pair<expression_type, tree_node*> > breakpoints_t;
|
||||||
|
|
||||||
|
|
||||||
inline bool is_mmprod(expression_type x)
|
inline bool is_mmprod(expression_type x)
|
||||||
|
@@ -8,41 +8,41 @@
|
|||||||
namespace isaac
|
namespace isaac
|
||||||
{
|
{
|
||||||
|
|
||||||
void fill(lhs_rhs_element &x, invalid_node)
|
void fill(tree_node &x, invalid_node)
|
||||||
{
|
{
|
||||||
x.subtype = INVALID_SUBTYPE;
|
x.subtype = INVALID_SUBTYPE;
|
||||||
x.dtype = INVALID_NUMERIC_TYPE;
|
x.dtype = INVALID_NUMERIC_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill(lhs_rhs_element & x, std::size_t node_index)
|
void fill(tree_node & x, std::size_t node_index)
|
||||||
{
|
{
|
||||||
x.subtype = COMPOSITE_OPERATOR_TYPE;
|
x.subtype = COMPOSITE_OPERATOR_TYPE;
|
||||||
x.dtype = INVALID_NUMERIC_TYPE;
|
x.dtype = INVALID_NUMERIC_TYPE;
|
||||||
x.node_index = node_index;
|
x.node_index = node_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill(lhs_rhs_element & x, for_idx_t index)
|
void fill(tree_node & x, for_idx_t index)
|
||||||
{
|
{
|
||||||
x.subtype = FOR_LOOP_INDEX_TYPE;
|
x.subtype = FOR_LOOP_INDEX_TYPE;
|
||||||
x.dtype = INVALID_NUMERIC_TYPE;
|
x.dtype = INVALID_NUMERIC_TYPE;
|
||||||
x.for_idx = index;
|
x.for_idx = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill(lhs_rhs_element & x, array_base const & a)
|
void fill(tree_node & x, array_base const & a)
|
||||||
{
|
{
|
||||||
x.subtype = DENSE_ARRAY_TYPE;
|
x.subtype = DENSE_ARRAY_TYPE;
|
||||||
x.dtype = a.dtype();
|
x.dtype = a.dtype();
|
||||||
x.array = (array_base*)&a;
|
x.array = (array_base*)&a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill(lhs_rhs_element & x, value_scalar const & v)
|
void fill(tree_node & x, value_scalar const & v)
|
||||||
{
|
{
|
||||||
x.dtype = v.dtype();
|
x.dtype = v.dtype();
|
||||||
x.subtype = VALUE_SCALAR_TYPE;
|
x.subtype = VALUE_SCALAR_TYPE;
|
||||||
x.vscalar = v.values();
|
x.vscalar = v.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
lhs_rhs_element::lhs_rhs_element(){}
|
tree_node::tree_node(){}
|
||||||
|
|
||||||
//
|
//
|
||||||
op_element::op_element() {}
|
op_element::op_element() {}
|
||||||
|
@@ -21,7 +21,7 @@ inline std::string to_string(node_type const & f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string to_string(lhs_rhs_element const & e)
|
inline std::string to_string(tree_node const & e)
|
||||||
{
|
{
|
||||||
if(e.subtype==COMPOSITE_OPERATOR_TYPE)
|
if(e.subtype==COMPOSITE_OPERATOR_TYPE)
|
||||||
{
|
{
|
||||||
|
@@ -48,7 +48,7 @@ void matrix_product::handle_node(math_expression::container_type const & tree, s
|
|||||||
|
|
||||||
matrix_product::args matrix_product::check(math_expression::container_type const & tree, size_t rootidx)
|
matrix_product::args matrix_product::check(math_expression::container_type const & tree, size_t rootidx)
|
||||||
{
|
{
|
||||||
lhs_rhs_element const * assigned = &tree[rootidx].lhs;
|
tree_node const * assigned = &tree[rootidx].lhs;
|
||||||
numeric_type dtype = assigned->dtype;
|
numeric_type dtype = assigned->dtype;
|
||||||
matrix_product::args result ;
|
matrix_product::args result ;
|
||||||
if(dtype==INVALID_NUMERIC_TYPE)
|
if(dtype==INVALID_NUMERIC_TYPE)
|
||||||
|
Reference in New Issue
Block a user