-
-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add vector construction utilities #1620
Add vector construction utilities #1620
Conversation
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
I'll review this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nicely documented and tested overall. I requested a bunch of simple changes on documenting exceptions and testing boundary conditions. The only real substantive change is that creating a simplex of size 0 should throw an exception and explaining what happens to linearly spaced with K = 0 and K = 1.
Thanks Bob! I've addressed almost everything, I've answered you for things I was not sure. As suggested I replaced most tests with loops, even if they used the same functions used in the headers being tested, but I left the tests for I've also changed the check in |
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: |
For K=0, the vector will be empty, for K=1 it returns high, which is what Eigen does. I'll add this to docs and tests.
Thanks! I had no idea what it did.
|
Summary
This adds the following function signatures (well the underlying code to implement them):
vector constant_vector(int K, real c)
vector one_hot_vector(int K, int k)
vector ones_vector(int K)
vector set_spaced_vector(int K, real low, real high)
vector uniform_simplex(int K)
vector zeros_vector(int K)
matrix identity_matrix(int K)
This departs slightly from the signatures mentioned in #692 for
constant_vector
,one_hot_vector
andset_spaced_vector
, in thatK
is always the first parameter, which is also what Eigen uses.Tests
Added.
Side Effects
None.
Checklist
Math issue Container construction utilities #692
Copyright holder: Marco Colombo
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 doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested