Conversation
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
|
Before we rewrite all of these do we want to wait for the var_value stuff? It feels like if we don't we'll end up rewriting these distributions multiple times |
|
Some functions I have rewritten using Eigen expressions instead of Other functions still use Whatever the reason, these will probably need some changes. I am not sure we can support |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
| using T_partials_return = partials_return_t<T_y, T_loc, T_scale>; | ||
| using T_partials_array = Eigen::Array<T_partials_return, Eigen::Dynamic, 1>; | ||
| using std::log; | ||
| using T_y_ref = ref_type_if_t<!is_constant<T_y>::value, T_y>; |
There was a problem hiding this comment.
What is the logic here? This is the type that will be responsible for .eval() ing the input right?
There was a problem hiding this comment.
Right, we are only evaling this if it is not constant. The reason being is that y_ref seems to be used twice. Once in construction of operands_and_partials and once in creation of y_col. However, prim implementation of operands_and_partials does not actually do anything with the arguemnts. So if y is double it is actually only used once and we don't need to eval it.
There was a problem hiding this comment.
Since it will get used at least once, it would always be safe to eval it though. So we can get rid of the conditional and it'll be the same.
There was a problem hiding this comment.
Yeah it is safe. However I prefere not to for performance reasons. If we avaluate multiple operations in same expression we need to load the data into cache just once. If we evaluate each operation separately we need to load them every time.
There was a problem hiding this comment.
I was looking at ref_type_if_t to see what it did and it looks like it returns a plain_type if it doesn't do a reference type.
That will induce a copy anyway: https://mc-stan.org/math/d2/d08/ref__type_8hpp_source.html
There was a problem hiding this comment.
No, it will not. If T_y is an expression T_optionally_ref will be a reference to the expression type and so will be the result of ref_type_if_t. No eval.
There was a problem hiding this comment.
Oh is the logic for ref_type_if_t is return a reference type if T is an expression or if the condition is true? (as opposed to only checking the condition)?
There was a problem hiding this comment.
The logic is to act as Eigen::Ref if the condition is true or just a regular reference (to expression if that is the argument) if the condition is false. Acting as Eigen::Ref means evaluating expensive expressions and not evaluating trivial ones.
There was a problem hiding this comment.
@bbbales2 I hope this is clear now. Or is it ... ?
There was a problem hiding this comment.
Yeah it's clear. I delayed cause this (and the other lpdf pulls) are major changes to lpdf and I got nervous and wanted at least #1989 to get in.
Until that is in there's at least a couple weaknesses in the testing framework that let bugs through before (though only one of those is with pmfs/pdfs - #1861).
I didn't get around to breaking that pull up Friday.
# Conflicts: # test/expressions/stan_math_sigs_exceptions.expected
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Summary
Generalizes Cauchy distribution related functions to accept general Eigen expressions.
Tests
Tested with expression testing framework.
Side Effects
None
Release notes
Generalized Cauchy distribution related functions to accept general Eigen expressions.
Checklist
Math issue Generalize matrix function signatures #1470
Copyright holder: Tadej Ciglarič
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit)make test-headers)make test-math-dependencies)make doxygen)make cpplint)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested