Skip to content
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

Merge some MatrixObj work into master #2640

Merged
merged 16 commits into from
Aug 15, 2018

Conversation

fingolfin
Copy link
Member

@fingolfin fingolfin commented Jul 12, 2018

Last year, we made some progress on MatrixObj. Sadly, we got stalled again. But I think even the partial work we did would already be useful.

I took the MatrixObj2 branch, and looked through it, and cleaned it up a lot. I also dropped (for now, this is only temporary) a few changes that I think are potentially more controversial (such as @ssiccha MultRowVector to MultVector change). Assuming this PR gets merged, I would then prepare a new branch and PR (or possibly multiple) with all the remaining work, which then can either merge, too, or continue to work on.

Some TODOs (?) before merge:

  • the tests in tst/test-matobj can be run via tst/test-matobj.g, but this is not currently hooked up to Travis. Is there any reason why we don't just move these tests into testinstall and/or (for very slow parts) into teststandard?
  • writing a summary of the changes in here for the GAP 4.10 release notes
  • running package tests against this PR, to see if it breaks any of them (maybe @alex-konovalov can help with that?)

@fingolfin fingolfin added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements topic: library labels Jul 12, 2018
@codecov
Copy link

codecov bot commented Jul 13, 2018

Codecov Report

Merging #2640 into master will decrease coverage by 0.01%.
The diff coverage is 54.23%.

@@            Coverage Diff             @@
##           master    #2640      +/-   ##
==========================================
- Coverage   75.48%   75.47%   -0.02%     
==========================================
  Files         478      478              
  Lines      241601   243156    +1555     
==========================================
+ Hits       182382   183524    +1142     
- Misses      59219    59632     +413
Impacted Files Coverage Δ
lib/matblock.gi 88.19% <ø> (ø) ⬆️
hpcgap/lib/vecmat.gi 64.52% <ø> (+0.91%) ⬆️
lib/memory.gi 2.59% <ø> (ø) ⬆️
lib/vecmat.gi 68.55% <ø> (+0.52%) ⬆️
lib/mat8bit.gi 68.31% <ø> (+1.23%) ⬆️
lib/vspcrow.gi 78.82% <100%> (ø) ⬆️
lib/vspcmat.gi 92.47% <100%> (ø) ⬆️
lib/ctblpope.gi 73.85% <100%> (ø) ⬆️
lib/ringsc.gi 71.99% <100%> (ø) ⬆️
lib/zlattice.gi 77.27% <100%> (ø) ⬆️
... and 29 more

@frankluebeck
Copy link
Member

I support to proceed as suggested here. Most changes will not influence existing GAP code and it would be good to start over from a master branch that contains most of the changes from the MatrixObj branch.

Looking through the diffs I did not notice anything problematic. Moving the files from tst/test-matobj to
tst/testinstall seems ok.

Currently, some tests of TraceMat fail. This could be fixed by a method in matobjplist.gi:

InstallMethod( \[\], "for a plist matrix and two positive integers",
  [ IsPlistMatrixRep, IsPosInt, IsPosInt ],
  function( m, r, c )
    return m![ROWSPOS][r][c];
  end );

Or should we also merge the more efficient kernel code that provides this functionality?

@fingolfin
Copy link
Member Author

The failing tests are a very recent regression (the previous build was fine), and I'll fix it. I also already moved the tests into testinstall, and added a few more.

@fingolfin
Copy link
Member Author

Actually, the TraceMat one is already fixed by adding methods for [i,j] resp. [i,j]:=; both for IsPlistMatrixRep, and also generic ones for IsMatrixObj which delegate to MatElm and SetMatElm.

The current test failure is something new, I'll investigate

Copy link
Contributor

@ThomasBreuer ThomasBreuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are fine.

There are just two things which I do not understand:
The file hpcgap/lib/vec8bit.gi gets changed
but there are no changes for lib/vec8bit.gi;
as far as I see, the current code in lib/vec8bit.gi still contains ConvertToVectorRepNC calls
which we want to get rid of.
And what is the reason to replace, in hpcgap/lib/vec8bit.gi,
the one-line statements involving CopyToVectorRep and an arithmetic operation by two statements?

@fingolfin
Copy link
Member Author

There were changes in hpcgap/lib/vec8bit.gi to align it closer to the code in lib/vec8bit.gi, making the actual differences (ConvertToRep vs. CopyRep) stand out more. Anyway, while it is on the old MatrixObj2 branch, it doesn't really fit into this PR, so I dropped it.

@markuspf
Copy link
Member

I enthusiastically support merging this; it's useful code that shouldn't lie around somewhere bitrotting.

