[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: how to make a matrix with all combinations of digits efficiently

**From**: |
Juan Pablo Carbajal |

**Subject**: |
Re: how to make a matrix with all combinations of digits efficiently |

**Date**: |
Fri, 29 Dec 2017 00:07:43 +0100 |

On Thu, Dec 28, 2017 at 9:25 PM, Jean Dubois <address@hidden> wrote:
>* I'd like to generate a matrix like this (small version to give you the idea):*
>
>* 0 0 0 (three columns in this example)*
>* 0 0 1*
>* 0 0 2*
>* 0 0 3*
>* .*
>* .*
>* .*
>* 9 9 8*
>* 9 9 9*
>
>* Could anyone here show me how to do this efficiently?*
>
>* thanks in advance*
>
>* _______________________________________________*
>* Help-octave mailing list*
>* address@hidden*
>* https://lists.gnu.org/mailman/listinfo/help-octave*
This is the decomposition on base 10, a way of doing it is
nc = 3; # number of columns
base = 10;
i = (0:(base^nc-1)).'; # row index - 1
counter = mod( floor (i ./ base.^[(nc-1):-1:0]), base);
it should work for any integer base, but please do check.

**how to make a matrix with all combinations of digits efficiently**, *Jean Dubois*, `2017/12/28`
**Re: how to make a matrix with all combinations of digits efficiently**,
*Juan Pablo Carbajal* **<=**
**Re: how to make a matrix with all combinations of digits efficiently**, *Jean Dubois*, `2017/12/29`
**Re: how to make a matrix with all combinations of digits efficiently**, *Francesco PotortÃ¬*, `2017/12/29`
**Re: how to make a matrix with all combinations of digits efficiently**, *Jean Dubois*, `2017/12/29`
**Re: how to make a matrix with all combinations of digits efficiently**, *Francesco PotortÃ¬*, `2017/12/29`
**Re: how to make a matrix with all combinations of digits efficiently**, *Juan Pablo Carbajal*, `2017/12/29`
**Re: how to make a matrix with all combinations of digits efficiently**, *Jean Dubois*, `2017/12/30`
**Re: how to make a matrix with all combinations of digits efficiently**, *Jean Dubois*, `2017/12/30`
**Re: how to make a matrix with all combinations of digits efficiently**, *Juan Pablo Carbajal*, `2017/12/30`
**Re: how to make a matrix with all combinations of digits efficiently**, *Juan Pablo Carbajal*, `2017/12/30`