-
Notifications
You must be signed in to change notification settings - Fork 176
MatrixObj: MultRowVector #1685
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
MatrixObj: MultRowVector #1685
Conversation
Codecov Report
@@ Coverage Diff @@
## MatrixObj2 #1685 +/- ##
==============================================
+ Coverage 64.46% 64.46% +<.01%
==============================================
Files 1002 1002
Lines 326543 326564 +21
Branches 13218 13220 +2
==============================================
+ Hits 210505 210528 +23
+ Misses 113167 113162 -5
- Partials 2871 2874 +3
|
|
0854fd9 to
9621032
Compare
lib/listcoef.gd
Outdated
| ## | ||
| ## <#GAPDoc Label="MultRowVector"> | ||
| ## <#GAPDoc Label="MultRowVectorLeft"> | ||
| ## <#GAPDoc Label="MultRowVectorRight"> |
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.
Why are these called MultRowVectorLeft/Right? In the new scheme, they should be MultVectorLeft/Right, no?
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.
Last week, you mentioned wanting to rename them in a second step later on, but I don't understand why -- why would we introduce a new name, only to then rename it immediately after?
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.
Also note that the above is invalid syntax, and cause make doc to fail.
lib/listcoef.gd
Outdated
| ## <C>MultRowVectorLeft</C>. | ||
| ## </P> | ||
| ## These operations multiply <A>list1</A> with <A>mul</A> in-place and write | ||
| ## the result to <A>list1</A>. |
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.
"... [modify] list1 ... in-place and write the result to list1" seems a bit redundant... I'd stop after "in-place". Or, if you really want to elaborate on that, perhaps: "... in-place, i.e., the result overwrites list1" or so -- here, the "i.e." makes clear the following is just a clarification of what came before.
lib/listcoef.gd
Outdated
| ## <ManSection> | ||
| ## <Oper Name="MultRowVector" Arg='list1, [poss1, list2, poss2, ]mul'/> | ||
| ## <Oper Name="MultRowVectorLeft" Arg='list1, [poss1, list2, poss2, ]mul'/> | ||
| ## <Oper Name="MultRowVectorRight" Arg='list1, [poss1, list2, poss2, ]mul'/> |
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.
You write later on that the 5-arg version will be removed. So, why document it here?
OK, I could understand if you want to document it for MultRowVector, for the sake of people who may have used the 5-arg version and want to find out what happened / is going to happen to it.
But in that case, I'd rather split this documentation: Write one mansection which just discusses MultVectorLeft/Right. In it, only list and document the 2-arg versions.
Then, have a separate man section for MultRowVector, which just says that its 2-arg version is just a synonym of MultVectorLeft, and that the 5-arg version is obsolete, should not be used, and is only there for backwards compatibility.
Bonus points for moving MultRowVector into lib/obsolete.{gi,gd}.
lib/listcoef.gd
Outdated
| ## <Description> | ||
| ## The five argument version of this operation replaces | ||
| ## Note that <C>MultRowVector</C> is only a Synonym for | ||
| ## <C>MultRowVectorLeft</C>. |
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.
"only" -> "just", "Synonym" -> "synonym"
It also seems weird to start with this side remark. I'd move this sentence to a later spot, say right after MultRowVectorLeft has been declared.
lib/listcoef.gd
Outdated
| ## <C>MultRowVectorLeft</C> multiplies <A>mul</A> to <A>list1</A> from the | ||
| ## left. <C>MultRowVectorRight</C> does so from the right. | ||
| ## The two-argument version simply multiplies each element of <A>list1</A>, | ||
| ## in-place, by <A>mul</A> from the left. |
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 was about to write "simply", but upon closer inspection, I'll rather say: Just drop that sentence, it is redundant.
lib/listcoef.gi
Outdated
| #M MultRowVectorLeft( <list1>, <poss1>, <list2>, <poss2>, <mult> ) | ||
| ## | ||
| InstallMethod( MultRowVector,"generic method", | ||
| InstallMethod( MultRowVectorLeft, "generic method", |
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 should be (in my proposed new scheme):
InstallOtherMethod( MultRowVector, "obsolete five argument method",
lib/listcoef.gi
Outdated
| end ); | ||
|
|
||
| InstallOtherMethod( MultRowVector,"error if immutable",true, | ||
| InstallOtherMethod( MultRowVectorLeft, "error if immutable", true, |
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.
revert this line back
lib/listcoef.gi
Outdated
| InstallOtherMethod( MultRowVector, | ||
| "Two argument kernel method for small list", | ||
| InstallMethod( MultRowVectorLeft, | ||
| "Two argument kernel method for small list", |
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.
"Two" -> "two"
But actually, more idiomatic would be to write "for a mutable dense small list and a multiplicative element" -- and this of course also applies to other InstallMethod calls you are adding or modifying.
lib/listcoef.gi
Outdated
| [ IsSmallList and IsDenseList and IsMutable and IsPlistRep and | ||
| IsCyclotomicCollection, | ||
| [ IsSmallList and IsDenseList and IsMutable and IsPlistRep and | ||
| IsCyclotomicCollection, |
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.
IsPlistRep implies IsSmallList so you can get rid of that.
lib/matobj2.gd
Outdated
| ############################################################################ | ||
|
|
||
|
|
||
| # The following are guaranteed to be always set or cheaply calculable: |
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.
Remove that line? Or at least put an empty line between it and the new comment below.
|
This PR also mixes several things together: namely you remove When doing that, you can also squash the first commit ("typos") with the one that removes Finally, the commit "MatrixObj: Remove test diffs due to ws/line breaks" could just be pushed directly to MatrixObj2 |
|
Thanks for the review! I just split some commits into different PRs as you suggested. I'll try to get to the requested changes and clean up this PR tomorrow. |
15444db to
dbc9466
Compare
|
Ah, I'll rename the *RowVector -> *Vector too |
|
This passes |
|
I additionally changed:
|
lib/matobj2.gd
Outdated
|
|
||
| # maybe have this: vec := vec{[from..to]} * scal ?? cvec has it | ||
| # TODO: rename MultVector to MultVector; but keep in mind that | ||
| # historically there already was MultVector, so be careful to not break that |
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.
That TODO is outdated (and now impossible to understand)
lib/listcoef.gd
Outdated
| ## The two-argument version simply multiplies each element of <A>list1</A>, | ||
| ## in-place, by <A>mul</A>. | ||
| ## Note that <C>MultVectorLeft</C> is just a synonym for | ||
| ## <C>MultVector</C>. |
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.
Hmmm... perhaps it should be the other way around? What's the motivation for doing it this way?
In the end, it's not that important, of course; but for reasons of symmetry, I'd find it more natural if the left/right names were the "regular" ones, and the one without a convenience alias.
| #M MultVectorLeft( <list>, <mul> ) | ||
| ## | ||
| InstallMethod( MultRowVector,"generic method", | ||
| InstallMethod( MultVectorLeft, |
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.
If MultVectorLeft is just a synonym, it would be more natural to install the method for MultVector here...
lib/listcoef.gi
Outdated
| IsDenseList, | ||
| IsDenseList, | ||
| IsMultiplicativeElement ], | ||
| 0, |
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.
While you are at it, you might just as well remove the true and 0 here, as they are superfluous.
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.
Same for the other InstallMethod calls you change
lib/matobj2.gd
Outdated
| ## <Returns>nothing</Returns> | ||
| ## | ||
| ## <Description> | ||
| ## Note that <C>MultVector</C> is only a Synonym for |
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.
"Synonym" -> "synonym"
| DeclareOperation( "MultVectorRight", | ||
| [ IsVectorObj and IsMutable, IsMultiplicativeElement, IsInt, IsInt ] ); | ||
| # Note that MultVector is declared a Synonym for MultVectorLeft in | ||
| # listcoef.gd |
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.
fix "Synonym"
| ## <Oper Name="MultRowVector" Arg='list1, [poss1, list2, poss2, ]mul'/> | ||
| ## <Returns>nothing</Returns> | ||
| ## | ||
| ## <Description> |
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 text should make it explicit that new code should not use MultRowVector anymore. So perhaps replace "is just a synonym" by "is an obsolete synonym", and add at the end "New code should use MultVectorLeft instead." or so
Moreover, this documentation section is (I think) still being included by doc/ref/vector.xml -- can you move it to doc/ref/obsolete.xml ?
| prd = PROD(prd,mult); | ||
| ASS_LIST(list,i,prd); | ||
| CHANGED_BAG(list); | ||
| } |
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.
Do you have clang-format installed? If so, please consider using git clang-format on your commits to reformat the modified code.
But don't worry about this if you don't have clang-format.
tst/test-matobj/MultRowVector.tst
Outdated
| gap> MultRowVector(v, -1); | ||
| gap> Unpack(v); | ||
| [ Z(5)^2, Z(5)^3, Z(5), Z(5), 0*Z(5), Z(5)^0 ] | ||
| gap> MultRowVector(v, Z(5)^3, 3, 4); |
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.
Why does this still use MultRowVector ?
tst/test-matobj/MultRowVector.tst
Outdated
| <algebra-with-one of dimension 4 over Rationals> | ||
| gap> q := NewVector( IsPlistVectorRep, Q, [One(Q), Zero(Q), Q.2, Q.3] ); | ||
| <plist vector over AlgebraWithOne( Rationals, [ e, i, j, k ] ) of length 4> | ||
| gap> MultRowVectorRight(q, Q.2); |
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.
Seems the test file was not updated to match the name change?
|
@ssiccha any plans tomupdate this? |
|
@fingolfin yep, I'll try to update it until next week. The last weeks were pretty busy. |
- Split MultRowVector to MultRowVectorLeft / MultRowVectorRight.
- MultRowVector is declared a synonym for MultRowVectorLeft.
- MultRowVectorOp is renamed to MultRowVectorLeftOp on the C level.
- Add four argument declarations for MultRowVectorLeft( vec, mul, from, to )
and ..Right
- Remove the five argument version of MultRowVector in MatrixObj.
Deprecate it also in the library. This version was not used anywhere in
the library or packages
- Add generic and plist implementations of MultRowVector where necessary
- Implement and declare ..Left and ..Right versions in matrixobj*
- Only do the ..Left version in listcoef.g?. The methods from listcoef.gi
are only used for integers and FFEs in the library.
Adding the ..Right versions would only introduce lots of unused code.
People wanting to use the ..Right versions should use vector objs.
- Have a kernel function MULT_ROW_VECTOR_LEFT_RIGHT_2 which is called by
MULT_ROW_VECTOR_LEFT_2 and ..RIGHT_2
- Add tests for MultRowVector
0f60c85 to
f5a5bae
Compare
|
@fingolfin I think it should be done now. All changes are in the "WIP" commit because I think that makes it easier to review. I will squash it into the previous commit later. |
|
Oops, I forgot the |
|
@fingolfin OK, I hope it should be done now. I should probably have a look at which lines are covered by the tests. |
Performs the following sed commands in the directories
`lib/`, `src/`, `hpcgap/`. Then undo the changes in
the `obsolete.{gd,gi}` files.
sed -i 's/MULT_ROW_VECTOR/MULT_VECTOR/g' `find . -type f`
sed -i 's/MULT_ROWVECTOR/MULT_VECTOR/g' `find . -type f`
sed -i 's/MultRowVector/MultVector/g' `find . -type f`
git checkout -- obsolete.{gd,gi}
Also perform:
sed -i 's/MultRowVector/MultVector/g' doc/ref/vector.xml
Uh oh!
There was an error while loading. Please reload this page.