Random \(k\)-form objects and \(k\)-tensors, intended as quick “get you going” examples

rform(terms=9, k=3, n=7, ensure=TRUE, integer=TRUE)
rformm(terms=30, k=7, n=20, ensure=TRUE, integer=TRUE)
rformmm(terms=90, k=15, n=30, ensure=TRUE, integer=TRUE)
rtensor(terms=9, k=3, n=7, integer=TRUE)

Arguments

terms

Number of distinct terms

k, n

A \(k\)-form maps \(V^k\) to \(\mathbb{R}\), where \(V=\mathbb{R}^n\)

ensure

Boolean with default TRUE meaning to ensure that the dovs() of the returned value is in fact equal to n. If FALSE, sometimes the dovs() is strictly less than n because of random sampling

integer

Boolean specifying whether the coefficients are integers or not

Details

Random \(k\)-form objects and \(k\)-tensors.

By default, function rform() returns a simple \(k\)-form; rformm() and rformmm() return successively more complicated objects. Note that argument terms is an upper bound, as the index matrix might contain repeats which are combined.

Function rtensor() returns a random tensor.

Value

All functions documented here return an object of class kform or ktensor.

Author

Robin K. S. Hankin

Examples


(a <- rform())
#> An alternating linear map from V^3 to R with V=R^7:
#>            val
#>  4 5 7  =    9
#>  1 5 7  =    5
#>  1 3 6  =    4
#>  1 6 7  =    4
#>  2 4 6  =    6
#>  1 2 6  =   -6
#>  4 6 7  =    1
(b <- rform())
#> An alternating linear map from V^3 to R with V=R^7:
#>            val
#>  1 2 4  =    9
#>  1 2 7  =    8
#>  2 4 7  =    6
#>  1 2 6  =   -4
#>  1 3 5  =   -3
#>  5 6 7  =    2
#>  4 5 7  =   -7
#>  1 2 3  =    5
#>  3 5 7  =    1
a ^ b
#> An alternating linear map from V^6 to R with V=R^7:
#>                  val
#>  1 2 3 5 6 7  =   -6
#>  1 3 4 5 6 7  =  -31
#>  1 2 4 5 6 7  =   78
#>  1 2 3 4 5 6  =  -18
#>  2 3 4 5 6 7  =   -6
#>  1 2 3 4 6 7  =  -29
#>  1 2 3 4 5 7  =  -45

a
#> An alternating linear map from V^3 to R with V=R^7:
#>            val
#>  4 5 7  =    9
#>  1 5 7  =    5
#>  1 3 6  =    4
#>  1 6 7  =    4
#>  2 4 6  =    6
#>  1 2 6  =   -6
#>  4 6 7  =    1
a ^ dx
#> An alternating linear map from V^4 to R with V=R^7:
#>              val
#>  1 4 6 7  =   -1
#>  1 2 4 6  =   -6
#>  1 4 5 7  =   -9
a ^ dx ^ dy
#> An alternating linear map from V^5 to R with V=R^7:
#>                val
#>  1 2 4 6 7  =    1
#>  1 2 4 5 7  =    9

(x <- rtensor())
#> A linear map from V^3 to R with V=R^7:
#>            val
#>  6 4 7  =    9
#>  2 4 5  =    6
#>  6 2 5  =    7
#>  6 7 5  =    5
#>  6 2 3  =    4
#>  5 7 3  =    8
#>  6 3 2  =    3
#>  3 1 1  =    2
#>  6 3 6  =    1
x %X% x
#> A linear map from V^6 to R with V=R^7:
#>                  val
#>  6 3 6 6 3 6  =    1
#>  3 1 1 6 3 6  =    2
#>  5 7 3 6 3 6  =    8
#>  6 2 3 6 3 6  =    4
#>  6 2 5 6 3 6  =    7
#>  6 3 2 6 3 6  =    3
#>  6 3 6 3 1 1  =    2
#>  3 1 1 3 1 1  =    4
#>  6 2 3 3 1 1  =    8
#>  6 7 5 3 1 1  =   10
#>  2 4 5 3 1 1  =   12
#>  6 7 5 6 3 6  =    5
#>  6 4 7 3 1 1  =   18
#>  6 3 6 6 3 2  =    3
#>  3 1 1 6 3 2  =    6
#>  6 3 2 6 3 2  =    9
#>  5 7 3 6 3 2  =   24
#>  6 4 7 6 7 5  =   45
#>  5 7 3 2 4 5  =   48
#>  6 7 5 6 2 5  =   35
#>  6 2 3 6 4 7  =   36
#>  2 4 5 6 3 6  =    6
#>  2 4 5 6 7 5  =   30
#>  2 4 5 6 2 5  =   42
#>  6 3 2 2 4 5  =   18
#>  5 7 3 3 1 1  =   16
#>  6 2 3 6 2 5  =   28
#>  3 1 1 2 4 5  =   12
#>  6 2 3 5 7 3  =   32
#>  6 2 5 6 3 2  =   21
#>  6 3 6 2 4 5  =    6
#>  6 4 7 6 4 7  =   81
#>  6 2 5 6 4 7  =   63
#>  6 2 5 6 2 5  =   49
#>  6 2 3 2 4 5  =   24
#>  6 3 2 6 2 5  =   21
#>  3 1 1 6 2 3  =    8
#>  2 4 5 6 4 7  =   54
#>  6 2 5 5 7 3  =   56
#>  6 3 2 6 4 7  =   27
#>  6 7 5 6 4 7  =   45
#>  6 7 5 6 7 5  =   25
#>  3 1 1 6 2 5  =   14
#>  5 7 3 6 4 7  =   72
#>  6 2 5 2 4 5  =   42
#>  6 4 7 2 4 5  =   54
#>  3 1 1 6 4 7  =   18
#>  5 7 3 6 2 5  =   56
#>  6 7 5 2 4 5  =   30
#>  6 3 6 6 4 7  =    9
#>  6 3 6 6 2 5  =    7
#>  6 2 5 6 7 5  =   35
#>  6 4 7 6 2 5  =   63
#>  5 7 3 6 7 5  =   40
#>  3 1 1 6 7 5  =   10
#>  6 2 5 6 2 3  =   28
#>  6 3 6 6 7 5  =    5
#>  6 3 2 6 7 5  =   15
#>  5 7 3 5 7 3  =   64
#>  6 7 5 6 2 3  =   20
#>  6 4 7 6 3 2  =   27
#>  3 1 1 5 7 3  =   16
#>  6 4 7 6 3 6  =    9
#>  5 7 3 6 2 3  =   32
#>  6 3 2 6 2 3  =   12
#>  6 3 6 6 2 3  =    4
#>  6 4 7 5 7 3  =   72
#>  6 7 5 6 3 2  =   15
#>  2 4 5 5 7 3  =   48
#>  2 4 5 2 4 5  =   36
#>  6 4 7 6 2 3  =   36
#>  2 4 5 6 2 3  =   24
#>  6 7 5 5 7 3  =   40
#>  6 2 5 3 1 1  =   14
#>  6 3 2 5 7 3  =   24
#>  6 3 2 3 1 1  =    6
#>  6 3 6 5 7 3  =    8
#>  6 2 3 6 2 3  =   16
#>  2 4 5 6 3 2  =   18
#>  6 2 3 6 7 5  =   20
#>  6 2 3 6 3 2  =   12