Skip to content

Conversation

smichr
Copy link
Member

@smichr smichr commented Sep 16, 2023

References to other Issues or PRs

#25661 related

Brief description of what is fixed or changed

Other comments

see issue page and the questions I raise there

Release Notes

  • matrices
    • A.rref_rhs(b) will return rref of A and resulting form of b without reducing b; pivots are returned as 3rd arg

@sympy-bot
Copy link

sympy-bot commented Sep 16, 2023

Hi, I am the SymPy bot. I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • matrices
    • A.rref_rhs(b) will return rref of A and resulting form of b without reducing b; pivots are returned as 3rd arg (#25687 by @smichr)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.13.

Click here to see the pull request description that was parsed.
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->

#25661 related

#### Brief description of what is fixed or changed


#### Other comments

see issue page and the questions I raise there

#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers. Formerly, `log(-x)` incorrectly gave `-log(x)`.

* physics.units
  * Corrected a semantical error in the conversion between volt and statvolt which
    reported the volt as being larger than the statvolt.

or if no release note(s) should be included use:

NO ENTRY

See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
information on how to write release notes. The bot will check your release
notes automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* matrices
  * `A.rref_rhs(b)` will return rref of A and resulting form of b without reducing b; pivots are returned as 3rd arg
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@github-actions
Copy link

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

| Change   | Before [8059df73] <sympy-1.12^0>   | After [781442f7]    |   Ratio | Benchmark (Parameter)                                                |
|----------|------------------------------------|---------------------|---------|----------------------------------------------------------------------|
| -        | 85.6±1ms                           | 56.9±0.2ms          |    0.67 | integrate.TimeIntegrationRisch02.time_doit(10)                       |
| -        | 85.8±1ms                           | 55.7±0.2ms          |    0.65 | integrate.TimeIntegrationRisch02.time_doit_risch(10)                 |
| +        | 22.6±0.07μs                        | 39.0±0.09μs         |    1.73 | integrate.TimeIntegrationRisch03.time_doit(1)                        |
| -        | 6.97±0.01ms                        | 3.74±0.01ms         |    0.54 | logic.LogicSuite.time_load_file                                      |
| -        | 4.25±1ms                           | 2.25±0ms            |    0.53 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(2, 'dense')            |
| -        | 2.11±0.01ms                        | 660±2μs             |    0.31 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse')          |
| -        | 10.3±0.02ms                        | 1.96±0.01ms         |    0.19 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse')          |
| -        | 367±0.8μs                          | 81.9±0.1μs          |    0.22 | polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse')             |
| -        | 4.84±0.01ms                        | 364±0.8μs           |    0.08 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse')             |
| -        | 10.6±0.02ms                        | 1.10±0ms            |    0.1  | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse')             |
| -        | 6.23±0.02ms                        | 3.95±0.01ms         |    0.63 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse') |
| -        | 27.1±0.05ms                        | 12.1±0.02ms         |    0.44 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| -        | 6.95±0.02ms                        | 1.18±0ms            |    0.17 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse')    |
| -        | 16.2±0.02ms                        | 9.22±0.02ms         |    0.57 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse')    |
| -        | 211±0.3ms                          | 70.7±0.2ms          |    0.33 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse')    |
| -        | 6.38±0.01ms                        | 535±1μs             |    0.08 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse')     |
| -        | 27.7±0.05ms                        | 857±2μs             |    0.03 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse')     |
| -        | 613±2μs                            | 199±1μs             |    0.32 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse') |
| -        | 6.48±0.01ms                        | 201±0.9μs           |    0.03 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse') |
| -        | 17.1±0.04ms                        | 205±0.9μs           |    0.01 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse') |
| -        | 164±0.1μs                          | 89.0±0.2μs          |    0.54 | solve.TimeMatrixOperations.time_rref(3, 0)                           |
| -        | 316±0.4μs                          | 107±0.7μs           |    0.34 | solve.TimeMatrixOperations.time_rref(4, 0)                           |
| -        | 31.6±0.06ms                        | 13.5±0.03ms         |    0.43 | solve.TimeSolveLinSys189x49.time_solve_lin_sys                       |

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@oscarbenjamin
Copy link
Collaborator

What about having a separate function like rref_aug or rref_rhs or something?

@sylee957
Copy link
Member

I wanted to vote about the idea to have separate function, especially if the structure of return is dependent on some parameters.

@smichr smichr marked this pull request as ready for review September 17, 2023 00:09
@donnaaboise
Copy link

Thanks for SymPy developers for looking into this!

I haven't actually tested the PR, but do have the following questions/comments :

  • Does this PR handle the case that @smichr pointed out? That is, the case in the pivot rows are not the first r=A.rank() rows? A fix would be to allow row exchanges. It seems that A.rref() already does row exchanges and can handle, for example, Matrix([[0,0],[0,1]]). Can this PR get at the row permutations needed? (my original approach failed with this matrix).

@smichr
Copy link
Member Author

smichr commented Sep 17, 2023

Thanks for SymPy developers for looking into this!

I haven't actually tested the PR, but do have the following questions/comments :

  • Does this PR handle the case that @smichr pointed out? That is, the case in the pivot rows are not the first r=A.rank() rows? A fix would be to allow row exchanges. It seems that A.rref() already does row exchanges and can handle, for example, Matrix([[0,0],[0,1]]). Can this PR get at the row permutations needed? (my original approach failed with this matrix).

Yes, this case is handled and the rank calculation is omitted. @sylee957 pointed out that simply satcking a full identity matrix is a more robust aproach.

@sylee957 sylee957 merged commit 29c5514 into sympy:master Sep 17, 2023
Comment on lines +324 to +330
rhs : Matrix
If ``rhs`` is passed it must have the same number of rows as ``M``.
Reduction steps will not take place in this matrix, but
the elements will be included in the reduction steps. If a single
column matrix of symbols is passed, the expressions in each
row at the end of the reduction will indicate how rows were
combined to perform the reduction.
Copy link
Member

@sylee957 sylee957 Sep 17, 2023

Choose a reason for hiding this comment

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

Unfortunately, I missed this point that this should move to the documentation in rref_rhs. This option should not be carried by rref.__doc__ = _rref.__doc__

Copy link
Member Author

Choose a reason for hiding this comment

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

I will make new pr. Sorry I missed that.

@smichr smichr deleted the rref branch September 17, 2023 21:58
@oscarbenjamin
Copy link
Collaborator

Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants