Subset of an Vector

Hi,
i have an vector and i want to get another vector that is a part of that initial vector just like the substring function of a string gives an subset of the initial string. Can anyone tell me if there is an simple way of doing this, rather than doing it manually (an cycle, for instance)?
Thankx in advance.

Explaining janxious's answer:
import java.util.*;
class Test156 {
    public static void main(String[] args) throws Exception {
        Vector v1 = new Vector();
        for (int i = 0; i < 10; ++i)
           v1.add (new Integer(i));
        System.out.println (v1);          
        Vector v2 = new Vector (v1.subList(3, 7)); // from position 3 (inclusive) to 7 (exclusive)
        System.out.println (v2);
}It prints:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[3, 4, 5, 6]

Similar Messages

  • Subsets of a specific length

    I have a Vector of Integers, like so: {1, 2, 4, 7}, and I need to generate all subsets of a given size. So if I wanted all the subsets of size three for the above set, I would get: {{1, 2, 4}, {1, 2, 7}, {1, 4, 7}, and {2, 4, 7}}.
    How can I generate all these subsets? I found the following code (by schillj) posted on another topic, but it generates all possible subsets of all possible sizes, where I only need ones of a given size:
    int[] arr = new int[] {1,2,3,4};
    long num_permutations = (1<<(arr.length));
    System.out.println("Number of permutations = " + num_permutations);
    // print out all the sets
    for(int loop = 0; loop < num_permutations; loop++) {
      System.out.print("Set #" + loop + ":  ");
      // do the bit chunking
      for(int bit = 0; bit < arr.length; bit++) {
        if(0 != (loop & (1<<bit)) ) {
          System.out.print( arr[bit] + " ");
      System.out.println("");
    }Any ideas how I might generate my subsets?

    Well, after working at it for a while, here's what I've come up with... It's not elegant, but I post it here in case anyone else is interested. I'd be interested to hear if anyone has a simpler or more elegant solution to what seems like it should be a simple problem.
    // Given a set (a Vector) v, generates all the subsets of this set of
    // the given length. Returns a Vector of Vectors (each of which is one
    // of the subsets).
    public static Vector subsetsOfSize(Vector v, int s) {
      // Initialize the positions array.  Each element is set to its index.
      int[] positions = new int[s];
      for (int i = 0; i < positions.length; i++) {
        positions[i] = i;
      // Generate all the subsets of size s
      int maxVal = v.size() - 1;
      boolean maxedOut = false;
      Vector subsets = new Vector();
      do {
        subsets.add(createSubset(v, positions));
        maxedOut = rIncrementVars(positions, 0, maxVal);
      } while (maxedOut == false);
      subsets.add(createSubset(v, positions));
      return subsets;
    // A helper function used by subsetsOfSize().
    private static Vector createSubset(Vector v, int[] positions) {
      Vector subset = new Vector();
      for (int i = 0; i < positions.length; i++) {
        subset.add(v.get(positions));
    return subset;
    // Recursively increments any number of variables in the manner used by
    // subsetsOfSize(). That is, it creates all the combinations of the
    // (vars.length) numbers from 0 to maxVal. Returns true to the calling
    // function when it has generated the last such combination, returns
    // false otherwise. The first time this function is called, vars
    // should be an array with each element set to its index.
    private static boolean rIncrementVars(int[] vars, int n, int maxVal) {
    boolean incThisVar;
    if (n < vars.length - 1) {
    incThisVar = rIncrementVars(vars, n + 1, maxVal);
    } else {
    incThisVar = true;
    if (incThisVar == true) {
    int maxValN = maxVal - (vars.length - 1 - n);
    if (vars[n] < maxValN) {
    vars[n]++;
    for (int i = n + 1; i < vars.length; i++) {
    vars[i] = vars[i - 1] + 1;
    if (n == 0 && vars[n] == maxValN) {
    return true;
    } else {
    return false;
    } else {
    return true;
    } else {
    return false;

  • Using a non-static vector in a generic class with static methods

    I have a little problem with a class (the code is shown underneath). The problem is the Assign method. This method should return a clone (an exact copy) of the set given as an argument. When making a new instance of a GenericSet (with the Initialize method) within the Assign method, the variables of the original set and the clone have both a reference to the same vector, while there exists two instances of GenericSet. My question is how to refer the clone GenericSet's argument to a new vector instead of the existing vector of the original GenericSet. I hope you can help me. Thanks
    package genericset;
    import java.util.*;
    public class GenericSet<E>{
    private Vector v;
    public GenericSet(Vector vec) {
    v = vec;
    private <T extends Comparable> Item<T> get(int index) {
    return (Item<T>) v.get(index);
    public static <T extends Comparable> GenericSet<T> initialize() {
    return new GenericSet<T>(new Vector());
    public Vector getVector() {
    return v;
    public static <T extends Comparable> GenericSet<T> insert (GenericSet<T> z, Item<T> i){
    GenericSet<T> g = assign(z);
    Vector v = g.getVector();
    if (!member(g,i))
    v.addElement(i);
    return g;
    public static <T extends Comparable> GenericSet<T> delete(GenericSet<T> z, Item<T> i){
    GenericSet<T> g = assign(z);
    Vector v = g.getVector();
    if (member(g,i))
    v.remove(i);
    return g;
    public static <T extends Comparable> boolean member(GenericSet<T> z, Item<T> i) {
    Vector v = z.getVector();
    return v.contains(i);
    public static <T extends Comparable> boolean equal(GenericSet<T> z1, GenericSet<T> z2) {
    Vector v1 = z1.getVector();
    Vector v2 = z2.getVector();
    if((v1 == null) && (v2 != null))
    return false;
    return v1.equals(v2);
    public static <T extends Comparable> boolean empty(GenericSet<T> z) {
    return (cardinality(z) == 0);
    public static <T extends Comparable> GenericSet<T> union(GenericSet<T> z1, GenericSet<T> z2) {
    GenericSet<T> g = assign(z1);
    for(int i=0; i<cardinality(z2); i++) {
    Item<T> elem = z2.get(i);
    insert(g, elem);
    return g;
    public static <T extends Comparable> GenericSet<T> intersection(GenericSet<T> z1, GenericSet<T> z2) {
    GenericSet<T> g = initialize();
    for(int i=0; i<cardinality(z2); i++) {
    Item<T> elem = z2.get(i);
    if(member(z1, elem))
    insert(g, elem);
    return g;
    public static <T extends Comparable> GenericSet<T> difference(GenericSet<T> z1, GenericSet<T> z2) {
    GenericSet<T> g = initialize();
    for(int i=0; i<cardinality(z1); i++) {
    Item<T> elem = z1.get(i);
    if(!member(z2, elem))
    insert(g, elem);
    for(int i=0; i<cardinality(z2); i++) {
    Item<T> elem = z2.get(i);
    if(!member(z1, elem))
    insert(g, elem);
    return g;
    public static <T extends Comparable> GenericSet<T> assign(GenericSet<T> z) {
    GenericSet<T> g = initialize();
    for(int i=0; i<cardinality(z); i++) {
    Item<T> elem = z.get(i);
    insert(g, elem);
    return g;
    public static <T extends Comparable> boolean subset(GenericSet<T> z1, GenericSet<T> z2) {
    for(int i=0; i<cardinality(z1); i++) {
    Item<T> elem = z1.get(i);
    if(!member(z2, elem))
    return false;
    return true;
    public static <T extends Comparable> int cardinality(GenericSet<T> z){
    Vector v = z.getVector();
    return v.size();
    }

    The issue is not "reference a non-static interface", but simply that you cannot reference a non-static field in a static method - what value of the field ed would the static method use? Seems to me your findEditorData should look something like this:   public static EditorBean findEditorData( String username, EditorBean editorData )
          return editorData.ed.findEditor( username );
       }

  • Can one embed the complete font (not a subset of it) when saving as an EPS in Illustrator (CS4)?

    We are running into some display font issues when our clients use Acrobat 7 or older versions of reader to view our PDF proofs.  On occasion, subsetted fonts conflict and reveal question marks instead of the desired type in the final PDF.
    We use a proprietary composition system to perform the majority of our file composition, but use Illustrator for tables and charts.  Our composition system requires imported elements to be saved in the EPS file format.  As far as I can tell, there is no way to have Illustrator embed the complete font rather than a subset of it when saving the file as an EPS.  Please correct me if I am wrong?
    All help is greatly appreciated.

    Russel,
    I appreciate your advice.
    To answer your befuddlement, the PDF supplied to our client is generated from a PostScript file created from our proprietary composition system.  Unfortunately, the casue of the subset conflict is occuring prior to the PDF distillation.  We do not create the PDF in Illustrator.  Our proprietary composition system can only import the EPS file format for linked bitmap and vector images.  The moment the EPS is saved is where the issue is occuring.  A redistill further downstream (when the EPS and composition files are already combined in the PostScript) does not appear to eliminate the conflict.
    If there was a way for us to embed the entire font and not just a subset of it in the EPS that we export out of Illustrator, then the likelihood of a subset conflict occuring in the PDF during distilling would be eliminated.  Fortunately, the question marks only show up when the PDF is displayed on screen in Acrobat.  The output from this same PDF looks fine when sent to a printer.  Considering the size of our print runs (often in the millions) and the importance of all type displaying properly (risk of large SEC fines), the explanation that the job will print correctly even though it displays improperly does not satisfy our clients.
    We can not convert the text to outlines since the fonts would appear slightly heavier in the tables than they would appear in the portion that is composed in our proprietary composition system where the same font is used. 
    Any other ideas?

  • Software Component Vector in Modification Adjustment Transport

    Hello all,
    We are in the middle of a support pack project for our SRM system, and I've run into a snag as I prepare to move them into QAS.  We've had this system for many years, and when DEV was originally installed in 2000 it was as a B2B 2.0a system.  It was upgraded to 2.0b before GoLive, and the QAS and PRD systems were installed directly as 2.0b systems.  The entire landscape has been upgraded several times in the twelve years since, and today it is on release SRM 5.0.
    The problem is that the DEV system still shows an installed software component of NDI_ERM (Extended Relationship Management) in release 20A.  Obviously that is actually long gone, but it still shows up in SPAM in the Display Package Level function, and under Attribute SAPCOMPONENT in the properties of all transport requests released from this system.  It should have been passively deleted during the first (or subsequent) upgrade long ago, but for whatever reason that didn't happen.  This software component never existed in QAS or PRD and does not show up in SPAM in those systems.
    This hasn't been an issue in the past, and so I've just ignored it as I always had bigger fish to fry.  I've performed upgrades and support packages for these systems without an issue, but we hadn't done any of these tasks for the past three years.
    Until now.
    I successfully installed support package stack 28 for SRM 5.0 into DEV a few months ago, and I performed the required modification adjustments in SPAU, creating the usual modification adjustment transport.  Now, however, when I am trying to import the support packs into QAS, I have a problem when defining the queue, at the step for adding the modification adjustment transport.  The transport is marked with a Software Component Vector that includes the defunct ghost NDI_ERM 20A, and NDI_ERM doesn't exist in QAS.  SPAM finds the transport, but marks it with a red light ("Transport does not fit").  Drilling into details shows me that everything matches perfectly except for my ghost.  On that line I get "The software component is not installed," and SPAM will not allow me to add the transport into the queue.
    I should point out that I can import regular transports just fine, and I'm pretty sure I could just import the queue without the modification adjustment transport, and then import it manually when SPAM gets to the step about performing the adjustment.  No doubt that would work, and that's almost certainly what I'm going to end up doing.  But it bugs me that I can't fix this.
    I have some thoughts about fixes that might work, and I'd like input on whether anyone else has dealt with (and solved) this problem before.
    I think that I could probably just delete the line in DEV in table CVERS for NDI_ERM and so have it no longer show up in the attributes of future transports.  That might solve the problem going forward, though it won't fix the mod adjust transport I've already released.  Any thoughts about this?
    I was able to get the existing transport to no longer show NDI_ERM in its attributes by deleting the appropriate line in DEV in table E070A.  After doing that the transport looked fine in the STMS queue for QAS when drilling into its properties.  However, this apparently isn't enough for SPAM.  As I had already uploaded the transport in SPAM once, SPAM 'remembers' it and seems to have therefore cached its properties, including the NDI_ERM software component.  I haven't been able to figure out how to get SPAM to 'forget' this transport so I could completely upload it anew and hopefully get new attributes that will then match the correct software component vector for the target system.  Resetting the queue status doesn't do it.
    Any thoughts on where (what tables) SPAM stores information about modification adjustment transports, and how to clear that information out?  Any thoughts on the (admittedly drastic) measures I've mentioned above?
    Thanks in advance,
    --Matt

    Hello,
    SAP strictly forbids the modification of those tables for specific Add-Ons or even essential software component. As you do not really delete those products from a SAP system. This will only partially remove meta information from a SAP sytem.  After the "reinstallation" the data and many other log files are still exists and may have some really inconvenient side effects in a SAP systems (inconsistent installation, incomplete database table conversion, problems regarding maintenance via notes and support packages, modifications cannot be reverted...) .
    Additionaly it will be very difficult or even impossible to resolve upgrade or maintenance issues.
    If you have any  issue regarding an installation of a SAP product, you should contact the corresponding SAP support. They will provide you the right solution. 
    Currently SAP only provides for a small subset of Add-Ons the deinstallation.
    Thanks a lot for your understanding
    with kind regards,
       Thorsten Scheyter  (Development support)

  • Vectors printing jagged when placed over raster images

    I am fixing a previously designed flyer for a reprint. On the last print, any vector object placed on top of the raster image was very noticeably jagged. This included both white text, which simply had jagged edges, to colored text, which had white jaggies as well. Drawn vector objects and clipping paths in jpgs were also jagged.
    I used InDesign CS3 to create it, but I outlined the type, embedded all the images and exported as a .pdf (my project manager insists on this; so maybe it's not even an ID issue).
    It looks fine when I print it on my hp LaserJet 2550n or the office's Canon iR 2800i - but that's never been a good way to tell how it's going to turn out at the end.
    I know just making it all in Photoshop is probably the safest option, but I would really like to keep the sharpness of the vectors, and I've got Character/Paragraph styles etc going that would be a pain to redo in Photoshop. Plus, copy+pasting it into Photoship creates pdf/vector object that looks just as horrid (on screen - it looks the same when I print it on the above-mentioned printers, but I'm still paranoid).
    Thanks for taking the time to read this and for any help you are able to offer!
    Lisa

    Peter, thank you for your reply. I really appreciate the help.
    Generally, I use the default settings for [Press Quality], since I don't have a complete understanding of all the settings. I have appended the .txt pdf setting summary at the bottom of this post.
    I'm aware that outlining type is supposed to be unnecessary but 1) my project manager insists on it because he doesn't want to deal with any kind of font problems (maybe if this is at the root of the problem it will push him to accept it), 2) I'm using Fontin & Fontin Sans by Jos Buivenga (a high quality free font) and the ligatures/alternate characters
    sometimes don't show correctly when printed (replaced by a ?) or viewed on another computer without the font.
    Yes, I embed the images into the ID document (Links - embed images). This is only because my project manager insists on this as well. It is unnecessary to do this when saving to a .pdf, correct?
    Here are the settings I generally use when exporting a pdf to send to the printer (who do not specify any kind of settings):
    Description
    Use these settings to create Adobe PDF documents best suited for high-quality prepress printing. Created PDF documents can be opened with Acrobat and Adobe Reader 5.0 and later.
    PDF Preset: [Press Quality]
    Compatibility: Acrobat 5 (PDF 1.4)
    Standards Compliance: None
    General
    Pages: All
    Spreads: Off
    Generate Thumbnails: Off
    Optimize PDF: On
    Create Acrobat Layers: N/A
    Export Layers: Visible and Printable Layers
    Include Bookmarks: Off
    Include Hyperlinks: Off
    Export Nonprinting Objects: Off
    Export Visible Guides and Baseline Grids: Off
    Create Tagged PDF: Off
    Include Interactive Elements: Off
    Multimedia: N/A
    Compression
    Color Images
    Bicubic Downsample at: 300 ppi
    for images above: 450 ppi
    Compression: Automatic
    Tile Size: N/A
    Quality: Maximum
    Grayscale Images
    Bicubic Downsample at: 300 ppi
    for images above: 450 ppi
    Compression: Automatic
    Tile Size: N/A
    Quality: Maximum
    Monochrome Images
    Bicubic Downsample at: 1200 ppi
    for images above: 1800 ppi
    Compression: CCITT Group 4
    Compress Text and Line Art: On
    Crop Image Data to Frames: On
    Marks and Bleeds
    Crop Marks: Off
    Bleed Marks: Off
    Registration Marks: Off
    Color Bars: Off
    Page Information: Off
    Page Mark Type: Default
    Weight: 0.25 pt
    Offset: 6 pt
    Use Document Bleed Settings: Off
    Bleed Top: 0 pt
    Bleed Bottom: 0 pt
    Bleed Left: 0 pt
    Bleed Right: 0 pt
    Include Slug Area: Off
    Output
    Color Conversion: Convert to Destination (Preserve Numbers)
    Destination: Document CMYK - U.S. Web Coated (SWOP) v2
    Profile Inclusion Policy: Don't Include Profiles
    Simulate Overprint: N/A
    Output Intent Profile Name: N/A
    Output Condition: N/A
    Output Condition Identifier: N/A
    Registry Name: N/A
    Advanced
    Subset Fonts Below: 100%
    Omit PDF: Off
    Omit EPS: Off
    Omit Bitmap Images: Off
    Transparency Flattener Preset: N/A
    Ignore Spread Overrides: N/A
    Security
    N/A
    Warnings

  • Vector instructions in GCC 4.04

    I am trying to write an optimized routine using 32 bit vector instructions on a v9 sparc. Using the inforamtion below I have been unable to convince gcc 3.4.6 or gcc 4.0.4 to emilt a vector fpadd instruction - it always just emits 2 32 bit add instructions. I can't find any known good sample code to start from so I presume I am doing something silly. Any help would be most appreciated.
    6.54.14 SPARC VIS Built-in Functions
    GCC supports SIMD operations on the SPARC using both the generic vector extensions (see Vector Extensions) as well as built-in functions for the SPARC Visual Instruction Set (VIS). When you use the -mvis switch, the VIS extension is exposed as the following built-in functions:
    typedef int v2si __attribute__ ((vector_size (8)));
    typedef short v4hi __attribute__ ((vector_size (8)));
    typedef short v2hi __attribute__ ((vector_size (4)));
    typedef char v8qi __attribute__ ((vector_size (8)));
    typedef char v4qi __attribute__ ((vector_size (4)));
    void * __builtin_vis_alignaddr (void *, long);
    int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
    v2si __builtin_vis_faligndatav2si (v2si, v2si);
    v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
    v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
    v4hi __builtin_vis_fexpand (v4qi);
    v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
    v4hi __builtin_vis_fmul8x16au (v4qi, v4hi);
    v4hi __builtin_vis_fmul8x16al (v4qi, v4hi);
    v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
    v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
    v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
    v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
    v4qi __builtin_vis_fpack16 (v4hi);
    v8qi __builtin_vis_fpack32 (v2si, v2si);
    v2hi __builtin_vis_fpackfix (v2si);
    v8qi __builtin_vis_fpmerge (v4qi, v4qi);
    int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
    6.49 Using vector instructions through built-in functions
    On some targets, the instruction set contains SIMD vector instructions that operate on multiple values contained in one large register at the same time. For example, on the i386 the MMX, 3DNow! and SSE extensions can be used this way.
    The first step in using these extensions is to provide the necessary data types. This should be done using an appropriate typedef:
    typedef int v4si __attribute__ ((vector_size (16)));
    The int type specifies the base type, while the attribute specifies the vector size for the variable, measured in bytes. For example, the declaration above causes the compiler to set the mode for the v4si type to be 16 bytes wide and divided into int sized units. For a 32-bit int this means a vector of 4 units of 4 bytes, and the corresponding mode of foo will be V4SI.
    The vector_size attribute is only applicable to integral and float scalars, although arrays, pointers, and function return values are allowed in conjunction with this construct.
    All the basic integer types can be used as base types, both as signed and as unsigned: char, short, int, long, long long. In addition, float and double can be used to build floating-point vector types.
    Specifying a combination that is not valid for the current architecture will cause GCC to synthesize the instructions using a narrower mode. For example, if you specify a variable of type V4SI and your architecture does not allow for this specific SIMD type, GCC will produce code that uses 4 SIs.
    The types defined in this manner can be used with a subset of normal C operations. Currently, GCC will allow using the following operators on these types: +, -, *, /, unary minus, ^, |, &, ~, %.
    The operations behave like C++ valarrays. Addition is defined as the addition of the corresponding elements of the operands. For example, in the code below, each of the 4 elements in a will be added to the corresponding 4 elements in b and the resulting vector will be stored in c.
    typedef int v4si __attribute__ ((vector_size (16)));
    v4si a, b, c;
    c = a + b;
    Subtraction, multiplication, division, and the logical operations operate in a similar manner. Likewise, the result of using the unary minus or complement operators on a vector type is a vector whose elements are the negative or complemented values of the corresponding elements in the operand.
    You can declare variables and use them in function calls and returns, as well as in assignments and some casts. You can specify a vector type as a return type for a function. Vector types can also be used as function arguments. It is possible to cast from one vector type to another, provided they are of the same size (in fact, you can also cast vectors to and from other datatypes of the same size).
    You cannot operate between vectors of different lengths or different signedness without a cast.
    A port that supports hardware vector operations, usually provides a set of built-in functions that can be used to operate on vectors. For example, a function to add two vectors and multiply the result by a third could look like this:
    v4si f (v4si a, v4si b, v4si c)
    v4si tmp = __builtin_addv4si (a, b);
    return __builtin_mulv4si (tmp, c);
    }

    I am trying to write an optimized routine using 32 bit vector instructions on a v9 sparc. Using the inforamtion below I have been unable to convince gcc 3.4.6 or gcc 4.0.4 to emilt a vector fpadd instruction - it always just emits 2 32 bit add instructions. I can't find any known good sample code to start from so I presume I am doing something silly. Any help would be most appreciated.
    6.54.14 SPARC VIS Built-in Functions
    GCC supports SIMD operations on the SPARC using both the generic vector extensions (see Vector Extensions) as well as built-in functions for the SPARC Visual Instruction Set (VIS). When you use the -mvis switch, the VIS extension is exposed as the following built-in functions:
    typedef int v2si __attribute__ ((vector_size (8)));
    typedef short v4hi __attribute__ ((vector_size (8)));
    typedef short v2hi __attribute__ ((vector_size (4)));
    typedef char v8qi __attribute__ ((vector_size (8)));
    typedef char v4qi __attribute__ ((vector_size (4)));
    void * __builtin_vis_alignaddr (void *, long);
    int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
    v2si __builtin_vis_faligndatav2si (v2si, v2si);
    v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
    v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
    v4hi __builtin_vis_fexpand (v4qi);
    v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
    v4hi __builtin_vis_fmul8x16au (v4qi, v4hi);
    v4hi __builtin_vis_fmul8x16al (v4qi, v4hi);
    v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
    v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
    v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
    v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
    v4qi __builtin_vis_fpack16 (v4hi);
    v8qi __builtin_vis_fpack32 (v2si, v2si);
    v2hi __builtin_vis_fpackfix (v2si);
    v8qi __builtin_vis_fpmerge (v4qi, v4qi);
    int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
    6.49 Using vector instructions through built-in functions
    On some targets, the instruction set contains SIMD vector instructions that operate on multiple values contained in one large register at the same time. For example, on the i386 the MMX, 3DNow! and SSE extensions can be used this way.
    The first step in using these extensions is to provide the necessary data types. This should be done using an appropriate typedef:
    typedef int v4si __attribute__ ((vector_size (16)));
    The int type specifies the base type, while the attribute specifies the vector size for the variable, measured in bytes. For example, the declaration above causes the compiler to set the mode for the v4si type to be 16 bytes wide and divided into int sized units. For a 32-bit int this means a vector of 4 units of 4 bytes, and the corresponding mode of foo will be V4SI.
    The vector_size attribute is only applicable to integral and float scalars, although arrays, pointers, and function return values are allowed in conjunction with this construct.
    All the basic integer types can be used as base types, both as signed and as unsigned: char, short, int, long, long long. In addition, float and double can be used to build floating-point vector types.
    Specifying a combination that is not valid for the current architecture will cause GCC to synthesize the instructions using a narrower mode. For example, if you specify a variable of type V4SI and your architecture does not allow for this specific SIMD type, GCC will produce code that uses 4 SIs.
    The types defined in this manner can be used with a subset of normal C operations. Currently, GCC will allow using the following operators on these types: +, -, *, /, unary minus, ^, |, &, ~, %.
    The operations behave like C++ valarrays. Addition is defined as the addition of the corresponding elements of the operands. For example, in the code below, each of the 4 elements in a will be added to the corresponding 4 elements in b and the resulting vector will be stored in c.
    typedef int v4si __attribute__ ((vector_size (16)));
    v4si a, b, c;
    c = a + b;
    Subtraction, multiplication, division, and the logical operations operate in a similar manner. Likewise, the result of using the unary minus or complement operators on a vector type is a vector whose elements are the negative or complemented values of the corresponding elements in the operand.
    You can declare variables and use them in function calls and returns, as well as in assignments and some casts. You can specify a vector type as a return type for a function. Vector types can also be used as function arguments. It is possible to cast from one vector type to another, provided they are of the same size (in fact, you can also cast vectors to and from other datatypes of the same size).
    You cannot operate between vectors of different lengths or different signedness without a cast.
    A port that supports hardware vector operations, usually provides a set of built-in functions that can be used to operate on vectors. For example, a function to add two vectors and multiply the result by a third could look like this:
    v4si f (v4si a, v4si b, v4si c)
    v4si tmp = __builtin_addv4si (a, b);
    return __builtin_mulv4si (tmp, c);
    }

  • How do I add a subset of records to a set of records?

    I have a result set of consultants and branch offices and I need to add a subset of employees to each branch office.
    I added an Employee[ ] subset to my consultant getter/setters. A PL/SQL package returns a cursor result set
    of consultants and branch offices and another cursor result set of employees. Each employee is assigned an
    office ID and each consultant and branch office is assigned an office ID.
    I am unsure in Java how to traverse the employee result set to get each subset of employees with the correct office.
    Here is the code that calls the PL/SQL and loads my vector array with consultants and branch offices:
        public Consultant[] getConsultants(String pvConsultant_Firm,
                                            String pvAddr_City_Main,
                                            String pvAddr_State_Main,
                                            String pvAddr_Zip_Main, 
                                            String pvAddr_City_Branch,
                                            String pvAddr_State_Branch,
                                            String pvAddr_Zip_Branch,
                                            String pvResidency,
                                            String pvFirst_Name,    
                                            String pvLast_Name,
                                            String pvOrder_By_Office,
                                            String pvOrder_By_Employee,
                                            String display_Branch,
                                            String display_Employee)
          Vector retval = new Vector();
          DBConnection conn = new DBConnection();
          CallableStatement cstmt = conn.prepareCall("begin " + PACKAGE + "Get_Consultant_Cursors(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);end;");
          ResultSet rsConsultant;
          ResultSet rsEmployee;
          Consultant curConsult;
          Employee curEmployee;
          try
             if(cstmt!=null)
                String Consult_Type = null;
                if ("true".equalsIgnoreCase(display_Branch) ||
                     "true".equalsIgnoreCase(display_Employee)){
                   Consult_Type = null;
                else {
                   Consult_Type = "MAIN";
                cstmt.setString("pvConsultant_Firm", pvConsultant_Firm);
                cstmt.setString("pvOffice_Type", Consult_Type);
                cstmt.setString("pvAddr_City_Main", pvAddr_City_Main);
                cstmt.setString("pvAddr_State_Main", pvAddr_State_Main);
                cstmt.setString("pvAddr_Zip_Main", pvAddr_Zip_Main);
                cstmt.setString("pvAddr_City_Branch", pvAddr_City_Branch);
                cstmt.setString("pvAddr_State_Branch", pvAddr_State_Branch);
                cstmt.setString("pvAddr_Zip_Branch", pvAddr_Zip_Branch);
                cstmt.setString("pvResidency", pvResidency);
                cstmt.setString("pvFirst_Name", pvFirst_Name);
                cstmt.setString("pvLast_Name", pvLast_Name);
                cstmt.setString("pvOrder_By_Employee", pvOrder_By_Employee);
                cstmt.setString("pvOrder_By_Office", pvOrder_By_Office);
                cstmt.registerOutParameter("pcurConsultant_Office", OracleTypes.CURSOR);
                cstmt.registerOutParameter("pcurConsultant_Employee", OracleTypes.CURSOR);
                cstmt.execute();
                rsConsultant = (ResultSet)cstmt.getObject("pcurConsultant_Office");
                rsEmployee = (ResultSet)cstmt.getObject("pcurConsultant_Employee");
                while(rsConsultant.next())
                    curConsult = getConsultant(rsConsultant);
                    retval.add(curConsult);
                     if ("true".equalsIgnoreCase(display_Employee)){
    HOW DO I HANDLE THIS?
                 rsConsultant.close();
                 conn.closeCstmt(cstmt);
              catch (SQLException e)
                 conn.logToFile(this, "getConsultants()", e);
              conn.close();
           return (Consultant[])retval.toArray(new Consultant[retval.size()]);
        }

    It will basically look something like this:
    Consultant A           Main Office
                                                 Employee 1
                                                 Employee 2
                                                 Employee 3
                           Branch A       
                                                 Employee 4
                                                 Employee 5
                           Branch B
                                                 Employee 6
                                                 Employee 7
    Consultant B           Main Office
                                                 Employee 8
                                                 Employee 9
                           Branch A       
                                                 Employee 10
                                                 Employee 11The consultant and branch offices are in one result set and the employees are in another. I need to combine them
    so I can return them and display them as above in my JSP.

  • How to create vector X(n) = [x(n) x(n-1) x(n-2).........x(n-N+1) in labview

    i want to create an input signal vector X(n)  = [x(n) x(n-1) x(n-2).........x(n-N+1)

    rashi wrote:
    i want to create an input signal vector X(n)  = [x(n) x(n-1) x(n-2).........x(n-N+1)
    This question is quite ambiguous, because you don't really define anything, but you could try "array subset" and "reverse array".
    Can you give an actual example of an input array and desired output?
    LabVIEW Champion . Do more with less code and in less time .

  • Androiod, openGL, and 3 dimensional vectors

    Hi,
    I am learning java for the android phones. I got to a part in my book that deals very lightly with 3d graphics(OpenGL) and I am trying to convert some code from DirectX. The problem I am having is finding the equivalent of a 3 dimensional Vector in
    the subset of java for the android platform. An example would be converting these vectors to their equivalent in the Android platform and java code:
            public Vector3 Position;
            public Vector3 Normal;
            public Vector3 Tangent;
            public Vector2 TextureCoordinate;What are the equivalents in java and the android platform?
    Thanks in advance for help with this.

    Just as a Vector can be used instead of a single dimension array, a Vector containing Vector objects can be used instead of a 2 dimensional array.
    So in your example ...
    Vector rowVector = new Vector();
    while(myresultset.next()) {
    ResultSetMetaData rsmd=myresultset.getMetaData();
    int numOfColumns=rsmd.getColumnCount();
    Vector columnVector = new Vector();
    for(int columnCtr=0; columnCtr<numOfColumns; columnCtr++) {
    columnVector.add(myresultset.getString(columnCtr+1));
    rowVector.add(columnVector);
    int numberOfRows = rowVector.size();
    int numberOfColumnsInRow1 = ((Vector)rowVector.get(0)).size();
    String column3ForRow1 = (numberOfColumnsInRow1 >= 3) ? (String)((Vector)rowVector.get(0)).get(2) : null;

  • Filtering assoc rules using subset method.

    Hello,
    Am trying to filter the association rules using subset method of arules package.
    I have a vector of items that are to be filtered from LHS/RHS.
    Here is the sample code that i have used.
    metalAssoc.mod <-ore.odmAssocRules(~.,NBAssocreqOF,case.id.column="TRANSACTION_VALUE",item.id.column = "PARAM_NAME",
      item.value.column = "PARAM_VALUE_BIN",min.support = 0.05 ,min.confidence = 0.5,max.rule.length = 5)
    rules <- rules(metalAssoc.mod)
    arules <- ore.pull(rules)
    1. Able to filter the rules using below condition.
    arules.subset <- subset(arules, subset= rhs %pin% "Temperature" |  rhs %pin% "Pressure" )
    2. We get a string like  "Temperature";"Pressure" to the function as input.
    Tried forming a vector out of the string and
    arules.subset <- subset(arules, subset= rhs %pin% c( "Temperature", "Pressure")
    This command throws the below error.
    Error in rhs %in% c("Pressure", "Temperature") :
      table contains an unknown item label
    3. Tried forming a string str with valuerhs %pin% "Temperature" |  rhs %pin% "Pressure"
    arules.subset <- subset(arules, subset= str )
    Got the below error
    Error in .translate_index(i, rownames(x), nrow(x)) :
      subscript out of bounds
    Our aim is to filter the rules based on the list of items from RHS/LHS that are passed as a function variable.
    Any help is greatly appreciated.
    Thanks,
    Swathi.

    Swathi,
    If I understand correctly, the following example from the ore.odmAssocRules help file accomplishes what you want using the functions itemsets() along with subset():
    set.seed(7654)
    id <- 1:10
    color <- sample(c("B", "Y", "W", "G"), 10, replace=TRUE)
    shape <- sample(c("tri", "rect", "round"), 10, replace=TRUE)
    state <- sample(c("MA", "CA", "NY"), 10, replace=TRUE)
    data3.ore <- ore.frame(ID=id, COLOR=color, SHAPE=shape, STATE=state)
    ar.mod3 <- ore.odmAssocRules(~., data3.ore, case.id.column = "ID",
             min.support = 0.15, min.confidence = 0.05, max.rule.length = 2)
    rules <- subset(rules(ar.mod3), min.confidence=0.5,
             lhs=list(SHAPE="tri", COLOR="B"), orderby="lift")
    itemsets <- subset(itemsets(ar.mod3), min.support=0.35)
    To view the help file for ore.odmAssocRules, type at the R command prompt:
    ?ore.odmAssocRules
    Sherry

  • Vector PDFs?

    Sorry if this is a really dumb question (my background is web design, and I do the odd bit of work in Illustrator and InDesign), but is there anything special about a Vector PDF, or are PDFs just a vector (supporting) format?
    I'm asking as I've just done some business card designs for a client - the printers I use just print from hi res JPGs, and I've had clients need the designs in PDF before.
    I use Fireworks quite a bit, so I usially do the design in FW, export out as a hi res 300dpi JPG, drop the JPG into InDesign, and export out the PDF.
    With this job, a Vector PDF is required, so just wanted to check if that's what I'm getting anyway, or if I need a different workflow / export option to create a Vector PDF.
    Thanks for any clarification.

    FIrst, you need to know if the printing is going to be color-separated and then printed via commerical offset, or if it is going to be printed to some kind of composite (full color) digital device. In this case, that is specified in the last of the requirements list:
    -Final artwork submitted to us should be created suitably for high-resolution 4-colour process lithographic printing.
    This means the file is going to be color-separated and printed using normal CMYK process. Your full-color raster images should be CMYK color mode, and (conventonally) saved as TIFF. Your Illustator file should be CMYK color mode. The swatches you create and work with should be CMYK process swatches.
    Any images/photographs should be in TIFF format, or maximum-quality JPG;
    Generally speaking, for commercial-quality offset printing, you should save your images as CMYK TIFF. If you use RGB images, they will be automatically converted to CMYK when the file is color-separated at the printer. That's okay if color accuracy is not critical. But best practice is for you to save your files as CMYK before placing them in the page layout.
    JPEG is a lossy compression algorithm, originally intended to minimize bandwidth for online work and better avoided for print work. Everytime you re-save a raster image as JPEG, the image is degraded somewhat. There's not going to be any image on a business card large enough that file size is going to be a significant issue. In short, there's no need to use JPEG for this.
    ...and at a resolution of 600dpi
    Ridiculous. You don't need 600 PPI for a continuous-tone raster image (like a normal photo). For a continuous-tone raster image, you would only need 600 PPI if the image were to be color-separated at a halftone ruling of 400 LPI. (It won't be.). The rule-of-thumb for continuous-tone raster image resolution is 1-to-2-times the halftone ruling. Typical halftone ruling for CMYK process on business cards is in the neighborhood of 150 LPI (Lines Per Inch). At 150 LPI, 225 PPI is plenty.
    600 PPI or more would make sense only if the raster image in question is 1-bit color mode, becauuse 1-bit images are effectively "line art." That is, assuming they are colored with a solid ink (not a tint), then they are not converted to halftone dots; they are mapped directly to the tiny dots which a printing device builds everything out of (Printer Spots). But even with a 1-bit image, if you colorize it with a CMYK mixture that has no 100% component value, it will be halftoned.
    For example: Suppose you have a line-art graphic (think of an ink pen drawing) that you only have available as a 1-bit raster image. If that image is set to be printed with 100% K (black) ink, then it will not be halftoned. The pixels of the image will be mapped to the tiny printer spots (which can be as small as 1/3000 inch). In sharply-printed line art, 300-per-inch pixels can give the image a somewhat (not drastically) jagged appearance (a little more evident than if printed on a typical laser printer). But if that image were colorized with, say,  50% Cyan, then the imagestter has to reproduce it using much larger dots (Halftone Dots) which are built up from Printer Spots. So even if the 1-bit image had a PPI of 600, it will be subject to the same "edge softening" as would be a continuous-tone (8 bit per channel) image, because its pixels will be rendered out of (probably) 150 LPI halftone dots, not out of (typically) 2480 SPI printer spots. So in that case, higher image PPI is rendered moot; the excess resolution will effectively be "averaged away" by the halftone process that will be necessary to render it as a 50% tint.
    -Your artwork should be output as a (vector) Press Quality PDF
    Poorly stated. There is no such thing as a "vector PDF" per se. There is such a thing as a PDF which happens to contain only vector objects, but that would be a ridiculous requirement. Don't confuse yourself over poorly-stated requirements. Conceptually, it's pretty simple: Don't think of "PDF" as either raster or vector. Just think of PDF as a container. That container can contain any combination of text objects, raster objects, and/or vector objects.
    (with embedded fonts and images).
    When you save (or export) a PDF from your page layout or illustration program, any raster images will be embedded. Somewhere in the export or save PDF dialog, you are provided a setting to optionally specifiy whether fonts are embedded, not embedded, or embedded as a subset (only the characters actually used in the document). In Illustrator, if you use the "Press Ready" PDF save presets, the fonts you use in the file will be embedded as subsets.
    JET

  • Problems with vectors

    Hi,
    In response to an earlier problem i posted which i thought i had resolved i have to ask some more advice as i am still having problems.
    Basically i have two points (0,0,0) and (1,1,1) where two spheres are located, im trying to connect a cylinder to these spheres. I have tried using Pythagoras theorem and this connects the spheres up perfectly if the z value is assigned to 0 when i use the rotZ() method with the resulting angle. What i would like to know is there any way of connecting the spheres with 3 coordinates for x,y,z using the same method.
    The main formula i was working on was after connecting up the spheres in just 2 dimensions (ie z value equal to 0) as i mentioned earlier, was to calculate the length of the hypoteneus and have the z value divide this (ie using Pytagoras' theorem again tan teeta = z2-z1/c where c is the sqrt(x*x+y*y) ). Once i got this angle i then rotated it around the Y axis (im not sure if i am actually rotating it around the correct axis, i know that i also have to rotate around the X axis a certain degree but i dont know how much) however the spheres still did not connect up.
    Is it possible to do it the above way or do i need to do i need to use all vector calculations (dot, cross products etc) which i would prefer to stay away from?
    Sorry if it is not very clear it is kind of hard to explain!
    Any help would be greatly appreciated because it is really driving me nuts.
    Regards
    Andy

    Hi
    Just putting up the code to show how i am figuring out the angles and what rotations im using
              double tanTeetaXY = (y-0.0f)/(x-0.0f);
                   double teetaXY = Math.atan(tanTeetaXY);
                   double tanTeetaXZ = (z-0.0f)/(x-0.0f);
                   double teetaXZ = Math.atan(tanTeetaXZ);
                   double testang = (y-0.0f)/(z-0.0f);
                   double teetatest = Math.atan(testang);
                   rotate.rotZ((Math.PI/2.0f)-teetaXY);
                   temprotate.rotY(teetaXZ);
                   rotate.mul(temprotate);
                   temprotate.rotX(teetatest);
                   rotate.mulInverse(temprotate);
                   rotate.invert();Am i completely off with this or is there a better way to figure things out does anyone know? I just cant get my head around it!
    Much appreciated
    Andy

  • HELP!!Need to import and print vector drawings

    I am trying this topic again in the hope of help. I need to
    import drawings in a vector format for printing. These drawings
    will be cast members not sprites. I have tried printing a swf
    version via Printomatic but it cannot print Flash members. My
    questions are:
    1. Is therre any way to print a swf cast member (not a
    sprite)
    2. How can I import an EPS file? - I have heard that it can
    be done but every version I have tried seems to fail

    Darrel Plant has written an importer for .ai and .eps files.
    You can get
    it at:
    http://www.moshplant.com/direct-or/ps2vs/
    Haven't used it for a while but it works pretty good.
    Downside is that it creates multiple members because Director
    can't
    (couldn't?) handle multiple-line vector members.
    Dsotm wrote:
    > I am trying this topic again in the hope of help. I need
    to import drawings in
    > a vector format for printing. These drawings will be
    cast members not sprites.
    > I have tried printing a swf version via Printomatic but
    it cannot print Flash
    > members. My questions are:
    > 1. Is therre any way to print a swf cast member (not a
    sprite)
    > 2. How can I import an EPS file? - I have heard that it
    can be done but every
    > version I have tried seems to fail
    >
    Manno Bult
    [email protected]

  • Class vector can't be resolved

    hi ,
    plz i got the following error while running a J2ME
    program
    cannot resolve symbol
    symbol : method add (java.lang.String)
    location: class java.util.Vector
    any ideas????

    First of all, crosspost:
    http://forum.java.sun.com/thread.jspa?threadID=629578
    Please only use one thread.
    There is no method "add(someStringVariable)" in the Vector library for j2me. However, there is "addElement (Object o)".
    j2me specs and j2se specs are very different.
    J2ME leaves out alot of methods due for mobile usage.
    To get specs for cldc and midp, look here:
    http://java.sun.com/j2me/docs/index.html

Maybe you are looking for

  • Clip within a clip equals jagged edges

    I have placed an video clip (Dad) incide of another video clip (son) to look as if the Dad is coming in over a video telecast on a black laptop. Problem is I am seeing jagged edges along two sides of the Dad clip. Is this caused by aliasing? Is there

  • Printing two photos onto a page etc.

    I have just been trying to print photos using iPhoto. You use to be able to choose how many photos you printed to a page (e.g. n-up mode) but now I can only find an option for 1 photo a page or a contact sheet.Anyone know how to change the number of

  • CC&B Integeration with BI Publisher(OBIEE 11g)

    Hello Friends, we are using BI Publisher coming with OBIEE 11g, But in ccb installation document consist support for bi publisher 10g , can any one pls explain how we can configure CC&B with BI publisher coming with OBIEE 11g.Any documentation availa

  • MUTLI_ROW_INSERT

    To all, I have a need to create a form/report that has the capability for inserting numerous records into a table. The report is a multi-table join based on certain criteria and that data needs to be inserted into another table based on the user's se

  • G 505S "Plugged in and not charging" (Tried everything!!!)

    Hi everyone! I hope someone in the community can help me out. I've tried calling in to Lenovo and I've only been disapointed and VERY ANGRY with Lenovo so I hope someone here can help me. My G505s has never properly charged the battery. The battery i