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
423cb723
Commit
423cb723
authored
Feb 15, 2018
by
Kirill Terekhov
Browse files
Some fixes for autodiff with delayed evaluation for the case when vector of variations is NULL
parent
929113d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/Headers/inmost_expression.h
View file @
423cb723
...
...
@@ -602,26 +602,35 @@ namespace INMOST
/// Retrive derivatives with multiplier into Sparse::RowMerger structure.
__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
;
if
(
entries
)
{
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
GetJacobian
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
if
(
CheckCurrentAutomatizator
()
)
FromGetJacobian
(
*
this
,
mult
,
r
);
else
if
(
entries
)
{
for
(
Sparse
::
Row
::
iterator
it
=
entries
->
Begin
();
it
!=
entries
->
End
();
++
it
)
r
[
it
->
first
]
+=
it
->
second
*
mult
;
if
(
CheckCurrentAutomatizator
()
)
FromGetJacobian
(
*
this
,
mult
,
r
);
else
{
for
(
Sparse
::
Row
::
iterator
it
=
entries
->
Begin
();
it
!=
entries
->
End
();
++
it
)
r
[
it
->
first
]
+=
it
->
second
*
mult
;
}
}
}
__INLINE
void
GetHessian
(
INMOST_DATA_REAL_TYPE
multJ
,
Sparse
::
Row
&
J
,
INMOST_DATA_REAL_TYPE
multH
,
Sparse
::
HessianRow
&
H
)
const
{
J
=
*
entries
;
if
(
!
J
.
isSorted
()
)
std
::
sort
(
J
.
Begin
(),
J
.
End
());
for
(
Sparse
::
Row
::
iterator
it
=
J
.
Begin
();
it
!=
J
.
End
();
++
it
)
it
->
second
*=
multJ
;
H
.
Clear
();
if
(
entries
)
{
J
=
*
entries
;
if
(
!
J
.
isSorted
()
)
std
::
sort
(
J
.
Begin
(),
J
.
End
());
for
(
Sparse
::
Row
::
iterator
it
=
J
.
Begin
();
it
!=
J
.
End
();
++
it
)
it
->
second
*=
multJ
;
H
.
Clear
();
}
}
__INLINE
multivar_expression_reference
&
operator
=
(
INMOST_DATA_REAL_TYPE
pvalue
)
{
...
...
Source/Headers/inmost_variable.h
View file @
423cb723
...
...
@@ -284,6 +284,29 @@ namespace INMOST
abstract_dynamic_variable
*
Copy
()
const
{
return
static_cast
<
abstract_dynamic_variable
*>
(
new
const_variable
(
*
this
));}
};
class
const_link_variable
:
public
shell_dynamic_variable
<
const_expression
,
const_link_variable
>
{
private:
const
INMOST_DATA_REAL_TYPE
*
value
;
public:
const_link_variable
(
const
INMOST_DATA_REAL_TYPE
*
_value
)
:
value
(
_value
)
{}
const_link_variable
(
const
const_link_variable
&
other
)
:
value
(
other
.
value
)
{}
const_link_variable
&
operator
=
(
const
const_link_variable
&
other
)
{
value
=
other
.
value
;
return
*
this
;
}
INMOST_DATA_REAL_TYPE
Value
(
const
Storage
&
e
)
const
{
return
*
value
;}
multivar_expression
Variable
(
const
Storage
&
e
)
const
{
return
multivar_expression
(
*
value
);
}
const_expression
operator
[](
const
Storage
&
e
)
const
{
return
const_expression
(
*
value
);}
void
GetVariation
(
const
Storage
&
e
,
Sparse
::
Row
&
r
)
const
{
(
*
this
)[
e
].
GetJacobian
(
1.0
,
r
);
}
void
GetVariation
(
const
Storage
&
e
,
Sparse
::
RowMerger
&
r
)
const
{
(
*
this
)[
e
].
GetJacobian
(
1.0
,
r
);
}
abstract_dynamic_variable
*
Copy
()
const
{
return
static_cast
<
abstract_dynamic_variable
*>
(
new
const_link_variable
(
*
this
));}
};
class
static_variable
:
public
shell_dynamic_variable
<
const_expression
,
static_variable
>
{
private:
...
...
@@ -706,6 +729,7 @@ template<class A> __INLINE
}
template
<
class
A
,
class
B
>
__INLINE
INMOST
::
etype_branch_variable
<
A
,
B
>
etype_branch
(
INMOST
::
ElementType
true_type
,
INMOST
::
shell_dynamic_variable
<
typename
A
::
Var
,
A
>
const
&
iftrue
,
INMOST
::
shell_dynamic_variable
<
typename
B
::
Var
,
B
>
const
&
iffalse
)
{
return
INMOST
::
etype_branch_variable
<
A
,
B
>
(
true_type
,
iftrue
,
iffalse
);}
template
<
class
A
,
class
B
>
__INLINE
INMOST
::
marker_branch_variable
<
A
,
B
>
marker_branch
(
INMOST
::
MarkerType
marker
,
INMOST
::
shell_dynamic_variable
<
typename
A
::
Var
,
A
>
const
&
iftrue
,
INMOST
::
shell_dynamic_variable
<
typename
B
::
Var
,
B
>
const
&
iffalse
)
{
return
INMOST
::
marker_branch_variable
<
A
,
B
>
(
marker
,
iftrue
,
iffalse
);}
__INLINE
INMOST
::
const_link_variable
extval
(
const
INMOST_DATA_REAL_TYPE
&
pvar
)
{
return
INMOST
::
const_link_variable
(
&
pvar
);}
#endif //defined(USE_AUTODIFF) && defined(USE_MESH)
...
...
Source/Solver/solver_inner/solver_bcgsl.hpp
View file @
423cb723
...
...
@@ -15,7 +15,7 @@
//#define USE_LAPACK_SVD // use lapack's dgesvd routine instead of built-in svdnxn
//#if !defined(NDEBUG)
#define REPORT_RESIDUAL
//
#define REPORT_RESIDUAL
//#endif
//#define USE_OMP
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment