Re: Creating an matrix of possible combinations
- From: Duncan Muirhead <noone@xxxxxxxxxxxx>
- Date: Thu, 10 Aug 2006 10:40:15 +0100
On Wed, 09 Aug 2006 19:11:02 -0700, Russ.Dilley wrote:
I am writing a program to process forces and moments. In general I have[snip]
3 forces and 3 moments. As a simplified example, using only forces, I
am given values F1, F2, and F3. These values can be positive or
negative. As a result I have 6 possible force values. I want to create
a table with all the possible force combinations:
| F1 F2 F3 |
| F1 F2 -F3 |
| F1 -F2 F3 |
| F1 -F2 -F3 |
| -F1 F2 F3 |
| -F1 F2 -F3 |
| -F1 -F2 F3 |
| -F1 -F2 -F3 |
You could generate such a pattern by taking the
sign of the i+1,j+1 element of the table to be -1 if the j th
bit of i is set, and 1 otherwise. The magnitude is
F(j+1). Here 0<=i<2^n and 0<=j<number of forces
(well that will actually generate
( F1 F2 F3 )
( -F1 F2 F3 )
( F1 -F2 F3 )
( -F1 -F2 F3 )
....
If you really need the pattern shown you could determine
the sign based on the (numF-1-j)'th bit of i
)
Duncan
.
- Follow-Ups:
- Re: Creating an matrix of possible combinations
- From: Russ . Dilley
- Re: Creating an matrix of possible combinations
- References:
- Creating an matrix of possible combinations
- From: Russ . Dilley
- Creating an matrix of possible combinations
- Prev by Date: Re: Definite integral with huge variations in magnitude
- Next by Date: Re: Definite integral with huge variations in magnitude
- Previous by thread: Re: Creating an matrix of possible combinations
- Next by thread: Re: Creating an matrix of possible combinations
- Index(es):