Skip to content

Commit f9ca27b

Browse files
committed
use simpler tabulation function
1 parent 5e12782 commit f9ca27b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pages/tabulation_1dim_triangular.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ speed: 100
66

77
{{> tabulation_libs }}
88

9-
The solution for subword $i..j$ is stored at $M[|w|\cdot i - (i\cdot(i-1)) \div 2 + j]$ where $M$ is a one-dimensional array of size $(|w|+1)\cdot(|w|+2) / 2$. This completely eliminates the space loss of the [naive strategy](/tabulation_1dim_naive).
9+
The solution for subword $i..j$ is stored at $M[i + (j\cdot(j+1)) \div 2]$ where $M$ is a one-dimensional array of size $(|w|+1)\cdot(|w|+2) / 2$. This completely eliminates the space loss of the [naive strategy](/tabulation_1dim_naive).
1010

1111
{{> tabulation_speed_slider }}
1212

1313
{{> tabulation_length_slider }}
1414

1515
<script>
1616
Tabulation.prototype.adr = function(i,j) {
17-
//console.log(i + "," + j + " -> " + (this.len*i - Math.floor((i*(i-1)) / 2) + j));
18-
return this.len*i - Math.floor((i*(i-1)) / 2) + j;
17+
return i + Math.floor((j*(j+1)) / 2);
1918
}
2019

2120
Tabulation.prototype.solve = function(x1,x2,c) {
@@ -48,4 +47,4 @@ $(function() {
4847
tab.fill();
4948
window.tab = tab;
5049
});
51-
</script>
50+
</script>

0 commit comments

Comments
 (0)