Solve a system of equation

Description

This generic function solves the equation a \%*\% x = b for x, where b can be either a vector or a matrix.

If a and b are rational, return is a rational matrix.

If a and b are big integers (of class bigz) solution is in Z/nZ if there is a common modulus, or a rational matrix if not.

Usage

1
2
3
4
## S3 method for class 'bigz'
solve(a, b, ...)
## S3 method for class 'bigq'
solve(a, b, ...)

Arguments

a,b

A element of class bigz or bigq

...

Unused

Details

It uses the Gauss and trucmuch algo ... (to be detailled).

Value

If a and b are rational, return is a rational matrix.

If a and b are big integers (of class bigz) solution is in Z/nZ if there is a common modulus, of a rational matrix if not.

Author(s)

Antoine Lucas

See Also

solve

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 x <- matrix(1:4,2,2)
 ## standard solve
 solve(x)

 q <- as.bigq(x)
 ## solve with rational
 solve(q)

 z <- as.bigz(x)
 modulus(z) <- 7
 ## solve in Z/7Z
 solve(z)

 b <- c(1,3)

 solve(q,b)

 solve(z,b)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.