I haven't really worked on this code, so I don't have in-depth knowledge of what is added/changed.

I remember that MatrixObjs have been part of GAP for a long time already (and are used in packages), but I see that now they are documented and tested, so we should make extra-sure that (if we put this into 4.10), we're ready to continue supporting this code.

@fingolfin
Copy link
Member Author

This passes all tests now. But it would be good to run the package tests against this, too, as I wrote above, before merging; let's wait to hear from @alex-konovalov on this.

BTW, this PR add methods for m[i,j] and m[i,j]:=x which delegate to the old SetMatElm and MatElm. This is meant to allow people to convert code which uses MatElm and SetMatElm to instead use the new [i,j] syntax instead. But on the long run, I think we should drop MatElm and SetMatElm completely, or at least reverse the "fallback": I.e. in the future, we would have a MatElm default method which falls back to m[i,j]. But to get there, all packages implementing MatrixObj need to provide methods for the new access operations directly. I just added a patch for cvec that will be in the next cvec release. That leaves homalg, which uses MatElm all over the place. Perhaps @mohamed-barakat can start a push to convert it to use [i,j] instead everywhere -- with a regex search and replace, that should be doable with half an hour of work, and only needs GAP 4.9 to work, I think, nothing from this PR (as long as both MatElm/SetMatElm methods and methods for \[\] and \[\]\:\= with two indices are provided).

@olexandr-konovalov
Copy link
Member

@fingolfin hear this - doing tests now.

@fingolfin
Copy link
Member Author

@alex-konovalov any news on this?

@olexandr-konovalov
Copy link
Member

I have checked test logs from July 18th and I don't see diffs in package tests which are different from diffs that I've seen in their tests run with the GAP master branch. Since that was almost a month ago, may be worth to rebase this PR and run another round of tests to be sure.

fingolfin and others added 6 commits August 14, 2018 13:39
These delegate to MatElm resp. SetMatElm, so that old MatrixObj
implementations which only provide these old accessors can be used with the
new m[i,j] syntax.

Ideally, these will be removed again one day in the future, together with
MatElm and SetMatElm.
Note that the cvec package also installs methods for some of these, and should
possibly be adjusted to avoid them

We should also think about replacements. Perhaps there should be
PositionLastNonZeroRow and PositionLastNonZeroColumn methods?

Finally, why is PositionLastNonZero for (row) vectors
in vecmat.gi, which contains code for GF2 vectors and matrices?
Also add ZeroMatrix and IdentityMatrix variants, and add lots of comments.
frankluebeck and others added 10 commits August 14, 2018 13:39
This makes `Vector` the main interface function to create vector objects.
- get rid of IsCheckingVector and IsCheckingMatrix
- update internal doc:
  - NewMatrix now additionally accepts a flat list
  - remove redundant comments
changed most library calls to PositionNot

added attributes OneOfBaseDomain, ZeroOfBaseDomain,
and generic methods for plist vectors and plist matrices
IsCheckingVector and -Matrix do checks like:
- when doing v * s, check whether s in BaseDomain(v) holds. this
  can potentially be very expensive
- check whether accessing or binding to illegal entries
- check whether dimensions of matrices and vectors fit when doing
  AddRowVector etc.

\* for IsPlist*Rep already checks whether dimensions match and
whether the base domains are identical.

Instead some checks could be done (like index out of bounds checks)
on the kernel level.
and dealt with some side-effects:

- changed calls of `MatElm(m,i,j)` to `m[i,j]`
  where `MatElm` methods for plain lists of plain lists
  are missing

- changed those method installations from
  `InstallMethod` to `InstallOtherMethod`
  that currently cause a warning about matching
  multiple declarations;
  in a later step, some of these declarations
  will get merged

- changed calls of `BaseDomain` to calls of
  `OneOfBaseDomain` or `ZeroOfBaseDomain`
  where only the one or zero element are needed

- added comments to `lib/matobj1.gd`
@fingolfin
Copy link
Member Author

Thanks. Rebased now, let's see how the tests fare.

@fingolfin fingolfin added the release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes label Aug 14, 2018
@fingolfin
Copy link
Member Author

@alex-konovalov could you please run another round of extended tests, so that we can ideally merge this ASAP? Thanks!

@olexandr-konovalov
Copy link
Member

@fingolfin I've triggered extended tests yesterday, so I've just checked the outcome. I will be happy to merge this now.

@fingolfin fingolfin merged commit 6177a64 into gap-system:master Aug 15, 2018
@fingolfin fingolfin deleted the mh/MatrixObj-partial branch August 15, 2018 19:09
@fingolfin fingolfin added release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: added PRs introducing changes that have since been mentioned in the release notes topic: library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants