Commit 217fbf88 authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Synchronize

Renamed GetDerivative to GetJacobian
parent a2d5243c
......@@ -22,7 +22,7 @@ namespace INMOST
void FromBasicExpression(Sparse::Row & entries, const basic_expression & expr)
{
Sparse::RowMerger & merger = Automatizator::GetCurrent()->GetMerger();
expr.GetDerivative(1.0,merger);
expr.GetJacobian(1.0,merger);
merger.RetriveRow(entries);
merger.Clear();
}
......@@ -31,15 +31,15 @@ namespace INMOST
{
Sparse::RowMerger & merger = Automatizator::GetCurrent()->GetMerger();
merger.PushRow(multme,entries);
expr.GetDerivative(multit,merger);
expr.GetJacobian(multit,merger);
merger.RetriveRow(entries);
merger.Clear();
}
void FromGetDerivative(const basic_expression & expr, INMOST_DATA_REAL_TYPE mult, Sparse::Row & r)
void FromGetJacobian(const basic_expression & expr, INMOST_DATA_REAL_TYPE mult, Sparse::Row & r)
{
Sparse::RowMerger & merger = Automatizator::GetCurrent()->GetMerger();
expr.GetDerivative(mult,merger);
expr.GetJacobian(mult,merger);
merger.AddRow(1.0,r);
merger.RetriveRow(r);
merger.Clear();
......
......@@ -24,7 +24,6 @@
#if defined(USE_AUTODIFF)
namespace INMOST
{
class basic_expression
{
......@@ -32,15 +31,17 @@ namespace INMOST
basic_expression() {}//if( GetAutodiffPrint() ) std::cout << this << " Created" << std::endl;}
basic_expression(const basic_expression & other) {};//std::cout << this << " Created from " << &other << std::endl;}
virtual INMOST_DATA_REAL_TYPE GetValue() const = 0;
virtual void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const = 0;
virtual void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const = 0;
virtual void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const = 0;
virtual void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const = 0;
//virtual void GetHessian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const = 0;
//virtual void GetHessian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const = 0;
virtual ~basic_expression() {}//if( GetAutodiffPrint() ) std::cout << this << " Destroied" << std::endl;}
};
bool CheckCurrentAutomatizator();
void FromBasicExpression(Sparse::Row & entries, const basic_expression & expr);
void AddBasicExpression(Sparse::Row & entries, INMOST_DATA_REAL_TYPE multme, INMOST_DATA_REAL_TYPE multit, const basic_expression & expr);
void FromGetDerivative(const basic_expression & expr, INMOST_DATA_REAL_TYPE mult, Sparse::Row & r);
void FromGetJacobian(const basic_expression & expr, INMOST_DATA_REAL_TYPE mult, Sparse::Row & r);
//bool GetAutodiffPrint();
//void SetAutodiffPrint(bool set);
......@@ -51,8 +52,10 @@ namespace INMOST
shell_expression() {}// if( GetAutodiffPrint() ) std::cout << this << " Shell Created for " << dynamic_cast<basic_expression *>(this) << std::endl;}
shell_expression(const shell_expression & other) {}//std::cout << this << " Shell Created from " << &other << std::endl;}
__INLINE virtual INMOST_DATA_REAL_TYPE GetValue() const {return static_cast<const Derived *>(this)->GetValue(); }
__INLINE virtual void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const { return static_cast<const Derived *>(this)->GetDerivative(mult,r); }
__INLINE virtual void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const { return static_cast<const Derived *>(this)->GetDerivative(mult,r); }
__INLINE virtual void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const { return static_cast<const Derived *>(this)->GetJacobian(mult,r); }
__INLINE virtual void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const { return static_cast<const Derived *>(this)->GetJacobian(mult,r); }
//__INLINE virtual void GetHessian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {return static_cast<const Derived *>(this)->GetHessian(mult,r); }
//__INLINE virtual void GetHessian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {return static_cast<const Derived *>(this)->GetHessian(mult,r); }
operator Derived & () {return *static_cast<Derived *>(this);}
operator const Derived & () const {return *static_cast<const Derived *>(this);}
~shell_expression() {}// if( GetAutodiffPrint() ) std::cout << this << " Shell Destroied for " << dynamic_cast<basic_expression *>(this) << std::endl;}
......@@ -68,8 +71,10 @@ namespace INMOST
const_expression(const const_expression & other) :value(other.value) {}
const_expression(INMOST_DATA_REAL_TYPE pvalue) : value(pvalue) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {}
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {}
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {}
//__INLINE void GetHessian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {}
//__INLINE void GetHessian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {}
__INLINE const_expression & operator =(const_expression const & other)
{
value = other.value;
......@@ -86,8 +91,8 @@ namespace INMOST
var_expression(const var_expression & other) :value(other.value), index(other.index) {}
var_expression(INMOST_DATA_REAL_TYPE pvalue, INMOST_DATA_ENUM_TYPE pindex) : value(pvalue), index(pindex) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {if( index != ENUMUNDEF ) r[index] += mult;}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {if( index != ENUMUNDEF ) r[index] += mult;}
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {if( index != ENUMUNDEF ) r[index] += mult;}
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {if( index != ENUMUNDEF ) r[index] += mult;}
__INLINE var_expression & operator =(var_expression const & other)
{
value = other.value;
......@@ -121,19 +126,19 @@ namespace INMOST
value = expr.GetValue();
if( CheckCurrentAutomatizator() )
FromBasicExpression(entries,expr); //Optimized version
else expr.GetDerivative(1.0,entries);
else expr.GetJacobian(1.0,entries);
}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void SetValue(INMOST_DATA_REAL_TYPE val) { value = val; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
for(Sparse::Row::const_iterator it = entries.Begin(); it != entries.End(); ++it)
r[it->first] += it->second*mult;
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
if( CheckCurrentAutomatizator() )
FromGetDerivative(*this,mult,r);
FromGetJacobian(*this,mult,r);
else
{
for(Sparse::Row::const_iterator it = entries.Begin(); it != entries.End(); ++it)
......@@ -154,7 +159,7 @@ namespace INMOST
else
{
Sparse::Row tmp;
expr.GetDerivative(1.0,tmp);
expr.GetJacobian(1.0,tmp);
entries.Swap(tmp);
}
return *this;
......@@ -175,7 +180,7 @@ namespace INMOST
else
{
Sparse::Row tmp(entries);
expr.GetDerivative(1.0,tmp);
expr.GetJacobian(1.0,tmp);
entries.Swap(tmp);
}
return *this;
......@@ -188,7 +193,7 @@ namespace INMOST
else
{
Sparse::Row tmp(entries);
expr.GetDerivative(-1.0,tmp);
expr.GetJacobian(-1.0,tmp);
entries.Swap(tmp);
}
return *this;
......@@ -202,7 +207,7 @@ namespace INMOST
{
Sparse::Row tmp(entries);
for(Sparse::Row::iterator it = tmp.Begin(); it != tmp.End(); ++it) it->second *= rval;
expr.GetDerivative(lval,tmp);
expr.GetJacobian(lval,tmp);
entries.Swap(tmp);
}
value *= rval;
......@@ -219,7 +224,7 @@ namespace INMOST
{
Sparse::Row tmp(entries);
for(Sparse::Row::iterator it = tmp.Begin(); it != tmp.End(); ++it) it->second *= reciprocial_rval;
expr.GetDerivative(-value*reciprocial_rval,tmp);
expr.GetJacobian(-value*reciprocial_rval,tmp);
entries.Swap(tmp);
}
return *this;
......@@ -321,16 +326,16 @@ namespace INMOST
/// Set value without changing derivatives
__INLINE void SetValue(INMOST_DATA_REAL_TYPE val) { value = val; }
/// Retrive derivatives with multiplier into Sparse::RowMerger structure.
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
for(Sparse::Row::iterator it = entries.Begin(); it != entries.End(); ++it)
r[it->first] += it->second*mult;
}
/// Retrive derivatives with multiplier into Sparse::Row structure.
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
if( CheckCurrentAutomatizator() )
FromGetDerivative(*this,mult,r);
FromGetJacobian(*this,mult,r);
else
{
for(Sparse::Row::iterator it = entries.Begin(); it != entries.End(); ++it)
......@@ -351,7 +356,7 @@ namespace INMOST
else
{
Sparse::Row tmp;
expr.GetDerivative(1.0,tmp);
expr.GetJacobian(1.0,tmp);
entries.Swap(tmp);
}
return *this;
......@@ -378,7 +383,7 @@ namespace INMOST
else
{
Sparse::Row tmp(entries);
expr.GetDerivative(1.0,tmp);
expr.GetJacobian(1.0,tmp);
entries.Swap(tmp);
}
return *this;
......@@ -391,7 +396,7 @@ namespace INMOST
else
{
Sparse::Row tmp(entries);
expr.GetDerivative(-1.0,tmp);
expr.GetJacobian(-1.0,tmp);
entries.Swap(tmp);
}
return *this;
......@@ -405,7 +410,7 @@ namespace INMOST
{
Sparse::Row tmp(entries);
for(Sparse::Row::iterator it = tmp.Begin(); it != tmp.End(); ++it) it->second *= rval;
expr.GetDerivative(lval,tmp);
expr.GetJacobian(lval,tmp);
entries.Swap(tmp);
}
value *= rval;
......@@ -422,7 +427,7 @@ namespace INMOST
{
Sparse::Row tmp(entries);
for(Sparse::Row::iterator it = tmp.Begin(); it != tmp.End(); ++it) it->second *= reciprocial_rval;
expr.GetDerivative(-value*reciprocial_rval,tmp);
expr.GetJacobian(-value*reciprocial_rval,tmp);
entries.Swap(tmp);
}
return *this;
......@@ -471,13 +476,13 @@ namespace INMOST
}
const_multiplication_expression(const const_multiplication_expression & other) : arg(other.arg), value(other.value), dmult(other.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
};
......@@ -493,13 +498,13 @@ namespace INMOST
}
variation_multiplication_expression(const variation_multiplication_expression & other) : arg(other.arg), value(other.value), dmult(other.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
};
......@@ -517,13 +522,13 @@ namespace INMOST
}
const_division_expression(const const_division_expression & other) : arg(other.arg), value(other.value), dmult(other.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
};
......@@ -539,13 +544,13 @@ namespace INMOST
}
const_addition_expression(const const_addition_expression & other) : arg(other.arg), value(other.value) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult,r);
arg.GetJacobian(mult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult,r);
arg.GetJacobian(mult,r);
}
};
......@@ -561,13 +566,13 @@ namespace INMOST
}
const_subtraction_expression(const const_subtraction_expression & other) : arg(other.arg), value(other.value) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(-mult,r);
arg.GetJacobian(-mult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(-mult,r);
arg.GetJacobian(-mult,r);
}
};
......@@ -586,13 +591,13 @@ namespace INMOST
reciprocal_expression(const reciprocal_expression & other)
: arg(other.arg), value(other.value), reciprocial_val(other.reciprocial_val) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(-mult*value*reciprocial_val,r);
arg.GetJacobian(-mult*value*reciprocial_val,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(-mult*value*reciprocial_val,r);
arg.GetJacobian(-mult*value*reciprocial_val,r);
}
};
......@@ -605,13 +610,13 @@ namespace INMOST
unary_minus_expression(const shell_expression<A> & parg) : arg(parg) {value = -arg.GetValue();}
unary_minus_expression(const unary_minus_expression & b) : arg(b.arg) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const {return value;}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(-mult,r);
arg.GetJacobian(-mult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(-mult,r);
arg.GetJacobian(-mult,r);
}
};
......@@ -629,13 +634,13 @@ namespace INMOST
}
abs_expression(const abs_expression & b) : arg(b.arg), value(b.value), dmult(b.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const {return value;}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative( mult * dmult, r);
arg.GetJacobian( mult * dmult, r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative( mult * dmult, r);
arg.GetJacobian( mult * dmult, r);
}
};
......@@ -652,13 +657,13 @@ namespace INMOST
}
exp_expression(const exp_expression & b) : arg(b.arg), value(b.value) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; };
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative( mult * value, r);
arg.GetJacobian( mult * value, r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative( mult * value, r);
arg.GetJacobian( mult * value, r);
}
};
......@@ -676,13 +681,13 @@ namespace INMOST
}
log_expression(const log_expression & b) : arg(b.arg), value(b.value), dmult(b.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; };
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
};
......@@ -701,13 +706,13 @@ namespace INMOST
}
sin_expression(const sin_expression & b) : arg(b.arg), value(b.value), dmult(b.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; };
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
};
......@@ -725,13 +730,13 @@ namespace INMOST
}
cos_expression(const cos_expression & b) : arg(b.arg), value(b.value), dmult(b.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; };
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
};
......@@ -747,13 +752,13 @@ namespace INMOST
}
sqrt_expression(const sqrt_expression & b) : arg(b.arg), value(b.value) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; };
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(0.5*mult/value,r);
arg.GetJacobian(0.5*mult/value,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(0.5*mult/value,r);
arg.GetJacobian(0.5*mult/value,r);
}
};
......@@ -772,13 +777,13 @@ namespace INMOST
}
soft_abs_expression(const soft_abs_expression & b) : arg(b.arg), value(b.value), dmult(b.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; };
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
};
......@@ -798,13 +803,13 @@ namespace INMOST
}
soft_sign_expression(const soft_sign_expression & b) : arg(b.arg), value(b.value), dmult(b.dmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; };
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
arg.GetDerivative(mult*dmult,r);
arg.GetJacobian(mult*dmult,r);
}
};
......@@ -826,15 +831,15 @@ namespace INMOST
soft_max_expression(const soft_max_expression & other)
: left(other.left), right(other.right), value(other.value), ldmult(other.ldmult), rdmult(other.rdmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
left.GetDerivative(mult*ldmult,r);
right.GetDerivative(mult*rdmult,r);
left.GetJacobian(mult*ldmult,r);
right.GetJacobian(mult*rdmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
left.GetDerivative(mult*ldmult,r);
right.GetDerivative(mult*rdmult,r);
left.GetJacobian(mult*ldmult,r);
right.GetJacobian(mult*rdmult,r);
}
};
......@@ -856,15 +861,15 @@ namespace INMOST
soft_min_expression(const soft_min_expression & other)
: left(other.left), right(other.right), value(other.value), ldmult(other.ldmult), rdmult(other.rdmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
left.GetDerivative(mult*ldmult,r);
right.GetDerivative(mult*rdmult,r);
left.GetJacobian(mult*ldmult,r);
right.GetJacobian(mult*rdmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
left.GetDerivative(mult*ldmult,r);
right.GetDerivative(mult*rdmult,r);
left.GetJacobian(mult*ldmult,r);
right.GetJacobian(mult*rdmult,r);
}
};
......@@ -885,15 +890,15 @@ namespace INMOST
multiplication_expression(const multiplication_expression & other)
: left(other.left), right(other.right), value(other.value), ldmult(other.ldmult), rdmult(other.rdmult) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
left.GetDerivative(mult*ldmult,r);
right.GetDerivative(mult*rdmult,r);
left.GetJacobian(mult*ldmult,r);
right.GetJacobian(mult*rdmult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
left.GetDerivative(mult*ldmult,r);
right.GetDerivative(mult*rdmult,r);
left.GetJacobian(mult*ldmult,r);
right.GetJacobian(mult*rdmult,r);
}
};
......@@ -913,15 +918,15 @@ namespace INMOST
}
division_expression(const division_expression & other) : left(other.left), right(other.right), value(other.value), reciprocal_rval(other.reciprocal_rval) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
left.GetDerivative(mult * reciprocal_rval,r);
right.GetDerivative(- mult * value * reciprocal_rval,r);
left.GetJacobian(mult * reciprocal_rval,r);
right.GetJacobian(- mult * value * reciprocal_rval,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
left.GetDerivative(mult * reciprocal_rval,r);
right.GetDerivative(- mult * value * reciprocal_rval,r);
left.GetJacobian(mult * reciprocal_rval,r);
right.GetJacobian(- mult * value * reciprocal_rval,r);
}
};
......@@ -939,15 +944,15 @@ namespace INMOST
addition_expression(const addition_expression & other)
: left(other.left), right(other.right), value(other.value) {}
__INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const
{
left.GetDerivative(mult,r);
right.GetDerivative(mult,r);
left.GetJacobian(mult,r);
right.GetJacobian(mult,r);
}
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
__INLINE void GetJacobian(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{