SolveTools[LinearSolvers]
RationalDenseNullSpace
fast nullspace computation over the field of rational numbers
Calling Sequence
Parameters
Description
Examples
RationalDenseNullSpace(M)
RationalDenseNullSpace(M, skiptest)
M
-
a Matrix of rational numbers
The RationalDenseNullSpace command computes the nullspace of the input Matrix. It does this by computing nullspaces modulo primes (see LinearAlgebra:-Modular:-RowReduce) followed by rational reconstruction (see iratrecon). Bad primes are discarded in the same way as in the modular gcd algorithm. The algorithm is output sensitive: the CPU time depends not only on the size of the input, but also on the output. Specifically, the number of primes that are used depends on the largest entry in the output. If its size is well below the theoretical upper bound, which is usually the case, then the algorithm will be very efficient. By default, it does not return an answer unless a correctness test is passed. If the test does not pass, an additional prime is used to update the answer and the test is run again (and so on, until the test passes).
To ensure that the algorithm returns the correct answer, it checks that M times the output is zero. However, this multiplication can cost more CPU time than the rest of the computation combined. If the option skiptest is given, that correctness check is skipped. This is most useful in code where the correctness of the answer can be verified more efficiently later.
with⁡SolveToolsLinearSolvers:
Time comparison with LinearAlgebra:-NullSpace
N≔200:n≔100:r≔rand⁡−1000..1000:
M≔Matrix⁡N+n,N:
foritoN+ndoforjfrommax⁡1,i−ntoNdoMi,j≔r⁡enddoenddo:
V1≔M·Vector⁡seq⁡r⁡,i=1..N:
V2≔M·Vector⁡seq⁡r⁡,i=1..N:
M≔V1|V2|M:
This is the general purpose way to compute nullspaces in Maple
CodeTools:-Usage⁡LinearAlgebra:-NullSpace⁡M:
memory used=11.36GiB, alloc change=333.86MiB, cpu time=80.69s, real time=72.35s, gc time=12.41s
This command gives a significant speedup, but requires advance knowledge that the matrix M is dense and rational.
CodeTools:-Usage⁡RationalDenseNullSpace⁡M:
memory used=21.30MiB, alloc change=484.00KiB, cpu time=98.00ms, real time=98.00ms, gc time=0ns
If the correctness check is skipped, it is much faster
CodeTools:-Usage⁡RationalDenseNullSpace⁡M,skiptest:
memory used=1.84MiB, alloc change=476.00KiB, cpu time=51.00ms, real time=51.00ms, gc time=0ns
See Also
LinearAlgebra:-NullSpace
SolveTools:-LinearSolvers:-RationalDense
Download Help Document