Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,38 @@
|
|||
func linear_combination(coeffs) {
|
||||
var res = ""
|
||||
for e,f in (coeffs.kv) {
|
||||
given(f) {
|
||||
when (1) {
|
||||
res += "+e(#{e+1})"
|
||||
}
|
||||
when (-1) {
|
||||
res += "-e(#{e+1})"
|
||||
}
|
||||
case (.> 0) {
|
||||
res += "+#{f}*e(#{e+1})"
|
||||
}
|
||||
case (.< 0) {
|
||||
res += "#{f}*e(#{e+1})"
|
||||
}
|
||||
}
|
||||
}
|
||||
res -= /^\+/
|
||||
res || 0
|
||||
}
|
||||
|
||||
var tests = [
|
||||
%n{1 2 3},
|
||||
%n{0 1 2 3},
|
||||
%n{1 0 3 4},
|
||||
%n{1 2 0},
|
||||
%n{0 0 0},
|
||||
%n{0},
|
||||
%n{1 1 1},
|
||||
%n{-1 -1 -1},
|
||||
%n{-1 -2 0 -3},
|
||||
%n{-1},
|
||||
]
|
||||
|
||||
tests.each { |t|
|
||||
printf("%10s -> %-10s\n", t.join(' '), linear_combination(t))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue