13 Function::Function(
const std::vector<std::shared_ptr<BasisSet> > &_args) : func_ID(ID_count++), m_argument(_args) {
15 for(
Index i = 0; i < m_argument.size(); i++) {
16 for(
Index j = 0; j < m_argument[i]->size(); j++) {
17 m_arg2sub.push_back(i);
18 m_arg2fun.push_back(j);
25 return inner_prod_table[this->class_ID()][RHS->
class_ID()]->dot(
this, RHS);
29 void Function::normalize() {
30 double mag(sqrt(this->
dot(
this)));
35 m_tex_formula.clear();
36 this->scale(1.0 / mag);
41 bool Function::shallow_compare(
Function const *RHS)
const {
42 return (operation_table[this->class_ID()][RHS->
class_ID()])->
compare(
this, RHS);
48 if(m_argument.size() != (RHS->
m_argument).size())
52 if(!operation_table[this->class_ID()][RHS->
class_ID()])
55 for(
Index i = 0; i < m_argument.size(); i++) {
60 return shallow_compare(RHS);
66 return operation_table[this->class_ID()][RHS->
class_ID()]->add(
this, RHS);
71 return operation_table[this->class_ID()][RHS->
class_ID()]->subtract(
this, RHS);
86 return (operation_table[this->class_ID()][RHS->
class_ID()])->multiply(
this, RHS);
92 m_tex_formula.clear();
94 return operation_table[this->class_ID()][RHS->
class_ID()]->add_to(
this, RHS);
100 m_tex_formula.clear();
102 return operation_table[this->class_ID()][RHS->
class_ID()]->subtract_from(
this, RHS);
109 for(
Index i = 0; i < m_argument.size(); i++) {
110 t_result[i] = m_argument[i]->basis_symrep_ID();
118 return (*m_argument[m_arg2sub[i]])[m_arg2fun[i]];
123 double Function::_arg_eval_cache(
Index i)
const {
124 return m_argument[m_arg2sub[i]]->eval_cache(m_arg2fun[i]);
129 double Function::_arg_deval_cache(
Index i)
const {
130 return m_argument[m_arg2sub[i]]->deval_cache(m_arg2fun[i]);
135 int Function::_dependency_layer()
const {
137 for(
Index i = 0; i < m_argument.size(); i++) {
138 tdep =
max(tdep, m_argument[i]->dependency_layer());
162 return _accept(visitor, home_basis_ptr);
167 void Function::refresh_ID() {
168 func_ID = ID_count++;
173 void Function::print(std::ostream &stream)
const {
174 if(!m_formula.size()) {
175 this->make_formula();
182 void Function::print_tex(std::ostream &stream)
const {
183 if(!m_formula.size()) {
184 this->make_formula();
186 stream << m_tex_formula;
192 Function *Function::sym_copy_coeffs(
const SymOp &op,
int dependency_level)
const {
222 return _update_dof_IDs(before_IDs, after_IDs);
227 std::string Function::formula()
const {
228 if(!m_formula.size()) {
229 this->make_formula();
237 std::string Function::tex_formula()
const {
238 if(!m_formula.size()) {
239 this->make_formula();
242 return m_tex_formula;
259 std::cerr <<
"WARNING: You are trying to evaluate a function using an Array<double> as argument,"
260 <<
" but that option is not available for the function:\n"
261 <<
" " << (this->formula()) <<
"\n";
269 std::cerr <<
"WARNING: You are trying to evaluate a function using an Array<int> as argument,\n"
270 <<
" but that option is not available for the function:\n"
271 <<
" " << (this->formula()) <<
"\n";
287 std::cerr <<
"WARNING: Multiplication of type " << LHS->
type_name() <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
294 std::cerr <<
"WARNING: Multiplication of type " << LHS->
type_name() <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
302 std::cerr <<
"WARNING: Addition of type " << LHS->
type_name() <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
309 std::cerr <<
"WARNING: Addition of type " << LHS->
type_name() <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
317 std::cerr <<
"WARNING: Subtraction of type " << LHS->
type_name() <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
324 std::cerr <<
"WARNING: Subtraction of type " << LHS->
type_name() <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
332 std::cerr <<
"WARNING: Polynomial division of type " << LHS->
type_name() <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
339 std::cerr <<
"WARNING: Polynomial division of type " << LHS->
type_name() <<
" with type " << RHS->
type_name() <<
" is undefined!!!\n";
368 json[
"m_formula"] = m_formula;
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.
bool compare(const T &A, const T &B, double tol)
Floating point comparison with tol, return A < B.
virtual Function * apply_sym_coeffs(const SymOp &op, int dependency_layer=1)
virtual jsonParser & to_json(jsonParser &json) const
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
virtual int class_ID() const =0
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
EigenIndex Index
For long integer indexing:
virtual std::string type_name() const =0
T max(const T &A, const T &B)
T dot(const Tensor< T > &LHS, const Tensor< T > &RHS)
Function * poly_remainder(Function const *RHS) const
jsonParser & put_obj()
Puts new empty JSON object.
static Array< Array< InnerProduct * > > inner_prod_table
ArgumentContainer m_argument
Function * poly_quotient(Function const *RHS) const
static Array< Array< FunctionOperation * > > operation_table
Basic std::vector like container (deprecated)