LinearAlgebraX
This module implements basic linear algebra methods for matrices with exact entries (e.g., Rational{Int}
values). The function names typically match the standard ones in Julia but with an x
(for "exact") appended.
The functions in this module work for all types of Integer
, Rational
, Complex{Integer}
, Complex{Rational}
, and Mod
entries in matrices. Other exact numbers may work as well, but are not tested.
As the goal of this module is always to give exact answers and, at the same time, be type stable, the results of many of these functions are big
. That is, the detx
of an integer matrix returns a BigInt
.
Functions
These functions in this module end with the letter x
and have the same definitions as their counterparts that do not have an x
. For exact types (such as Int
s) these functions give exact results.
detx
– exact determinantcofactor_det
– slower exact determinant (via cofactor expansion)nullspacex
– exact nullspacerankx
– exact rankinvx
– exact inverserrefx
– row reduced echelon formeye
– lovingly restoredchar_poly
– characteristic polynomialpermanent
– permanent of a square matrix
Examples follow.
Determinant
julia> A = ones(Int,10,10)+eye(Int,10);
+LinearAlgebraX · LinearAlgebraX LinearAlgebraX
This module implements basic linear algebra methods for matrices with exact entries (e.g., Rational{Int}
values). The function names typically match the standard ones in Julia but with an x
(for "exact") appended.
The functions in this module work for all types of Integer
, Rational
, Complex{Integer}
, Complex{Rational}
, and Mod
entries in matrices. Other exact numbers may work as well, but are not tested.
As the goal of this module is always to give exact answers and, at the same time, be type stable, the results of many of these functions are big
. That is, the detx
of an integer matrix returns a BigInt
.
Functions
These functions in this module end with the letter x
and have the same definitions as their counterparts that do not have an x
. For exact types (such as Int
s) these functions give exact results.
detx
– exact determinant cofactor_det
– slower exact determinant (via cofactor expansion)nullspacex
– exact nullspacerankx
– exact rankinvx
– exact inverserrefx
– row reduced echelon formeye
– lovingly restoredchar_poly
– characteristic polynomialpermanent
– permanent of a square matrix
Examples follow.
Determinant
julia> A = ones(Int,10,10)+eye(Int,10);
julia> det(A)
10.999999999999998
@@ -84,15 +84,39 @@
Mod{11}(0) Mod{11}(1) Mod{11}(0) Mod{11}(0) Mod{11}(0)
Mod{11}(0) Mod{11}(0) Mod{11}(1) Mod{11}(0) Mod{11}(0)
Mod{11}(0) Mod{11}(0) Mod{11}(0) Mod{11}(1) Mod{11}(0)
- Mod{11}(0) Mod{11}(0) Mod{11}(0) Mod{11}(0) Mod{11}(1)
- ```
+ Mod{11}(0) Mod{11}(0) Mod{11}(0) Mod{11}(0) Mod{11}(1)
Characteristic polynomial
julia> using SimplePolynomials, LinearAlgebra
- ## Characteristic polynomial
-
julia> using SimplePolynomials, LinearAlgebra
julia> x = getx() x
julia> A = triu(ones(Int,5,5)) 5×5 Array{Int64,2}: 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 1
julia> char_poly(A) -1 + 5x - 10x^2 + 10x^3 - 5x^4 + x^5
julia> ans == (x-1)^5 true
julia> using Mods
julia> A = rand(Mod{17},4,4) 4×4 Array{Mod{17},2}: Mod{17}(16) Mod{17}(10) Mod{17}(9) Mod{17}(12) Mod{17}(15) Mod{17}(1) Mod{17}(1) Mod{17}(6) Mod{17}(3) Mod{17}(2) Mod{17}(5) Mod{17}(11) Mod{17}(5) Mod{17}(15) Mod{17}(15) Mod{17}(7)
julia> char_poly(A) Mod{17}(1) + Mod{17}(1)x + Mod{17}(16)x^2 + Mod{17}(5)x^3 + Mod{17}(1)x^4
julia> detx(A) Mod{17}(1)
- ## Row reduced echelon form
+julia> x = getx()
+x
- ```
- julia> A = rand(Int,4,6) .% 10
+julia> A = triu(ones(Int,5,5))
+5×5 Array{Int64,2}:
+ 1 1 1 1 1
+ 0 1 1 1 1
+ 0 0 1 1 1
+ 0 0 0 1 1
+ 0 0 0 0 1
+
+julia> char_poly(A)
+-1 + 5*x - 10*x^2 + 10*x^3 - 5*x^4 + x^5
+
+julia> ans == (x-1)^5
+true
+
+julia> using Mods
+
+julia> A = rand(Mod{17},4,4)
+4×4 Array{Mod{17},2}:
+ Mod{17}(16) Mod{17}(10) Mod{17}(9) Mod{17}(12)
+ Mod{17}(15) Mod{17}(1) Mod{17}(1) Mod{17}(6)
+ Mod{17}(3) Mod{17}(2) Mod{17}(5) Mod{17}(11)
+ Mod{17}(5) Mod{17}(15) Mod{17}(15) Mod{17}(7)
+
+julia> char_poly(A)
+Mod{17}(1) + Mod{17}(1)*x + Mod{17}(16)*x^2 + Mod{17}(5)*x^3 + Mod{17}(1)*x^4
+
+julia> detx(A)
+Mod{17}(1)
Row reduced echelon form
julia> A = rand(Int,4,6) .% 10
4×6 Array{Int64,2}:
6 8 0 -6 -5 4
0 -5 2 0 -3 -4
@@ -118,24 +142,7 @@
1//1 0//1 0//1 -1//1 0//1 -23//130 -36//65
0//1 1//1 0//1 1//1 0//1 -883//325 158//325
0//1 0//1 1//1 1//1 0//1 551//650 512//325
- 0//1 0//1 0//1 0//1 1//1 -379//325 204//325
- ```
-
- ## Homogeneous Vectors
-
- A point in projective space is represented by a *homogeneous vector*. This is
- a list of numbers (like an ordinary vector) but two such vectors are equal
- if and only if one is a nonzero multiple of the other.
-
- We provide the `HVector` type to represent homogeneous vectors. The entries
- in an `HVector` are scaled so that the last nonzero coordinate is `1`.
- (Technically, we should forbid the all zero vector, but we don't implement
- that restriction.)
-
- To create an `HVector` provide either a list (one-dimensional array) of values
- or a list of arguments:
- ```
- julia> v = HVector([1,-2,3])
+ 0//1 0//1 0//1 0//1 1//1 -379//325 204//325
Homogeneous Vectors
A point in projective space is represented by a homogeneous vector. This is a list of numbers (like an ordinary vector) but two such vectors are equal if and only if one is a nonzero multiple of the other.
We provide the HVector
type to represent homogeneous vectors. The entries in an HVector
are scaled so that the last nonzero coordinate is 1
. (Technically, we should forbid the all zero vector, but we don't implement that restriction.)
To create an HVector
provide either a list (one-dimensional array) of values or a list of arguments:
julia> v = HVector([1,-2,3])
[1//3 : -2//3 : 1//1]
julia> w = HVector(2,-4,6)
@@ -191,4 +198,4 @@
3×3 Array{Rational{Int64},2}:
0//1 4//3 -1//1
-1//3 -4//3 2//3
- -1//1 0//1 1//1
Settings
This document was generated with Documenter.jl version 1.5.0 on Friday 30 August 2024. Using Julia version 1.10.5.
+ -1//1 0//1 1//1