Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1 @@
perm 4

View file

@ -0,0 +1,41 @@
program perm
local n=`1'
local r=1
forv i=1/`n' {
local r=`r'*`i'
}
clear
qui set obs `r'
forv i=1/`n' {
gen p`i'=0
}
mata: genperm()
end
mata
void genperm() {
real scalar n, i, j, k, s, p
real rowvector u
st_view(a=., ., .)
n = cols(a)
u = 1..n
p = 1
do {
a[p++, .] = u
for (i = n; i > 1; i--) {
if (u[i-1] < u[i]) break
}
if (i > 1) {
j = i
k = n
while (j < k) u[(j++, k--)] = u[(k, j)]
s = u[i-1]
for (j = i; u[j] < s; j++) {
}
u[i-1] = u[j]
u[j] = s
}
} while (i > 1)
}
end