Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Francesco Brarda
stan-math-petsc
Commits
2dece4d9
Commit
2dece4d9
authored
8 years ago
by
Sean Talts
Browse files
Options
Download
Email Patches
Plain Diff
Fix mixed multivariate operands_and_partials
parent
fcbcbb81
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
stan/math/fwd/mat/meta/operands_and_partials.hpp
+5
-4
stan/math/fwd/mat/meta/operands_and_partials.hpp
test/unit/math/mix/mat/meta/operands_and_partials_test.cpp
+1
-2
test/unit/math/mix/mat/meta/operands_and_partials_test.cpp
with
6 additions
and
6 deletions
+6
-6
stan/math/fwd/mat/meta/operands_and_partials.hpp
View file @
2dece4d9
...
...
@@ -58,12 +58,13 @@ namespace stan {
Dx
derivative
(
0
);
for
(
size_t
i
=
0
;
i
<
this
->
operands_
.
size
();
++
i
)
{
for
(
int
j
=
0
;
j
<
this
->
operands_
[
i
].
size
();
++
j
)
{
derivative
+=
this
->
partials_vec_
[
i
](
j
)
*
this
->
operands_
[
i
](
j
);
derivative
+=
this
->
partials_vec_
[
i
](
j
)
*
this
->
operands_
[
i
](
j
)
.
d_
;
}
}
return
derivative
;
}
};
}
}
}
}
// namespace detail
}
// namespace math
}
// namespace stan
#endif
This diff is collapsed.
Click to expand it.
test/unit/math/mix/mat/meta/operands_and_partials_test.cpp
View file @
2dece4d9
...
...
@@ -66,7 +66,6 @@ TEST(AgradPartialsVari, OperandsAndPartialsMultiMix) {
scalar
(
val_dxs
[
2
],
0.0
),
scalar
(
val_dxs
[
3
],
0.0
);
uni_mat
m2
(
2
,
2
);
// Set d_ to 1 for one variable we care about;
m1
<<
scalar
(
val_dxs
[
3
],
1.0
),
scalar
(
val_dxs
[
2
],
0.0
),
scalar
(
val_dxs
[
1
],
0.0
),
scalar
(
val_dxs
[
0
],
0.0
);
...
...
@@ -100,7 +99,7 @@ TEST(AgradPartialsVari, OperandsAndPartialsMultiMix) {
EXPECT_FLOAT_EQ
(
0.0
,
grad_grad
[
1
]);
EXPECT_FLOAT_EQ
(
0.0
,
grad_grad
[
2
]);
EXPECT_FLOAT_EQ
(
0.0
,
grad_grad
[
3
]);
EXPECT_FLOAT_EQ
(
1
.0
,
grad_grad
[
4
]);
EXPECT_FLOAT_EQ
(
0
.0
,
grad_grad
[
4
]);
EXPECT_FLOAT_EQ
(
0.0
,
grad_grad
[
5
]);
EXPECT_FLOAT_EQ
(
0.0
,
grad_grad
[
6
]);
EXPECT_FLOAT_EQ
(
0.0
,
grad_grad
[
7
]);
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help