10 Array<Array<InnerProduct *> >();
12 Array<Array<FunctionOperation *> >();
17 : func_ID(ID_count++), m_argument(_args) {
19 for (
Index i = 0; i < m_argument.size(); i++) {
20 for (
Index j = 0; j < m_argument[i]->size(); j++) {
21 m_arg2sub.push_back(i);
22 m_arg2fun.push_back(j);
29 return inner_prod_table[this->class_ID()][RHS->
class_ID()]->dot(
this, RHS);
33 void Function::normalize() {
34 double mag(sqrt(this->
dot(
this)));
39 m_tex_formula.clear();
40 this->scale(1.0 / mag);
45 bool Function::shallow_compare(
Function const *RHS)
const {
46 return (operation_table[this->class_ID()][RHS->
class_ID()])
53 if (m_argument.size() != (RHS->
m_argument).size())
return false;
56 if (!operation_table[this->class_ID()][RHS->
class_ID()])
return false;
58 for (
Index i = 0; i < m_argument.size(); i++) {
62 return shallow_compare(RHS);
68 return operation_table[this->class_ID()][RHS->
class_ID()]->add(
this, RHS);
73 return operation_table[this->class_ID()][RHS->
class_ID()]->subtract(
this,
91 return (operation_table[this->class_ID()][RHS->
class_ID()])
98 m_tex_formula.clear();
100 return operation_table[this->class_ID()][RHS->
class_ID()]->add_to(
this, RHS);
106 m_tex_formula.clear();
108 return operation_table[this->class_ID()][RHS->
class_ID()]->subtract_from(
this,
114 std::vector<Index>
const &compatibility_map) {
115 _set_arguments(new_arg, compatibility_map);
119 for (
Index i = 0; i < new_arg.size(); i++) {
120 for (
Index j = 0; j < new_arg[i]->size(); j++) {
121 m_arg2sub.push_back(i);
122 m_arg2fun.push_back(j);
130 for (
Index i = 0; i < m_argument.size(); i++) {
131 t_result[i] = m_argument[i]->basis_symrep_ID();
139 return (*m_argument[m_arg2sub[i]])[m_arg2fun[i]];
144 double Function::_arg_eval_cache(
Index i)
const {
145 return m_argument[m_arg2sub[i]]->eval_cache(m_arg2fun[i]);
150 double Function::_arg_deval_cache(
Index i)
const {
151 return m_argument[m_arg2sub[i]]->deval_cache(m_arg2fun[i]);
156 int Function::_dependency_layer()
const {
158 for (
Index i = 0; i < m_argument.size(); i++) {
159 tdep =
max(tdep, m_argument[i]->dependency_layer());
184 return _accept(visitor, home_basis_ptr);
190 BasisSet const *home_basis_ptr)
const {
202 return _accept(visitor, home_basis_ptr);
207 void Function::refresh_ID() { func_ID = ID_count++; }
211 void Function::print(std::ostream &stream)
const {
212 if (!m_formula.size()) {
213 this->make_formula();
220 void Function::print_tex(std::ostream &stream)
const {
221 if (!m_formula.size()) {
222 this->make_formula();
224 stream << m_tex_formula;
231 int dependency_level)
const {
238 int Function::register_remotes(
239 const std::vector<DoF::RemoteHandle> &remote_handles) {
250 bool Function::update_dof_IDs(
const std::vector<Index> &before_IDs,
251 const std::vector<Index> &after_IDs) {
264 return _update_dof_IDs(before_IDs, after_IDs);
268 void Function::set_identifier(
char _key, std::string
const &_value) {
269 m_identifiers[_key] = _value;
273 std::string Function::identifier(
char _key)
const {
274 auto it = m_identifiers.find(_key);
275 if (it == m_identifiers.end())
return "?";
281 std::string Function::formula()
const {
282 if (!m_formula.size()) {
283 this->make_formula();
291 std::string Function::tex_formula()
const {
292 if (!m_formula.size()) {
293 this->make_formula();
296 return m_tex_formula;
313 std::cerr <<
"WARNING: Multiplication of type " << LHS->
type_name()
314 <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
322 std::cerr <<
"WARNING: Multiplication of type " << LHS->
type_name()
323 <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
332 std::cerr <<
"WARNING: Addition of type " << LHS->
type_name() <<
" with type "
333 << RHS->
type_name() <<
" is undefined!!!\n";
340 std::cerr <<
"WARNING: Addition of type " << LHS->
type_name() <<
" with type "
341 << RHS->
type_name() <<
" is undefined!!!\n";
350 std::cerr <<
"WARNING: Subtraction of type " << LHS->
type_name()
351 <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
359 std::cerr <<
"WARNING: Subtraction of type " << LHS->
type_name()
360 <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
369 std::cerr <<
"WARNING: Polynomial division of type " << LHS->
type_name()
370 <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
378 std::cerr <<
"WARNING: Polynomial division of type " << LHS->
type_name()
379 <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
406 json[
"m_formula"] = m_formula;
Basic std::vector like container (deprecated)
Function * poly_remainder(Function const *RHS) const
virtual std::string type_name() const =0
ArgumentContainer m_argument
virtual jsonParser & to_json(jsonParser &json) const
virtual Function * apply_sym_coeffs(const SymOp &op, int dependency_layer=1)
std::vector< std::shared_ptr< BasisSet > > ArgumentContainer
static Array< Array< InnerProduct * > > inner_prod_table
Function * poly_quotient(Function const *RHS) const
virtual int class_ID() const =0
static Array< Array< FunctionOperation * > > operation_table
Function * multiply(Function const *RHS) const
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
jsonParser & put_obj()
Puts new empty JSON object.
T dot(const Tensor< T > &LHS, const Tensor< T > &RHS)
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
bool compare(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Compare ClusterInvariants.
INDEX_TYPE Index
For long integer indexing:
T max(const T &A, const T &B)
bool almost_zero(const MatrixBase< Derived > &val, double tol=CASM::TOL)
Round Eigen::MatrixXd.