-
Notifications
You must be signed in to change notification settings - Fork 92
Define dimension for AbstractScalarSet, add some tests. #342
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #342 +/- ##
==========================================
+ Coverage 94.6% 96.42% +1.81%
==========================================
Files 34 35 +1
Lines 4673 4725 +52
==========================================
+ Hits 4421 4556 +135
+ Misses 252 169 -83
Continue to review full report at Codecov.
|
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 reminds me of matlab's treatment of scalars (i.e., as 1x1 matrices) so it's a bit unsettling, but I don't have a more substantial objection than that so, ok with me.
src/sets.jl
Outdated
""" | ||
dimension(s::AbstractSet) | ||
|
||
Return the underlying dimension (number of vector components) in the set `s`, i.e., |
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.
"number of vector components" doesn't quite make sense anymore. Please clarify the definition.
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.
Hmm, yeah, what should it be?
Typically, mathematical definitions of dimension refer to an intrinsic property of a space (e.g. a vector space). Dimension isn't defined for arbitrary sets. In addition, for AbstractSet
there are cases like PositiveSemidefiniteConeTriangle
and PositiveSemidefiniteConeSquare
where the number we want to return is not the dimension of the vector space to which a given member of the set belongs: same mathematical object (a member of $S^n_+$
), two different dimensions.
So I guess concrete AbstractSet
subtypes implicitly define some particular vector space that is used to parameterize members of the set and the AbstractSet
's dimension
is the dimension of that vector space. (Note by the way that the real line is in fact a vector space, and as such it has a well-defined dimension.)
So how about:
The dimension of the vector space used to parameterize members of
s
.
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.
Alternatively, it is equal to the dimension that an AbstractFunction
should have to be used with the set. Then the dimension of an AbstractFunction
is 1 for scalar function and the number of rows for a vector function.
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.
Whichever you want, just let me know and I'll change it.
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.
I think the link with the function is simpler, the vector space might be ambiguous for cases like PSDCTriangle
src/sets.jl
Outdated
@@ -184,7 +188,7 @@ dimension(s::Union{ExponentialCone, DualExponentialCone, PowerCone, DualPowerCon | |||
|
|||
The (vectorized) cone of symmetric positive semidefinite matrices, with side length `dimension` and with off-diagonals unscaled. | |||
The entries of the upper triangular part of the matrix are given column by column (or equivalently, the entries of the lower triangular part are given row by row). | |||
An ``dimension \\times dimension`` matrix has ``dimension(dimension+1)/2`` lower-triangular elements, so for the vectorized cone of dimension ``n``, the corresponding symmetric matrix has side dimension ``\\sqrt{1/4 + 2 n} - 1/2`` elements. | |||
An ``dimension \\times dimension`` matrix has ``dimension * (dimension+1)/2`` lower-triangular elements, so for the vectorized cone of dimension ``n``, the corresponding symmetric matrix has side dimension ``\\sqrt{1/4 + 2 n} - 1/2`` elements. |
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.
As we use double backquote, we are in LaTeX mode. In LaTeX, I prefer \cdot
or \times
or nothing over *
. Here \times
would be ambiguous with matrix dimensions so \cdot
seems more appropriate
Updated the docstring. |
No description provided.