-
Permutating integer vectors
Hi everyone,
I'm trying to construct certain sets of vectors using C++, but I'm a very beginner.. Major problem at the moment is that how can I permutate vectors? If I have for example vector (consisting of integers)
(1,1,2,0,...,0)
of certain length, how can I obtain the set of vectors where's two 1's, one 2 in any position and other components are 0's?
So the eventual set would look something like
{(1,1,2,0,...,0), (1,2,1,0,...,0), (2,1,1,0,...,0), (0,1,0,1,2,0,...,0) + all other combination with 1,1,2, and lenght-3 zeros}.
Actually what I really need (the above would help me a lot already) is that I'm constructing sets of integer vectors, for which the sum of the squares of the components doesn't exceed some given maximal value. so if the maximal value would for ex. be 6 and the length of the vectors 8, then the vector
(1,1,2,0,0,0,0,0) would belong to the set, as 1^2+1^2+2^2 = 6 but
the vector
(2,2,0,...,0) would not, as 2^2+2^2 = 8.
I hope someone more skilled than me can help me! Thanks in advance,
johan
-
We had a related thread a few weeks ago:
http://forums.devx.com/showthread.php?t=145163
The bottom line: use std::next_permutation() to obtain the vector's permutations.
Danny Kalev
-
thanks, danny! but... still didn't quite get it. got you offer me something more specific? because in my vectors the components may be equal so i don't quite see how this fits to my case? or is there some way to permutate the indices somehow and in that way get the components permutated? any help is more than welcome, i'm getting desperate!! thanks again in advance,
johan
Similar Threads
-
By eduardoms in forum Security
Replies: 2
Last Post: 05-06-2005, 10:26 AM
-
By Eric Immerman in forum .NET
Replies: 7
Last Post: 10-04-2002, 10:12 AM
-
Replies: 146
Last Post: 08-12-2002, 10:40 PM
-
By IvanP in forum VB Classic
Replies: 14
Last Post: 04-18-2002, 10:45 PM
-
By Kunal Sharma in forum VB Classic
Replies: 2
Last Post: 04-25-2000, 03:45 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|