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
#>  1 3 6  =   -9
#>  4 6 7  =    7
#>  2 3 4  =   -3
#>  3 5 6  =   -4
#>  2 6 7  =   -6
#>  2 3 7  =    5
#>  1 4 6  =   -2
#>  2 4 6  =   -8
#>  2 3 6  =    1
(b <- rform())
#> An alternating linear map from V^3 to R with V=R^7:
#>            val
#>  4 5 7  =    6
#>  1 2 6  =   -3
#>  1 3 5  =   -9
#>  5 6 7  =    8
#>  1 5 7  =    2
#>  1 3 6  =    4
#>  3 5 7  =    7
#>  2 4 6  =    5
#>  1 6 7  =    1
a ^ b
#> An alternating linear map from V^6 to R with V=R^7:
#>                   val
#>  1 2 3 4 5 6  =    72
#>  1 2 4 5 6 7  =   -16
#>  1 3 4 5 6 7  =  -103
#>  1 2 3 4 6 7  =     3
#>  1 2 3 4 5 7  =     6
#>  2 3 4 5 6 7  =    38
#>  1 2 3 5 6 7  =   -52

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

(x <- rtensor())
#> A linear map from V^3 to R with V=R^7:
#>            val
#>  5 1 6  =    9
#>  4 7 6  =    7
#>  2 2 6  =   13
#>  2 7 3  =    6
#>  1 5 3  =    4
#>  3 7 1  =    3
#>  1 4 4  =    2
#>  1 7 2  =    1
x %X% x
#> A linear map from V^6 to R with V=R^7:
#>                  val
#>  1 4 4 1 7 2  =    2
#>  1 5 3 1 7 2  =    4
#>  2 7 3 2 7 3  =   36
#>  5 1 6 2 7 3  =   54
#>  1 7 2 2 2 6  =   13
#>  2 7 3 3 7 1  =   18
#>  1 7 2 3 7 1  =    3
#>  5 1 6 2 2 6  =  117
#>  1 5 3 2 2 6  =   52
#>  2 2 6 4 7 6  =   91
#>  5 1 6 1 5 3  =   36
#>  4 7 6 2 2 6  =   91
#>  4 7 6 2 7 3  =   42
#>  1 4 4 4 7 6  =   14
#>  1 5 3 2 7 3  =   24
#>  4 7 6 5 1 6  =   63
#>  3 7 1 4 7 6  =   21
#>  4 7 6 4 7 6  =   49
#>  1 4 4 2 2 6  =   26
#>  2 2 6 2 7 3  =   78
#>  2 2 6 2 2 6  =  169
#>  1 5 3 5 1 6  =   36
#>  2 2 6 5 1 6  =  117
#>  5 1 6 1 4 4  =   18
#>  2 7 3 5 1 6  =   54
#>  1 7 2 5 1 6  =    9
#>  1 4 4 5 1 6  =   18
#>  3 7 1 2 2 6  =   39
#>  3 7 1 1 5 3  =   12
#>  5 1 6 5 1 6  =   81
#>  1 5 3 4 7 6  =   28
#>  3 7 1 5 1 6  =   27
#>  3 7 1 2 7 3  =   18
#>  1 4 4 2 7 3  =   12
#>  3 7 1 1 4 4  =    6
#>  1 7 2 2 7 3  =    6
#>  4 7 6 1 5 3  =   28
#>  1 7 2 4 7 6  =    7
#>  1 4 4 3 7 1  =    6
#>  5 1 6 4 7 6  =   63
#>  2 2 6 1 5 3  =   52
#>  2 7 3 1 5 3  =   24
#>  2 7 3 1 7 2  =    6
#>  1 5 3 1 5 3  =   16
#>  2 7 3 2 2 6  =   78
#>  1 4 4 1 5 3  =    8
#>  4 7 6 1 4 4  =   14
#>  1 7 2 1 7 2  =    1
#>  1 7 2 1 5 3  =    4
#>  3 7 1 1 7 2  =    3
#>  1 4 4 1 4 4  =    4
#>  5 1 6 3 7 1  =   27
#>  3 7 1 3 7 1  =    9
#>  4 7 6 3 7 1  =   21
#>  2 2 6 3 7 1  =   39
#>  1 5 3 3 7 1  =   12
#>  2 2 6 1 4 4  =   26
#>  2 7 3 1 4 4  =   12
#>  1 5 3 1 4 4  =    8
#>  2 7 3 4 7 6  =   42
#>  1 7 2 1 4 4  =    2
#>  5 1 6 1 7 2  =    9
#>  4 7 6 1 7 2  =    7
#>  2 2 6 1 7 2  =   13