Skip to content

Conversation

@ssiccha
Copy link
Contributor

@ssiccha ssiccha commented Sep 7, 2017

  • Adjust some test files.
  • Get rid of IsCheckingVector for IsPlistVectorRep and same for matrices
  • Add some GAPDoc documentation
  • Implementation and Tests for MultRowVector

@codecov
Copy link

codecov bot commented Sep 7, 2017

Codecov Report

Merging #1685 into MatrixObj2 will increase coverage by <.01%.
The diff coverage is 48.1%.

@@              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
Impacted Files Coverage Δ
lib/obsolete.gd 28.35% <ø> (ø) ⬆️
lib/listcoef.gi 52.91% <ø> (+0.08%) ⬆️
lib/vec8bit.gi 48.14% <ø> (ø) ⬆️
hpcgap/lib/vec8bit.gi 46.87% <ø> (ø) ⬆️
hpcgap/lib/vecmat.gi 65.28% <0%> (ø) ⬆️
lib/obsolete.gi 0% <0%> (ø) ⬆️
lib/matobj.gi 8.67% <0%> (-0.46%) ⬇️
lib/matobjplist.gi 0% <0%> (ø) ⬆️
lib/grpffmat.gi 91.34% <0%> (ø) ⬆️
lib/vecmat.gi 67.32% <0%> (ø) ⬆️
... and 27 more

@frankluebeck
Copy link
Member

  • We want to remove commands XXXRowVectorYYY, just use Vector instead of RowVector.

  • Furthermore, for general semirings as coefficients, we need to distinguish scalar multiplication from the left and from the right.

  • E.g.,

    • introduce and document MultVectorLeft(vec, c) and MultVectorRight(vec, c) with the obvious meaning;
    • define and document MultVector as synonym for MultVectorLeft;
    • for backward compatibility define MultRowVector as further synonym for MultVectorLeft (either silently without documentation, or document this in an "obsolete functions" section).
  • Similarly, introduce AddVectorLeft, AddVectorRight and synonyms AddVector and for compatibility AddRowVector.

@ssiccha ssiccha changed the title MatrixObj2 Some documentation and implementations for MatrixObj2 Sep 7, 2017
@ssiccha ssiccha force-pushed the MatrixObj2 branch 8 times, most recently from 0854fd9 to 9621032 Compare September 8, 2017 12:19
@olexandr-konovalov olexandr-konovalov added the gapdays2017-fall Issues and PRs that arose at https://www.gapdays.de/gapdays2017-fall label Sep 9, 2017
lib/listcoef.gd Outdated
##
## <#GAPDoc Label="MultRowVector">
## <#GAPDoc Label="MultRowVectorLeft">
## <#GAPDoc Label="MultRowVectorRight">
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member

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>.
Copy link
Member

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'/>
Copy link
Member

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>.
Copy link
Member

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.
Copy link
Member

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",
Copy link
Member

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,
Copy link
Member

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",
Copy link
Member

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,
Copy link
Member

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:
Copy link
Member

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.

@fingolfin
Copy link
Member

This PR also mixes several things together: namely you remove IsCheckingMatrix etc., and deal with Mult(Row)Vector. This way, reviewers have to always look at both, and issues with one hold up the merge of the other.
I therefore recommend splitting this PR into two: Leave the MultRowVector stuff on this PR, but remove the IsCheckingMatrix changes from it into a new PR (git rebase -i can help with that; if you are not familiar with it, just ask on slack).

When doing that, you can also squash the first commit ("typos") with the one that removes IsCheckingMatrix (both "typos" are in functions which are removed later on anyway).

Finally, the commit "MatrixObj: Remove test diffs due to ws/line breaks" could just be pushed directly to MatrixObj2

@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 12, 2017

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.

@ssiccha ssiccha force-pushed the MatrixObj2 branch 2 times, most recently from 15444db to dbc9466 Compare September 13, 2017 11:50
@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 13, 2017

Ah, I'll rename the *RowVector -> *Vector too

@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 13, 2017

This passes make testinstall if PR #1718 gets merged. I'll have to somehow rerun the tests then.

@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 13, 2017

I additionally changed:

  • Make MultVectorLeft a synonym for MultVector. Then people who are only interested in commutative rings shouldn't get any MultVectorLeft things anywhere.
  • Have a kernel function MULT_ROW_VECTOR_LEFT_RIGHT_2 which is called by
    MULT_ROW_VECTOR_LEFT_2 and ..RIGHT_2
  • 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, I think. People wanting to use the ..Right versions then should use vector objs.

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
Copy link
Member

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>.
Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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
Copy link
Member

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>
Copy link
Member

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);
}
Copy link
Member

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.

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);
Copy link
Member

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 ?

<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);
Copy link
Member

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 ssiccha changed the title Some documentation and implementations for MatrixObj2 MatrixObj: MultRowVector Sep 15, 2017
@fingolfin
Copy link
Member

@ssiccha any plans tomupdate this?

@fingolfin fingolfin added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements kind: new feature labels Sep 28, 2017
@fingolfin fingolfin added this to the GAP 4.9.0 milestone Sep 28, 2017
@ssiccha
Copy link
Contributor Author

ssiccha commented Oct 7, 2017

@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
@ssiccha ssiccha force-pushed the MatrixObj2 branch 3 times, most recently from 0f60c85 to f5a5bae Compare October 7, 2017 19:36
@ssiccha
Copy link
Contributor Author

ssiccha commented Oct 7, 2017

@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.

@ssiccha
Copy link
Contributor Author

ssiccha commented Oct 9, 2017

Oops, I forgot the hpcgap directory. Will update that hopefully tomorrow

@ssiccha
Copy link
Contributor Author

ssiccha commented Oct 19, 2017

@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
@fingolfin fingolfin merged commit a0b1e68 into gap-system:MatrixObj2 Oct 24, 2017
@ssiccha ssiccha deleted the MatrixObj2 branch March 14, 2020 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gapdays2017-fall Issues and PRs that arose at https://www.gapdays.de/gapdays2017-fall kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements kind: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants