Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kirill Terekhov
INMOST
Commits
217fbf88
Commit
217fbf88
authored
Feb 08, 2016
by
Kirill Terekhov
Browse files
Synchronize
Renamed GetDerivative to GetJacobian
parent
a2d5243c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/Autodiff/autodiff.cpp
View file @
217fbf88
...
...
@@ -22,7 +22,7 @@ namespace INMOST
void
FromBasicExpression
(
Sparse
::
Row
&
entries
,
const
basic_expression
&
expr
)
{
Sparse
::
RowMerger
&
merger
=
Automatizator
::
GetCurrent
()
->
GetMerger
();
expr
.
Get
Derivative
(
1.0
,
merger
);
expr
.
Get
Jacobian
(
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
.
Get
Derivative
(
multit
,
merger
);
expr
.
Get
Jacobian
(
multit
,
merger
);
merger
.
RetriveRow
(
entries
);
merger
.
Clear
();
}
void
FromGet
Derivative
(
const
basic_expression
&
expr
,
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
void
FromGet
Jacobian
(
const
basic_expression
&
expr
,
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
{
Sparse
::
RowMerger
&
merger
=
Automatizator
::
GetCurrent
()
->
GetMerger
();
expr
.
Get
Derivative
(
mult
,
merger
);
expr
.
Get
Jacobian
(
mult
,
merger
);
merger
.
AddRow
(
1.0
,
r
);
merger
.
RetriveRow
(
r
);
merger
.
Clear
();
...
...
Source/Headers/inmost_expression.h
View file @
217fbf88
...
...
@@ -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
FromGet
Derivative
(
const
basic_expression
&
expr
,
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
);
void
FromGet
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
if
(
index
!=
ENUMUNDEF
)
r
[
index
]
+=
mult
;}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
if
(
index
!=
ENUMUNDEF
)
r
[
index
]
+=
mult
;}
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
if
(
index
!=
ENUMUNDEF
)
r
[
index
]
+=
mult
;}
__INLINE
void
Get
Jacobian
(
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
.
Get
Derivative
(
1.0
,
entries
);
else
expr
.
Get
Jacobian
(
1.0
,
entries
);
}
__INLINE
INMOST_DATA_REAL_TYPE
GetValue
()
const
{
return
value
;
}
__INLINE
void
SetValue
(
INMOST_DATA_REAL_TYPE
val
)
{
value
=
val
;
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
if
(
CheckCurrentAutomatizator
()
)
FromGet
Derivative
(
*
this
,
mult
,
r
);
FromGet
Jacobian
(
*
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
.
Get
Derivative
(
1.0
,
tmp
);
expr
.
Get
Jacobian
(
1.0
,
tmp
);
entries
.
Swap
(
tmp
);
}
return
*
this
;
...
...
@@ -175,7 +180,7 @@ namespace INMOST
else
{
Sparse
::
Row
tmp
(
entries
);
expr
.
Get
Derivative
(
1.0
,
tmp
);
expr
.
Get
Jacobian
(
1.0
,
tmp
);
entries
.
Swap
(
tmp
);
}
return
*
this
;
...
...
@@ -188,7 +193,7 @@ namespace INMOST
else
{
Sparse
::
Row
tmp
(
entries
);
expr
.
Get
Derivative
(
-
1.0
,
tmp
);
expr
.
Get
Jacobian
(
-
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
.
Get
Derivative
(
lval
,
tmp
);
expr
.
Get
Jacobian
(
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
.
Get
Derivative
(
-
value
*
reciprocial_rval
,
tmp
);
expr
.
Get
Jacobian
(
-
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
if
(
CheckCurrentAutomatizator
()
)
FromGet
Derivative
(
*
this
,
mult
,
r
);
FromGet
Jacobian
(
*
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
.
Get
Derivative
(
1.0
,
tmp
);
expr
.
Get
Jacobian
(
1.0
,
tmp
);
entries
.
Swap
(
tmp
);
}
return
*
this
;
...
...
@@ -378,7 +383,7 @@ namespace INMOST
else
{
Sparse
::
Row
tmp
(
entries
);
expr
.
Get
Derivative
(
1.0
,
tmp
);
expr
.
Get
Jacobian
(
1.0
,
tmp
);
entries
.
Swap
(
tmp
);
}
return
*
this
;
...
...
@@ -391,7 +396,7 @@ namespace INMOST
else
{
Sparse
::
Row
tmp
(
entries
);
expr
.
Get
Derivative
(
-
1.0
,
tmp
);
expr
.
Get
Jacobian
(
-
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
.
Get
Derivative
(
lval
,
tmp
);
expr
.
Get
Jacobian
(
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
.
Get
Derivative
(
-
value
*
reciprocial_rval
,
tmp
);
expr
.
Get
Jacobian
(
-
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
,
r
);
arg
.
Get
Jacobian
(
mult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
-
mult
,
r
);
arg
.
Get
Jacobian
(
-
mult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
-
mult
,
r
);
arg
.
Get
Jacobian
(
-
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
-
mult
*
value
*
reciprocial_val
,
r
);
arg
.
Get
Jacobian
(
-
mult
*
value
*
reciprocial_val
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
-
mult
*
value
*
reciprocial_val
,
r
);
arg
.
Get
Jacobian
(
-
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
-
mult
,
r
);
arg
.
Get
Jacobian
(
-
mult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
-
mult
,
r
);
arg
.
Get
Jacobian
(
-
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
value
,
r
);
arg
.
Get
Jacobian
(
mult
*
value
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
value
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
0.5
*
mult
/
value
,
r
);
arg
.
Get
Jacobian
(
0.5
*
mult
/
value
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
0.5
*
mult
/
value
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
mult
*
dmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
arg
.
Get
Derivative
(
mult
*
dmult
,
r
);
arg
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
left
.
Get
Derivative
(
mult
*
ldmult
,
r
);
right
.
Get
Derivative
(
mult
*
rdmult
,
r
);
left
.
Get
Jacobian
(
mult
*
ldmult
,
r
);
right
.
Get
Jacobian
(
mult
*
rdmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
left
.
Get
Derivative
(
mult
*
ldmult
,
r
);
right
.
Get
Derivative
(
mult
*
rdmult
,
r
);
left
.
Get
Jacobian
(
mult
*
ldmult
,
r
);
right
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
left
.
Get
Derivative
(
mult
*
ldmult
,
r
);
right
.
Get
Derivative
(
mult
*
rdmult
,
r
);
left
.
Get
Jacobian
(
mult
*
ldmult
,
r
);
right
.
Get
Jacobian
(
mult
*
rdmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
left
.
Get
Derivative
(
mult
*
ldmult
,
r
);
right
.
Get
Derivative
(
mult
*
rdmult
,
r
);
left
.
Get
Jacobian
(
mult
*
ldmult
,
r
);
right
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
left
.
Get
Derivative
(
mult
*
ldmult
,
r
);
right
.
Get
Derivative
(
mult
*
rdmult
,
r
);
left
.
Get
Jacobian
(
mult
*
ldmult
,
r
);
right
.
Get
Jacobian
(
mult
*
rdmult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
left
.
Get
Derivative
(
mult
*
ldmult
,
r
);
right
.
Get
Derivative
(
mult
*
rdmult
,
r
);
left
.
Get
Jacobian
(
mult
*
ldmult
,
r
);
right
.
Get
Jacobian
(
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
left
.
Get
Derivative
(
mult
*
reciprocal_rval
,
r
);
right
.
Get
Derivative
(
-
mult
*
value
*
reciprocal_rval
,
r
);
left
.
Get
Jacobian
(
mult
*
reciprocal_rval
,
r
);
right
.
Get
Jacobian
(
-
mult
*
value
*
reciprocal_rval
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
left
.
Get
Derivative
(
mult
*
reciprocal_rval
,
r
);
right
.
Get
Derivative
(
-
mult
*
value
*
reciprocal_rval
,
r
);
left
.
Get
Jacobian
(
mult
*
reciprocal_rval
,
r
);
right
.
Get
Jacobian
(
-
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
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
RowMerger
&
r
)
const
{
left
.
Get
Derivative
(
mult
,
r
);
right
.
Get
Derivative
(
mult
,
r
);
left
.
Get
Jacobian
(
mult
,
r
);
right
.
Get
Jacobian
(
mult
,
r
);
}
__INLINE
void
Get
Derivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
__INLINE
void
Get
Jacobian
(
INMOST_DATA_REAL_TYPE
mult