iheartla / Iheartla.github.io

0 stars 0 forks source link

[optimal_sampling_16] avoid use of "padded array" #6

Open pressureless opened 3 years ago

pressureless commented 3 years ago

Create by @alecjacobson :

The current I❤️LA translation

∑_i α_i + 1/M ∑_i ∑_(j for j ≤ n_i) (f(X_i,j)/`p_c`(X_i,j) - (∑_k α_k p_k(X_i,j))/`p_c`(X_i,j))

where

α ∈ ℝ^N
p_j ∈ ℝ → ℝ 
X ∈ ℝ^(N×m)
M ∈ ℝ  
n_i ∈ ℝ
f: ℝ → ℝ 
`p_c`: ℝ → ℝ

is a bit of a "hack" around pressureless/linear_algebra#74 . In the source, each X_i is vector of length n_i. This translation is defining X as a matrix with m columns and then adjusting the summation in the expression to only run over n_i elements (assuming that the n_i entries of X_i are stored in the first n_i entries of that row and that m ≥ max_i n_i.

This feels like bending over backwards to get around a limitation of I❤️LA. Hopefully we fix pressureless/linear_algebra#74 and this can be written more clearly, e.g., as:

∑_i α_i + 1/M ∑_i ∑_j (f(X_i,j)/`p_c`(X_i,j) - (∑_k α_k p_k(X_i,j))/`p_c`(X_i,j))

where

α ∈ ℝ^N
p_j ∈ ℝ → ℝ 
X_i ∈ ℝ^(n_i) for i≤N
M ∈ ℝ
f: ℝ → ℝ 
`p_c`: ℝ → ℝ
pressureless commented 3 years ago

Maybe the current target is:

∑_i α_i + 1/M ∑_i ∑_j (f(X_i,j)/`p_c`(X_i,j) - (∑_k α_k p_k(X_i,j))/`p_c`(X_i,j))

where

α ∈ ℝ^N
p_j ∈ ℝ → ℝ 
X_i ∈ ℝ^(n_i) 
M ∈ ℝ
f: ℝ → ℝ 
`p_c`: ℝ → ℝ