Created
August 7, 2015 18:13
-
-
Save meysampg/229b40d2cbb51f84b331 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function result = indToBernstienInd(d, k) | |
% Convert ordinary order to lexicographical order. | |
% Input: | |
% @d: integer, dimension of spline space. | |
% @k: integer, position on ordinary sequence order | |
% Output: | |
% @result: vector[3], position of k on exicography order | |
result = zeros(1,3); | |
delt = @(k) ceil((-3 + sqrt(9+8*(k-1)))/2); | |
result(1) = d - delt(k); | |
result(3) = k - ((d-result(1)+1)*(d-result(1)))/2 - 1; | |
result(2) = d - result(1) - result(3); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment