Permutating integer vectors


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Permutating integer vectors

  1. #1
    Join Date
    Aug 2005
    Posts
    2

    Question 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

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    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

  3. #3
    Join Date
    Aug 2005
    Posts
    2
    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

  1. Physical Address of the NIC
    By eduardoms in forum Security
    Replies: 2
    Last Post: 05-06-2005, 11:26 AM
  2. CopyFileEx API - NullReferenceException
    By Eric Immerman in forum .NET
    Replies: 7
    Last Post: 10-04-2002, 11:12 AM
  3. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 11:40 PM
  4. PrintDlgEx woes
    By IvanP in forum VB Classic
    Replies: 14
    Last Post: 04-18-2002, 11:45 PM
  5. Trying to print a PDF File from VB
    By Kunal Sharma in forum VB Classic
    Replies: 2
    Last Post: 04-25-2000, 04: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center