Triangular numbers
Triangular numbers (of dimension 2) are defined by T(n) = T(n;2) = n(n+1)/2 = Binomial(n+1,2)
.
More generally, triangular numbers of dimension 1 are T(n;1) = n = Binomial(n,1)
and triangular numbers of dimension d+1
are T(n;d+1) = T(1;d) + ... + T(n;d) = Binomial(n+d-1,d)
.
TriangularNumber (n :: RngIntElt, d :: RngIntElt)
-> RngIntElt
The n
th triangular number in dimension d
. Equal to Binomial(n+d-1,d)
.
TriangularNumber (n :: RngIntElt)
-> RngIntElt
The n
th triangular number. Equal to Binomial(n+1,2) = n*(n+1)/2
.
LinearToTriangularIndex (i :: RngIntElt, d :: RngIntElt)
-> []
Converts from linear to triangular indexing in dimension d
. That is, returns the i
th array [i1,i2,...,id]
lexicographically with i1 ge i2 ge ... ge id ge 1
.
LinearToTriangularIndex (i :: RngIntElt)
-> []
Converts from linear to triangular indexing. That is, returns the i
th array [i1,i2]
lexicographically with i1 ge i2 ge 1
.
TriangularToLinearIndex (idx :: [RngIntElt], d :: RngIntElt)
-> RngIntElt
Converts from triangular indexing in dimension d
to linear.
TriangularToLinearIndex (idx :: [RngIntElt])
-> RngIntElt
Converts from triangular indexing to linear.